Prev: F580 Up: Map Next: F5C4
F591: Swap Players
Used by the routines at StartNewGame, LoseLife and GameOver.
Does nothing if the second player has no ships. Otherwise it swaps the state of the two players, and the records for the scores and the numbers of ships that are printed at the top of the screen, so that the state of the player who is up is always at CurrentPlayerState. If the flag at CA1C is 99 it goes no further. If not it changes the number of the player, prints it and clears the playfield.
SwapPlayers F591 LD A,($F656) The other player's ships.
F594 AND A Return if A is zero.
F595 RET Z
F596 LD DE,$F5E7 The current player state.
F599 LD HL,$F650 The other player state.
F59C LD B,$69 B=69.
F59E CALL SwapBytes Call SwapBytes.
F5A1 LD DE,$C9EC The player 1 score text.
F5A4 LD HL,$C9FC The player 2 score text.
F5A7 LD B,$10 B=10.
F5A9 CALL SwapBytes Call SwapBytes.
F5AC LD A,($CA1C) The current player.
F5AF CP $99 Return if A is 99.
F5B1 RET Z
F5B2 XOR %00000001 Flip the bits of A that are set in 01.
F5B4 LD ($CA1C),A The other player is now up.
F5B7 CALL PrintPlayer Call PrintPlayer.
F5BA LD B,$08 B=08.
SwapPlayers_Delay F5BC CALL Delay Call Delay.
F5BF DJNZ SwapPlayers_Delay Decrease B and jump to SwapPlayers_Delay until none remain.
F5C1 JP ClearPlayfield Jump to ClearPlayfield.
Prev: F580 Up: Map Next: F5C4