Skip to navigation

Elite on the BBC Micro and NES

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

[BBC Master version]

Name: Main game loop (Part 5 of 6) [Show more] Type: Subroutine Category: Main loop Summary: Cool down lasers, make calls to update the dashboard Deep dive: Program flow of the main game loop The dashboard indicators
Context: See this subroutine in context in the source code Variations: See code variations for this subroutine in the different versions References: This subroutine is called as follows: * Main game loop (Part 2 of 6) calls via MLOOP * Main game loop (Part 3 of 6) calls via MLOOP * Main game loop (Part 4 of 6) calls via MLOOP * Main game loop (Part 6 of 6) calls via MLOOP

This is the first half of the minimal game loop, which we iterate when we are docked. This section covers the following: * Cool down lasers * Make calls to update the dashboard
Other entry points: MLOOP The entry point for the main game loop. This entry point comes after the call to the main flight loop and spawning routines, so it marks the start of the main game loop for when we are docked (as we don't need to call the main flight loop or spawning routines if we aren't in space)
.MLOOP LDX #&FF \ Set the stack pointer to &01FF, which is the standard TXS \ location for the 6502 stack, so this instruction \ effectively resets the stack LDX GNTMP \ If the laser temperature in GNTMP is non-zero, BEQ EE20 \ decrement it (i.e. cool it down a bit) DEC GNTMP .EE20 LDX LASCT \ Set X to the value of LASCT, the laser pulse count BEQ NOLASCT \ If X = 0 then jump to NOLASCT to skip reducing LASCT, \ as it can't be reduced any further DEX \ Decrement the value of LASCT in X BEQ P%+3 \ If X = 0, skip the next instruction DEX \ Decrement the value of LASCT in X again STX LASCT \ Store the decremented value of X in LASCT, so LASCT \ gets reduced by 2, but not into negative territory .NOLASCT \LDA QQ11 \ These instructions are commented out in the original \BNE P%+5 \ source JSR DIALS \ Call DIALS to update the dashboard LDA QQ11 \ If this is a space view, jump to plus13 to skip the BEQ plus13 \ following five instructions AND PATG \ If PATG = &FF (author names are shown on start-up) LSR A \ and bit 0 of QQ11 is 1 (the current view is type 1), BCS P%+7 \ then skip the following two instructions LDY #2 \ Wait for 2/50 of a second (0.04 seconds), to slow the JSR DELAY \ main loop down a bit .plus13 JSR TT17 \ Scan the keyboard for the cursor keys or joystick, \ returning the cursor's delta values in X and Y and \ the key pressed in A