Prev: 50573 Up: Map Next: 50643
50621: 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
0 Speed along x, -3 3 2
1 Speed along x, +3 2 3
2 Speed along y, +3 0 1
3 Speed along y, -3 1 0
Input
IX Record of the legs
Output
A Direction, from 0 to 3
Combine the mirror flag with bit 2 of the type.
GetFacingDirection 50621 LD A,(IX+7) Fetch the flags.
50624 RRCA Move bit 6, which mirrors the object, down to bit 3.
50625 RRCA
50626 RRCA
50627 AND %00001000 Keep only that bit.
50629 XOR %00001000 Flip it, to say that the object is not mirrored.
Merge in bit 2 of the type and keep the direction.
50631 LD L,A Stash the flag in L.
50632 LD A,(IX+0) Fetch the type.
50635 AND %00000100 Keep only bit 2 of the type.
50637 OR L Combine it with the other bit.
50638 RRCA Move the two bits down to bits 0 and 1.
50639 RRCA
50640 AND %00000011 Keep only those two bits.
50642 RET Return.
View the equivalent code in;
Prev: 50573 Up: Map Next: 50643