Skip to navigation

Elite on the BBC Micro and NES

Main loop: Main flight loop (Part 13 of 16)

[NES version, Bank 0]

Name: Main flight loop (Part 13 of 16) [Show more] Type: Subroutine Category: Main loop Summary: Show energy bomb effect, charge shields and energy banks Deep dive: Program flow of the main game loop Scheduling tasks with the main loop counter
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * FlightLoop4To16 calls via MA18

The main flight loop covers most of the flight-specific aspects of Elite. This section covers the following: * Show energy bomb effect (if applicable) * Charge shields and energy banks (every 7 iterations of the main loop)
Other entry points: MA18 Entry point for part 13 of the main flight loop
.MA18 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDA BOMB ; If we set off our energy bomb (see MA24 above), then BPL MA77 ; BOMB is now negative, so this skips to MA21 if our ; energy bomb is not going off ASL BOMB ; We set off our energy bomb, so rotate BOMB to the ; left by one place. BOMB was rotated left once already ; during this iteration of the main loop, back at MA24, ; so if this is the first pass it will already be ; %11111110, and this will shift it to %11111100 - so ; if we set off an energy bomb, it stays activated ; (BOMB > 0) for four iterations of the main loop BMI MA77 ; If the result has bit 7 set, skip the following ; instruction as the bomb is still going off JSR HideHiddenColour ; Set the hidden colour to black, to switch off the ; energy bomb effect (as the effect works by showing ; hidden content instead of the visible content) JSR UpdateIconBar_b3 ; Update the icon bar to remove the energy bomb icon, ; as it is a single-use weapon .MA77 LDA MCNT ; Fetch the main loop counter and calculate MCNT mod 7, AND #7 ; jumping to MA22 if it is non-zero (so the following BNE MA22 ; code only runs every 8 iterations of the main loop) JSR ChargeShields ; Charge the shields and energy banks