Skip to navigation


Start and end: RES2

[Commodore 64 version]

Name: RES2 [Show more] Type: Subroutine Category: Start and end Summary: Reset a number of flight variables and workspaces
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DEATH calls RES2 * DEATH2 calls RES2 * DOENTRY calls RES2 * ESCAPE calls RES2 * MJP calls RES2 * TT110 calls RES2 * TT18 calls RES2

This is called after we launch from a space station, arrive in a new system after hyperspace, launch an escape pod, or die a cold, lonely death in the depths of space.
Returns: Y Y is set to $FF
.RES2 JSR stopbd ; Stop playing the docking music (if it is playing) LDA BOMB ; If the energy bomb has been set off, then BOMB will be BPL BOMBOK ; negative, so this skips the following instructions if ; our energy bomb is not going off JSR BOMBOFF ; Switch off the energy bomb effect STA BOMB ; The call to BOMBOFF sets A = 0, so this zeroes BOMB to ; switch off the energy bomb explosion .BOMBOK LDA #NOST ; Reset NOSTM, the number of stardust particles, to the STA NOSTM ; maximum allowed (20) LDX #$FF ; Reset LSX2 and LSY2, the ball line heaps used by the STX LSX2 ; BLINE routine for drawing circles, to $FF, to set the STX LSY2 ; heap to empty STX MSTG ; Reset MSTG, the missile target, to $FF (no target) LDA #128 ; Set the current pitch rate to the mid-point, 128 STA JSTY STA ALP2 ; Reset ALP2 (roll sign) and BET2 (pitch sign) STA BET2 ; to negative, i.e. pitch and roll negative ASL A ; This sets A to 0 STA BETA ; Reset BETA (pitch angle alpha) to 0 STA BET1 ; Reset BET1 (magnitude of the pitch angle) to 0 STA ALP2+1 ; Reset ALP2+1 (flipped roll sign) and BET2+1 (flipped STA BET2+1 ; pitch sign) to positive, i.e. pitch and roll negative STA MCNT ; Reset MCNT (the main loop counter) to 0 STA TRIBCT ; Reset TRIBCT (the Trumbles counter) to 0 LDA #3 ; Reset DELTA (speed) to 3 STA DELTA STA ALPHA ; Reset ALPHA (roll angle alpha) to 3 STA ALP1 ; Reset ALP1 (magnitude of roll angle alpha) to 3 LDA #$10 ; Switch the text colour to white STA COL2 LDA #0 ; Set dontclip to 0 to enable line-clipping in the LL145 STA dontclip ; routine, as we only disable this for the Short-range ; Chart LDA #2*Y-1 ; Set Yx2M1 to the number of pixel lines in the space STA Yx2M1 ; view LDA SSPR ; Fetch the "space station present" flag, and if we are BEQ P%+5 ; not inside the safe zone, skip the next instruction JSR SPBLB ; Light up the space station bulb on the dashboard LDA ECMA ; Fetch the E.C.M. status flag, and if E.C.M. is off, BEQ yu ; skip the next instruction JSR ECMOF ; Turn off the E.C.M. sound .yu JSR WPSHPS ; Wipe all ships from the scanner JSR ZERO ; Reset the ship slots for the local bubble of universe, ; and various flight and ship status variables LDA #LO(LS%) ; We have reset the ship line heap, so we now point STA SLSP ; SLSP to LS% (the byte below the ship blueprints at D%) LDA #HI(LS%) ; to indicate that the heap is empty STA SLSP+1 ; Finally, fall through into ZINF to reset the INWK ; ship workspace