Prev: 43773 Up: Map Next: 43863
43779: Move Robot Horizontally
The handler for entity types 16 to 19 and 24 to 27, which are the robot when it is heading in direction zero or two (across the map).
Input
IX Robot
MoveRobotHorizontally 43779 SET 7,(IX+0) 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 43783 CALL UseActionKey Deal with the action key using UseActionKey.
43786 CALL UpdateRobotMarker Update the position of the robot on the map of the sectors using UpdateRobotMarker.
43789 CALL GetRobotSpeed Find how far the robot can move using GetRobotSpeed.
43792 LD A,(IX+6) Fetch the speed of the robot...
43795 AND 240 ...and move on to the next sprite using NextSpriteNumber if the robot is moving fast enough.
43797 CALL NZ,NextSpriteNumber
43800 CALL MoveRobot Move the robot using MoveRobot.
43803 LD A,(IX+0) Fetch the type of the robot...
43806 EX AF,AF' ...and keep it in A'.
43807 CALL CheckShotHit Check whether the robot has hit an enemy using CheckShotHit.
43810 LD A,(IX+0) Fetch the type of the robot again.
43813 CP 56 Jump if it has not been turned into smoke.
43815 JR NZ,MoveRobotHorizontally_ReadControls
43817 LD A,(38490) Fetch the number of sectors that have been dealt with.
43820 ADD A,26 Add 26 to get the energy that the collision costs...
43822 LD B,A ...and keep it in B.
43823 LD A,(38459) Fetch the energy of the battery.
43826 SUB B Take off the cost.
43827 JR C,MoveRobotHorizontally_NoEnergy Jump if there is not enough energy.
43829 EX AF,AF' Otherwise get the type that the robot had...
43830 LD (IX+0),A ...and restore it, so that it is not destroyed...
43833 EX AF,AF' Switch back to the energy.
43834 JR UpdateRobot_Store ...and jump to store the energy.
MoveRobotHorizontally_NoEnergy 43836 CALL ExplodeEnemies The battery is empty, so turn all of the enemies into smoke using ExplodeEnemies.
43839 XOR A Set the energy to zero.
UpdateRobot_Store 43840 LD (38459),A Store the energy of the battery.
MoveRobotHorizontally_ReadControls 43843 LD A,(38437) Fetch the controls.
43846 BIT 3,A Jump if the second weapon is not being fired.
43848 JR Z,MoveRobotHorizontally_FirstWeapon
43850 CALL FireWeaponB Fire the second weapon using FireWeaponB.
43853 JR UpdateRobot_Draw Jump to draw the robot.
MoveRobotHorizontally_FirstWeapon 43855 BIT 4,A Fire the first weapon using FireWeaponA if it is being fired.
43857 CALL NZ,FireWeaponA
UpdateRobot_Draw 43860 JP AddEntity Draw the robot using AddEntity.
Prev: 43773 Up: Map Next: 43863