Skip to navigation

Elite on the BBC Micro and NES

Universe: NWSPS

[NES version, Bank 0]

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: * SpawnSpaceStation calls NWSPS * TT110 calls NWSPS
.NWSPS LDX #%10000001 ; Set the AI flag in byte #32 to %10000001 (hostile, STX INWK+32 ; no AI, has an E.C.M.) 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 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 DEX ; Set the roll counter to 255 (maximum anti-clockwise STX INWK+29 ; roll with no damping) 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) JSR NwS1 ; And again to flip the sign of nosev_z_hi (byte #14) LDA #SST ; Set A to the space station type, and fall through ; into NWSHP to finish adding the space station to the ; universe JSR NWSHP ; Call NWSHP to add the space station to the universe LDX XX21+2*SST-2 ; Set (Y X) to the address of the Coriolis station's LDY XX21+2*SST-1 ; ship blueprint LDA tek ; If the system's tech level in tek is less than 10, CMP #10 ; jump to notadodo, so tech levels 0 to 9 have Coriolis BCC notadodo ; stations, while 10 and above will have Dodo stations LDX XX21+2*DOD-2 ; Set (Y X) to the address of the Dodo station's ship LDY XX21+2*DOD-1 ; blueprint .notadodo STX spasto ; Store the address of the space station in spasto(1 0) STY spasto+1 ; so we spawn the correct type of station in part 4 of ; the main flight loop JMP UpdateIconBar_b3 ; Update the icon bar so the docking computer icon gets ; displayed to reflect that we are in the station's safe ; zone, returning from the subroutine using a tail call