Prev: F11F Up: Map Next: F157
F127: Turn the sprites of the state-7 creature to face its way
Used by the routines at CREATURE_UPDATE and SAVE_OBJECT_POSITIONS.
The author's MITRO, which reads as "mirror troll": the six frames at SPRITE8BB8, 12 planes, the sprites of objects in state 7 (CREATURE_UPDATE), and turned back as a room is left (SAVE_OBJECT_POSITIONS).
Then MIRROR, at offset 6, the part the three share. The direction bits in C become two facing bits in E: bit 6 says which of the two views the sprites show, bit 5 whether the view is mirrored. $08 (Y to P, or the stick right) is view 0 as drawn; $40 (Q to T, up) view 0 mirrored; $80 (A to G, down) view 1 as drawn; $04 (H to ENTER, left) view 1 mirrored. E goes to IY+$72, the copy of +$0E that CHE3D writes back, and if bit 5 of the record's +$0E says the sprites face the other way they are mirrored in place (MW). With no direction bit ($CC) nothing changes.
The sprites are shared by every creature of a kind, so a record's bit 5 is only true if one creature of the kind is about: no room has two in state 7 or two in state 11 (measured over every room). Leaving a room turns them back (SAVE_OBJECT_POSITIONS), so the next room's creature, whose record comes fresh from its template with bit 5 clear, agrees with them; the knight's +$0E is kept through a new game for the same reason (TELE, TITLE_SCREEN). Krumlinde's names are Sub_F117, Sub_F11F and Sub_F127.
Input
C The direction bits
E The record's +$0E
IX The record
Output
E The new facing in bits 5 and 6, also at IY+$72
MITRO F127 LD HL,SPRITE8BB8 The first sprite; 12 planes
F12A EXX
F12B LD C,$0C
This entry point is used by the routines at MIMAN and MIWRAI.
MIRROR F12D EXX MIRROR: no direction, nothing to do
F12E LD A,C
F12F AND $CC
F131 RET Z
F132 RES 5,E Bit 5, mirrored: set for $40 and $04
F134 AND $88
F136 JR NZ,MW1
F138 SET 5,E
MW1 F13A LD A,C MW1: bit 6, view 1: set for $80 and $04
F13B SET 6,E
F13D AND $84
F13F JR NZ,MW2
F141 RES 6,E
MW2 F143 LD (IY+WORK_BEHAVIOUR-V),E MW2: the new facing for the record
F146 LD A,(IX+OBJ_WIDTH) The width in bytes (the carry is clear from the AND)
F149 RRA
F14A RRA
F14B RRA
F14C PUSH DE
F14D PUSH BC
F14E PUSH HL
F14F LD C,A
F150 CALL MW Mirror them if they face the other way
F153 POP HL
F154 POP BC
F155 POP DE
F156 RET
Prev: F11F Up: Map Next: F157