.game7 \ If we get here then the game is still in progress, so \ we progress the gameplay JSR ProcessGameplay \ Run the gameplay loop that processes all game key \ presses, returning here when the player moves, quits, \ loses or pans BCC game8 \ The ProcessGameplay routine will return with the C \ flag clear if we just finished a landscape pan and the \ player is still holding down a pan key, in which case \ jump to game8 to process the pan JMP MainGameLoop \ Otherwise the ProcessGameplay routine returned because \ one of the following is true: \ \ * The Sentinel has won \ \ * The player has moved to a new tile \ \ * The player has performed a U-turn \ \ * The player has pressed the quit game key \ \ so jump to MainGameLoop to process these actions .game8 \ If we get here then the player is holding down a pan \ key and wants to pan the screen, so we need to process \ the pan LDA panKeyBeingPressed \ Update lastPanKeyPressed with the details of the pan STA lastPanKeyPressed \ key being pressed, so we can check later on whether it \ is still being held down LDA #0 \ Set numberOfScrolls = 0 to reset the scroll counter STA numberOfScrolls \ so the interrupt handler will not scroll the screen \ while we set up the new pan STA doNotDitherObject \ Clear bit 7 of doNotDitherObject to enable objects to \ be updated on the screen with a dithered effect BIT sightsAreVisible \ If bit 7 of sightsAreVisible is set then the sights BMI game9 \ are being shown, so jump to game9 to skip the \ following two instructions \ \ This ensures that when we pan the screen as a result \ of the sights moving off the edge of the screen, the \ panning process completes and doesn't get aborted if \ the player releases the pan key SEC \ The sights are not visible so we are panning the ROR keepCheckingPanKey \ screen because the player has pressed a pan key, so \ set bit 7 of keepCheckingPanKey so DrawLandscapeView \ will abort the drawing process if the player releases \ the pan key before the drawing process has finished .game9 JSR PanLandscapeView \ Pan the landscape and update the landscape view LSR keepCheckingPanKey \ Clear bit 7 of keepCheckingPanKey so DrawLandscapeView \ will keep drawing the landscape irrespective of the \ pan keys being held down (so this takes the routine \ back to its default behaviour) JSR UpdateIconsScanner \ Update the icons in the top-left corner of the screen \ to show the player's current energy level and redraw \ the scanner box LDA numberOfScrolls \ Set scrollCounter to the number of scrolls required, STA scrollCounter \ so the interrupt handler will scroll the screen by \ this many steps in the background .game10 LDA scrollCounter \ Loop around until scrollCounter is zero, so this waits BNE game10 \ until the interrupt handler has finished scrolling the \ landscape view, thus implementing the pan on-screen BEQ game7 \ Jump back to the start of part 2 to continue with \ progressing the gameplay (this BEQ is effectively a \ JMP as we just passed through a BNE)Name: MainGameLoop (Part 2 of 2) [Show more] Type: Subroutine Category: Main game loop Summary: Progress gameplay as part of the main game loop Deep dive: Program flow of the main game loopContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Subroutine MainGameLoop (Part 1 of 2) (category: Main game loop)
The main game loop for playing a landscape
[X]
Subroutine PanLandscapeView (category: Drawing the landscape)
Pan the landscape and update the landscape view
[X]
Subroutine ProcessGameplay (category: Gameplay)
A gameplay loop that processes all game key presses, returning to the main game loop when the player moves, quits, loses or pans
[X]
Subroutine UpdateIconsScanner (category: Scanner/energy row)
Update the icons in the top-left corner of the screen to show the player's current energy level and redraw the scanner box
[X]
Variable doNotDitherObject in workspace Main variable workspace
Controls whether the DitherScreenBuffer routine can update an object on the screen using a dithered effect
[X]
Label game10 is local to this routine
[X]
Label game7 is local to this routine
[X]
Label game8 is local to this routine
[X]
Label game9 is local to this routine
[X]
Variable keepCheckingPanKey in workspace Main variable workspace
Controls whether the DrawLandscapeView routine aborts drawing if the pan key is released before it has finished
[X]
Variable lastPanKeyPressed in workspace Zero page
The direction of the last pan key that was pressed (which may not still be held down)
[X]
Variable numberOfScrolls in workspace Main variable workspace
The total number of scrolls that we need to perform for the current panning operation
[X]
Variable panKeyBeingPressed in workspace Zero page
The direction in which the player is currently panning
[X]
Variable scrollCounter in workspace Main variable workspace
A counter for the number of columns or rows we still need to scroll in the player's scrolling landscape view when the player pans
[X]
Variable sightsAreVisible in workspace Main variable workspace
Controls whether the sights are being shown