.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 callName: SPS4 [Show more] Type: Subroutine Category: Maths (Geometry) Summary: Calculate the vector to the space stationContext: 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.

[X]

Workspace K% (category: Workspaces)

Ship data blocks

[X]

Configuration variable: NI% = 37

The number of bytes in each ship's data block (as stored in INWK and K%)

[X]

Label SPL1 is local to this routine

[X]

Subroutine TAS2 (category: Maths (Geometry))

Normalise the three-coordinate vector in K3