.MultiplyHeight STA U \ Set U to the multiplication factor in A LDA yTrackSegmentI,Y \ Store the sign of the height * directionFacing on EOR directionFacing \ the stack PHP LDA yTrackSegmentI,Y \ Set A to the track height in the Y-th yTrackSegmentI JSR Absolute8Bit \ Set A = |A| \ = |yTrackSegmentI| JSR Multiply8x8 \ Set (A T) = A * U \ = U * |yTrackSegmentI| PLP \ Set the N flag to the sign of yTrackSegmentI * \ directionFacing, so this will be set if the height \ sign is different to bit 7 of directionFacing, clear \ if the height sign matches bit 7 of directionFacing JSR Absolute8Bit \ Give A the sign in the N flag RTS \ Return from the subroutineName: MultiplyHeight [Show more] Type: Subroutine Category: Track geometry Summary: Multiply the height above ground of a specified track segment by AContext: See this subroutine in context in the source code References: This subroutine is called as follows: * ApplyElevation (Part 3 of 5) calls MultiplyHeight * ApplyElevation (Part 5 of 5) calls MultiplyHeight
For segment vector Y, calculate: A = A * yTrackSegmentI flipping the sign if we are facing backwards.
Arguments: A The number to multiply the height by Y Index of the segment vector to multiply
Returns: N flag Set according to the result in A
Other entry points: MultiplyHeight+11 Set A = A * U while retaining the sign in A (the sign of A must be on the stack before calling this entry point)
[X]
Subroutine Absolute8Bit (category: Maths (Arithmetic))
Calculate the absolute value (modulus) of an 8-bit number
[X]
Subroutine Multiply8x8 (category: Maths (Arithmetic))
Calculate (A T) = T * U
[X]
Variable directionFacing in workspace Zero page
The direction that our car is facing
[X]
Variable yTrackSegmentI in workspace trackData
Vector y-coordinates between two consecutive segments on the inside of the track