.ResetVariables LDX #0 \ Set A = 0 to use as our zero value TXA \ Set X = 0 to use as a counter for zeroing 256 bytes in \ the rset1 loop STA alienSlot \ Set alienSlot = 0 to clear out the first alien slot \ (we clear out the other three slots below) STA forceFactor+7 \ Set the force factor for yFlapsLift = 0 STA hitTimer \ Set hitTimer = 0 to cancel any alien explosions STA randomNumbers \ Set randomNumbers = 0 to reset the pointer for the \ list of random numbers STA scoreLo \ Set (scoreHi scoreLo) = 0 to reset the current score STA scoreHi .rset1 \ This loop zeroes the whole page at pointStatus, which \ zeroes both pointStatus and objectStatus, resetting \ all the point and object statuses STA pointStatus,X \ Zero the X-th byte of pointStatus DEX \ Decrement the byte counter BNE rset1 \ Loop back until we have zeroed the whole page \ We now zero all the workspace variables from xTurnHi \ to yPlaneHi, so their default values are all zero \ unless they are explicitly set below LDX #255 \ Set X = 255 to use as a counter for zeroing 255 bytes \ in the rset2 loop STA relatedPoints \ Set relatedPoints = 0 to reset the relatedPoints list STA mainLoopCounter \ Set mainLoopCounter = 0 to reset the main loop counter .rset2 STA xTurnHi-1,X \ Zero the X-1-th byte of the workspace variables DEX \ Decrement the byte counter BNE rset2 \ Loop back until we have zeroed from xTurnHi to \ yPlaneHi \ We now zero the eight bytes at alienState to reset the \ state of the aliens LDX #7 \ Set X = 7 to use as a counter for zeroing eight bytes \ in the following loop .rset3 STA alienState,X \ Zero the X-th byte of alienState DEX \ Decrement the byte counter BPL rset3 \ Loop back until we have zeroed alienState to \ alienState+7 LDA #&48 \ Set (zPlaneHi zPlaneLo) = &485C STA zPlaneHi LDA #&5C STA zPlaneLo LDA #&C6 \ Set (xPlaneHi xPlaneLo) = &C6E5 STA xPlaneHi LDA #&E5 STA xPlaneLo LDA #&0A \ Set (yPlaneHi yPlaneLo) = &000A STA yPlaneLo STA alienSpeed \ Set alienSpeed = 10, the movement speed for the first \ wave of aliens LDA #242 \ Set the force factor for zLiftDrag = 242, which is STA forceFactor+5 \ quickly adjusted by +10 for the undercarriage being \ down and -200 for the flaps being off, giving a \ starting value of 52 when we are sitting on the runway LDA #1 \ Set ucStatus = 1, so the undercarriage is down STA ucStatus STA brakesStatus \ Set brakesStatus = 1, so the brakes are on STA landingStatus \ Set landingStatus = 1, so we do all landing tasks JSR IndicatorU \ Update the undercarriage indicator LDA #1 \ Set onGround = 1, so we start on the ground STA onGround LDA #47 \ Set lineBuffer2Count = 47, so line buffer 2 is empty STA lineBuffer2Count LDA #255 \ Set themeStatus = 255, so the Theme is disabled STA themeStatus STA lineBuffer1Count \ Set lineBuffer1Count = 255, so line buffer 1 is empty \ We now zero the eight bytes at alienObjectId, so no \ objects are associated with any aliens LDX #7 \ Set X = 7 to use as a counter for zeroing eight bytes \ in the following loop STX xRotationHi \ Set xRotationHi = 7, so the plane tilts backwards by \ 7/256 = 9.84 degrees when its wheels are on the ground .rset4 STA alienObjectId,X \ Zero the X-th byte of alienObjectId DEX \ Decrement the byte counter BPL rset4 \ Loop back until we have zeroed all 8 alienObjectId \ bytes \ We now zero alienSlot+1 to alienSlot+3 to clear out \ the rest of the alien slots (we already zeroed \ alienSlot above) LDX #2 \ Set X = 2 to use as a counter for zeroing three bytes \ in the following loop .rset5 STA alienSlot+1,X \ Zero the X-th byte of alienSlot+1 DEX \ Decrement the byte counter BPL rset5 \ Loop back until we have zeroed all three bytes JSR IndicatorT \ Update the Theme indicator LDX #11 \ Update the thrust indicator JSR UpdateIndicator LDA #65 \ Set fuelLevel = 65, to indicate a full tank STA fuelLevel \ We now drain the fuel tank one point at a time, \ updating the fuel gauge as we go so the fuel gauge \ gets cleared down to empty at the same time as \ the value in fuelLevel .rset6 DEC fuelLevel \ Decrement the counter in fuelLevel JSR UpdateFuelGauge \ Update the fuel gauge LDA fuelLevel \ Loop back until fuelLevel = 0, by which point we have BNE rset6 \ reset the fuel tanks and cleared the fuel gauge \ Fall through into ResetRadar to reset the radar \ displayName: ResetVariables [Show more] Type: Subroutine Category: Setup Summary: Reset most variables to prepare for a new flightContext: See this subroutine in context in the source code References: This subroutine is called as follows: * NewGame calls ResetVariables
[X]
Subroutine IndicatorT (category: Dashboard)
Update the Theme indicator ("T")
[X]
Subroutine IndicatorU (category: Dashboard)
Update the undercarriage indicator ("U") and related variables
[X]
Subroutine UpdateFuelGauge (category: Dashboard)
Update the fuel gauge every 16 iterations of the main loop
[X]
Subroutine UpdateIndicator (Part 1 of 15) (category: Dashboard)
Update a single indicator on the dashboard
[X]
Variable alienObjectId (category: The Theme)
Object IDs for each of the eight aliens
[X]
Variable alienSlot (category: The Theme)
Slots for up to three aliens that are ready to start moving towards the town
[X]
Variable alienSpeed in workspace Main variable workspace
The speed at which the aliens move, which starts at 10 for the first wave, then 14 for the second, 18 for the third, and 22 for all subsequent waves
[X]
Variable alienState (category: The Theme)
The state of each of the eight aliens
[X]
Variable brakesStatus in workspace Main variable workspace
Brakes status
[X]
Variable forceFactor (category: Flight model)
The factors by which the flight forces are multiplied as part of the scaling process
[X]
Variable fuelLevel (category: Flight model)
The current fuel level
[X]
Variable hitTimer (category: The Theme)
The time since we hit an alien, so we can time its explosion
[X]
Variable landingStatus in workspace Main variable workspace
The current landing status
[X]
Variable lineBuffer1Count in workspace Main variable workspace
Offset of the last line stored in buffer 1
[X]
Variable lineBuffer2Count in workspace Main variable workspace
Offset of the last line stored in buffer 2
[X]
Variable mainLoopCounter (category: Main loop)
The main loop counter
[X]
Variable onGround in workspace Main variable workspace
"On the ground" status
[X]
Variable pointStatus in workspace Main variable workspace
Each point's status byte
[X]
Variable randomNumbers (category: Utility routines)
A list for keeping a list of random numbers
[X]
Label rset1 is local to this routine
[X]
Label rset2 is local to this routine
[X]
Label rset3 is local to this routine
[X]
Label rset4 is local to this routine
[X]
Label rset5 is local to this routine
[X]
Label rset6 is local to this routine
[X]
Variable scoreHi (category: Scoring)
Score (high byte)
[X]
Variable scoreLo (category: Scoring)
Score (low byte)
[X]
Variable themeStatus in workspace Main variable workspace
Theme status
[X]
Variable ucStatus in workspace Main variable workspace
Undercarriage status
[X]
Variable xPlaneHi in workspace Main variable workspace
Plane longitude/x-coordinate (high byte)
[X]
Variable xPlaneLo in workspace Main variable workspace
Plane longitude/x-coordinate (low byte)
[X]
Variable xRotationHi in workspace Main variable workspace
Plane rotation angle around the x-axis (high byte)
[X]
Variable xTurnHi in workspace Main variable workspace
Turn rate around the x-axis (high byte)
[X]
Variable yPlaneLo in workspace Main variable workspace
Plane altitude/y-coordinate (low byte)
[X]
Variable zPlaneHi in workspace Main variable workspace
Plane latitude/z-coordinate (high byte)
[X]
Variable zPlaneLo in workspace Main variable workspace
Plane latitude/z-coordinate (low byte)