.rotm6 \ By this point, we have the yaw angle vector's \ x-coordinate in sinAngle and the y-coordinate in \ cosAngle \ \ The above calculations were done on an angle that was \ reduced to a quarter-circle, so now we need to add the \ correct signs according to which quarter-circle the \ original vectorYawAngle in (J T) was in LDA J \ If J is positive then vectorYawAngle is positive (as BPL rotm7 \ J contains vectorYawAngleHi), so jump to rotm7 to skip \ the following \ If we get here then vectorYawAngle is negative \ \ The degree system in the Sentinel looks like this: \ \ 0 \ -32 | +32 Overhead view of player \ \ | / \ \ | / 0 = looking straight ahead \ \|/ +64 = looking sharp right \ -64 -----+----- +64 -64 = looking sharp left \ /|\ \ / | \ \ / | \ \ -96 | +96 \ 128 \ \ So vectorYawAngle is in the left half of the above \ diagram, where the x-coordinates are negative, so we \ need to negate the x-coordinate LDA #1 \ Negate sinAngle by setting bit 0 of the low byte, ORA sinAngleLo \ as sinAngle is a sign-magnitude number STA sinAngleLo .rotm7 LDA J \ If bits 6 and 7 of J are the same (i.e. their EOR is ASL A \ zero), jump to rotm8 to return from the subroutine as EOR J \ the sign of cosAngle is correct BPL rotm8 \ Bits 6 and 7 of J, i.e. of vectorYawAngleHi, are \ different, so the angle is in one of these ranges: \ \ * 64 to 127 (%01000000 to %01111111) \ \ * -128 to -65 (%10000000 to %10111111) \ \ The degree system in the Sentinel looks like this: \ \ 0 \ -32 | +32 Overhead view of player \ \ | / \ \ | / 0 = looking straight ahead \ \|/ +64 = looking sharp right \ -64 -----+----- +64 -64 = looking sharp left \ /|\ \ / | \ \ / | \ \ -96 | +96 \ 128 \ \ So vectorYawAngle is in the bottom half of the above \ diagram, where the y-coordinates are negative, so we \ need to negate the y-coordinate LDA #1 \ Negate cosAngle by setting bit 0 of the low byte, ORA cosAngleLo \ as cosAngle is a sign-magnitude number STA cosAngleLo .rotm8 LDX xStoreMatrix \ Restore the value of X that we stored in xStoreMatrix \ at the start of the routine, so that it's preserved RTS \ Return from the subroutineName: GetRotationMatrix (Part 5 of 5) [Show more] Type: Subroutine Category: Maths (Geometry) Summary: Apply the correct signs to the resultContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Variable J in workspace Main variable workspace
Temporary storage, used in the maths routines from Revs
[X]
Variable cosAngleLo in workspace Main variable workspace
The low byte of the cosine of a pitch or yaw angle, as calculated by the GetRotationMatrix routine
[X]
Label rotm7 is local to this routine
[X]
Label rotm8 is local to this 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 xStoreMatrix (category: Maths (Geometry))
Temporary storage for X so it can be preserved through calls to GetRotationMatrix