Prev: A891 Up: Map Next: A8E4
A8A4: Finish Robot Turn
The handler for entity types 20 to 2F, which are the sprites that the robot has while it is turning. The turn is finished at once; the entity gets one of the types for walking (10 to 1F) and the robot is checked for a collision with an enemy. If the robot has hit an enemy it loses some energy, and it is destroyed if it has none left. This routine then handles the entity again as its new type, without drawing it.
Input
IX Entity
FinishRobotTurn A8A4 LD A,($9625) Fetch the controls...
A8A7 AND $FC ...clear the left and right bits...
A8A9 LD ($9625),A ...and store them.
A8AC LD B,(IX+$06) Fetch the speed of the robot into B.
A8AF LD C,$00 Clear the low byte of the step count.
A8B1 LD A,(IX+$00) Fetch the type of the robot...
A8B4 AND $8F ...change it into the matching type for walking...
A8B6 OR $10
A8B8 LD (IX+$00),A ...and store it.
A8BB LD A,(IX+$00) Fetch the new type...
A8BE EX AF,AF' ...and keep it in A'.
A8BF CALL CheckShotHit Check whether the robot has hit an enemy using CheckShotHit.
A8C2 LD A,(IX+$00) Fetch the type of the robot again.
A8C5 CP $38 Jump if it has not been turned into smoke.
A8C7 JR NZ,FinishRobotTurn_Discard
A8C9 LD A,($965A) Fetch the number of sectors that have been dealt with.
A8CC ADD A,$1A Add 1A to get the energy that the collision costs...
A8CE LD B,A ...and keep it in B.
A8CF LD A,($963B) Fetch the energy of the battery.
A8D2 SUB B Take off the cost.
A8D3 JR C,FinishRobotTurn_NoEnergy Jump if there is not enough energy.
A8D5 EX AF,AF' Otherwise get the type that the robot had...
A8D6 LD (IX+$00),A ...and restore it, so that it is not destroyed...
A8D9 EX AF,AF' Switch back to the energy.
A8DA JR FinishRobotTurn_Store ...and jump to store the energy.
FinishRobotTurn_NoEnergy A8DC XOR A The battery is empty.
FinishRobotTurn_Store A8DD LD ($963B),A Store the energy of the battery.
FinishRobotTurn_Discard A8E0 POP HL Discard the return address...
A8E1 JP MainLoop_Dispatch ...and handle the entity again as its new type using MainLoop_Dispatch.
Prev: A891 Up: Map Next: A8E4