Prev: 53674 Up: Map Next: 53839
53712: Game Loop
Used by the routines at GameOver and InputHandler_Common.
Game_Loop 53712 DI Disable interrupts.
Print the main menu options.
53713 LD A,0 Set border colour to BLACK.
53715 OUT (254),A
53717 LD HL,52193 HL=Data_MainMenu.
53720 CALL UnpackScreenData Call UnpackScreenData.
53723 CALL Handler_MainMenu Call Handler_MainMenu.
Initialise a new game.
53726 LD BC,0 Initialise *Score_Digit_01, *Score_Digit_02 and *Score_Digit_03 to 000000.
53729 LD (55412),BC
53733 LD (55413),BC
53737 XOR A Write 0 to *55405.
53738 LD (55405),A
Print the in-game surround.
53741 LD A,5 Set border colour to CYAN.
53743 OUT (254),A
53745 LD HL,49830 HL=Data_PlayareaSurround.
53748 CALL UnpackScreenData Call UnpackScreenData.
Set the starting lives.
53751 LD A,4 Write 4 to *Lives.
53753 LD (55335),A
53756 LD HL,23258 Write 23258 (attribute buffer location) to *55410.
53759 LD (55410),HL
Initialise the new game with the level 1 data.
53762 LD HL,53901 Write Table_LevelData to *Pointer_CurrentLevelData.
53765 LD (53899),HL
Note, this level counter counts down instead of up.
53768 LD B,10 Set a counter in B for the total number of levels (10).
This level counter is used for display purposes.
53770 XOR A Write 0 to *Level.
53771 LD (55406),A
The game loops here in-game to begin a new level.
Game_NewLevel 53774 PUSH BC Stash the level counter on the stack.
53775 LD HL,(53899) HL=*Pointer_CurrentLevelData.
53778 LD E,(HL) DE=current level data pointer.
53779 INC HL
53780 LD D,(HL)
53781 INC HL Increment the level data pointer by one to point to the next level.
53782 LD (53899),HL Write the next level pointer to *Pointer_CurrentLevelData.
53785 EX DE,HL Exchange the DE and HL registers.
Add one to the current level.
53786 LD A,(55406) A=*Level.
53789 INC A Increment A by one.
53790 DAA Adjust A for BCD operations.
53791 LD (55406),A Write A back to *Level.
Set everything up...
53794 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.
53797 LD A,1 Set 1 in A to indicate the last level.
53799 POP BC Restore the level counter from the stack.
53800 PUSH BC But keep a stashed copy of the level counter on the stack.
53801 CP B Jump to Skip_MarilynMonroe if the level countdown is equal to 1 (and so is the last level).
53802 JR Z,Skip_MarilynMonroe
53804 CALL Print_HelperPreviewImage Else this isn't the last level; call Print_HelperPreviewImage.
Skip_MarilynMonroe 53807 CALL Colourise_PreviewGrid Call Colourise_PreviewGrid.
53810 EI Enable interrupts.
53811 CALL StartGame Call StartGame.
53814 POP BC Restore the level counter from the stack.
53815 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!
53817 LD B,30 B=30.
53819 LD HL,53839 HL=53839.
53822 CALL 61258 Call 61258.
53825 CALL Controller_GameOver Call Controller_GameOver.
Long pause...
53828 LD BC,0 BC=0000.
Pause_Loop 53831 DEC BC Decrease BC by one.
53832 LD A,B Jump to Pause_Loop until BC is zero.
53833 OR C
53834 JR NZ,Pause_Loop
53836 JP Game_Loop Jump to Game_Loop.
Prev: 53674 Up: Map Next: 53839