Prev: B6B9 Up: Map Next: B73C
B6F9: Handle Guard Or Wizard Bottom Half
Handles the bottom half of a guard that moves in any direction or of the wizard. The graphic of the bottom half follows the direction in which the guard is moving: the lowest bit of the graphic number says which of two frames of the walking animation is shown, bit 3 says whether the guard faces towards or away from the player, and the horizontal flip flag of the object is set for the directions that mirror the sprites.
Input
IX Address of the bottom half of the guard
Face the legs in the direction the guard is moving.
HandleGuardBottomHalf B6F9 CALL SetPixelAdjustments_Legs Set the pixel adjustments of a guard.
B6FC LD A,(IX+$09) Fetch the speed in X.
B6FF OR (IX+$0A) Combine it with the speed in Y.
B702 RET Z Return if the guard is not moving.
B703 CALL PlayGuardFootstepsSound Play the sound of the guard's footsteps.
B706 LD A,(IX+$09) Fetch the speed in X.
B709 CP (IX+$0A) Compare it with the speed in Y.
B70C JR C,HandleGuardBottomHalf_Y Jump to HandleGuardBottomHalf_Y if it is smaller.
B70E BIT 7,A Jump to HandleGuardBottomHalf_NegativeX if the speed in X is negative.
B710 JR NZ,HandleGuardBottomHalf_NegativeX
B712 SET 3,(IX+$00) Select the graphic of a guard facing in the positive X direction.
HandleGuardBottomHalf_ClearFlip B716 RES 6,(IX+$07) Clear the horizontal flip flag.
HandleGuardBottomHalf_Draw B71A CALL HandleWalking_Animate Set the direction of the legs.
B71D JP SetWipeAndDrawFlags Flag the object to be drawn again.
HandleGuardBottomHalf_NegativeX B720 RES 3,(IX+$00) Select the graphic of a guard facing in the negative X direction.
B724 JR HandleGuardBottomHalf_ClearFlip Jump to HandleGuardBottomHalf_ClearFlip.
HandleGuardBottomHalf_Y B726 BIT 7,(IX+$0A) Jump to HandleGuardBottomHalf_PositiveY if the speed in Y is not negative.
B72A JR Z,HandleGuardBottomHalf_PositiveY
B72C SET 3,(IX+$00) Select the graphic of a guard facing in the negative Y direction.
HandleGuardBottomHalf_SetFlip B730 SET 6,(IX+$07) Set the horizontal flip flag.
B734 JR HandleGuardBottomHalf_Draw Jump to HandleGuardBottomHalf_Draw.
HandleGuardBottomHalf_PositiveY B736 RES 3,(IX+$00) Select the graphic of a guard facing in the positive Y direction.
B73A JR HandleGuardBottomHalf_SetFlip Jump to HandleGuardBottomHalf_SetFlip.
Prev: B6B9 Up: Map Next: B73C