Skip to navigation

Elite on the BBC Micro and NES

Flight: ESCAPE

[Elite-A, Flight]

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 \ --- Mod: Code removed for Elite-A: ------------------> \ LDX #CYL \ Set the current ship type to a Cobra Mk III, so we \ STX TYPE \ can show our ship disappear into the distance when we \ \ eject in our pod \ \ JSR FRS1 \ Call FRS1 to launch the Cobra Mk III straight ahead, \ \ like a missile launch, but with our ship instead \ \ BCS ES1 \ If the Cobra was successfully added to the local \ \ bubble, jump to ES1 to skip the following instructions \ \ LDX #CYL2 \ The Cobra wasn't added to the local bubble for some \ JSR FRS1 \ reason, so try launching a pirate Cobra Mk III instead \ \.ES1 \ \ LDA #8 \ Set the Cobra's byte #27 (speed) to 8 \ STA INWK+27 \ \ LDA #194 \ Set the Cobra's byte #30 (pitch counter) to 194, so it \ STA INWK+30 \ pitches up as we pull away \ \ LSR A \ Set the Cobra's byte #32 (AI flag) to %01100001, so it \ STA INWK+32 \ has no AI, and we can use this value as a counter to \ \ do the following loop 97 times \ --- And replaced by: --------------------------------> 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 up 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 \ --- End of replacement ------------------------------> .ESL1 JSR MVEIT \ Call MVEIT to move the escape pod in space JSR LL9 \ 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 \ --- Mod: Code removed for Elite-A: ------------------> \ LDX #16 \ We lose all our cargo when using our escape pod, so \ \ up a counter in X so we can zero the 17 cargo slots \ \ in QQ20 \ --- And replaced by: --------------------------------> 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 \ --- End of replacement ------------------------------> .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 \ --- Mod: Code removed for Elite-A: ------------------> \ LDA #70 \ Our replacement ship is delivered with a full tank of \ STA QQ14 \ fuel, so set the current fuel level in QQ14 to 70, or \ \ 7.0 light years \ --- And replaced by: --------------------------------> 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 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 \ --- End of replacement ------------------------------> JMP GOIN \ Go to the docking bay (i.e. show the ship hangar \ screen) and return from the subroutine with a tail \ call