Some years ago, I've written an engine that shows all permitted moves in a certain position. I think, only some castling-rules were not correct, but I could send you the code if you want.
Best regards,
perl -e "print a|r,p|d=>b|p=>chr 3**2 .7=>t and t"