Prev: 52102 Up: Map Next: 52290
52243: Set Facing Flags
Used by the routines at HandleOutlaw and TurnSheriff.
Sets the flip bit and the walking-frame set from FacingFlags. When ViewRotation is set, the heading is XORed with two so opposite headings swap.
Input
IX The address of the object
Keep the heading in the lowest two bits.
SetFacingFlags 52243 LD A,(IX+6) Fetch the heading.
52246 RLCA Move the heading into the lowest two bits.
52247 RLCA
52248 AND %00000011 Keep only the heading.
52250 LD L,A Keep it in L.
XOR the heading with two if ViewRotation is set.
52251 LD A,(41576) Fetch ViewRotation.
52254 ADD A,A Double it.
52255 XOR L XOR it with the heading.
52256 LD L,A Keep the index in L.
52257 LD H,0 Clear H.
52259 LD BC,52414 Point BC at FacingFlags.
52262 ADD HL,BC Find the entry.
Set bits 6 and 7 of the flags.
52263 LD A,(HL) Fetch the entry.
52264 AND %11000000 Keep bits 6 and 7.
52266 LD C,A Keep them in C.
52267 LD A,(IX+7) Fetch the flags.
52270 AND %00111111 Clear bits 6 and 7.
52272 OR C Set them from the table.
52273 LD (IX+7),A Set the flags.
Set bit 2 of the walking frame.
52276 LD A,(HL) Fetch the entry again.
52277 AND %00000100 Keep bit 2.
52279 LD C,A Keep it in C.
52280 LD A,(IX+12) Fetch the walking frame.
52283 AND %11111011 Clear bit 2.
52285 OR C Set it from the table.
52286 LD (IX+12),A Set the walking frame and return.
52289 RET
View the equivalent code in;
Prev: 52102 Up: Map Next: 52290