Prev: 24720 Up: Map Next: 24829
24746: Player Turn Ends
Used by the routine at AnimateExplosion.
Runs when Robbie has been killed. If the flower has also been eaten away then the "YOUR PLANT HAS BEEN EATEN" message is shown first and the flower is reset. All of the bugs are removed, and then either the current player starts another turn, the other player takes over, or the game is over.
Before After (flower eaten)
turn-ends-before turn-ends-after
PlayerTurnEnds 24746 XOR A Write 0 to State_BonusItem.
24747 LD (24124),A
Check whether the flower has been eaten right down to the ground.
24750 LD HL,24206 Point HL at the flower's Y position (State_Flower_Pos_Y).
24753 LD A,(HL) A=the flower Y position.
24754 CP 183 Jump to PlayerTurnEnds_RemoveBugs if the flower Y position is less than 183.
24756 JR C,PlayerTurnEnds_RemoveBugs
24758 LD (HL),167 Reset the flower Y position to 167.
24760 CALL CreateWindow Create the game window using CreateWindow.
24763 LD DE,24720 DE=the "YOUR PLANT HAS BEEN EATEN" message (Message_Eaten).
24766 LD HL,28704 HL=28704 (screen position).
24769 CALL GameOverPrint_Pause Print the message and pause using GameOverPrint_Pause.
Remove all of the bugs and the explosion object.
PlayerTurnEnds_RemoveBugs 24772 LD HL,24244 HL=State_Bugs (the first bug).
24775 LD B,7 Set the object counter to 7 (the bugs and the explosion).
24777 CALL SetObjectInactive Set the objects inactive using SetObjectInactive.
Is this a 2UP game?
24780 LD A,(24067) A=the game options from GameOptions.
24783 AND %00000001 Keep only bit 0 (the player count).
24785 JR NZ,PlayerTurnEnds_2UP Jump to PlayerTurnEnds_2UP if this is a 2UP game.
Handle 1UP player.
PlayerTurnEnds_1UP 24787 LD A,(24120) Jump to GameOver_ControllerRestart if the current player is out of lives (using CurrentPlayer_Lives).
24790 AND A
24791 JP Z,GameOver_ControllerRestart
24794 CALL LevelInit Create the game window using LevelInit.
24797 JP PlayerInit Jump to PlayerInit to start the player's next turn.
Handle 2UP player.
PlayerTurnEnds_2UP 24800 LD A,(24122) Jump to PlayerTurnEnds_1UP if the other player is out of lives (using InactivePlayer_Lives).
24803 AND A
24804 JR Z,PlayerTurnEnds_1UP
24806 LD A,(24120) Call GameOver_Controller if the current player is out of lives (using CurrentPlayer_Lives).
24809 AND A
24810 CALL Z,GameOver_Controller
24813 CALL ChangePlayer Swap the two players' data using ChangePlayer.
24816 LD A,(24094) Change current player at Current_Player (flip bits between 0 and 255).
24819 CPL
24820 LD (24094),A
24823 CALL LevelInit Create the game window using LevelInit.
24826 JP PlayerInit Jump to PlayerInit to start the other player's turn.
Prev: 24720 Up: Map Next: 24829