Prev: EA9C Up: Map Next: EAF9
EAA2: Load Room Decorations
Used by the routine at Draw_Room.
Copies the four decorations of the room that Sabreman is in from the table at Room_Decoration_Table into the four object records that start at Object_Record_8. It is used for the special rooms (a room y below 10), where the decorations are the furniture and the pictures.
The table has eight bytes for each room, and 80 bytes for each row of 10 rooms. A pair of bytes describes each decoration. The first byte is the sprite id, which becomes the type of the object. The high nibble of the second byte is the x position in units of 10 pixels and the low nibble is the y position in units of 08 pixels.
The records are set up with the attribute 45 (cyan) and bit 0 of the redraw flags set, so that the decorations are drawn when they are first handled (by Handle_Plain_Decoration or Handle_Coloured_Decoration).
Input
IX Object record of Sabreman
Load_Room_Decorations EAA2 LD H,(IX+$04) Fetch the room y of Sabreman into H.
EAA5 LD L,(IX+$02) Fetch the room x of Sabreman into L.
EAA8 SLA L Multiply the room x by eight, as there are eight bytes in an entry.
EAAA SLA L
EAAC SLA L
EAAE XOR A Clear A and halve the room y, with the lowest bit going into bit 7 of A. This makes the offset of the row of rooms (80 bytes for each room y).
EAAF SRL H
EAB1 RRA
EAB2 ADD A,L Add the offset for the room x.
EAB3 LD L,A HL is now the offset of the entry in the table.
EAB4 LD DE,$6800 Point DE at Room_Decoration_Table.
EAB7 ADD HL,DE Make HL point at the entry of the room.
EAB8 DI Disable interrupts.
EAB9 PUSH IY Save IY.
EABB LD IY,$8F7A Point IY at Object_Record_8.
EABF LD DE,$0010 Set the size of an object record in DE.
EAC2 LD B,$04 Set the number of decorations to load to 04.
Load_Room_Decorations_Loop EAC4 LD A,(HL) Fetch the sprite id of the decoration.
EAC5 LD (IY+$00),A Store it as the type of the object.
EAC8 INC HL Move on to the position byte.
EAC9 LD A,(HL) Fetch the position byte.
EACA AND %11110000 Keep the high nibble.
EACC ADD A,$08 Add 08.
EACE LD (IY+$01),A Set the x position of the decoration.
EAD1 LD A,(HL) Fetch the position byte again.
EAD2 RLA Shift it left three times, which moves the low nibble to bits 3 to 6.
EAD3 RLA
EAD4 RLA
EAD5 AND %01111000 Keep only those bits.
EAD7 ADD A,$3F Add 3F.
EAD9 LD (IY+$03),A Set the y position of the decoration.
EADC LD A,(IX+$02) Fetch the room x.
EADF LD (IY+$02),A Set the room x of the decoration.
EAE2 LD A,(IX+$04) Fetch the room y.
EAE5 LD (IY+$04),A Set the room y of the decoration.
EAE8 LD (IY+$0F),$01 Set bit 0 of the redraw flags, as the decoration has not been drawn yet.
EAEC LD (IY+$05),$45 Set the attribute of the decoration to 45 (cyan).
EAF0 INC HL Move on to the next pair of bytes in the table.
EAF1 ADD IY,DE Move on to the next object record.
EAF3 DJNZ Load_Room_Decorations_Loop Loop back until all four decorations have been loaded.
EAF5 POP IY Restore IY.
EAF7 EI Enable interrupts.
EAF8 RET Return.
Prev: EA9C Up: Map Next: EAF9