Prev: A2F0 Up: Map Next: A39B
A30D: Switch Player
Used by the routine at RunGame.
Switches to the other player in a two-player game, by swapping the saved game state of the two players, and sets up the level for the new player.
SwitchPlayer A30D LD A,($DEFD) Fetch the number of lives of the second player from OtherPlayerState.
A310 AND A Test it.
A311 RET Z Return if there is no second player.
This entry point is used by the routine at RunGame.
SwitchPlayer_Flip A312 LD A,($A414) Fetch the low byte of the operand of the instruction at A413.
A315 XOR %11100000 Flip bits 5-7.
A317 LD ($A414),A Store it.
A31A LD ($D2FA),A Store it in the operand byte at D2FA.
A31D LD HL,$DEDE Point HL at Lives.
A320 LD DE,$DEFD Point DE at OtherPlayerState.
A323 LD B,$1F Set the number of bytes to 1F.
A325 CALL SwapBytes Swap the two game states.
A328 LD HL,$E12E Point HL at ScoreTextPlayerOne_Record.
A32B LD DE,$E140 Point DE at ScoreTextPlayerTwo_Record.
A32E LD B,$09 Set the number of bytes to 09.
A330 CALL SwapBytes Swap them.
A333 LD HL,$E1A5 Point HL at LivesTextPlayerOne_Record.
A336 LD DE,$E1AB Point DE at LivesTextPlayerTwo_Record.
A339 LD B,$06 Set the number of bytes to 06.
A33B CALL SwapBytes Swap them.
A33E LD HL,$E1B1 Point HL at BottlesTextPlayerOne_Record.
A341 LD DE,$E1B7 Point DE at BottlesTextPlayerTwo_Record.
A344 LD B,$06 Set the number of bytes to 06.
A346 CALL SwapBytes Swap them.
A349 LD DE,$A59D Point DE at Gauges.
A34C LD HL,$A5A1 Point HL at Gauges_Second.
A34F LD B,$04 Set the number of bytes to 04.
A351 CALL SwapBytes Swap them.
A354 LD A,($60FB) Fetch the control method of the first player from Player1ControlMethod and keep it in B.
A357 LD B,A
A358 LD A,($60FC) Fetch the control method of the second player from Player2ControlMethod.
A35B LD ($60FB),A Make it the control method of the first player.
A35E LD A,B Fetch the old control method of the first player.
A35F LD ($60FC),A Make it the control method of the second player.
A362 LD A,($DEDE) Fetch the number of lives of the new player from Lives.
A365 AND A Test it.
A366 RET Z Return if the new player has no lives.
A367 XOR A Set A to zero.
A368 LD ($A59D),A Clear the first of the saved values at Gauges.
A36B LD ($A5A1),A Clear the second of the saved values at A5A1.
A36E LD A,($DEDD) Fetch the number of the current player from CurrentPlayer.
A371 XOR %00000001 Flip bit 0.
A373 LD ($DEDD),A Store it.
A376 CALL ShowPlayerNumber Call ShowPlayerNumber.
A379 CALL ResetAttributes Call ResetAttributes.
A37C CALL ClearScreen Call ClearScreen.
A37F CALL DrawPanel Call DrawPanel.
A382 LD C,$00 C is 00 so that the player is not placed.
A384 CALL StartLevel_FindData Call 86FB to find the data of the level.
A387 LD A,($DEE0) Fetch the number of bottles left from BottlesLeft.
A38A PUSH AF Save it.
A38B CALL SetLevelGraphics Call SetLevelGraphics to set the graphics of the level.
A38E POP AF Restore the number of bottles left.
A38F LD ($DEE0),A Store it.
A392 LD HL,$7730 Set the position of the panel attributes.
A395 LD DE,$E11C Point DE at PanelRectangle.
A398 JP FillRectangle Jump to FillRectangle to fill the attributes.
Prev: A2F0 Up: Map Next: A39B