Prev: B73C Up: Map Next: B7A3
B76C: 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 B76C LD A,(IX+$09) Fetch the speed in X.
B76F OR (IX+$0A) Combine it with the speed in Y.
B772 RET Z Return if the guard is not moving.
B773 LD A,(IX+$09) Fetch the speed in X.
B776 CP (IX+$0A) Compare it with the speed in Y.
B779 JR C,FaceDirectionOfMovement_MovingAlongY Jump to FaceDirectionOfMovement_MovingAlongY if it is smaller.
B77B BIT 7,A Jump to FaceDirectionOfMovement_NegativeX if the speed in X is negative.
B77D JR NZ,FaceDirectionOfMovement_NegativeX
B77F SET 0,(IX+$00) Select the graphic that faces in the positive X direction.
FaceDirectionOfMovement_ClearFlip B783 RES 6,(IX+$07) Clear the horizontal flip flag.
B787 RET Return.
FaceDirectionOfMovement_NegativeX B788 RES 0,(IX+$00) Select the graphic that faces in the negative X direction.
B78C JR FaceDirectionOfMovement_ClearFlip Jump to FaceDirectionOfMovement_ClearFlip.
FaceDirectionOfMovement_MovingAlongY B78E BIT 7,(IX+$0A) Jump to FaceDirectionOfMovement_PositiveY if the speed in Y is not negative.
B792 JR Z,FaceDirectionOfMovement_PositiveY
B794 SET 0,(IX+$00) Select the graphic that faces in the negative Y direction.
FaceDirectionOfMovement_SetFlip B798 SET 6,(IX+$07) Set the horizontal flip flag.
B79C RET Return.
FaceDirectionOfMovement_PositiveY B79D RES 0,(IX+$00) Select the graphic that faces in the positive Y direction.
B7A1 JR FaceDirectionOfMovement_SetFlip Jump to FaceDirectionOfMovement_SetFlip.
View the equivalent code in;
Prev: B73C Up: Map Next: B7A3