Prev: B6F9 Up: Map Next: B76C
B73C: Handle Guard Moving East West
Handles the top half of a guard that patrols east and west. The guard walks at a speed of 02 and turns round when it hits something. The bottom half of the guard, which is the next object in the table, is kept in step.
Input
IX Address of the top half of the guard
Walk east or west and turn when the guard hits something.
HandleGuardMovingEastWest B73C CALL SetPixelAdjustments_Guard Set the pixel adjustments of a guard.
B73F BIT 0,(IX+$0D) Test whether the guard is heading east.
B743 LD A,$02 Set the speed to 02.
B745 JR NZ,HandleGuardMovingEastWest_Speed Jump to HandleGuardMovingEastWest_Speed if the guard is heading east.
B747 NEG Make the speed negative.
HandleGuardMovingEastWest_Speed B749 LD (IX+$09),A Set the speed in X of the guard.
B74C LD (IX+$29),A Set the speed in X of the bottom half of the guard too.
B74F CALL FaceDirectionOfMovement Choose the graphic of the guard from its direction.
B752 CALL ApplyGravityAndMove Apply gravity to the guard and move it.
B755 BIT 0,(IX+$0C) Jump to HandleGuardMovingEastWest_BottomHalf if the guard has not hit something along the X axis.
B759 JR Z,HandleGuardMovingEastWest_BottomHalf
B75B LD A,(IX+$0D) Fetch the direction flags of the guard.
B75E XOR %00000001 Turn the guard round.
B760 LD (IX+$0D),A Store them.
Keep the bottom half in step and make the guard deadly.
HandleGuardMovingEastWest_BottomHalf B763 LD A,(IX+$01) Fetch the X coordinate of the guard.
B766 LD (IX+$21),A Give it to the bottom half of the guard.
B769 JP SetDeadlyFlagsAndDraw Make the guard deadly and flag it to be drawn again.
Prev: B6F9 Up: Map Next: B76C