Prev: C9FB Up: Map Next: CA32
CA1E: 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 00 west, 01 east, 02 north and 03 south.
Input
IX The address of the object
Output
A The direction
Bit 6 of the flags to bit 1.
GetFacingDirection CA1E LD A,(IX+$07) Fetch the flags of the object.
CA21 RRCA Rotate bit 6 into bit 4.
CA22 RRCA
CA23 AND %00010000 Keep only bit 4.
CA25 LD L,A Copy it to L.
Bit 3 of the graphic number to bit 0.
CA26 LD A,(IX+$00) Fetch the graphic number of the object.
CA29 AND %00001000 Keep only bit 3.
CA2B OR L Merge L.
CA2C RRCA Rotate the two bits into place.
CA2D RRCA
CA2E RRCA
CA2F AND %00000011 Keep only bits 0 and 1.
CA31 RET Return.
View the equivalent code in;
Prev: C9FB Up: Map Next: CA32