Prev: 31874 Up: Map Next: 32327
32217: Start Game
Used by the routine at TitleScreen.
First collect the control method.
StartGame 32217 CALL Print_ControlMenu Call Print_ControlMenu.
This is a game the player started, so disable the demo mode and unset the game-over flag.
32220 XOR A Write 0 to;
32221 LD (26357),A
32224 LD (26355),A
32227 INC A Write 1 to *Flag_ExtraLife.
32228 LD (26351),A
32231 LD A,4 Write 4 to *Phase.
32233 LD (26353),A
Set the players starting life count.
32236 INC A Write 5 to *Player_Lives.
32237 LD (26352),A
32240 CALL InitialiseLevel Call InitialiseLevel.
Game_Loop 32243 CALL Handler_PlayerDeathGameOver Call Handler_PlayerDeathGameOver.
32246 CALL Handler_AliensMovement_Spawning Call Handler_AliensMovement_Spawning.
32249 CALL Handler_Aliens Call Handler_Aliens.
32252 CALL Handler_AlienExplosions Call Handler_AlienExplosions.
32255 CALL Handler_LevelReset Call Handler_LevelReset.
32258 CALL DifficultyDelay Call DifficultyDelay.
32261 LD A,(26357) Jump back to Game_Loop unless *Flag_GameOver is active.
32264 OR A
32265 JR Z,Game_Loop
*Flag_GameOver is active, start the "Game Over" process.
32267 LD D,8 Set an outer loop counter in D for 8 loops.
GameOver_PauseOuterLoop 32269 LD BC,0 Set an inner counter in BC of 0000 (65536 as it decreases by one in the loop).
GameOver_PauseInnerLoop 32272 DJNZ GameOver_PauseInnerLoop Decrease the counter in B by one and loop back to GameOver_PauseInnerLoop until the counter is zero.
32274 DEC C Decrease C by one.
32275 JR NZ,GameOver_PauseInnerLoop Jump back to GameOver_PauseInnerLoop until C is zero.
32277 DEC D Decrease the outer loop counter by one.
32278 JR NZ,GameOver_PauseOuterLoop Jump back to GameOver_PauseOuterLoop until the outer loop is zero.
Did the player achieve a new high score?
32280 LD HL,25876 HL=Messaging_Score.
32283 LD DE,25887 DE=Messaging_HighScore.
32286 LD B,6 Set a length counter in B for 6 score digits to compare.
32288 PUSH HL Stash the score and highscore pointers on the stack.
32289 PUSH DE
CompareScoreDigit 32290 LD A,(DE) Jump to CheckNextScoreDigit if the players score digit is equal to the same digit of the highscore.
32291 CP (HL)
32292 JR Z,CheckNextScoreDigit
32294 JR C,SetHighScore Jump to SetHighScore if the players score digit is less than the same digit of the highscore.
32296 JR ScoresAreBothEqual Jump to ScoresAreBothEqual.
Move to the next digits of the score/ highscore.
CheckNextScoreDigit 32298 INC DE Move to the next digit of the score.
32299 INC HL Move to the next digit of the highscore.
32300 DJNZ CompareScoreDigit Decrease counter by one and loop back to CompareScoreDigit until all digits of the scores have been compared.
If we got here then the scores are the same so don't do anything/ treat this as though the score was less than the highscore and move on and reset.
ScoresAreBothEqual 32302 POP DE Restore the highscore pointer from the stack.
32303 JR Reset_ScoreMessaging Jump to Reset_ScoreMessaging.
A new highscore has been achieved, so overwrite the current highscore.
SetHighScore 32305 POP DE Restore the score and highscore pointers from the stack.
32306 POP HL
32307 PUSH HL Stash the highscore pointer on the stack.
32308 LD BC,6 Copy 0006 bytes from the players score over to the highscore messaging buffer.
32311 LDIR
Reset the players score to "000000".
Reset_ScoreMessaging 32313 POP HL Restore the score pointer from the stack.
32314 LD DE,25877 Point the target (DE) to the second digit of the players score: 25877.
32317 LD (HL),48 Write ASCII 48 ("0") to *HL.
32319 LD BC,5 Copy the "0" across the rest of the 0005 bytes of the score.
32322 LDIR
32324 JP TitleScreen Jump to TitleScreen.
Prev: 31874 Up: Map Next: 32327