That switch statement will end up huge (64 sq * 8 rays).
Anyway, switch can be implemented as a chain of cmp/jcc, as a decision tree, or by means of a jump table (if there are lots of values in a tight range).
I don''t think performance matters here - it''s just a one time init thing.
Here''s how I did it (yuck
)
for each square on board (padded => no move leads ''out of bounds'') for each piece (w pawn, b pawn, all others) for each ray (dependent on piece) do advance along ray if on valid square SETBIT(move_array[piece][from_sq], to_sq) while(piece is ranged && on valid square)
Hope that helps a little
Jan
E8 17 00 42 CE DC D2 DC E4 EA C4 40 CA DA C2 D8 CC 40 CA D0 E8 40E0 CA CA 96 5B B0 16 50 D7 D4 02 B2 02 86 E2 CD 21 58 48 79 F2 C3