.FillUpFuelTank LDA mainLoopCounter \ If the mainLoopCounter is a multiple of 4, jump to AND #3 \ fuel1 to add some fuel to the tank (so we do this BEQ fuel1 \ every four iterations of the main loop) RTS \ Return from the subroutine .fuel1 TAX \ We got here because A = 0, so this sets X = 0 LDA fuelLevel \ If fuelLevel >= 65, then the tank is already full, so CMP #65 \ jump to fuel2 to skip filling it up any more BCS fuel2 INC fuelLevel \ fuelLevel < 65, so increment the fuel level by 1, to \ fill up the fuel tank by 1/65th of a full tank JMP DrawFuelPixel \ Draw an extra pixel at the top of the fuel level, so \ the fuel gauge goes up by one pixel, returning from \ the subroutine using a tail call .fuel2 \ If we get here then the fuel tank is full STX landingStatus \ Set landingStatus = 0 to disable all the landing tasks \ in the main loop, including filling up with fuel RTS \ Return from the subroutineName: FillUpFuelTank [Show more] Type: Subroutine Category: Flight model Summary: Fill up the fuel tank by 1/65th of a full tank every four iterations of the main loop Deep dive: Scheduling tasks in the main loopContext: See this subroutine in context in the source code References: This subroutine is called as follows: * MainLoop (Part 9 of 15) calls FillUpFuelTank
[X]
Subroutine DrawFuelPixel (category: Dashboard)
Draw or erase a pixel on the fuel gauge on the dashboard
[X]
Label fuel1 is local to this routine
[X]
Label fuel2 is local to this routine
[X]
Variable fuelLevel (category: Flight model)
The current fuel level
[X]
Variable landingStatus in workspace Main variable workspace
The current landing status
[X]
Variable mainLoopCounter (category: Main loop)
The main loop counter