Skip to navigation

Aviator on the BBC Micro

The Theme: UpdateAliens (Part 5 of 5)

Name: UpdateAliens (Part 5 of 5) [Show more] Type: Subroutine Category: The Theme Summary: Check whether the whole wave has been destroyed, and award points accordingly Deep dive: 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
LDX #7 \ We now work through all the aliens, from alien 7 down \ to alien 0, to check whether they have all been \ destroyed (i.e. whether they all have a negative \ object ID), so set a loop counter in X .upal18 LDA alienObjectId,X \ If the X-th alien object ID is positive, then that BPL upal19 \ alien is still at large, so jump to upal19 to return \ from the subroutine, as we haven't destroyed all eight \ aliens in this wave DEX \ Decrement the loop counter to point to the next alien BPL upal18 \ Loop back until we have checked all eight aliens \ If we get here then all eight aliens have negative \ object IDs, so they have all been destroyed LDA #8 \ Set themeStatus = 8 to initiate a brand new wave of STA themeStatus \ aliens LDX #&00 \ Add 500 points to the score and make a beep by calling LDA #&50 \ ScorePoints with (X A) = &0050 JSR ScorePoints \ \ This is the score for completing a wave in the Theme LDA alienSpeed \ Set A = alienSpeed + 4 CLC ADC #4 CMP #19 \ If A >= 19, skip the following instruction, so BCS upal19 \ alienSpeed has a maximum value of 22 (as alienSpeed \ starts with a value of 10, and increases by 4 with \ each wave until it is >= 19, which happens when it \ reaches 22) STA alienSpeed \ Update alienSpeed with the faster speed so the next \ wave has faster-moving aliens .upal19 RTS \ Return from the subroutine