![]() |
Routines |
| Prev: 43459 | Up: Map | Next: 43546 |
|
Used by the routines at MoveEntity and MoveRobot.
Moves an entity in direction zero, which decreases the X position. See MoveEntity for how the move works.
|
||||||||||||||||||||||
| MoveLeft | 43485 | LD A,B | Return if there are no steps left. | |||||||||||||||||||
| 43486 | AND A | |||||||||||||||||||||
| 43487 | RET Z | |||||||||||||||||||||
| 43488 | LD A,E | Jump if the entity is at the start of a cell. | ||||||||||||||||||||
| 43489 | AND A | |||||||||||||||||||||
| 43490 | JR Z,MoveLeft_CellStart | |||||||||||||||||||||
| 43492 | SUB B | Take the steps off the fraction, and jump if that goes back into the previous cell. | ||||||||||||||||||||
| 43493 | JR C,MoveLeft_NextCell | |||||||||||||||||||||
| 43495 | LD E,A | Store the new fraction. | ||||||||||||||||||||
| MoveLeft_Finish | 43496 | XOR A | Clear the number of steps that are left, and return with the zero flag set. | |||||||||||||||||||
| 43497 | LD B,A | |||||||||||||||||||||
| 43498 | RET | |||||||||||||||||||||
| MoveLeft_NextCell | 43499 | NEG | Work out how many steps are left over... | |||||||||||||||||||
| 43501 | LD B,A | ...and keep them in B. | ||||||||||||||||||||
| 43502 | XOR A | Move to the start of the cell, and return with the zero flag set. | ||||||||||||||||||||
| 43503 | LD E,A | |||||||||||||||||||||
| 43504 | RET | Return. | ||||||||||||||||||||
| MoveLeft_CellStart | 43505 | PUSH DE | Save the X position. | |||||||||||||||||||
| 43506 | SUB B | Take the steps off the fraction, which goes back into the previous cell... | ||||||||||||||||||||
| 43507 | LD E,A | ...and keep it. | ||||||||||||||||||||
| 43508 | LD A,D | Fetch the X cell... | ||||||||||||||||||||
| 43509 | SBC A,0 | ...and take one off... | ||||||||||||||||||||
| 43511 | AND 63 | ...making sure that the cell is within the map. | ||||||||||||||||||||
| 43513 | LD D,A | |||||||||||||||||||||
| 43514 | LD (38483),DE | Keep this position. | ||||||||||||||||||||
| 43518 | CALL FindMapCell | Find the cell using FindMapCell. | ||||||||||||||||||||
| 43521 | JR Z,MoveLeft_Clear | Jump if the cell is empty. | ||||||||||||||||||||
| 43523 | PUSH HL | Save the Y position. | ||||||||||||||||||||
| 43524 | LD HL,(38446) | Fetch the address of the cell... | ||||||||||||||||||||
| 43527 | LD A,(HL) | ...and its contents... | ||||||||||||||||||||
| 43528 | POP HL | ...and restore the Y position. | ||||||||||||||||||||
| 43529 | AND 15 | Jump if the cell has no type. | ||||||||||||||||||||
| 43531 | JR Z,MoveLeft_Clear | |||||||||||||||||||||
| 43533 | CP 15 | Jump if the cell is not type 15, which is an obstacle. | ||||||||||||||||||||
| 43535 | JR NZ,MoveLeft_Blocked | |||||||||||||||||||||
| MoveLeft_Clear | 43537 | INC SP | Discard the old X position... | |||||||||||||||||||
| 43538 | INC SP | |||||||||||||||||||||
| 43539 | JR MoveLeft_Finish | ...and jump to finish the move. | ||||||||||||||||||||
| MoveLeft_Blocked | 43541 | POP DE | The entity is blocked, so restore the old X position. | |||||||||||||||||||
| 43542 | XOR A | Clear the number of steps that are left... | ||||||||||||||||||||
| 43543 | LD B,A | |||||||||||||||||||||
| 43544 | INC A | ...and set A to 1. | ||||||||||||||||||||
| 43545 | RET | Return. | ||||||||||||||||||||
| Prev: 43459 | Up: Map | Next: 43546 |