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 (Graphics_RoomScaffolding_Empty) to *CHARS.
A91E LD ($5C36),HL
Set the attributes for drawing the room scaffolding (i.e. ceilings and floors).
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 the terminator character has been received (FF).
A931 CP C
A932 JR Z,DrawRoomLadders
A934 PUSH HL Stash the current room data buffer on the stack.
A935 CALL $A86E Call A86E.
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 Call PopulateRoomBuffer.
A943 CALL PrintUDG Call PrintUDG.
A946 LD A,$22 A=Graphics_RoomScaffolding_Top2 (22).
A948 CALL PopulateRoomBuffer Call PopulateRoomBuffer.
A94B CALL PrintUDG Call PrintUDG.
A94E DJNZ DrawRoomScaffolding_Loop Decrease counter by one and loop back to DrawRoomScaffolding_Loop until counter is zero.
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=*HL.
A95D CP $FF Jump to DrawRoomDoors if the room data is the termination byte (FF).
A95F JR Z,DrawRoomDoors
A961 LD C,A C=A.
A962 INC HL Increment HL by one.
A963 LD B,(HL) B=*HL.
A964 INC HL Increment HL by one.
A965 LD A,$2F A=Graphics_Ladder (2F).
A967 LD E,$02 E=Sprite width (02).
A969 LD D,$05 D=Sprite height (05).
A96B CALL $A83F Call A83F.
A96E CALL $A8AF Call A8AF.
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=*HL.
A977 INC HL Increment HL by one.
A978 LD B,(HL) B=*HL.
A979 INC HL Increment HL by one.
A97A LD A,(HL) A=*HL.
A97B INC HL Increment HL by two.
A97C INC HL
A97D PUSH AF Stash AF on the stack.
A97E LD A,$FF Jump to DrawRoomKeysAndLockedDoors if FF is equal to C.
A980 CP C
A981 JR Z,DrawRoomKeysAndLockedDoors
A983 LD A,$10 Set INK to ...
A985 RST $10
A986 POP AF Restore AF from the stack.
A987 RST $10 ... the value held in A (from the stack).
A988 LD A,$23 A=Graphics_Door (23).
A98A LD E,$03 E=Sprite width (03).
A98C LD D,$04 D=Sprite height (04).
A98E CALL $A83F Call A83F.
A991 CALL $A8AF Call A8AF.
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.
A997 LD A,$10 Set INK: *ActiveRoom_ScaffoldingColour.
A999 RST $10
A99A LD A,($5BCF)
A99D RST $10
A99E LD IX,($5BDA) IX=*ReferenceKeysAndLockedDoors.
DrawRoomKeysAndLockedDoors_Loop A9A2 LD C,(IX+$00) C=*IX+00.
A9A5 LD A,$FF Jump to DrawRoomItems if FF is equal to C.
A9A7 CP C
A9A8 JR Z,DrawRoomItems
A9AA LD A,(IX+$05) Jump to DrawRoomKeysAndLockedDoors_Next if *IX+05 is equal to 00.
A9AD CP $00
A9AF JR Z,DrawRoomKeysAndLockedDoors_Next
A9B1 LD (IX+$05),$03 Write 03 to *IX+05.
A9B5 LD B,(IX+$01) B=*IX+01.
A9B8 PUSH BC Stash BC on the stack.
A9B9 CALL $A86E Call A86E.
A9BC CALL $0DD9 Call CL_SET.
A9BF LD A,$10 Set INK: *ActiveRoom_ScaffoldingColour.
A9C1 RST $10
A9C2 LD A,($5BCF)
A9C5 RST $10
A9C6 LD A,(IX+$04) A=*IX+04.
A9C9 ADD A,$38 A+=38.
A9CB CALL PopulateRoomBuffer Call PopulateRoomBuffer.
A9CE CALL PrintUDG Call PrintUDG.
A9D1 LD A,$10 Set INK: *ActiveRoom_ClosedDoorColour.
A9D3 RST $10
A9D4 LD A,($5BCD)
A9D7 RST $10
A9D8 POP BC Restore BC from the stack.
A9D9 DEC B Decrease B by one.
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 $A83F Call A83F.
A9E3 CALL $A8AF Call A8AF.
A9E6 LD C,(IX+$02) C=*IX+02.
A9E9 LD B,(IX+$03) B=*IX+03.
A9EC PUSH BC Stash BC on the stack.
A9ED CALL $A86E Call A86E.
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=*IX+04.
A9FD ADD A,$41 A+=41.
A9FF CALL PopulateRoomBuffer Call PopulateRoomBuffer.
AA02 CALL PrintUDG Call PrintUDG.
AA05 POP BC Restore BC from the stack.
AA06 DEC B Decrease B by one.
AA07 CALL $A86E Call A86E.
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 Call PopulateRoomBuffer.
AA12 CALL PrintUDG Call PrintUDG.
DrawRoomKeysAndLockedDoors_Next AA15 LD DE,$0006 IX+=0006.
AA18 ADD IX,DE
AA1A JR DrawRoomKeysAndLockedDoors_Loop Jump to DrawRoomKeysAndLockedDoors_Loop.
Draw room items.
DrawRoomItems AA1C LD IX,($5BE0) IX=*ReferenceItems.
DrawRoomItems_Loop AA20 LD A,(IX+$00) Jump to DrawRoomFurniture if *IX+00 is equal to FF.
AA23 CP $FF
AA25 JR Z,DrawRoomFurniture
AA27 LD A,(IX+$05) Jump to DrawRoomItems_Next if *IX+05 is equal to 00.
AA2A CP $00
AA2C JR Z,DrawRoomItems_Next
AA2E LD A,$10 Set INK: *IX+04.
AA30 RST $10
AA31 LD A,(IX+$04)
AA34 RST $10
AA35 LD C,(IX+$00) C=*IX+00.
AA38 LD B,(IX+$01) B=*IX+01.
AA3B LD D,$02 D=Sprite height (02).
AA3D LD E,$02 E=Sprite width (02).
AA3F LD A,(IX+$06) A=*IX+06.
AA42 CALL $A83F Call A83F.
AA45 CALL $A8AF Call A8AF.
DrawRoomItems_Next AA48 LD DE,$0007 IX+=0007.
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 (Graphics_Barrels) to *CHARS.
AA52 LD ($5C36),HL
AA55 LD IX,($5BE2) IX=*ReferenceFurniture.
DrawRoomFurniture_Loop AA59 LD A,(IX+$00) Jump to WriteRoomAttributes if *IX+00 is equal to FF.
AA5C CP $FF
AA5E JR Z,WriteRoomAttributes
AA60 LD A,$10 Set INK: *IX+03.
AA62 RST $10
AA63 LD A,(IX+$03)
AA66 RST $10
AA67 LD C,(IX+$00) C=*IX+00.
AA6A LD B,(IX+$01) B=*IX+01.
AA6D LD D,$04 D=Sprite height (04).
AA6F LD E,$06 E=Sprite width (06).
AA71 LD A,(IX+$02) A=*IX+02.
AA74 OR %10000000 Set bit 7.
AA76 CALL $A83F Call A83F.
AA79 AND %01111111 Keep only bits 0-6.
AA7B CALL $A8AF Call A8AF.
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