Prev: D94F Up: Map Next: D9A3
D978: Set a villain's or a monster's picture for its facing
Used by the routines at MONSTER112_UPDATE and VILLAIN_WANDER.
A villain has two pictures, one for facing +V or -U and one for +U or -V (bit 1 of its graphic), and each is mirrored for the U facings (bit 6 of +7, from the facing's bit 6); bit 0 is toggled every turn, the walking frame. With the town turned round (VIEW) bit 1 is flipped, since the knight then sees the villain's other side. Used for the monsters of graphics 112-127 too (MONSTER112_UPDATE).
Input
IX The record
FACING_PICTURE D978 LD A,(VIEW) B: 2 if the town is turned round
D97B ADD A,A
D97C LD B,A
D97D LD A,(IX+$06) C: 2 for facing +V or -U, 0 for +U or -V
D980 SUB $40
D982 RLCA
D983 RLCA
D984 AND $02
D986 LD C,A
D987 LD A,(IX+$00) Bit 1 of the graphic from C, flipped by the view; bit 0 toggled
D98A AND $FD
D98C OR C
D98D XOR $01
D98F XOR B
D990 LD (IX+$00),A
D993 LD A,(IX+$06) Mirrored when facing along U
D996 AND $40
D998 LD C,A
D999 LD A,(IX+$07)
D99C AND $BF
D99E OR C
D99F LD (IX+$07),A
D9A2 RET
Prev: D94F Up: Map Next: D9A3