Prev: AAFD Up: Map Next: AB57
AB03: Move Robot Horizontally
The handler for entity types 10 to 13 and 18 to 1B, which are the robot when it is heading in direction zero or two (across the map).
Input
IX Robot
MoveRobotHorizontally AB03 SET 7,(IX+$00) Show the sprite flipped.
This entry point is used by the routine at MoveRobotVertically.
This entry point is shared by both handlers. It does all of the work for the robot in a frame: it looks at the action key, shows the robot on the map, works out how far to move, moves the robot, checks whether it has hit an enemy and fires the weapons.
UpdateRobot AB07 CALL UseActionKey Deal with the action key using UseActionKey.
AB0A CALL UpdateRobotMarker Update the position of the robot on the map of the sectors using UpdateRobotMarker.
AB0D CALL GetRobotSpeed Find how far the robot can move using GetRobotSpeed.
AB10 LD A,(IX+$06) Fetch the speed of the robot...
AB13 AND $F0 ...and move on to the next sprite using NextSpriteNumber if the robot is moving fast enough.
AB15 CALL NZ,NextSpriteNumber
AB18 CALL MoveRobot Move the robot using MoveRobot.
AB1B LD A,(IX+$00) Fetch the type of the robot...
AB1E EX AF,AF' ...and keep it in A'.
AB1F CALL CheckShotHit Check whether the robot has hit an enemy using CheckShotHit.
AB22 LD A,(IX+$00) Fetch the type of the robot again.
AB25 CP $38 Jump if it has not been turned into smoke.
AB27 JR NZ,MoveRobotHorizontally_ReadControls
AB29 LD A,($965A) Fetch the number of sectors that have been dealt with.
AB2C ADD A,$1A Add 1A to get the energy that the collision costs...
AB2E LD B,A ...and keep it in B.
AB2F LD A,($963B) Fetch the energy of the battery.
AB32 SUB B Take off the cost.
AB33 JR C,MoveRobotHorizontally_NoEnergy Jump if there is not enough energy.
AB35 EX AF,AF' Otherwise get the type that the robot had...
AB36 LD (IX+$00),A ...and restore it, so that it is not destroyed...
AB39 EX AF,AF' Switch back to the energy.
AB3A JR UpdateRobot_Store ...and jump to store the energy.
MoveRobotHorizontally_NoEnergy AB3C CALL ExplodeEnemies The battery is empty, so turn all of the enemies into smoke using ExplodeEnemies.
AB3F XOR A Set the energy to zero.
UpdateRobot_Store AB40 LD ($963B),A Store the energy of the battery.
MoveRobotHorizontally_ReadControls AB43 LD A,($9625) Fetch the controls.
AB46 BIT 3,A Jump if the second weapon is not being fired.
AB48 JR Z,MoveRobotHorizontally_FirstWeapon
AB4A CALL FireWeaponB Fire the second weapon using FireWeaponB.
AB4D JR UpdateRobot_Draw Jump to draw the robot.
MoveRobotHorizontally_FirstWeapon AB4F BIT 4,A Fire the first weapon using FireWeaponA if it is being fired.
AB51 CALL NZ,FireWeaponA
UpdateRobot_Draw AB54 JP AddEntity Draw the robot using AddEntity.
Prev: AAFD Up: Map Next: AB57