Prev: 39890 Up: Map Next: 40033
39914: Draw Room Frame
Used by the routine at EnterRoom.
Clears GameFlags (so the next pass of MainLoop draws the items in the room), reads the room's attribute from RoomAttributes and draws the frame. The entry point at DrawRoomFrame_Room draws the frame of the room in A, which is how FallThroughTrapdoor draws the frame of room 150. The entry for the shape of the room in RoomShapeTable gives the width and height of the floor (written to CurrentRoom_Width and CurrentRoom_Height), the coordinates of the corners of the frame and the lists of the lines to draw between them (see TunnelFrameCoordinates and TunnelFrameLines for the frame of room 150). Each list has a corner to start from, followed by the corners to draw lines to, ending with 255. The list of lists ends with 255.
Input
A The room (at the entry point DrawRoomFrame_Room)
Before After
room-frame-before room-frame-after
The frame of a cave room (room 48):
room-frame-cave
DrawRoomFrame 39914 XOR A Reset A.
39915 LD (24084),A Update the game flags in GameFlags.
39918 LD A,(60049) Fetch the room of the player from PlayerRoom.
This entry point is used by the routine at FallThroughTrapdoor.
DrawRoomFrame_Room 39921 LD BC,43092 Point BC at the room attribute table at RoomAttributes.
39924 LD L,A Keep the room in L.
39925 LD H,0 Clear the high byte of the room.
39927 ADD HL,HL Multiply HL by 2.
39928 ADD HL,BC Add BC to HL to get the entry for the room.
39929 LD A,(HL) Fetch the attribute of the room.
39930 INC HL Move on to the shape of the room.
39931 LD (24090),A Update the room attribute in CurrentRoom_Attribute.
39934 EXX Switch to the shadow registers.
39935 LD HL,22528 HL'=22528 (the attribute buffer).
39938 LD BC,6168 BC'=6168 (the size of the play area).
39941 LD A,(24090) Fetch the room attribute from CurrentRoom_Attribute.
39944 CALL ClearPlayArea_Row Call ClearPlayArea_Row to fill the play area with the attribute.
39947 EXX Switch back to the main registers.
39948 LD L,(HL) Fetch the shape of the room.
39949 LD H,0 Clear the high byte of the shape.
39951 ADD HL,HL Multiply HL by 2.
39952 LD C,L Keep the shape multiplied by two in BC.
39953 LD B,H
39954 ADD HL,HL Multiply HL by 2.
39955 ADD HL,BC Add BC to HL, to multiply the shape by 6.
39956 LD BC,43394 Point BC at the room shape table at RoomShapeTable.
39959 ADD HL,BC Add BC to HL to get the entry for the shape.
39960 LD A,(HL) Fetch the width.
39961 INC HL Move on to the next byte.
39962 LD (24093),A Update the room width in CurrentRoom_Width.
39965 LD A,(HL) Fetch the height.
39966 INC HL Move on to the next byte.
39967 LD (24094),A Update the room height in CurrentRoom_Height.
39970 LD E,(HL) Fetch the low byte of the address of the coordinates.
39971 INC HL Move on to the next byte.
39972 LD D,(HL) Fetch the high byte of the address of the coordinates.
39973 INC HL Move on to the next byte.
39974 LD A,(HL) Fetch the low byte of the address of the lists of lines.
39975 INC HL Move on to the next byte.
39976 LD H,(HL) Fetch the high byte of the address of the lists of lines.
39977 LD L,A Keep the low byte of the address of the lists of lines in L.
39978 PUSH DE Copy DE into IX, as the address of the coordinates.
39979 POP IX
Start a list. The corner to start from is found by changing the offsets in the instructions at 39997 and 40000.
39981 PUSH BC Stash BC on the stack.
DrawRoomFrame_List 39982 POP BC Restore BC from the stack.
39983 LD A,(HL) Fetch the corner to start from.
39984 INC HL Move HL on to the next byte.
39985 CP 255 Return if there are no more lists.
39987 RET Z
39988 SLA A Multiply the corner by 2.
39990 LD (39999),A Write it as the offset in the instruction at 39997.
39993 INC A Increment it.
39994 LD (40002),A Write it as the offset in the instruction at 40000.
39997 LD C,(IX+0) Fetch the X coordinate of the corner.
40000 LD B,(IX+0) Fetch the Y coordinate of the corner.
DrawRoomFrame_Line 40003 PUSH BC Stash the coordinates of the corner on the stack.
40004 LD A,(HL) Fetch the corner to draw a line to.
40005 INC HL Move HL on to the next byte.
40006 CP 255 Jump to DrawRoomFrame_List if this is the end of the list.
40008 JR Z,DrawRoomFrame_List
40010 SLA A Multiply the corner by 2.
40012 LD (40021),A Write it as the offset in the instruction at 40019.
40015 INC A Increment it.
40016 LD (40024),A Write it as the offset in the instruction at 40022.
40019 LD E,(IX+0) Fetch the X coordinate of the corner.
40022 LD D,(IX+0) Fetch the Y coordinate of the corner.
40025 PUSH HL Stash HL on the stack.
40026 CALL DrawLine Call DrawLine to draw the line.
40029 POP HL Restore HL from the stack.
40030 POP BC Restore the coordinates of the first corner from the stack.
40031 JR DrawRoomFrame_Line Jump back to DrawRoomFrame_Line to draw the next line of the frame.
Prev: 39890 Up: Map Next: 40033