LDA scoreDisplayTimer \ If scoreDisplayTimer = 0, jump to main22 to skip the BEQ main22 \ following three instructions, as we are not currently \ displaying the score CMP #220 \ If scoreDisplayTimer <> 220, jump down to main23 to BNE main23 \ decrement the timer and keep displaying the score BEQ main24 \ If scoreDisplayTimer = 220, it's time to remove the \ score from the screen, so jump down to main24 .main22 LDX #&C8 \ Scan the keyboard to see if "P" is being pressed JSR ScanKeyboard BNE main25 \ If "P" is not being pressed, jump to main25 to \ continue with the main loop .main23 \ If we get here then either we just pressed "P" or the \ score is already being displayed, so in either case we \ should update the timer and display the score DEC scoreDisplayTimer \ Decrement the score timer JSR DisplayScore \ Display the score, so we show it for the first time if \ we just pressed "P", or update it if it changes while \ being displayed JMP main25 \ Jump down to main25 to continue with the main loop .main24 JSR RemoveScore \ Remove the score from the screen LDA #0 \ Set scoreDisplayTimer = 0 as we are no longer showing STA scoreDisplayTimer \ the score on-screenName: MainLoop (Part 14 of 15) [Show more] Type: Subroutine Category: Main loop Summary: Handle the score display 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 DisplayScore (category: Scoring)
Print the scores on-screen
[X]
Subroutine RemoveScore (category: Scoring)
Remove the score display from the screen
[X]
Subroutine ScanKeyboard (category: Keyboard)
Scan the keyboard for a specific key
[X]
Label main22 is local to this routine
[X]
Label main23 is local to this routine
[X]
Label main24 is local to this routine
[X]
Label main25 in subroutine MainLoop (Part 15 of 15)
[X]
Variable scoreDisplayTimer in workspace Main variable workspace
Counter for removing the score after displaying it for a fixed amount of time