Skip to navigation

Main loop: MainLoop (Part 5 of 15)

Name: MainLoop (Part 5 of 15) [Show more] Type: Subroutine Category: Main loop Summary: Update lines, check flying skills, increment main loop counter, update the radar 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
.main6 JSR UpdateLinesToShow \ Update the linesToShow list, moving any lines that \ aren't visible into the linesToHide list JSR ExplodeAlien \ If an alien has been hit, process its explosion, with \ all the convulsions that entails LDY #2 \ Check to see if we are flying under the suspension JSR CheckFlyingSkills \ bridge and award points if we are LDY #34 \ Check to see if we are flying down the main street of JSR CheckFlyingSkills \ Acornsville and award points if we are INC mainLoopCounter \ Increment the main loop counter LDA mainLoopCounter \ If (loop counter + 4) mod 8 <> 0, jump to main7, so CLC \ we only do the following once every 8 iterations of ADC #4 \ the main loop, when the loop counter is 4, 12, 20 and AND #7 \ so on BNE main7 LDY #1 \ Update the runway on the radar JSR UpdateRadarBlip LDX alienToMove \ Set X to the number of the alien whose turn it is to \ move towards Acornsville in this iteration of the main \ loop, which we set in UpdateAliens BMI main7 \ If X is negative, then there is no alien to move, so \ jump to main7 to skip the following LDY #33 \ Set Y = 33 so the call to UpdateRadarBlip updates the \ alien on the radar LDA alienState,X \ If the moving alien's state is < 27, skip the CMP #27 \ following instruction as the alien is not flying BCC main7 JSR UpdateRadarBlip \ The moving alien's state is >= 27, which means it is \ either flying to Acornsville or is in the final \ descent stage, so update the alien on the radar