Prev: 51707 Up: Map Next: 51762
51742: Get Facing Direction
Used by the routines at HandleTurning and SetPlayerSpeed.
Works out the direction that an object is facing from the horizontal flip flag and bit 3 of the graphic number: bit 6 of the flags of the object is made into bit 1 of the direction, and bit 3 of the graphic number into bit 0. The direction is 0 west, 1 east, 2 north and 3 south.
Input
IX The address of the object
Output
A The direction
Bit 6 of the flags to bit 1.
GetFacingDirection 51742 LD A,(IX+7) Fetch the flags of the object.
51745 RRCA Rotate bit 6 into bit 4.
51746 RRCA
51747 AND %00010000 Keep only bit 4.
51749 LD L,A Copy it to L.
Bit 3 of the graphic number to bit 0.
51750 LD A,(IX+0) Fetch the graphic number of the object.
51753 AND %00001000 Keep only bit 3.
51755 OR L Merge L.
51756 RRCA Rotate the two bits into place.
51757 RRCA
51758 RRCA
51759 AND %00000011 Keep only bits 0 and 1.
51761 RET Return.
View the equivalent code in;
Prev: 51707 Up: Map Next: 51762