.UpdateAliens LDA mainLoopCounter \ If the mainLoopCounter is a multiple of 128, jump to AND #127 \ upal3 to move on to part 2 (so we only do this part BNE upal3 \ on 2 out of every 256 iterations round the main loop) LDX #7 \ We now progress the state of each alien, from alien 7 \ down to alien 0, so set a loop counter in X .upal1 LDA alienState,X \ If the state of alien X is zero, jump to upal2 BEQ upal2 \ to move on to the next alien CMP #22 \ If the state of alien X is 22, jump to upal2 BEQ upal2 \ to move on to the next alien CMP #27 \ If the state of alien X is 27 or higher, jump BCS upal2 \ to upal2 to move on to the next alien INC alienState,X \ If we get here then the state of alien X is not 0, 22 \ or >= 27, i.e. it's 1-21 or 23-26, so increment the \ state to progress through the feeding and take-off \ stages .upal2 DEX \ Decrement the alien number BPL upal1 \ Loop back until we have progressed all eight aliens \ to the next stateName: UpdateAliens (Part 1 of 5) [Show more] Type: Subroutine Category: The Theme Summary: Update the aliens so they progress through their feeding or attack cycles Deep dive: Scheduling tasks in the main loop Alien feeding and growth patternsContext: See this subroutine in context in the source code References: This subroutine is called as follows: * MainLoop (Part 6 of 15) calls UpdateAliens
We start by incrementing the state of any non-dormant aliens, so they slowly move through their feeding or take-off cycles.
The state of each of the eight aliens
The main loop counter
Label upal1 is local to this routine
Label upal2 is local to this routine