Prev: A6D3 Up: Map Next: A724
A6EB: Get Direction Vector
Used by the routine at MoveEntity.
Finds the sine and cosine of a heading in units of 01/40 of a turn, using the table at DirectionTable. Bits 0-3 of the heading are the angle within a quadrant, and bits 4-5 are the quadrant. This entry point takes the heading from the entity.
Input
A The heading (when entered at GetDirectionVector_Heading)
IX The entity (when entered at GetDirectionVector)
Output
BC The first component (a signed number)
HL The second component (a signed number)
GetDirectionVector A6EB LD A,(IX+$11) Fetch the heading of the entity.
A6EE LD ($5CD8),A Store it in ScratchValue.
This entry point is used by the routine at DrawDirectionGauge.
GetDirectionVector_Heading A6F1 LD HL,$A7C0 Point HL at the table of values.
A6F4 AND %00001111 Keep the angle within the quadrant.
A6F6 LD B,A Keep it in B.
A6F7 CALL AddToAddress Add the angle to the address.
A6FA LD C,(HL) Fetch the first value.
A6FB LD A,B Fetch the angle.
A6FC XOR %00001111 Subtract it from 0F...
A6FE INC A ...and add one.
A6FF LD HL,$A7C0 Point HL at DirectionTable.
A702 CALL AddToAddress Add the new angle to the address.
A705 LD L,(HL) Fetch the second value.
A706 LD H,$00 Clear H.
A708 LD B,H Clear B.
A709 LD A,($5CD8) Fetch the heading.
A70C AND %00110000 Keep the quadrant.
A70E RET Z Return if it is zero.
A70F CP $10 Jump to GetDirectionVector_Quadrant2 unless it is 10.
A711 JR NZ,GetDirectionVector_Quadrant2
A713 LD A,L Fetch the second value.
A714 LD L,C Swap the values...
A715 LD C,A ...in L and C.
A716 DEC B B is FF to make the first value negative.
A717 RET Return.
GetDirectionVector_Quadrant2 A718 CP $20 Jump to GetDirectionVector_Quadrant3 unless it is 20.
A71A JR NZ,GetDirectionVector_Quadrant3
A71C DEC H H is FF to make the second value negative.
A71D DEC B B is FF to make the first value negative.
A71E RET Return.
GetDirectionVector_Quadrant3 A71F LD A,C Fetch the first value.
A720 LD C,L Swap the values...
A721 LD L,A ...in L and C.
A722 DEC H H is FF to make the second value negative.
A723 RET Return.
Prev: A6D3 Up: Map Next: A724