![]() |
Routines |
| Prev: 43546 | Up: Map | Next: 43671 |
|
Used by the routines at MoveEntity and MoveRobot.
Moves an entity in direction two, which increases the X position. See MoveEntity for how the move works.
|
||||||||||||||||||||||
| MoveRight | 43608 | LD A,B | Return if there are no steps left. | |||||||||||||||||||
| 43609 | AND A | |||||||||||||||||||||
| 43610 | RET Z | |||||||||||||||||||||
| 43611 | LD A,E | Jump if the entity is at the start of a cell. | ||||||||||||||||||||
| 43612 | AND A | |||||||||||||||||||||
| 43613 | JR Z,MoveRight_CellStart | |||||||||||||||||||||
| 43615 | ADD A,B | Add the steps to the fraction, and jump if that goes into the next cell. | ||||||||||||||||||||
| 43616 | JR C,MoveRight_NextCell | |||||||||||||||||||||
| 43618 | LD E,A | Store the new fraction. | ||||||||||||||||||||
| MoveRight_Finish | 43619 | XOR A | Clear the number of steps that are left, and return with the zero flag set. | |||||||||||||||||||
| 43620 | LD B,A | |||||||||||||||||||||
| 43621 | RET | |||||||||||||||||||||
| MoveRight_NextCell | 43622 | LD B,A | Keep the steps that are left over. | |||||||||||||||||||
| 43623 | LD A,D | Fetch the X cell... | ||||||||||||||||||||
| 43624 | INC A | ...and add one... | ||||||||||||||||||||
| 43625 | AND 63 | ...making sure that the cell is within the map. | ||||||||||||||||||||
| 43627 | LD D,A | |||||||||||||||||||||
| 43628 | XOR A | Move to the start of the cell, and return with the zero flag set. | ||||||||||||||||||||
| 43629 | LD E,A | |||||||||||||||||||||
| 43630 | RET | Return. | ||||||||||||||||||||
| MoveRight_CellStart | 43631 | ADD A,B | Add the steps to the fraction... | |||||||||||||||||||
| 43632 | LD E,A | ...and keep it. | ||||||||||||||||||||
| 43633 | LD (38483),DE | Keep this position. | ||||||||||||||||||||
| 43637 | PUSH DE | Save the X position. | ||||||||||||||||||||
| 43638 | LD A,D | Fetch the X cell... | ||||||||||||||||||||
| 43639 | INC A | ...and add one... | ||||||||||||||||||||
| 43640 | AND 63 | ...making sure that the cell is within the map. | ||||||||||||||||||||
| 43642 | LD D,A | |||||||||||||||||||||
| 43643 | CALL FindMapCell | Find the cell using FindMapCell. | ||||||||||||||||||||
| 43646 | JR Z,MoveRight_Clear | Jump if the cell is empty. | ||||||||||||||||||||
| 43648 | PUSH HL | Save the Y position. | ||||||||||||||||||||
| 43649 | LD HL,(38446) | Fetch the address of the cell... | ||||||||||||||||||||
| 43652 | LD A,(HL) | ...and its contents... | ||||||||||||||||||||
| 43653 | POP HL | ...and restore the Y position. | ||||||||||||||||||||
| 43654 | AND 15 | Jump if the cell has no type. | ||||||||||||||||||||
| 43656 | JR Z,MoveRight_Clear | |||||||||||||||||||||
| 43658 | CP 15 | Jump if the cell is not type 15, which is an obstacle. | ||||||||||||||||||||
| 43660 | JR NZ,MoveRight_Blocked | |||||||||||||||||||||
| MoveRight_Clear | 43662 | POP DE | Restore the X position... | |||||||||||||||||||
| 43663 | JR MoveRight_Finish | ...and jump to finish the move. | ||||||||||||||||||||
| MoveRight_Blocked | 43665 | POP DE | The entity is blocked, so restore the old X position. | |||||||||||||||||||
| 43666 | XOR A | Clear the number of steps that are left... | ||||||||||||||||||||
| 43667 | LD B,A | |||||||||||||||||||||
| 43668 | LD E,A | ...and the fraction... | ||||||||||||||||||||
| 43669 | INC A | ...and set A to 1. | ||||||||||||||||||||
| 43670 | RET | Return. | ||||||||||||||||||||
| Prev: 43546 | Up: Map | Next: 43671 |