![]() |
Routines |
| Prev: AA58 | Up: Map | Next: AAD3 |
|
Used by the routines at MoveEntity and MoveRobot.
Moves an entity in direction three, which decreases the Y position. See MoveEntity for how the move works.
|
||||||||||||||||||||||
| MoveDown | AA97 | LD A,B | Return if there are no steps left. | |||||||||||||||||||
| AA98 | AND A | |||||||||||||||||||||
| AA99 | RET Z | |||||||||||||||||||||
| AA9A | LD A,L | Jump if the entity is at the start of a cell. | ||||||||||||||||||||
| AA9B | AND A | |||||||||||||||||||||
| AA9C | JR Z,MoveDown_CellStart | |||||||||||||||||||||
| AA9E | SUB B | Take the steps off the fraction, and jump if that goes back into the previous cell. | ||||||||||||||||||||
| AA9F | JR C,MoveDown_NextCell | |||||||||||||||||||||
| AAA1 | LD L,A | Store the new fraction. | ||||||||||||||||||||
| MoveDown_Finish | AAA2 | XOR A | Clear the number of steps that are left, and return with the zero flag set. | |||||||||||||||||||
| AAA3 | LD B,A | |||||||||||||||||||||
| AAA4 | RET | |||||||||||||||||||||
| MoveDown_NextCell | AAA5 | NEG | Work out how many steps are left over... | |||||||||||||||||||
| AAA7 | LD B,A | ...and keep them in B. | ||||||||||||||||||||
| AAA8 | XOR A | Move to the start of the cell, and return with the zero flag set. | ||||||||||||||||||||
| AAA9 | LD L,A | |||||||||||||||||||||
| AAAA | RET | Return. | ||||||||||||||||||||
| MoveDown_CellStart | AAAB | PUSH HL | Save the Y position. | |||||||||||||||||||
| AAAC | SUB B | Take the steps off the fraction, which goes back into the previous cell... | ||||||||||||||||||||
| AAAD | LD L,A | ...and keep it. | ||||||||||||||||||||
| AAAE | LD A,H | Fetch the Y cell... | ||||||||||||||||||||
| AAAF | SBC A,$00 | ...and take one off... | ||||||||||||||||||||
| AAB1 | AND $3F | ...making sure that the cell is within the map. | ||||||||||||||||||||
| AAB3 | LD H,A | |||||||||||||||||||||
| AAB4 | LD ($9655),HL | Keep this position. | ||||||||||||||||||||
| AAB7 | CALL FindMapCell | Find the cell using FindMapCell. | ||||||||||||||||||||
| AABA | JR Z,MoveDown_Clear | Jump if the cell is empty. | ||||||||||||||||||||
| AABC | PUSH HL | Save the Y position. | ||||||||||||||||||||
| AABD | LD HL,($962E) | Fetch the address of the cell... | ||||||||||||||||||||
| AAC0 | LD A,(HL) | ...and its contents... | ||||||||||||||||||||
| AAC1 | POP HL | ...and restore the Y position. | ||||||||||||||||||||
| AAC2 | AND $0F | Jump if the cell has no type. | ||||||||||||||||||||
| AAC4 | JR Z,MoveDown_Clear | |||||||||||||||||||||
| AAC6 | CP $0F | Jump if the cell is not type 0F, which is an obstacle. | ||||||||||||||||||||
| AAC8 | JR NZ,MoveDown_Blocked | |||||||||||||||||||||
| MoveDown_Clear | AACA | INC SP | Discard the old Y position... | |||||||||||||||||||
| AACB | INC SP | |||||||||||||||||||||
| AACC | JR MoveDown_Finish | ...and jump to finish the move. | ||||||||||||||||||||
| MoveDown_Blocked | AACE | POP HL | The entity is blocked, so restore the old Y position. | |||||||||||||||||||
| AACF | XOR A | Clear the number of steps that are left... | ||||||||||||||||||||
| AAD0 | LD B,A | |||||||||||||||||||||
| AAD1 | INC A | ...and set A to 01. | ||||||||||||||||||||
| AAD2 | RET | Return. | ||||||||||||||||||||
| Prev: AA58 | Up: Map | Next: AAD3 |