.clan1 LDA yPlaneHi \ If the high byte of the plane's y-coordinate is BMI clan3 \ negative, then jump to clan3 to zero it (as we can't \ be below ground level) BEQ clan4 \ If the high byte of the plane's y-coordinate is zero, \ then jump to clan4 to keep checking for a good landing CMP #2 \ If the high byte of the plane's y-coordinate is < 2, BCC clan2 \ skip the following instruction STA reached512ft \ The high byte of the plane's y-coordinate is >= 2, so \ set reached512ft to a non-zero value to indicate that \ we have reached 512 feet .clan2 LDA #0 \ If we get here then either the high byte of the STA onGround \ plane's y-coordinate is positive and non-zero, in \ which case we are at least 256 feet above the ground, \ or the plane is further from the ground than the \ distance from the cockpit to the lowest part of the \ plane, in which case we have not touched down, so \ set onGround to 0 to indicate that we are not on the \ ground RTS \ Return from the subroutine .clan3 LDX #&EE \ If we get here then yPlaneHi is negative, so set JSR ResetVariable \ (yPlaneHi yPlaneLo) = 0 as we can't be below ground .clan4 LDA yLandingGear \ If yLandingGear < yPlaneLo then the plane is further CMP yPlaneLo \ from the ground than the distance from the cockpit to BCC clan2 \ the lowest part of the plane, so we are still flying \ above the ground and have not touched down, so jump \ up to clan2 to return from the subroutineName: ProcessLanding (Part 2 of 7) [Show more] Type: Subroutine Category: Flight model Summary: If we are too high to be touching the ground then we can't be landing, so stop the landing checks Deep dive: Take-offs and landingsContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
This part checks whether the plane is touching the ground, and aborts the landing checks if it isn't.
[X]
Subroutine ResetVariable (category: Utility routines)
Set a 16-bit in the variable workspace to 0
[X]
Label clan2 is local to this routine
[X]
Label clan3 is local to this routine
[X]
Label clan4 is local to this routine
[X]
Variable onGround in workspace Main variable workspace
"On the ground" status
[X]
Variable reached512ft in workspace Main variable workspace
Have we reached 512 feet in altitude since taking off?
[X]
Variable yLandingGear in workspace Main variable workspace
The vertical distance between the cockpit and the lowest part of the plane
[X]
Variable yPlaneHi in workspace Main variable workspace
Plane altitude/y-coordinate (high byte)
[X]
Variable yPlaneLo in workspace Main variable workspace
Plane altitude/y-coordinate (low byte)