- empty = pos.empty_squares();
-
- // Pawn moves. This is somewhat messy, and we use separate code for white
- // and black, because we can't shift by negative numbers in C/C++. :-(
-
- if (us == WHITE)
- {
- // Pawn moves which give 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.
-
- // Find all friendly pawns not on the enemy king's file
- b1 = pos.pawns(us) & ~file_bb(ksq);
-
- // Discovered checks, single pawn pushes
- b2 = b3 = ((b1 & dc) << 8) & ~Rank8BB & empty;
- while (b3)
- {
- to = pop_1st_bit(&b3);
- mlist[n++].move = make_move(to - DELTA_N, to);
- }
-
- // Discovered checks, double pawn pushes
- b3 = ((b2 & Rank3BB) << 8) & empty;
- while (b3)
- {
- to = pop_1st_bit(&b3);
- mlist[n++].move = make_move(to - DELTA_N - DELTA_N, to);
- }
-
- // Direct checks. These are possible only for pawns on neighboring files
- // of the enemy king
-
- b1 &= (~dc & neighboring_files_bb(ksq)); // FIXME why ~dc ??
-
- // Direct checks, single pawn pushes
- b2 = (b1 << 8) & empty;
- b3 = b2 & pos.pawn_attacks(BLACK, ksq);
- while (b3)
- {
- to = pop_1st_bit(&b3);
- mlist[n++].move = make_move(to - DELTA_N, to);
- }
-
- // Direct checks, double pawn pushes
- b3 = ((b2 & Rank3BB) << 8) & empty & pos.pawn_attacks(BLACK, ksq);
- while (b3)
- {
- to = pop_1st_bit(&b3);
- mlist[n++].move = make_move(to - DELTA_N - DELTA_N, to);
- }
- }
- else { // (us == BLACK)
-
- // Pawn moves which give 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.
-
- // Find all friendly pawns not on the enemy king's file:
- b1 = pos.pawns(us) & ~file_bb(ksq);
-
- // Discovered checks, single pawn pushes
- b2 = b3 = ((b1 & dc) >> 8) & ~Rank1BB & empty;
- while (b3)
- {
- to = pop_1st_bit(&b3);
- mlist[n++].move = make_move(to - DELTA_S, to);
- }