Prev: 48093 Up: Map Next: 48231
48119: Draw Room
Used by the routines at GameComplete, HandlerGameMenu, NewHighScore and 48093.
Input
HL The Room Data memory address (e.g. Room_Special_MainMenu, Room_00)
The room data is held as:
Byte Type
1 Room Graphic Data Address
2
3 X Position
4 Y Position
And is terminated when 0000 is reached.
Fetch the room data graphic address.
DrawRoom 48119 LD E,(HL) DE=room data graphic address.
48120 INC HL
48121 LD D,(HL)
48122 LD A,E Return if the terminator is found.
48123 OR D
48124 RET Z
Fetch the X/ Y position data.
48125 INC HL Increment HL by one.
48126 LD C,(HL) BC=X/ Y position data.
48127 INC HL
48128 LD B,(HL)
48129 INC HL Increment HL by one, ready for the next loop.
48130 PUSH HL Stash HL (room graphic data pointer) on the stack.
48131 LD H,B HL=BC.
48132 LD L,C
48133 CALL DrawRoom_Process Call DrawRoom_Process.
48136 POP HL Restore HL from the stack (room graphic data pointer).
48137 JR DrawRoom Jump back to DrawRoom.
At the point of processing; HL contains X/ Y position data, DE contains the room data graphic address (and BC is throwaway).
DrawRoom_Process 48139 PUSH HL Stash HL (X/ Y position) on the stack.
48140 CALL ScreenAddress Call ScreenAddress.
48143 LD A,(DE) C=room graphic width byte.
48144 LD C,A
48145 INC DE Increment DE by one.
48146 LD A,(DE) B=room graphic height byte.
48147 LD B,A
48148 INC DE Increment DE by one.
DrawRoom_Row_Loop 48149 PUSH BC Stash BC on the stack.
DrawRoom_Write_Row 48150 LD A,(DE) A=fetch a byte of graphics data.
48151 CPL Invert the bits.
48152 LD (HL),A Write the graphic data to HL (screen buffer).
48153 INC L Move onto the next screen location.
48154 INC DE Increment DE by one.
48155 DJNZ DrawRoom_Write_Row Decrease the width counter by one and loop back to DrawRoom_Write_Row until counter is zero.
48157 POP BC Restore BC from the stack.
48158 LD A,L L=L-B.
48159 SUB B
48160 LD L,A
48161 CALL ScreenPos1PixelBelow Call ScreenPos1PixelBelow.
48164 DEC C Decrease the height counter by one and loop back to DrawRoom_Row_Loop until counter is zero.
48165 JR NZ,DrawRoom_Row_Loop
48167 POP HL Restore HL from the stack.
48168 CALL AttributeAddress Call AttributeAddress.
48171 LD A,(DE)
48172 INC DE
48173 LD C,A
48174 LD A,(DE)
48175 INC DE
48176 LD B,A
48177 LD A,(38578) If 38578 is not zero, jump to DrawRoom_2.
48180 AND A
48181 JR NZ,DrawRoom_2
DrawRoom_0 48183 PUSH BC
48184 PUSH HL
DrawRoom_1 48185 LD A,(DE)
48186 INC DE
48187 LD (HL),A
48188 INC L
48189 DJNZ DrawRoom_1
48191 POP HL
48192 LD BC,32 BC=0032.
48195 ADD HL,BC
48196 POP BC
48197 DEC C
48198 JR NZ,DrawRoom_0
48200 RET Return.
DrawRoom_2 48201 PUSH BC Stash BC on the stack.
48202 XOR A Write 0 to 38578.
48203 LD (38578),A
DrawRoom_3 48206 ADD A,C
48207 DJNZ DrawRoom_3
48209 LD C,A
48210 LD B,0
48212 EX DE,HL
48213 ADD HL,BC
48214 EX DE,HL
48215 POP BC
48216 JR DrawRoom_0
48218 LD HL,0 HL=0000.
48221 LD B,8 B=8.
DrawRoom_4 48223 ADD HL,HL
48224 RLCA
48225 JR NC,DrawRoom_5
48227 ADD HL,DE
DrawRoom_5 48228 DJNZ DrawRoom_4
48230 RET Return.
Prev: 48093 Up: Map Next: 48231