Skip to navigation


Flight: ChargeShields

[NES version, Bank 0]

Name: ChargeShields [Show more] Type: Subroutine Category: Flight Summary: Charge the shields and energy banks
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * InSystemJump calls ChargeShields * Main flight loop (Part 13 of 16) calls ChargeShields
.ChargeShields 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 LDX ENERGY ; Fetch our ship's energy levels and skip to b if bit 7 BPL b ; is not set, i.e. only charge the shields from the ; energy banks if they are at more than 50% charge LDX ASH ; Call SHD to recharge our aft shield and update the JSR SHD ; shield status in ASH STX ASH LDX FSH ; Call SHD to recharge our forward shield and update JSR SHD ; the shield status in FSH STX FSH .b SEC ; Set A = ENERGY + ENGY + 1, so our ship's energy LDA ENGY ; level goes up by 2 if we have an energy unit fitted, ADC ENERGY ; otherwise it goes up by 1 BCS paen1 ; If the value of A did not overflow (the maximum STA ENERGY ; energy level is $FF), then store A in ENERGY .paen1 RTS ; Return from the subroutine