Aviator on the BBC Micro

# 3D geometry: AddTempToPoint (Part 1 of 2)

```       Name: AddTempToPoint (Part 1 of 2)                            [Show more]
Type: Subroutine
Category: 3D geometry
Summary: Add the xTemp1 vector to a point, store the result in another
point, and set the result to hidden if it overflows
Context: See this subroutine in context in the source code
References: This subroutine is called as follows:
* ProcessRunwayLine (Part 2 of 5) calls AddTempToPoint
* ProcessRunwayLine (Part 4 of 5) calls AddTempToPoint
* ProcessRunwayLine (Part 5 of 5) calls AddTempToPoint

Set point X to the sum of the xTemp1 vector and point Y. In other words, add
the following:

(xTemp1 yTemp1 zTemp1) + point Y's coordinate in (xPoint, yPoint, zPoint)

and store the results in point X's coordinate in (xPoint, yPoint, zPoint).

We also set showLine to "hidden" if the addition overflows in any of the axes.

Arguments:

X                    The ID of the point in which to store the result

Y                    The ID of the point to add to the xTemp1 vector

Returns:

showLine             If the calculation overflows, then the coordinate does
not fit within the boundaries of Aviator's 3D world, so
bit 6 is set to indicate that the line containing this
point should not be shown

LDA xTemp1Lo           \ Set point X's x-coordinate to the following:
CLC                    \
ADC xPointLo,Y         \  (xTemp1Hi xTemp1Lo) + (xPointHi+Y xPointLo+Y)
STA xPointLo,X         \
LDA xTemp1Hi           \ i.e. we add xTemp1 and point Y's x-coordinate
STA xPointHi,X

PHP                    \ Store the flags for the x-axis addition on the stack,
\ so we can check them in part 2

CLC                    \ Set point X's y-coordinate to the following:
LDA yTemp1Lo           \
ADC yPointLo,Y         \  (yTemp1Hi yTemp1Lo) + (yPointHi+Y yPointLo+Y)
STA yPointLo,X         \
LDA yTemp1Hi           \ i.e. we add yTemp1 and point Y's y-coordinate
STA yPointHi,X

PHP                    \ Store the flags for the y-axis addition on the stack,
\ so we can check them in part 2

CLC                    \ Set point X's z-coordinate to the following:
LDA zTemp1Lo           \
ADC zPointLo,Y         \  (zTemp1Hi zTemp1Lo) + (zPointHi+Y zPointLo+Y)
STA zPointLo,X         \
LDA zTemp1Hi           \ i.e. we add zTemp1 and point Y's z-coordinate