Skip to navigation

Elite on the BBC Micro

Flight: ESCAPE [Elite-A, Parasite]

Name: ESCAPE [Show more] Type: Subroutine Category: Flight Summary: Launch our escape pod
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * Main flight loop (Part 3 of 16) calls ESCAPE

This routine displays our doomed Cobra Mk III disappearing off into the ether before arranging our replacement ship. Called when we press ESCAPE during flight and have an escape pod fitted.
.ESCAPE JSR RES2 \ Reset a number of flight variables and workspaces LDX #ESC \ Set the current ship type to an escape pod, so we can STX TYPE \ show it disappearing into the distance when we eject \ in our pod JSR FRS1 \ Call FRS1 to launch the escape pod straight ahead, \ like a missile launch, but with our ship instead LDA #16 \ Set the escape pod's byte #27 (speed) to 8 STA INWK+27 LDA #194 \ Set the escape pod's byte #30 (pitch counter) to 194, STA INWK+30 \ so it pitches as we pull away LSR A \ Set the escape pod's byte #32 (AI flag) to %01100001, STA INWK+32 \ so it has no AI, and we can use this value as a \ counter to do the following loop 97 times .ESL1 JSR MVEIT_FLIGHT \ Call MVEIT_FLIGHT to move the escape pod in space JSR LL9_FLIGHT \ Call LL9 to draw the Cobra on-screen DEC INWK+32 \ Decrement the counter in byte #32 BNE ESL1 \ Loop back to keep moving the Cobra until the AI flag \ is 0, which gives it time to drift away from our pod JSR SCAN \ Call SCAN to remove the Cobra from the scanner (by \ redrawing it) LDA #0 \ Set A = 0 so we can use it to zero the contents of \ the cargo hold STA QQ20+16 \ We lose any alien items when using our escape pod, so \ set QQ20+16 to 0 (which is where they are stored) LDX #12 \ We lose all our cargo canisters when using our escape \ pod (i.e. all the cargo except gold, platinum and gem \ stones), so up a counter in X so we can zero cargo \ slots 0-12 in QQ20 .ESL2 STA QQ20,X \ Set the X-th byte of QQ20 to zero, so we no longer \ have any of item type X in the cargo hold DEX \ Decrement the counter BPL ESL2 \ Loop back to ESL2 until we have emptied the entire \ cargo hold STA FIST \ Launching an escape pod also clears our criminal \ record, so set our legal status in FIST to 0 ("clean") STA ESCP \ The escape pod is a one-use item, so set ESCP to 0 so \ we no longer have one fitted INC new_hold \ We just used our escape pod, and as it's a single-use \ item, we no longer have an escape pod, so increment \ the free space in our ship's hold, as the pod is no \ longer taking up space LDA new_range \ Our replacement ship is delivered with a full tank of STA QQ14 \ fuel, so fetch our current ship's hyperspace range \ from new_range and set the current fuel level in QQ14 \ to this value JSR update_pod \ Update the dashboard colours as we no longer have an \ escape pod JSR ping \ Set the target system to the current system (which \ will move the location in (QQ9, QQ10) to the current \ home system JSR TT111 \ Select the system closest to galactic coordinates \ (QQ9, QQ10) JSR jmp \ Set the current system to the selected system JMP GOIN \ Go to the docking bay (i.e. show the ship hanger \ screen) and return from the subroutine with a tail \ call