Elite on the BBC Micro and NES

# Flight: DCS1

## [6502 Second Processor version]

Name: DCS1 Type: Subroutine Category: Flight Summary: Calculate the vector from the ideal docking position to the ship
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DOCKIT calls DCS1

This routine is called by the docking computer routine in DOCKIT. It works out the vector between the ship and the ideal docking position, which is straight in front of the docking slot, but some distance away. Specifically, it calculates the following: * K3(2 1 0) = K3(2 1 0) - nosev_x_hi * 4 * K3(5 4 3) = K3(5 4 3) - nosev_y_hi * 4 * K3(8 7 6) = K3(8 7 6) - nosev_x_hi * 4 where K3 is the vector from the station to the ship, and nosev is the nose vector for the space station. The nose vector points from the centre of the station through the slot, so -nosev * 4 is the vector from a point in front of the docking slot, but some way from the station, back to the centre of the station. Adding this to the vector from the station to the ship gives the vector from the point in front of the station to the ship. In practice, this routine is called twice, so the ideal docking position is actually at a distance of 8 unit vectors from the centre of the station. Back in DOCKIT, we flip this vector round to get the vector from the ship to the point in front of the station slot.
Arguments: K3 The vector from the station to the ship
Returns: K3 The vector from the ship to the ideal docking position (4 unit vectors from the centre of the station for each call to DCS1, so two calls will return the vector to a point that's 8 unit vectors from the centre of the station)