![]() |
Routines |
| Prev: AB03 | Up: Map | Next: AC30 |
|
Used by the routine at MoveRobotHorizontally.
Moves the robot in the direction that it is heading, by the number of steps that is in B. The robot can only turn when it is at the start of a cell: if a turn key is being pressed then the robot turns and carries on in the new direction. When the robot is blocked by something in the map then HandleObstacle deals with it.
|
||||||||||
| MoveRobot | AB57 | CALL GetPosition | Fetch the position of the robot. | |||||||
| AB5A | LD ($9653),DE | Keep the X position... | ||||||||
| AB5E | LD ($9655),HL | ...and the Y position, so that the move can be undone. | ||||||||
| AB61 | LD A,(IX+$00) | Fetch the type of the robot... | ||||||||
| AB64 | RRCA | ...and turn it into the direction that it is heading in. | ||||||||
| AB65 | RRCA | |||||||||
| AB66 | AND $03 | Jump to move in direction zero (X decreasing)... | ||||||||
| AB68 | JP Z,MoveRobot_Left | |||||||||
| AB6B | DEC A | ...or direction one (Y increasing)... | ||||||||
| AB6C | JP Z,MoveRobot_Up | |||||||||
| AB6F | DEC A | ...or direction two (X increasing)... | ||||||||
| AB70 | JP Z,MoveRobot_Right | |||||||||
|
Direction three (Y decreasing). The four sections that follow all work in the same way. When the robot is at the start of a cell, and a key to turn is being pressed, the robot is turned and the routine carries on with the section for the new direction. Otherwise the robot moves, and if it was blocked then HandleObstacle is called to deal with the obstacle. This is repeated until there are no more steps.
|
||||||||||
| MoveRobot_Down | AB73 | LD A,L | Jump if the robot is not at the start of a cell. | |||||||
| AB74 | AND A | |||||||||
| AB75 | JR NZ,MoveRobot_DownStep | |||||||||
| AB77 | LD A,($9625) | Fetch the controls. | ||||||||
| AB7A | BIT 1,A | Jump if the key to turn left is pressed. | ||||||||
| AB7C | JR NZ,MoveRobot_Down_TurnLeft | |||||||||
| AB7E | BIT 0,A | Jump if the key to turn right is pressed. | ||||||||
| AB80 | JR NZ,MoveRobot_Down_TurnRight | |||||||||
| MoveRobot_DownStep | AB82 | CALL MoveDown | Move the robot down using MoveDown. | |||||||
| AB85 | CALL NZ,HandleObstacle | Deal with the obstacle using HandleObstacle if it was blocked. | ||||||||
| AB88 | LD A,B | Loop back if there are steps left. | ||||||||
| AB89 | AND A | |||||||||
| AB8A | JR NZ,MoveRobot_Down | |||||||||
| AB8C | JP MoveRobot_Store | Jump to MoveRobot_Store. | ||||||||
| MoveRobot_Down_TurnLeft | AB8F | CALL TurnRobotLeft | Turn the robot left using TurnRobotLeft... | |||||||
| AB92 | RES 7,(IX+$00) | ...and show the sprite without flipping it. | ||||||||
| AB96 | JR MoveRobot_Right | Jump to carry on heading right. | ||||||||
| MoveRobot_Down_TurnRight | AB98 | CALL TurnRobotRight | Turn the robot right using TurnRobotRight... | |||||||
| AB9B | SET 7,(IX+$00) | ...and show the sprite flipped. | ||||||||
| AB9F | JR MoveRobot_Left | Jump to carry on heading left. | ||||||||
| MoveRobot_Right | ABA1 | LD A,E | Jump if the robot is not at the start of a cell. | |||||||
| ABA2 | AND A | |||||||||
| ABA3 | JR NZ,MoveRobot_RightStep | |||||||||
| ABA5 | LD A,($9625) | Fetch the controls. | ||||||||
| ABA8 | BIT 1,A | Jump if the key to turn left is pressed. | ||||||||
| ABAA | JR NZ,MoveRobot_Right_TurnLeft | |||||||||
| ABAC | BIT 0,A | Jump if the key to turn right is pressed. | ||||||||
| ABAE | JR NZ,MoveRobot_Right_TurnRight | |||||||||
| MoveRobot_RightStep | ABB0 | CALL MoveRight | Move the robot right using MoveRight. | |||||||
| ABB3 | CALL NZ,HandleObstacle | Deal with the obstacle using HandleObstacle if it was blocked. | ||||||||
| ABB6 | LD A,B | Loop back if there are steps left. | ||||||||
| ABB7 | AND A | |||||||||
| ABB8 | JR NZ,MoveRobot_Right | |||||||||
| ABBA | SET 7,(IX+$00) | Show the sprite flipped. | ||||||||
| ABBE | JP MoveRobot_Store | Jump to MoveRobot_Store. | ||||||||
| MoveRobot_Right_TurnLeft | ABC1 | CALL TurnRobotLeft | Turn the robot left using TurnRobotLeft... | |||||||
| ABC4 | SET 7,(IX+$00) | ...and show the sprite flipped. | ||||||||
| ABC8 | JR MoveRobot_Up | Jump to carry on heading up. | ||||||||
| MoveRobot_Right_TurnRight | ABCA | CALL TurnRobotRight | Turn the robot right using TurnRobotRight... | |||||||
| ABCD | SET 7,(IX+$00) | ...and show the sprite flipped. | ||||||||
| ABD1 | JR MoveRobot_Down | Jump to carry on heading down. | ||||||||
| MoveRobot_Up | ABD3 | LD A,L | Jump if the robot is not at the start of a cell. | |||||||
| ABD4 | AND A | |||||||||
| ABD5 | JR NZ,MoveRobot_UpStep | |||||||||
| ABD7 | LD A,($9625) | Fetch the controls. | ||||||||
| ABDA | BIT 1,A | Jump if the key to turn left is pressed. | ||||||||
| ABDC | JR NZ,MoveRobot_Up_TurnLeft | |||||||||
| ABDE | BIT 0,A | Jump if the key to turn right is pressed. | ||||||||
| ABE0 | JR NZ,MoveRobot_Up_TurnRight | |||||||||
| MoveRobot_UpStep | ABE2 | CALL MoveUp | Move the robot up using MoveUp. | |||||||
| ABE5 | CALL NZ,HandleObstacle | Deal with the obstacle using HandleObstacle if it was blocked. | ||||||||
| ABE8 | LD A,B | Loop back if there are steps left. | ||||||||
| ABE9 | AND A | |||||||||
| ABEA | JR NZ,MoveRobot_Up | |||||||||
| ABEC | JP MoveRobot_Store | Jump to MoveRobot_Store. | ||||||||
| MoveRobot_Up_TurnLeft | ABEF | CALL TurnRobotLeft | Turn the robot left using TurnRobotLeft... | |||||||
| ABF2 | RES 7,(IX+$00) | ...and show the sprite without flipping it. | ||||||||
| ABF6 | JR MoveRobot_Left | Jump to carry on heading left. | ||||||||
| MoveRobot_Up_TurnRight | ABF8 | CALL TurnRobotRight | Turn the robot right using TurnRobotRight... | |||||||
| ABFB | SET 7,(IX+$00) | ...and show the sprite flipped. | ||||||||
| ABFF | JR MoveRobot_Right | Jump to carry on heading right. | ||||||||
| MoveRobot_Left | AC01 | LD A,E | Jump if the robot is not at the start of a cell. | |||||||
| AC02 | AND A | |||||||||
| AC03 | JR NZ,MoveRobot_LeftStep | |||||||||
| AC05 | LD A,($9625) | Fetch the controls. | ||||||||
| AC08 | BIT 1,A | Jump if the key to turn left is pressed. | ||||||||
| AC0A | JR NZ,MoveRobot_Left_TurnLeft | |||||||||
| AC0C | BIT 0,A | Jump if the key to turn right is pressed. | ||||||||
| AC0E | JR NZ,MoveRobot_Left_TurnRight | |||||||||
| MoveRobot_LeftStep | AC10 | CALL MoveLeft | Move the robot left using MoveLeft. | |||||||
| AC13 | CALL NZ,HandleObstacle | Deal with the obstacle using HandleObstacle if it was blocked. | ||||||||
| AC16 | LD A,B | Loop back if there are steps left. | ||||||||
| AC17 | AND A | |||||||||
| AC18 | JR NZ,MoveRobot_Left | |||||||||
| MoveRobot_Store | AC1A | JP SetPosition | Jump to SetPosition. | |||||||
| MoveRobot_Left_TurnLeft | AC1D | CALL TurnRobotLeft | Turn the robot left using TurnRobotLeft... | |||||||
| AC20 | RES 7,(IX+$00) | ...and show the sprite without flipping it. | ||||||||
| AC24 | JP MoveRobot_Down | Jump to carry on heading down. | ||||||||
| MoveRobot_Left_TurnRight | AC27 | CALL TurnRobotRight | Turn the robot right using TurnRobotRight... | |||||||
| AC2A | RES 7,(IX+$00) | ...and show the sprite without flipping it. | ||||||||
| AC2E | JR MoveRobot_Up | Jump to carry on heading up. | ||||||||
| Prev: AB03 | Up: Map | Next: AC30 |