Skip to navigation


Start and end: RESET

[NES version, Bank 0]

Name: RESET [Show more] Type: Subroutine Category: Start and end Summary: Reset most variables
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * ShowStartScreen calls RESET * TITLE calls RESET

Reset our ship and various controls, recharge shields and energy, and then fall through into RES2 to reset the stardust and the ship workspace at INWK. In this subroutine, this means zero-filling the following locations: * BETA to BETA+6, which covers the following: * BETA, BET1 - Set pitch to 0 * XC, YC - Set text cursor to (0, 0) * QQ22 - Set hyperspace counters to 0 * ECMA - Turn E.C.M. off It also sets QQ12 to $FF, to indicate we are docked, recharges the shields and energy banks, and then falls through into RES2.
.RESET JSR ZERO ; Reset the ship slots for the local bubble of universe, ; and various flight and ship status variables LDA #%00000000 ; Clear bits 6 and 7 of selectedSystemFlag to indicate STA selectedSystemFlag ; that there is no currently selected system LDX #6 ; Set up a counter for zeroing BETA through BETA+6 .SAL3 STA BETA,X ; Zero the X-th byte after BETA DEX ; Decrement the loop counter BPL SAL3 ; Loop back for the next byte to zero TXA ; X is now negative - i.e. $FF - so this sets A and QQ12 STA QQ12 ; to $FF to indicate we are docked LDX #2 ; We're now going to recharge both shields and the ; energy bank, which live in the three bytes at FSH, ; ASH (FSH+1) and ENERGY (FSH+2), so set a loop counter ; in X for 3 bytes .REL5 STA FSH,X ; Set the X-th byte of FSH to $FF to charge up that ; shield/bank DEX ; Decrement the loop counter BPL REL5 ; Loop back to REL5 until we have recharged both shields ; and the energy bank LDA #$FF ; Set iconBarType to $FF so no icon bar is shown STA iconBarType ; Fall through into RES2 to reset the stardust and ship ; workspace at INWK