- // Calculate our parametrized parameters at compile time
- const Color Them = (Us == WHITE ? BLACK : WHITE);
- const Bitboard TRank8BB = (Us == WHITE ? Rank8BB : Rank1BB);
- const Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB);
- const SquareDelta TDELTA_N = (Us == WHITE ? DELTA_N : DELTA_S);
- const SquareDelta TDELTA_S = (Us == WHITE ? DELTA_S : DELTA_N);
-
- Square to;
- Bitboard b1, b2, b3;
- Bitboard pawns = pos.pieces(PAWN, Us);
-
- if (dc & pawns)
- {
- Bitboard empty = pos.empty_squares();
-
- // Pawn moves which gives discovered check. This is possible only if the
- // pawn is not on the same file as the enemy king, because we don't
- // generate captures.
- b1 = pawns & ~file_bb(ksq);
-
- // Discovered checks, single pawn pushes, no promotions
- b2 = b3 = move_pawns<Us, DELTA_N>(b1 & dc) & empty & ~TRank8BB;
- SERIALIZE_MOVES_D(b3, -TDELTA_N);
-
- // Discovered checks, double pawn pushes
- b3 = move_pawns<Us, DELTA_N>(b2 & TRank3BB) & empty;
- SERIALIZE_MOVES_D(b3, -TDELTA_N -TDELTA_N);
- }
-
- // Direct checks. These are possible only for pawns on neighboring files
- // and in the two ranks that, after the push, are in front of the enemy king.
- b1 = pawns & neighboring_files_bb(ksq) & ~dc;
-
- // We can get false positives if (ksq + x) is not in [0,63] range but
- // is not a problem, they will be filtered out later.
- b2 = b1 & (rank_bb(ksq + 2 * TDELTA_S) | rank_bb(ksq + 3 * TDELTA_S));
- if (!b2)
- return mlist;
-
- // Direct checks, single pawn pushes
- Bitboard empty = pos.empty_squares();
- b2 = move_pawns<Us, DELTA_N>(b1) & empty;
- b3 = b2 & pos.pawn_attacks(ksq, Them);
- SERIALIZE_MOVES_D(b3, -TDELTA_N);
-
- // Direct checks, double pawn pushes
- b3 = move_pawns<Us, DELTA_N>(b2 & TRank3BB) & empty & pos.pawn_attacks(ksq, Them);
- SERIALIZE_MOVES_D(b3, -TDELTA_N -TDELTA_N);
- return mlist;
- }