According to the comments preceding the castle subroutine, you need to flag the spaces of pieces that may legally castle. The subroutine does not care what the pieces are. If you flag both the rook and the cannon, it will, once other conditions pertain, initially allow castling with the rook, but if the rook moves out of the way, it will allow castling with the cannon.
According to the comments preceding the castle subroutine, you need to flag the spaces of pieces that may legally castle. The subroutine does not care what the pieces are. If you flag both the rook and the cannon, it will, once other conditions pertain, initially allow castling with the rook, but if the rook moves out of the way, it will allow castling with the cannon.