From memory, pieces coordinates are stored for both players as if the board was displayed always with the same orientation.
Then for the player for which the board needs to be rotated, we use some math to convert the coordinates for proper display with the rotated board.