Prev: A9B1 Up: Map Next: AA43
A9C7: Handle Remote Control Robot
The update routine for the remote control robot (objects 7C to 7F). The pads at HandleRemoteControlArrow and HandleRemoteControlBlock leave a command in RemoteControlCommand: bit 7 says a robot is listening, and bits 0 to 5 hold the command. The first robot to be updated claims bit 7 of RemoteControlCommand and bit 7 of IX+10. When a command arrives it sets bit 6 instead and follows the pad until it is released.
Input
IX The address of the object
See whether this robot is listening or following.
HandleRemoteControlRobot A9C7 CALL SetPixelAdjustments Call SetPixelAdjustments.
A9CA LD HL,$5B42 Point HL at RemoteControlCommand.
A9CD LD A,(HL) Fetch the command.
A9CE AND %10000000 Keep bit 7.
A9D0 JR Z,HandleRemoteControlRobot_BecomeListener Jump to HandleRemoteControlRobot_BecomeListener if no robot is listening.
A9D2 LD A,(IX+$10) Fetch the state of this robot.
A9D5 AND %11000000 Keep bits 6 and 7.
A9D7 JR Z,HandleRemoteControlRobot_Move Jump to HandleRemoteControlRobot_Move if this robot is neither.
A9D9 BIT 7,(IX+$10) Jump to HandleRemoteControlRobot_Listening if this robot is listening.
A9DD JR NZ,HandleRemoteControlRobot_Listening
This robot is following the pad.
A9DF LD A,(HL) Fetch the command.
A9E0 AND %00111111 Keep bits 0 to 5.
A9E2 JR NZ,HandleRemoteControlRobot_CarryOutCommand Jump to HandleRemoteControlRobot_CarryOutCommand if there is a command.
A9E4 RES 7,(HL) Reset bit 7 of RemoteControlCommand.
A9E6 RES 6,(IX+$10) Reset bit 6 of the state.
A9EA XOR A Write 00.
A9EB LD (IX+$09),A Stop the speed along the x axis.
A9EE LD (IX+$0A),A Stop the speed along the y axis.
Move the robot and redraw it if it is moving.
HandleRemoteControlRobot_Move A9F1 CALL ApplyGravityAndMove Call ApplyGravityAndMove.
A9F4 CALL TestObjectMoving Return if the robot is not moving.
A9F7 RET Z
A9F8 CALL PlaySoundFromHeight Call PlaySoundFromHeight.
A9FB JP SetWipeAndDrawFlags Jump to SetWipeAndDrawFlags.
Make this robot the listener.
HandleRemoteControlRobot_BecomeListener A9FE SET 7,(HL) Set bit 7 of RemoteControlCommand.
AA00 SET 7,(IX+$10) Set bit 7 of the state.
AA04 JR HandleRemoteControlRobot_Move Jump to HandleRemoteControlRobot_Move.
This robot is listening.
HandleRemoteControlRobot_Listening AA06 LD A,(HL) Fetch the command.
AA07 AND %01111111 Keep bits 0 to 6.
AA09 JR Z,HandleRemoteControlRobot_Move Jump to HandleRemoteControlRobot_Move if there is no command.
AA0B LD A,(IX+$10) Fetch the state of this robot.
AA0E AND %00111111 Keep bits 0 to 5.
AA10 OR %01000000 Set bit 6.
AA12 LD (IX+$10),A Store the state.
Carry out a command from RemoteControlRobotSpeeds.
HandleRemoteControlRobot_CarryOutCommand AA15 LD A,(HL) Fetch the command.
AA16 LD (HL),$80 Set RemoteControlCommand to 80.
AA18 DEC A Take one off the command.
AA19 RLCA Double it.
AA1A AND %01111110 Keep bits 1 to 6.
AA1C LD HL,$AA43 Point HL at RemoteControlRobotSpeeds.
AA1F CALL AddAToHL Call AddAToHL.
AA22 LD A,(HL) Fetch the speed along the x axis.
AA23 INC HL Move on to the speed along the y axis.
AA24 LD (IX+$09),A Set the speed along the x axis.
AA27 LD A,(HL) Fetch the speed along the y axis.
AA28 DEC HL Move HL back.
AA29 LD (IX+$0A),A Set the speed along the y axis.
AA2C CALL NextSpriteNumber Call NextSpriteNumber.
AA2F LD A,(IX+$09) Jump to HandleRemoteControlRobot_PlaySound if the robot is not moving.
AA32 OR (IX+$0A)
AA35 JR Z,HandleRemoteControlRobot_PlaySound
AA37 CALL ApplyGravityAndMove Call ApplyGravityAndMove.
HandleRemoteControlRobot_PlaySound AA3A LD HL,$B6A9 Point HL at MovingSoundLengths.
AA3D CALL PlayMovingSound Call PlayMovingSound.
AA40 JP SetWipeAndDrawFlags Jump to SetWipeAndDrawFlags.
Prev: A9B1 Up: Map Next: AA43