Prev: 42163 Up: Map Next: 42199
42179: Face Direction
Used by the routine at HandlerChasingNastie.
Updates the sprite ID of an actor so that it faces the way it is moving and flips its animation frame. Bit 1 of the sprite ID is set when the X velocity is positive, and bit 0 of the sprite ID is flipped.
Input
IX Actor record
FaceDirection 42179 LD A,(IX+6) Fetch the X velocity of the actor.
42182 RLCA Rotate the X velocity left twice, so that the direction is in bit 1.
42183 RLCA
42184 AND %00000010 Keep only the direction bit (bit 1).
42186 LD C,A Stash the direction bit in C.
42187 LD A,(IX+0) Fetch the sprite ID of the actor.
42190 AND %11111101 Keep only bits 0 and 2-7.
42192 OR C Merge in the direction bit.
42193 XOR %00000011 Flip bits 0 and 1.
42195 LD (IX+0),A Set the new sprite ID of the actor.
42198 RET Return.
Prev: 42163 Up: Map Next: 42199