Prev: A8D8 Up: Map Next: AA97
A900: Draw Room
Used by the routine at Controller_DrawRoom.
Clear the screen to BLACK.
DrawRoom A900 LD A,$00 Write BLACK to *ATTR_P.
A902 LD ($5C8D),A
A905 CALL ClearRoomBuffer Call ClearRoomBuffer.
A908 LD A,($5BD1) A=*ActiveRoom_PaperColour.
A90B SLA A Convert a PAPER value (using bits 3, 4 and 5) to an "INK" value (shifted left to bits 0, 1 and 2).
A90D SLA A
A90F SLA A
A911 LD ($5C8D),A Write A to *ATTR_P.
A914 LD A,$11 Set PAPER: *ActiveRoom_PaperColour.
A916 RST $10
A917 LD A,($5BD1)
A91A RST $10
Set the UDG graphics pointer.
A91B LD HL,$8378 Write 8378 to *CHARS.
A91E LD ($5C36),HL
Set the attributes for drawing the room scaffolding (i.e. ceilings and floors).
DrawRoom_SetScaffoldingInk A921 LD A,$10 Set INK: *ActiveRoom_ScaffoldingColour.
A923 RST $10
A924 LD A,($5BCF)
A927 RST $10
Fetch the address of the current room data buffer.
A928 LD HL,($5BE8) HL=*PointerCurrentRoomBuffer.
Draw the ceilings/ floors.
DrawRoomScaffolding A92B LD C,(HL) Get the screen co-ordinates where the scaffolding will begin printing from the current room data buffer and store them in BC.
A92C INC HL
A92D LD B,(HL)
A92E INC HL Increment the current room data buffer by one.
A92F LD A,$FF Jump to DrawRoomLadders if this scaffolding entry is the terminator (FF).
A931 CP C
A932 JR Z,DrawRoomLadders
A934 PUSH HL Stash the current room data buffer on the stack.
A935 CALL ConvertDrawCoordinate Convert this position into a room-buffer offset using ConvertDrawCoordinate.
Set the co-ordinates of where we're going to PRINT AT.
A938 CALL $0DD9 Call CL_SET.
A93B POP HL Restore the current room data buffer from the stack.
A93C LD B,(HL) Fetch the length counter and store it in B.
A93D INC HL Increment the current room data buffer by one.
All scaffolding is two bytes wide, alternating between Graphics_RoomScaffolding_Top1 and Graphics_RoomScaffolding_Top2.
DrawRoomScaffolding_Loop A93E LD A,$21 A=Graphics_RoomScaffolding_Top1 (21).
A940 CALL PopulateRoomBuffer Write it into the room buffer using PopulateRoomBuffer.
A943 CALL PrintUDG Print that tile using PrintUDG.
A946 LD A,$22 A=Graphics_RoomScaffolding_Top2 (22).
A948 CALL PopulateRoomBuffer Write it into the room buffer using PopulateRoomBuffer.
A94B CALL PrintUDG Print that tile using PrintUDG.
A94E DJNZ DrawRoomScaffolding_Loop Decrease the remaining length and loop back to DrawRoomScaffolding_Loop until this run is drawn.
A950 JR DrawRoomScaffolding Jump to DrawRoomScaffolding.
Draw the ladders.
DrawRoomLadders A952 LD A,$10 Set INK: *ActiveRoom_LadderColour.
A954 RST $10
A955 LD A,($5BD2)
A958 RST $10
A959 LD HL,($5BD8) HL=*ReferenceLadders.
DrawRoomLadders_Loop A95C LD A,(HL) A=this ladder's column.
A95D CP $FF Jump to DrawRoomDoors if this ladder entry is the terminator (FF).
A95F JR Z,DrawRoomDoors
A961 LD C,A C=the column, then advance to the row.
A962 INC HL
A963 LD B,(HL) B=the row, then advance past this entry.
A964 INC HL
A965 LD A,$2F Set the ladder graphic, width and height.
A967 LD E,$02
A969 LD D,$05
A96B CALL WriteSpriteBuffer Write the ladder into the room buffer using WriteSpriteBuffer.
A96E CALL PrintSpriteTiles Print the ladder using PrintSpriteTiles.
A971 JR DrawRoomLadders_Loop Jump to DrawRoomLadders_Loop.
Draws the front facing doors which lead to other rooms.
DrawRoomDoors A973 LD HL,($5BD6) HL=*ReferenceDoors.
DrawRoomDoors_Loop A976 LD C,(HL) C=the door column, then advance to the row.
A977 INC HL
A978 LD B,(HL) B=the door row, then advance to the colour.
A979 INC HL
A97A LD A,(HL) A=the door colour, then skip the unused byte.
A97B INC HL
A97C INC HL
A97D PUSH AF Stash the door colour on the stack.
A97E LD A,$FF Jump to DrawRoomKeysAndLockedDoors if this door entry is the terminator (FF).
A980 CP C
A981 JR Z,DrawRoomKeysAndLockedDoors
A983 LD A,$10 Set INK from the door colour.
A985 RST $10
A986 POP AF
A987 RST $10
A988 LD A,$23 Set the door graphic, width and height.
A98A LD E,$03
A98C LD D,$04
A98E CALL WriteSpriteBuffer Write the door into the room buffer using WriteSpriteBuffer.
A991 CALL PrintSpriteTiles Print the door using PrintSpriteTiles.
A994 JR DrawRoomDoors_Loop Jump to DrawRoomDoors_Loop.
Draws the numbered keys and locked doors which correlate to them.
DrawRoomKeysAndLockedDoors A996 POP AF Restore AF from the stack.
DrawRoomKeysAndLockedDoors_SetInk A997 LD A,$10 Set INK: *ActiveRoom_ScaffoldingColour.
A999 RST $10
A99A LD A,($5BCF)
A99D RST $10
A99E LD IX,($5BDA) Point IX at *ReferenceKeysAndLockedDoors.
DrawRoomKeysAndLockedDoors_Loop A9A2 LD C,(IX+$00) C=the locked-door column.
A9A5 LD A,$FF Jump to DrawRoomItems if this key entry is the terminator (FF).
A9A7 CP C
A9A8 JR Z,DrawRoomItems
A9AA LD A,(IX+$05) Jump to DrawRoomKeysAndLockedDoors_Next if this key has already been taken.
A9AD CP $00
A9AF JR Z,DrawRoomKeysAndLockedDoors_Next
A9B1 LD (IX+$05),$03 Mark this key as present in the room.
A9B5 LD B,(IX+$01) B=the locked-door row.
A9B8 PUSH BC Stash the door position on the stack.
A9B9 CALL ConvertDrawCoordinate Convert the door into a room-buffer offset.
A9BC CALL $0DD9 Call CL_SET.
DrawRoomKeysAndLockedDoors_SetDoorNumberInk A9BF LD A,$10 Set INK: *ActiveRoom_ScaffoldingColour.
A9C1 RST $10
A9C2 LD A,($5BCF)
A9C5 RST $10
A9C6 LD A,(IX+$04) A=this key's ID.
A9C9 ADD A,$38 A+=38 (door number graphic).
A9CB CALL PopulateRoomBuffer Write the door number into the room buffer using PopulateRoomBuffer.
A9CE CALL PrintUDG Print the door number using PrintUDG.
DrawRoomKeysAndLockedDoors_SetDoorBodyInk A9D1 LD A,$10 Set INK: *ActiveRoom_ClosedDoorColour.
A9D3 RST $10
A9D4 LD A,($5BCD)
A9D7 RST $10
A9D8 POP BC Restore the door position from the stack.
A9D9 DEC B Move one row down for the door body.
A9DA LD A,$4C A=Graphics_DoorClosed (4C).
A9DC LD E,$01 E=Sprite width (01).
A9DE LD D,$04 D=Sprite height (04).
A9E0 CALL WriteSpriteBuffer Write the locked door into the room buffer using WriteSpriteBuffer.
A9E3 CALL PrintSpriteTiles Print the locked door using PrintSpriteTiles.
A9E6 LD C,(IX+$02) C=the key column.
A9E9 LD B,(IX+$03) B=the key row.
A9EC PUSH BC Stash the key position on the stack.
A9ED CALL ConvertDrawCoordinate Convert the key into a room-buffer offset.
A9F0 CALL $0DD9 Call CL_SET.
A9F3 LD A,$10 Set INK: *ActiveRoom_KeyColour.
A9F5 RST $10
A9F6 LD A,($5BCC)
A9F9 RST $10
A9FA LD A,(IX+$04) A=this key's ID.
A9FD ADD A,$41 A+=41 (key letter; see Graphics_KeyLabels).
A9FF CALL PopulateRoomBuffer Write the key letter into the room buffer using PopulateRoomBuffer.
AA02 CALL PrintUDG Print the key letter using PrintUDG.
AA05 POP BC Restore the key position from the stack.
AA06 DEC B Move one row down for the key stem.
AA07 CALL ConvertDrawCoordinate Convert it into a room-buffer offset.
AA0A CALL $0DD9 Call CL_SET.
All the keys share the same bottom half.
AA0D LD A,$4B A=Graphics_KeyBottom (4B).
AA0F CALL PopulateRoomBuffer Write the key stem into the room buffer using PopulateRoomBuffer.
AA12 CALL PrintUDG Print the key stem using PrintUDG.
DrawRoomKeysAndLockedDoors_Next AA15 LD DE,$0006 Move IX on to the next six-byte key entry.
AA18 ADD IX,DE
AA1A JR DrawRoomKeysAndLockedDoors_Loop Jump to DrawRoomKeysAndLockedDoors_Loop.
Draw room items.
DrawRoomItems AA1C LD IX,($5BE0) Point IX at *ReferenceItems.
DrawRoomItems_Loop AA20 LD A,(IX+$00) Jump to DrawRoomFurniture if this item entry is the terminator (FF).
AA23 CP $FF
AA25 JR Z,DrawRoomFurniture
AA27 LD A,(IX+$05) Jump to DrawRoomItems_Next if this item has already been collected.
AA2A CP $00
AA2C JR Z,DrawRoomItems_Next
AA2E LD A,$10 Set INK from the item colour.
AA30 RST $10
AA31 LD A,(IX+$04)
AA34 RST $10
AA35 LD C,(IX+$00) C=the item column.
AA38 LD B,(IX+$01) B=the item row.
AA3B LD D,$02 D=Sprite height (02).
AA3D LD E,$02 E=Sprite width (02).
AA3F LD A,(IX+$06) A=the item UDG.
AA42 CALL WriteSpriteBuffer Write the item into the room buffer using WriteSpriteBuffer.
AA45 CALL PrintSpriteTiles Print the item using PrintSpriteTiles.
DrawRoomItems_Next AA48 LD DE,$0007 Move IX on to the next seven-byte item entry.
AA4B ADD IX,DE
AA4D JR DrawRoomItems_Loop Jump to DrawRoomItems_Loop.
Draw all the room "furniture", like the barrels and stacks of crates.
DrawRoomFurniture AA4F LD HL,$8678 Write 8678 to *CHARS.
AA52 LD ($5C36),HL
AA55 LD IX,($5BE2) Point IX at *ReferenceFurniture.
DrawRoomFurniture_Loop AA59 LD A,(IX+$00) Jump to WriteRoomAttributes if this furniture entry is the terminator (FF).
AA5C CP $FF
AA5E JR Z,WriteRoomAttributes
AA60 LD A,$10 Set INK from the furniture colour.
AA62 RST $10
AA63 LD A,(IX+$03)
AA66 RST $10
AA67 LD C,(IX+$00) C=the furniture column.
AA6A LD B,(IX+$01) B=the furniture row.
AA6D LD D,$04 D=Sprite height (04).
AA6F LD E,$06 E=Sprite width (06).
AA71 LD A,(IX+$02) A=the furniture UDG.
AA74 OR %10000000 Set bit 7.
AA76 CALL WriteSpriteBuffer Write the furniture into the room buffer using WriteSpriteBuffer.
AA79 AND %01111111 Keep only bits 0-6.
AA7B CALL PrintSpriteTiles Print the furniture using PrintSpriteTiles.
AA7E LD DE,$0004 IX+=0004.
AA81 ADD IX,DE
AA83 JR DrawRoomFurniture_Loop Jump to DrawRoomFurniture_Loop.
Copy the room attributes buffer to the screen.
WriteRoomAttributes AA85 LD DE,$5800 Copy 0300 bytes of data from BufferRoomAttributes to the attribute buffer.
AA88 LD HL,$A4E4
AA8B LD BC,$0300
AA8E LDIR
AA90 LD A,($5BD0) Set the border to *Active_BorderColour using BORDER.
AA93 CALL $229B
AA96 RET Return.
Prev: A8D8 Up: Map Next: AA97