Skip to navigation

Elite on the BBC Micro and NES

Main loop: Main game loop (Part 6 of 6)

[Elite-A, Flight]

Name: Main game loop (Part 6 of 6) [Show more] Type: Subroutine Category: Main loop Summary: Process non-flight key presses (red function keys, docked keys) 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: * RSHIPS calls via FRCE

This is the second half of the minimal game loop, which we iterate when we are docked. This section covers the following: * Process more key presses (red function keys, docked keys etc.) It also supports joining the main loop with a key already "pressed", so we can jump into the main game loop to perform a specific action. In practice, this is used when we enter the docking bay in BAY to display Status Mode (red key f8), and when we finish buying or selling cargo in BAY2 to jump to the Inventory (red key f9).
Other entry points: FRCE The entry point for the main game loop if we want to jump straight to a specific screen, by pretending to "press" a key, in which case A contains the internal key number of the key we want to "press"
.FRCE \ --- Mod: Code added for Elite-A: --------------------> PHA \ Store the key to "press" in A on the stack LDA QQ22+1 \ Fetch QQ22+1, which contains the number that's shown \ on-screen during hyperspace countdown BNE l_locked \ If the hyperspace countdown is non-zero, jump to \ l_locked so the key does not get "pressed" PLA \ Retrieve the key to "press" from the stack into A so \ we can now process it \ --- End of added code -------------------------------> JSR TT102 \ Call TT102 to process the key pressed in A JMP TT100 \ Otherwise jump to TT100 to restart the main loop from \ the start \ --- Mod: Code added for Elite-A: --------------------> .l_locked PLA \ Retrieve the key to "press" from the stack into A JSR TT107 \ Call TT107 to progress the countdown of the hyperspace \ counter JMP TT100 \ Jump to TT100 to restart the main loop from the start \ --- End of added code ------------------------------->