![]() |
Routines |
| Prev: C6C7 | Up: Map | Next: C738 |
|
Works out where the corner of the cell last set by GetMapCell is on the screen. With the distances from the sheriff as dx and dy, the horizontal position is (dx + dy + F0) / 2 and the vertical position is (dy - dx + 01B0) / 4. They are put in ScreenHorizontalPosition and ScreenVerticalPosition. When bit 0 of ViewRotation is set, the sheriff's position is turned round.
|
||||
|
Set the position of the corner of the cell.
|
||||
| ProjectCell | C6DC | LD A,($A255) | Fetch CellRow as a position in HL. | |
| C6DF | LD L,$00 | |||
| C6E1 | LD H,A | |||
| C6E2 | PUSH HL | Stash it on the stack. | ||
| C6E3 | LD A,($A254) | Fetch CellColumn as a position in HL. | ||
| C6E6 | LD L,$00 | |||
| C6E8 | LD H,A | |||
|
This entry point is used by the routine at ProjectObject.
Find the position on the screen. HL is the horizontal position, and the vertical position is on the stack.
|
||||
| ProjectCell_Position | C6E9 | LD DE,($A27E) | Fetch the sheriff's horizontal position from A27E. | |
| C6ED | LD A,($A268) | Fetch ViewRotation. | ||
| C6F0 | AND %00000001 | Keep the lowest bit. | ||
| C6F2 | JR Z,ProjectCell_X | Jump to ProjectCell_X if the view is not rotated. | ||
| C6F4 | LD A,E | Complement E. | ||
| C6F5 | CPL | |||
| C6F6 | LD E,A | |||
| C6F7 | LD A,D | Complement D. | ||
| C6F8 | CPL | |||
| C6F9 | AND %00001111 | Keep the lowest four bits. | ||
| C6FB | LD D,A | Set D. | ||
|
Find the horizontal distance.
|
||||
| ProjectCell_X | C6FC | AND A | Subtract the sheriff's position. | |
| C6FD | SBC HL,DE | |||
| C6FF | EX DE,HL | Copy the distance into DE. | ||
| C700 | POP HL | Restore the vertical position from the stack. | ||
|
Find the vertical distance.
|
||||
| C701 | LD BC,($A280) | Fetch the sheriff's vertical position from A280. | ||
| C705 | LD A,($A268) | Fetch ViewRotation. | ||
| C708 | AND %00000001 | Keep the lowest bit. | ||
| C70A | JR Z,ProjectCell_Y | Jump to ProjectCell_Y if the view is not rotated. | ||
| C70C | LD A,C | Complement C. | ||
| C70D | CPL | |||
| C70E | LD C,A | |||
| C70F | LD A,B | Complement B. | ||
| C710 | CPL | |||
| C711 | AND %00001111 | Keep the lowest four bits. | ||
| C713 | LD B,A | Set B. | ||
|
Work out the screen position.
|
||||
| ProjectCell_Y | C714 | AND A | Subtract the sheriff's position. | |
| C715 | SBC HL,BC | |||
| C717 | PUSH HL | Stash the distance on the stack. | ||
| C718 | LD BC,$00F0 | Set BC to F0. | ||
| C71B | ADD HL,DE | Add the two distances and F0. | ||
| C71C | ADD HL,BC | |||
| C71D | SRA H | Halve it. | ||
| C71F | RR L | |||
| C721 | LD ($A24E),HL | Set ScreenHorizontalPosition. | ||
| C724 | POP HL | Restore the vertical distance from the stack. | ||
| C725 | AND A | Subtract the horizontal distance. | ||
| C726 | SBC HL,DE | |||
| C728 | LD BC,$01B0 | Set BC to 01B0. | ||
| C72B | ADD HL,BC | Add it. | ||
| C72C | SRA H | Divide it by four. | ||
| C72E | RR L | |||
| C730 | SRA H | |||
| C732 | RR L | |||
| C734 | LD ($A250),HL | Set ScreenVerticalPosition and return. | ||
| C737 | RET | |||
|
View the equivalent code in;
|
||||
| Prev: C6C7 | Up: Map | Next: C738 |