Skip to navigation


Utility routines: ZERO

[NES version, Bank 0]

Name: ZERO [Show more] Type: Subroutine Category: Utility routines Summary: Reset the local bubble of universe and ship status
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * RES2 calls ZERO * RESET calls ZERO

This resets the following workspaces to zero: * WP workspace variables from FRIN to de, which include the ship slots for the local bubble of universe, and various flight and ship status variables, including the MANY block
.ZERO JSR SetupPPUForIconBar ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDX #(de-FRIN+1) ; We're going to zero the WP workspace variables from ; FRIN to de, so set a counter in X for the correct ; number of bytes LDA #0 ; Set A = 0 so we can zero the variables .ZEL STA FRIN-1,X ; Zero byte X-1 of FRIN to de DEX ; Decrement the loop counter BNE ZEL ; Loop back to zero the next variable until we have done ; them all from FRIN to FRIN+42 LDX #NTY ; We're now going to zero the NTY bytes in the MANY ; block, so set a counter in X for the correct number of ; bytes .ZEL2 STA MANY,X ; Zero the X-th byte of MANY DEX ; Decrement the loop counter BPL ZEL2 ; Loop back to zero the next variable until we have done ; them all from MANY to MANY+33 JSR SetupPPUForIconBar ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 RTS ; Return from the subroutine