Skip to navigation

Main game loop: PlayGame

Name: PlayGame [Show more] Type: Subroutine Category: Main game loop Summary: Start playing the generated landscape Deep dive: Program flow of the main game loop
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * CheckSecretCode (Part 2 of 2) calls PlayGame
EQUB &B9 \ This byte is never executed, as the stack modification \ in part 2 of the CheckSecretCode routine sets the \ return address on the stack to PlayGame-1, so the RTS \ instruction at the end of CheckSecretCode will \ therefore jump to PlayGame (as that's how the RTS \ instruction works) \ \ This byte is the opcode for a Y-indexed absolute LDA \ instruction, so this makes it look like there is a \ PlayGame routine that starts with the following: \ \ &B9 &A9 &83 LDA &83A9,Y \ \ as the LDA instruction below assembles into &A9 &83 \ \ This is intended to confuse any crackers who have \ reached this point in their analysis .PlayGame LDA #&83 \ Set the palette to the first set of colours from the JSR SetColourPalette \ colourPalettes table, which the SpawnEnemies routine \ set to the correct palette for playing the game (so \ for landscape 0000 that would be blue, black, white \ and green, for example) \ \ So this displays the landscape preview screen that we \ drew in PreviewLandscape with an all-blue palette \ before jumping here JSR ReadKeyboard \ Enable the keyboard, flush the keyboard buffer and \ read a character from it (so this waits for a key \ press before starting the game, following the "PRESS \ ANY KEY" message on the landscape preview screen) LSR gameInProgress \ Clear bit 7 of gameInProgress to indicate that a game \ now in progress and we are no longer in the title and \ preview screens (so the interrupt handler can now \ update the game)