Prev: 46777 Up: Map Next: 46908
46841: 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 46841 CALL SetPixelAdjustments_Legs Set the pixel adjustments of a guard.
46844 LD A,(IX+9) Fetch the speed in X.
46847 OR (IX+10) Combine it with the speed in Y.
46850 RET Z Return if the guard is not moving.
46851 CALL PlayGuardFootstepsSound Play the sound of the guard's footsteps.
46854 LD A,(IX+9) Fetch the speed in X.
46857 CP (IX+10) Compare it with the speed in Y.
46860 JR C,HandleGuardBottomHalf_Y Jump to HandleGuardBottomHalf_Y if it is smaller.
46862 BIT 7,A Jump to HandleGuardBottomHalf_NegativeX if the speed in X is negative.
46864 JR NZ,HandleGuardBottomHalf_NegativeX
46866 SET 3,(IX+0) Select the graphic of a guard facing in the positive X direction.
HandleGuardBottomHalf_ClearFlip 46870 RES 6,(IX+7) Clear the horizontal flip flag.
HandleGuardBottomHalf_Draw 46874 CALL HandleWalking_Animate Set the direction of the legs.
46877 JP SetWipeAndDrawFlags Flag the object to be drawn again.
HandleGuardBottomHalf_NegativeX 46880 RES 3,(IX+0) Select the graphic of a guard facing in the negative X direction.
46884 JR HandleGuardBottomHalf_ClearFlip Jump to HandleGuardBottomHalf_ClearFlip.
HandleGuardBottomHalf_Y 46886 BIT 7,(IX+10) Jump to HandleGuardBottomHalf_PositiveY if the speed in Y is not negative.
46890 JR Z,HandleGuardBottomHalf_PositiveY
46892 SET 3,(IX+0) Select the graphic of a guard facing in the negative Y direction.
HandleGuardBottomHalf_SetFlip 46896 SET 6,(IX+7) Set the horizontal flip flag.
46900 JR HandleGuardBottomHalf_Draw Jump to HandleGuardBottomHalf_Draw.
HandleGuardBottomHalf_PositiveY 46902 RES 3,(IX+0) Select the graphic of a guard facing in the positive Y direction.
46906 JR HandleGuardBottomHalf_SetFlip Jump to HandleGuardBottomHalf_SetFlip.
Prev: 46777 Up: Map Next: 46908