Prev: 43863 Up: Map Next: 44132
44080: Handle Obstacle
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.
Input
IX Robot
HandleObstacle 44080 PUSH HL Save the Y position.
44081 LD HL,(38446) Fetch the address of the cell...
44084 LD A,(HL) ...and its contents...
44085 AND 15 ...and keep the type.
44087 CP 3 Jump if the cell is not a battery (type 3).
44089 JR NZ,HandleObstacle_NotBattery
44091 LD A,(HL) Fetch the contents of the cell...
44092 AND 240 ...and clear the type, so that the battery is gone...
44094 LD (HL),A
44095 CALL MakeBumpSound Make a sound using MakeBumpSound.
44098 LD A,116 Fill up the battery.
44100 LD (38459),A
44103 PUSH BC Save BC...
44104 PUSH DE ...and DE.
44105 LD C,70 Flash the panel in bright yellow using SetBatteryAttributes.
44107 CALL SetBatteryAttributes
44110 POP DE Restore DE...
44111 POP BC ...and BC.
HandleObstacle_Return 44112 POP HL Restore the Y position.
44113 RET Return.
HandleObstacle_NotBattery 44114 CP 15 Jump if the cell is type 15, to undo the move.
44116 JR Z,HandleObstacle_Undo
44118 CALL MakeBeep Make a beep using MakeBeep.
44121 JR HandleObstacle_Return Jump to return.
HandleObstacle_Undo 44123 POP HL Discard the saved Y position.
44124 LD HL,(38485) Restore the Y position...
44127 LD DE,(38483) ...and the X position from before the move.
44131 RET Return.
Prev: 43863 Up: Map Next: 44132