![]() |
Routines |
| Prev: DFD1 | Up: Map | Next: E11C |
|
Used by the routine at GameEntry.
The main loop of the game. A game starts with the title menu, and then each life is played in the loop from RunGame_Life. When the player loses a life the next player is switched to if there is a second player. When the last life is lost the high score is checked and the game starts again.
|
||||
|
Clear the bytes at ScratchValue that the game uses as variables.
|
||||
| RunGame | DFF0 | LD HL,$5CD8 | Clear 30 bytes starting at ScratchValue. | |
| DFF3 | LD B,$30 | |||
| DFF5 | CALL ClearBytes | |||
|
Start a new game from the title menu. Make player 1 the player on the left of the panel, and go to the first level.
|
||||
| RunGame_Loop | DFF8 | LD A,($E12E) | Fetch the flag that shows the scores are swapped. | |
| DFFB | AND A | Test it. | ||
| DFFC | CALL NZ,SwitchPlayer_Flip | Swap the players back if they were swapped. | ||
| DFFF | XOR A | Set the level number to zero. | ||
| E000 | LD ($DEDF),A | |||
| E003 | CALL SetLevelGraphics | Set the colours and the shape of the level. | ||
| E006 | CALL ResetAttributes | Reset the attributes of the screen. | ||
| E009 | CALL ClearScreen | Clear the screen. | ||
| E00C | CALL ShowTitleMenu | Show the title menu and wait for the game to be started. | ||
| E00F | CALL StartGame | Set up the lives, the scores, the gauges and the bottles for a new game. | ||
| E012 | CALL ShowPlayerNumber | Show the number of the player. | ||
| E015 | CALL ResetAttributes | Reset the attributes of the screen. | ||
| E018 | CALL ClearScreen | Clear the screen. | ||
| E01B | CALL DrawPanel | Draw the panel. | ||
|
Colour the window of the game for the level.
|
||||
| RunGame_Loop2 | E01E | LD HL,$7730 | Set HL to the position 7730 of the game window. | |
| E021 | LD DE,$E11C | Point DE at PanelRectangle. | ||
| E024 | CALL FillRectangle | Colour the window. | ||
|
Start a life. Draw the icon of each player that shows whether the player has the bottle flag set, putting the icon of the current player on the left.
|
||||
| RunGame_Life | E027 | LD A,($DEFC) | Fetch the bottle flag of the first player and keep it in C. | |
| E02A | LD C,A | |||
| E02B | LD A,($DF1B) | Fetch the bottle flag of the second player and keep it in B. | ||
| E02E | LD B,A | |||
| E02F | LD A,($DEDD) | Fetch the number of the current player. | ||
| E032 | AND A | Test it. | ||
| E033 | JR Z,RunGame_Pictures | Jump to RunGame_Pictures if it is the first player. | ||
| E035 | LD A,C | Swap the flags of the players, so that the flag of the current player is in C. | ||
| E036 | LD C,B | |||
| E037 | LD B,A | |||
| RunGame_Pictures | E038 | PUSH BC | Stash the flags on the stack. | |
| E039 | LD HL,$6808 | Set HL to the position 6808 of the icon on the left of the panel. | ||
| E03C | LD DE,$64BC | Point DE at EmptyCupPicture. | ||
| E03F | LD A,C | Fetch the flag for the icon. | ||
| E040 | AND A | Test it. | ||
| E041 | JR Z,RunGame_LeftIcon | Jump to RunGame_LeftIcon if the flag is not set. | ||
| E043 | LD DE,$6498 | Point DE at FilledCupPicture. | ||
| RunGame_LeftIcon | E046 | CALL DrawPicture | Draw the icon on the left. | |
| E049 | LD L,$E8 | Move across to the icon on the right of the panel. | ||
| E04B | LD DE,$64BC | Point DE at EmptyCupPicture. | ||
| E04E | POP BC | Restore the flags. | ||
| E04F | LD A,B | Fetch the flag for the icon on the right. | ||
| E050 | AND A | Test it. | ||
| E051 | JR Z,RunGame_RightIcon | Jump to RunGame_RightIcon if the flag is not set. | ||
| E053 | LD DE,$6498 | Point DE at FilledCupPicture. | ||
| RunGame_RightIcon | E056 | CALL DrawPicture | Draw the icon on the right. | |
|
Update the panel, reset the state of the player and print the digits of the lives and the bottles.
|
||||
| E059 | CALL UpdatePanelDigits | Update the digits of the lives and the bottles. | ||
| E05C | CALL StartGame_Life | Reset the state of the player, the countdown timer and the gauges. | ||
| E05F | LD DE,$E1A5 | Point DE at LivesTextPlayerOne_Record. | ||
| E062 | LD B,$04 | Set the number of text records to 04. | ||
| E064 | CALL PrintTextRecords | Print the digits of the lives and the bottles of both players. | ||
|
Put the entities and the bottles of the level in place, build the view and print the messages.
|
||||
| E067 | CALL ResetEntities | Reset the entities. | ||
| E06A | CALL RestoreBottles | Restore the bottles that the player has not yet collected. | ||
| E06D | CALL BuildView | Build the view of the level. | ||
| E070 | CALL ScrollStageMessage | Scroll in the message for the stage. | ||
| E073 | CALL ShowExitMessage | Show the exit message, if all of the bottles have been collected. | ||
|
Draw the first frame, and wipe it on to the screen.
|
||||
| RunGame_Frame | E076 | LD IX,$B540 | Point IX at Entities. | |
| E07A | CALL ProjectPlayerEntity | Project the player on to the screen. | ||
| E07D | CALL UpdateEntities | Update the entities. | ||
| E080 | CALL BuildDrawList | Build the draw list. | ||
| E083 | CALL SortDrawList | Sort the draw list. | ||
| E086 | CALL DrawItems | Draw the items of the draw list. | ||
| E089 | CALL WipeViewIn | Wipe the view on to the screen. | ||
| E08C | CALL RestoreItemRows | Put the rows of the screen buffer back. | ||
|
Run the frames of the game until the player loses a life or leaves the level. Then remove the entities that were made from the objects of the level, and clear the message.
|
||||
| E08F | CALL RunFrame | Run the frames of the game. | ||
| E092 | CALL RemoveObjectEntities | Remove the entities that were made from the objects of the level. | ||
| E095 | LD DE,$CE5A | Point DE at ExitClosedMessages. | ||
| E098 | CALL PrintText | Clear the first part of the message. | ||
| E09B | CALL PrintText | Clear the second part of the message. | ||
| E09E | LD A,($AA5A) | Fetch the flag that shows a life has been lost. | ||
| E0A1 | AND A | Test it. | ||
| E0A2 | JR Z,RunGame_Complete | Jump to RunGame_Complete if the player has left the level. | ||
|
The player lost a life. Wipe the view off the screen and take away a life.
|
||||
| RunGame_Lost | E0A4 | CALL WipeViewOut | Wipe the view off the screen. | |
| E0A7 | LD A,($DEDE) | Fetch the number of lives. | ||
| E0AA | DEC A | Take away a life. | ||
| RunGame_Loop3 | E0AB | LD ($DEDE),A | Store the number of lives. | |
| E0AE | JR Z,RunGame_Over | Jump to RunGame_Over if the player has no lives left. | ||
|
Hand over to the other player in a game with two players, and carry on from the start of a life.
|
||||
| E0B0 | LD A,($60FD) | Fetch the number of players. | ||
| E0B3 | AND A | Test it. | ||
| E0B4 | CALL NZ,SwitchPlayer | Swap the details of the two players if there are two players. | ||
| E0B7 | JP RunGame_Life | Start the next life. | ||
|
The player has no lives left. Show the message 'GAME OVER' and the number of the player, and check the high score.
|
||||
| RunGame_Over | E0BA | CALL ResetAttributes | Reset the attributes of the screen. | |
| E0BD | CALL ClearScreen | Clear the screen. | ||
| E0C0 | LD DE,$DED0 | Point DE at GameOverText. | ||
| E0C3 | CALL PrintText | Print it. | ||
| E0C6 | CALL ShowPlayerNumber_Print | Print the number of the player and play the game over tune. | ||
| E0C9 | CALL UpdateHighScore | Check whether the score is a new high score. | ||
| E0CC | LD A,($60FD) | Fetch the number of players. | ||
| E0CF | AND A | Test it. | ||
| E0D0 | JP Z,RunGame_Loop | Go back to the title menu if there is only one player. | ||
| E0D3 | LD A,($DEFD) | Fetch the number of lives of the other player. | ||
| E0D6 | AND A | Test it. | ||
| E0D7 | JP Z,RunGame_Loop | Go back to the title menu if the other player has no lives left either. | ||
| E0DA | CALL SwitchPlayer | Swap the details of the two players. | ||
| E0DD | JP RunGame_Life | Start a life for the other player. | ||
|
The player has left the level. Go on to the next level, put all of the bottles back and give the bonus for the time that is left.
|
||||
| RunGame_Complete | E0E0 | XOR A | Clear the bottle flag of the player. | |
| E0E1 | LD ($DEFC),A | Store it. | ||
| E0E4 | LD A,($DEDF) | Fetch the number of the level. | ||
| E0E7 | INC A | Go on to the next level. | ||
| E0E8 | LD ($DEDF),A | Store it. | ||
| E0EB | LD HL,$DEE1 | Point HL at BottleStates. | ||
| E0EE | LD A,$81 | Set the state of an uncollected bottle. | ||
| E0F0 | LD B,$14 | Set the number of bottles to 14. | ||
| RunGame_Loop4 | E0F2 | LD (HL),A | Set the state of a bottle. | |
| E0F3 | INC HL | Move on to the next bottle. | ||
| E0F4 | DJNZ RunGame_Loop4 | Loop back to RunGame_Loop4 until all of the bottles have been done. | ||
| E0F6 | LD HL,$0000 | Clear the wanted heading of the player. | ||
| E0F9 | LD ($B564),HL | Store it. | ||
| E0FC | CALL PlayFanfare | Play the fanfare. | ||
| E0FF | CALL CountDownTime | Count down the time that is left and add it to the score. | ||
| E102 | CALL WipeViewOut | Wipe the view off the screen. | ||
| E105 | XOR A | Clear the restart position. | ||
| E106 | LD ($DEF7),A | Store it. | ||
|
After the last level, show the ending and finish the game.
|
||||
| E109 | LD A,($DEDF) | Fetch the number of the level. | ||
| E10C | SUB $05 | Take away the number of levels. | ||
| E10E | JR NZ,RunGame_Next | Jump to RunGame_Next if the last level has not been finished. | ||
| E110 | CALL ShowEnding | Show the ending. | ||
| E113 | XOR A | Set the number of lives to zero. | ||
| E114 | JR RunGame_Loop3 | Jump to RunGame_Loop3 to finish the game. | ||
| RunGame_Next | E116 | CALL SetLevelGraphics | Set the colours and the shape of the next level. | |
| E119 | JP RunGame_Loop2 | Start the level. | ||
| Prev: DFD1 | Up: Map | Next: E11C |