Prev: 46908 Up: Map Next: 47011
46956: Face Direction Of Movement
Used by the routines at HandleGuardMovingEastWest and HandleGuardOrWizard.
Chooses the graphic of a guard or of the wizard from the direction that it is moving in. The lowest bit of the graphic number is changed to pick one of two graphics and the horizontal flip flag is set or cleared to mirror it.
Input
IX Address of the object
Choose the graphic from the larger of the X and Y speeds.
FaceDirectionOfMovement 46956 LD A,(IX+9) Fetch the speed in X.
46959 OR (IX+10) Combine it with the speed in Y.
46962 RET Z Return if the guard is not moving.
46963 LD A,(IX+9) Fetch the speed in X.
46966 CP (IX+10) Compare it with the speed in Y.
46969 JR C,FaceDirectionOfMovement_MovingAlongY Jump to FaceDirectionOfMovement_MovingAlongY if it is smaller.
46971 BIT 7,A Jump to FaceDirectionOfMovement_NegativeX if the speed in X is negative.
46973 JR NZ,FaceDirectionOfMovement_NegativeX
46975 SET 0,(IX+0) Select the graphic that faces in the positive X direction.
FaceDirectionOfMovement_ClearFlip 46979 RES 6,(IX+7) Clear the horizontal flip flag.
46983 RET Return.
FaceDirectionOfMovement_NegativeX 46984 RES 0,(IX+0) Select the graphic that faces in the negative X direction.
46988 JR FaceDirectionOfMovement_ClearFlip Jump to FaceDirectionOfMovement_ClearFlip.
FaceDirectionOfMovement_MovingAlongY 46990 BIT 7,(IX+10) Jump to FaceDirectionOfMovement_PositiveY if the speed in Y is not negative.
46994 JR Z,FaceDirectionOfMovement_PositiveY
46996 SET 0,(IX+0) Select the graphic that faces in the negative Y direction.
FaceDirectionOfMovement_SetFlip 47000 SET 6,(IX+7) Set the horizontal flip flag.
47004 RET Return.
FaceDirectionOfMovement_PositiveY 47005 RES 0,(IX+0) Select the graphic that faces in the positive Y direction.
47009 JR FaceDirectionOfMovement_SetFlip Jump to FaceDirectionOfMovement_SetFlip.
View the equivalent code in;
Prev: 46908 Up: Map Next: 47011