Prev: D1AA Up: Map Next: D24F
D1D0: Game Loop
Used by the routines at GameOver and InputHandler_Common.
Game_Loop D1D0 DI Disable interrupts.
Print the main menu options.
D1D1 LD A,$00 Set border colour to BLACK.
D1D3 OUT ($FE),A
D1D5 LD HL,$CBE1 HL=Data_MainMenu.
D1D8 CALL UnpackScreenData Call UnpackScreenData.
D1DB CALL Handler_MainMenu Call Handler_MainMenu.
Initialise a new game.
D1DE LD BC,$0000 Initialise *Score_Digit_01, *Score_Digit_02 and *Score_Digit_03 to 000000.
D1E1 LD ($D874),BC
D1E5 LD ($D875),BC
D1E9 XOR A Write 00 to *D86D.
D1EA LD ($D86D),A
Print the in-game surround.
D1ED LD A,$05 Set border colour to CYAN.
D1EF OUT ($FE),A
D1F1 LD HL,$C2A6 HL=Data_PlayareaSurround.
D1F4 CALL UnpackScreenData Call UnpackScreenData.
Set the starting lives.
D1F7 LD A,$04 Write 04 to *Lives.
D1F9 LD ($D827),A
D1FC LD HL,$5ADA Write 5ADA (attribute buffer location) to *D872.
D1FF LD ($D872),HL
Initialise the new game with the level 1 data.
D202 LD HL,$D28D Write Table_LevelData to *Pointer_CurrentLevelData.
D205 LD ($D28B),HL
Note, this level counter counts down instead of up.
D208 LD B,$0A Set a counter in B for the total number of levels (0A).
This level counter is used for display purposes.
D20A XOR A Write 00 to *Level.
D20B LD ($D86E),A
The game loops here in-game to begin a new level.
Game_NewLevel D20E PUSH BC Stash the level counter on the stack.
D20F LD HL,($D28B) HL=*Pointer_CurrentLevelData.
D212 LD E,(HL) DE=current level data pointer.
D213 INC HL
D214 LD D,(HL)
D215 INC HL Increment the level data pointer by one to point to the next level.
D216 LD ($D28B),HL Write the next level pointer to *Pointer_CurrentLevelData.
D219 EX DE,HL Exchange the DE and HL registers.
Add one to the current level.
D21A LD A,($D86E) A=*Level.
D21D INC A Increment A by one.
D21E DAA Adjust A for BCD operations.
D21F LD ($D86E),A Write A back to *Level.
Set everything up...
D222 CALL Game_Initialisation Call Game_Initialisation.
Marilyn Monroe is the last level, and to make it more difficult, no preview image is shown. Instead, the last frame of the "static" generated by StaticAnimation is left on the screen.
D225 LD A,$01 Set 01 in A to indicate the last level.
D227 POP BC Restore the level counter from the stack.
D228 PUSH BC But keep a stashed copy of the level counter on the stack.
D229 CP B Jump to Skip_MarilynMonroe if the level countdown is equal to 01 (and so is the last level).
D22A JR Z,Skip_MarilynMonroe
D22C CALL Print_HelperPreviewImage Else this isn't the last level; call Print_HelperPreviewImage.
Skip_MarilynMonroe D22F CALL Colourise_PreviewGrid Call Colourise_PreviewGrid.
D232 EI Enable interrupts.
D233 CALL StartGame Call StartGame.
D236 POP BC Restore the level counter from the stack.
D237 DJNZ Game_NewLevel Decrease the level counter by one and loop back to Game_NewLevel until all the levels have been played.
The game has been completed!
D239 LD B,$1E B=1E.
D23B LD HL,$D24F HL=D24F.
D23E CALL $EF4A Call EF4A.
D241 CALL Controller_GameOver Call Controller_GameOver.
Long pause...
D244 LD BC,$0000 BC=0000.
Pause_Loop D247 DEC BC Decrease BC by one.
D248 LD A,B Jump to Pause_Loop until BC is zero.
D249 OR C
D24A JR NZ,Pause_Loop
D24C JP Game_Loop Jump to Game_Loop.
Prev: D1AA Up: Map Next: D24F