![]() |
Routines |
| Prev: AB57 | Up: Map | Next: AC64 |
|
Used by the routine at MoveRobot.
Deals with the cell that has blocked the robot. If it is a battery then the cell is emptied and the battery is refilled; otherwise a beep is made.
|
||||||||
| HandleObstacle | AC30 | PUSH HL | Save the Y position. | |||||
| AC31 | LD HL,($962E) | Fetch the address of the cell... | ||||||
| AC34 | LD A,(HL) | ...and its contents... | ||||||
| AC35 | AND $0F | ...and keep the type. | ||||||
| AC37 | CP $03 | Jump if the cell is not a battery (type 03). | ||||||
| AC39 | JR NZ,HandleObstacle_NotBattery | |||||||
| AC3B | LD A,(HL) | Fetch the contents of the cell... | ||||||
| AC3C | AND $F0 | ...and clear the type, so that the battery is gone... | ||||||
| AC3E | LD (HL),A | |||||||
| AC3F | CALL MakeBumpSound | Make a sound using MakeBumpSound. | ||||||
| AC42 | LD A,$74 | Fill up the battery. | ||||||
| AC44 | LD ($963B),A | |||||||
| AC47 | PUSH BC | Save BC... | ||||||
| AC48 | PUSH DE | ...and DE. | ||||||
| AC49 | LD C,$46 | Flash the panel in bright yellow using SetBatteryAttributes. | ||||||
| AC4B | CALL SetBatteryAttributes | |||||||
| AC4E | POP DE | Restore DE... | ||||||
| AC4F | POP BC | ...and BC. | ||||||
| HandleObstacle_Return | AC50 | POP HL | Restore the Y position. | |||||
| AC51 | RET | Return. | ||||||
| HandleObstacle_NotBattery | AC52 | CP $0F | Jump if the cell is type 0F, to undo the move. | |||||
| AC54 | JR Z,HandleObstacle_Undo | |||||||
| AC56 | CALL MakeBeep | Make a beep using MakeBeep. | ||||||
| AC59 | JR HandleObstacle_Return | Jump to return. | ||||||
| HandleObstacle_Undo | AC5B | POP HL | Discard the saved Y position. | |||||
| AC5C | LD HL,($9655) | Restore the Y position... | ||||||
| AC5F | LD DE,($9653) | ...and the X position from before the move. | ||||||
| AC63 | RET | Return. | ||||||
| Prev: AB57 | Up: Map | Next: AC64 |