![]() |
Routines |
| Prev: 42707 | Up: Map | Next: 42788 |
|
Used by the routine at MoveEntity.
Finds the sine and cosine of a heading in units of 1/64 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.
|
||||||||||||||||
| GetDirectionVector | 42731 | LD A,(IX+17) | Fetch the heading of the entity. | |||||||||||||
| 42734 | LD (23768),A | Store it in ScratchValue. | ||||||||||||||
|
This entry point is used by the routine at DrawDirectionGauge.
|
||||||||||||||||
| GetDirectionVector_Heading | 42737 | LD HL,42944 | Point HL at the table of values. | |||||||||||||
| 42740 | AND %00001111 | Keep the angle within the quadrant. | ||||||||||||||
| 42742 | LD B,A | Keep it in B. | ||||||||||||||
| 42743 | CALL AddToAddress | Add the angle to the address. | ||||||||||||||
| 42746 | LD C,(HL) | Fetch the first value. | ||||||||||||||
| 42747 | LD A,B | Fetch the angle. | ||||||||||||||
| 42748 | XOR %00001111 | Subtract it from 15... | ||||||||||||||
| 42750 | INC A | ...and add one. | ||||||||||||||
| 42751 | LD HL,42944 | Point HL at DirectionTable. | ||||||||||||||
| 42754 | CALL AddToAddress | Add the new angle to the address. | ||||||||||||||
| 42757 | LD L,(HL) | Fetch the second value. | ||||||||||||||
| 42758 | LD H,0 | Clear H. | ||||||||||||||
| 42760 | LD B,H | Clear B. | ||||||||||||||
| 42761 | LD A,(23768) | Fetch the heading. | ||||||||||||||
| 42764 | AND %00110000 | Keep the quadrant. | ||||||||||||||
| 42766 | RET Z | Return if it is zero. | ||||||||||||||
| 42767 | CP 16 | Jump to GetDirectionVector_Quadrant2 unless it is 16. | ||||||||||||||
| 42769 | JR NZ,GetDirectionVector_Quadrant2 | |||||||||||||||
| 42771 | LD A,L | Fetch the second value. | ||||||||||||||
| 42772 | LD L,C | Swap the values... | ||||||||||||||
| 42773 | LD C,A | ...in L and C. | ||||||||||||||
| 42774 | DEC B | B is 255 to make the first value negative. | ||||||||||||||
| 42775 | RET | Return. | ||||||||||||||
| GetDirectionVector_Quadrant2 | 42776 | CP 32 | Jump to GetDirectionVector_Quadrant3 unless it is 32. | |||||||||||||
| 42778 | JR NZ,GetDirectionVector_Quadrant3 | |||||||||||||||
| 42780 | DEC H | H is 255 to make the second value negative. | ||||||||||||||
| 42781 | DEC B | B is 255 to make the first value negative. | ||||||||||||||
| 42782 | RET | Return. | ||||||||||||||
| GetDirectionVector_Quadrant3 | 42783 | LD A,C | Fetch the first value. | |||||||||||||
| 42784 | LD C,L | Swap the values... | ||||||||||||||
| 42785 | LD L,A | ...in L and C. | ||||||||||||||
| 42786 | DEC H | H is 255 to make the second value negative. | ||||||||||||||
| 42787 | RET | Return. | ||||||||||||||
| Prev: 42707 | Up: Map | Next: 42788 |