.MultiplyCoords LDA #0 \ Set H to sign to apply to the result of Multiply16x16 STA H \ (in bit 7), so setting H 0 ensures that that the \ result is positive LDA cosVectorPitchLo \ Set (QQ PP) = cosVectorPitch(Hi Lo) STA PP \ LDA cosVectorPitchHi \ where (QQ PP) is a 16-bit signed number STA QQ LDA sinAngleLo,Y \ Set (SS RR) to the 16-bit sign-magnitude number STA RR \ pointed to by Y LDA sinAngleHi,Y STA SS JSR Multiply16x16 \ Set (A T) = (QQ PP) * (SS RR) \ \ And apply the sign from bit 7 of H to ensure the \ result is positive STA xVectorLo,X \ Store the result in: LDA T \ STA xVectorBot,X \ * xVector(Lo Bot) when X = 0 \ \ * zVector(Lo Bot) when X = 2 RTS \ Return from the subroutineName: MultiplyCoords [Show more] Type: Subroutine Category: Maths (Arithmetic) Summary: Multiply a 16-bit signed number and a 16-bit sign-magnitude valueContext: See this subroutine in context in the source code References: This subroutine is called as follows: * GetVectorForAngles calls MultiplyCoords
This routine multiplies two 16-bit values and stores the result according to the arguments, as follows. When Y = 0, it calculates: cosVectorPitch(Hi Lo) * sinAngle(Hi Lo) i.e. cosVectorPitch * sinAngle When Y = 1, it calculates: cosVectorPitch(Hi Lo) * cosAngle(Hi Lo) i.e. cosVectorPitch * cosAngle When X = 0, store the result in xVector(Lo Bot). When X = 2, store the result in zVector(Lo Bot).
Arguments: cosVectorPitchHi The 16-bit signed number to multiply (high byte) cosVectorPitchLo The 16-bit signed number to multiply (low byte) Y Offset of the 16-bit sign-magnitude value to multiply: * 0 = sinAngle * 1 = cosAngle X Offset of the variable to store the result in: * 0 = xVector(Lo Bot) * 2 = zVector(Lo Bot)
[X]
Subroutine Multiply16x16 (category: Maths (Arithmetic))
Multiply a sign-magnitude 16-bit number and a signed 16-bit number
[X]
Variable cosVectorPitchHi in workspace Zero page
The high byte of cos(vectorPitchAngle) when converting pitch and yaw angles to cartesian vectors
[X]
Variable cosVectorPitchLo in workspace Zero page
The low byte of cos(vectorPitchAngle) when converting pitch and yaw angles to cartesian vectors
[X]
Variable sinAngleHi in workspace Main variable workspace
The high byte of the sine of a pitch or yaw angle, as calculated by the GetRotationMatrix routine
[X]
Variable sinAngleLo in workspace Main variable workspace
The low byte of the sine of a pitch or yaw angle, as calculated by the GetRotationMatrix routine
[X]
Variable xVectorBot in workspace Zero page
The x-coordinate of a vector (bottom byte)