Skip to navigation

Aviator on the BBC Micro

The Theme: UpdateAliens (Part 4 of 5)

Name: UpdateAliens (Part 4 of 5) [Show more] Type: Subroutine Category: The Theme Summary: When an alien reaches the next feeding stage, double its size Deep dive: Scheduling tasks in the main loop Alien feeding and growth patterns
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
.upal15 LDA mainLoopCounter \ If the mainLoopCounter is a multiple of 128, jump to AND #127 \ upal19 to skip the following (so we only do this part BNE upal19 \ on 2 out of every 256 iterations round the main loop, \ just like part 1) LDY #31 \ We now work our way through alien slots 31 and 32, \ so set a counter in Y for the slot number .upal16 LDX alienSlot-30,Y \ If alien slot Y contains a negative number, then the BMI upal17 \ slot is empty, so jump to upal17 to move on to the \ next slot LDA alienState,X \ If the alien's state is < 5, jump to upal17 to move on CMP #5 \ to the next slot, as the alien is still in feeding BCC upal17 \ stage 1 and doesn't need resizing CMP #20 \ If the alien's state is >= 20, jump to upal17 to move BCS upal17 \ on to the next slot, as the alien has already reached \ the last feeding stage and can't get any bigger AND #%00000011 \ Check whether the feeding state is in the form BNE upal17 \ %xxxxxx00, and if not, jump to upal17 to move on to \ the next slot \ If we get here, then the alien's state is between 6 \ and 19, and matches %xxxxxx00, so it's one of these: \ \ * 8 = %00001000 \ * 12 = %00001100 \ * 16 = %00010000 \ \ These are the points in the feeding stage when the \ size of the alien doubles JSR ResizeFeedingAlien \ Double the size of the feeding alien to move it onto \ the next feeding stage .upal17 INY \ Increment the counter to point to the next alien slot CPY #33 \ Loop back until we have done alien slots 31 and 32 BNE upal16