Skip to navigation

Elite on the BBC Micro and NES

Maths (Geometry): SPS4

[BBC Micro disc version, Flight]

Name: SPS4 [Show more] Type: Subroutine Category: Maths (Geometry) Summary: Calculate the vector to the space station
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * SP1 calls SPS4

Calculate the vector between our ship and the space station and store it in XX15.
.SPS4 LDX #8 \ First we need to copy the space station's coordinates \ into K3, so set a counter to copy the first 9 bytes \ (the 3-byte x, y and z coordinates) from the station's \ data block at K% + NI% into K3 .SPL1 LDA K%+NI%,X \ Copy the X-th byte from the station's data block at STA K3,X \ K% + NI% to the X-th byte of K3 DEX \ Decrement the loop counter BPL SPL1 \ Loop back to SPL1 until we have copied all 9 bytes JMP TAS2 \ Call TAS2 to build XX15 from K3, returning from the \ subroutine using a tail call