Skip to navigation

Elite on the BBC Micro and NES

Universe: NWSPS

[Elite-A, Flight]

Name: NWSPS [Show more] Type: Subroutine Category: Universe Summary: Add a new space station to our local bubble of universe
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * Main flight loop (Part 14 of 16) calls NWSPS * TT110 calls NWSPS
.NWSPS JSR SPBLB \ Light up the space station bulb on the dashboard LDX #%10000001 \ Set the AI flag in byte #32 to %10000001 (hostile, STX INWK+32 \ no AI, has an E.C.M.) \ --- Mod: Code removed for Elite-A: ------------------> \ LDX #0 \ Set pitch counter to 0 (no pitch, roll only) \ STX INWK+30 \ \ STX NEWB \ Set NEWB to %00000000, though this gets overridden by \ \ the default flags from E% in NWSHP below \ --- And replaced by: --------------------------------> LDX #255 \ Set the roll counter to 255 (maximum anti-clockwise STX INWK+29 \ roll with no damping) INX \ Set pitch counter to 0 (no pitch, roll only) STX INWK+30 \ --- End of replacement ------------------------------> STX FRIN+1 \ Set the second slot in the FRIN table to 0, so when we \ fall through into NWSHP below, the new station that \ gets created will go into slot FRIN+1, as this will be \ the first empty slot that the routine finds \ --- Mod: Code removed for Elite-A: ------------------> \ DEX \ Set the roll counter to 255 (maximum anti-clockwise \ STX INWK+29 \ roll with no damping) \ --- And replaced by: --------------------------------> STX INWK+33 \ As part of the setup, we want to point INWK(34 33) to \ LSO, the line heap for the space station. LSO is at \ &0E00, so this sets the low byte at byte #33 to 0 (we \ set the high byte below) LDA FIST \ If bit 7 of FIST is clear, i.e. FIST < 128, then jump BPL n_enemy \ to n_enemy with X = 0 to skip the following \ instruction and set the NEWB flags to 0 (so the \ station is not hostile) LDX #%00000100 \ Bit 7 of FIST is set, i.e. FIST >= 128 (so our \ "fugitive/innocent status" is very bad!), so set bit \ #3 of X so we the following sets the NEWB flags to \ make the station hostile .n_enemy STX NEWB \ Set the station's NEWB flag with the value in X, so it \ be hostile if FIST > 127, or friendly otherwise \ --- End of replacement ------------------------------> LDX #10 \ Call NwS1 to flip the sign of nosev_x_hi (byte #10) JSR NwS1 JSR NwS1 \ And again to flip the sign of nosev_y_hi (byte #12) \ --- Mod: Code added for Elite-A: --------------------> \ NwS1 increments X by 2 for each call, so at this point \ the value of X is 10 + 2 + 2 = 14 = &E, which we can \ use to set the correct INWK+34 value in the following STX INWK+34 \ As part of the setup, we want to point INWK(34 33) to \ LSO, the line heap for the space station. LSO is at \ &0E00, so this sets the high byte at byte #34 to &0E \ (we already set the low byte above) \ --- End of added code -------------------------------> JSR NwS1 \ And again to flip the sign of nosev_z_hi (byte #14) \ --- Mod: Code removed for Elite-A: ------------------> \ LDA #LO(LSO) \ Set bytes #33 and #34 to point to LSO for the ship \ STA INWK+33 \ line heap for the space station \ LDA #HI(LSO) \ STA INWK+34 \ --- End of removed code -----------------------------> LDA #SST \ Set A to the space station type, and fall through \ into NWSHP to finish adding the space station to the \ universe