I'm currently working on a chess engine and have a pseudo-legal move generator working. I'm looking for a way to efficiently generate a bitboard of pinned pieces, so I could skip them when generating legal moves. How would one go about doing this, given 12 bitboards for each piece, and a bitboard called UNSAFE with all the squares the opponent is threatening?