Skip to navigation

Elite on the BBC Micro and NES

Start and end: RES2

[NES version, Bank 0]

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 * PlayDemo 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 SEI ; Disable interrupts from any source except NMI, as we ; don't want any other interrupts to occur LDA #1 ; Set enableBitplanes to 1 so the game starts to use STA enableBitplanes ; two different bitplanes when displaying the screen LDA #1 ; Set the tile number for the left edge of the box to STA boxEdge1 ; tile 1, which is the standard edge for the box LDA #2 ; Set the tile number for the right edge of the box to STA boxEdge2 ; tile 2, which is the standard edge for the box LDA #80 ; Tell the PPU to send nametable entries up to tile STA lastNameTile ; 80 * 8 = 640 (i.e. to the end of tile row 19) in both STA lastNameTile+1 ; bitplanes LDA BOMB ; If the energy bomb has not been set off, jump to rese1 BPL rese1 ; to skip the following 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) STA BOMB ; The call to HideHiddenColour sets A = 15, which has ; bit 7 clear, so this clears bit 7 of BOMB to disable ; the energy bomb explosion .rese1 LDA #NOST ; Reset NOSTM, the number of stardust particles, to the STA NOSTM ; maximum allowed (20) LDX #$FF ; Reset MSTG, the missile target, to $FF (no target) STX MSTG LDA allowInSystemJump ; Set bit 7 of allowInSystemJump to prevent us from ORA #%10000000 ; being able to perform an in-system jump, as this is STA allowInSystemJump ; the default setting after launching LDA #128 ; Set the current pitch and roll rates to the mid-point, STA JSTX ; 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 demoInProgress ; Set demoInProgress to 0 to reset the demo flag, so if ; we are starting the game after playing the demo, the ; flag will be set correctly 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 LAS ; Set LAS to 0, to switch off laser pulsing STA unusedVariable ; Set unusedVariable to 0 (this is never read, so this ; has no effect) STA chargeDockingFee ; Set chargeDockingFee to 0 so the docking fee is marked ; as being not already paid 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 #72 ; Set the screen height variables for a screen height of JSR SetScreenHeight ; 144 (i.e. 2 * 72) 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 LDA QQ11a ; If bit 7 of the old view in QQ11a is set, then the old BMI rese2 ; view does not have a dashboard, so jump to rese2 to ; skip the following, as there is no scanner to clear JSR HideExplosionBurst ; Hide the four sprites that make up the explosion burst JSR ClearScanner ; Remove all ships from the scanner and hide the scanner ; sprites .rese2 JSR ZERO ; Reset the ship slots for the local bubble of universe, ; and various flight and ship status variables ; Finally, fall through into ZINF to reset the INWK ; ship workspace