Skip to navigation

Aviator on the BBC Micro

Main loop: MainLoop (Part 11 of 15)

Name: MainLoop (Part 11 of 15) [Show more] Type: Subroutine Category: Main loop Summary: Process engine start and stop Deep dive: Program flow of the main game loop
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
.main17 JSR UpdateFuelGauge \ Update the fuel gauge LDX #&DC \ Scan the keyboard to see if "T" is being pressed JSR ScanKeyboard BNE main18 \ If "T" is not being pressed, jump to main18 LDA pressingT \ If pressingT is non-zero, then we are still pressing BNE main19 \ "T" having already toggled the engine, so jump down \ to main19 so we don't keep switching the engine on and \ off by accident LDA propellorStatus \ If propellorStatus is non-zero, then the propellor is BNE main20 \ broken and we can't turn on the engine, so jump to \ main20 to skip the following \ At this point, we know that "T" is being pressed, \ pressingT is zero (so we haven't yet acted on the key \ press), and propellorStatus is zero (so the propellor \ is working), so now we toggle the engine status to \ switch it on or off LDA engineStatus \ Fetch the value of engineStatus and invert bit 0 so it EOR #1 \ changes to the opposite state JSR SetEngine \ Set the engine status to the value in A LDA #1 \ Set A = 1 to use as the new value of pressingT below, BNE main19 \ so that holding down "T" won't keep toggling the \ engine status .main18 LDA #0 \ "T" is not being pressed, so set A = 0 to use as the \ new value of pressingT .main19 STA pressingT \ Set pressingT = A, so we don't try toggling the engine \ again until we release the "T" key