Prev: C58D Up: Map Next: C5D3
C5BD: Get Facing Direction
Used by the routines at FireProjectile, HandleTurning and SetPlayerSpeed.
Works out which of the four directions the player is facing, from the mirror flag and the type of the legs.
Direction Walking Turn left Turn right
00 Speed along x, -03 03 02
01 Speed along x, +03 02 03
02 Speed along y, +03 00 01
03 Speed along y, -03 01 00
Input
IX Record of the legs
Output
A Direction, from 00 to 03
Combine the mirror flag with bit 2 of the type.
GetFacingDirection C5BD LD A,(IX+$07) Fetch the flags.
C5C0 RRCA Move bit 6, which mirrors the object, down to bit 3.
C5C1 RRCA
C5C2 RRCA
C5C3 AND %00001000 Keep only that bit.
C5C5 XOR %00001000 Flip it, to say that the object is not mirrored.
Merge in bit 2 of the type and keep the direction.
C5C7 LD L,A Stash the flag in L.
C5C8 LD A,(IX+$00) Fetch the type.
C5CB AND %00000100 Keep only bit 2 of the type.
C5CD OR L Combine it with the other bit.
C5CE RRCA Move the two bits down to bits 0 and 1.
C5CF RRCA
C5D0 AND %00000011 Keep only those two bits.
C5D2 RET Return.
View the equivalent code in;
Prev: C58D Up: Map Next: C5D3