Skip to navigation

Flight model: SetEngine

Name: SetEngine [Show more] Type: Subroutine Category: Flight model Summary: Set the engine status
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * ApplyFlightModel (Part 7 of 7) calls SetEngine * MainLoop (Part 11 of 15) calls SetEngine * ProcessLanding (Part 6 of 7) calls SetEngine

Arguments: A The new status of the engine: * 0 = engine off * 1 = engine on
.SetEngine CMP engineStatus \ If the value of engineStatus is already the same as A, BEQ seng3 \ jump to seng3 to return from the subroutine STA engineStatus \ Update the value of engineStatus to the new status in \ A TAX \ Either turn the engine sound off (if A = 0) or turn it JSR ToggleEngineSound \ on (if A is non-zero) LDA forceFactor+5 \ Set A to the force factor for zLiftDrag LDX engineStatus \ If the engine is now on, jump to seng1 BNE seng1 CLC \ Set A = A + 20 ADC #20 \ \ so having the engine off increases drag BNE seng2 \ Jump to seng2 (this BNE is effectively a JMP as A is \ never zero) .seng1 SEC \ Set A = A - 20 SBC #20 \ \ so having the engine on decreases drag .seng2 STA forceFactor+5 \ Update the force factor for zLiftDrag, so it is \ incremented by 20 when the engine is off, and reduced \ by 20 when the engine is on, i.e. having the engine \ off increases drag .seng3 RTS \ Return from the subroutine