| Routines

36147: Draw the current room to the screen buffer at 28672

Used by the routine at 35090.
36147 | CALL 36203 | Fill the buffer at 24064 with attribute bytes for the current room
36150 | LD IX,24064 | Point IX at the first byte of the attribute buffer at 24064
36154 | LD A,112 | Set the operand of the 'LD D,n' instruction at 36188 (below) to 112
36156 | LD (36189),A
36159 | CALL 36171 | Draw the tiles for the top half of the room to the screen buffer at 28672
36162 | LD IX,24320 | Point IX at the 256th byte of the attribute buffer at 24064 in preparation for drawing the bottom half of the room; this instruction is redundant, since IX already holds 24320
36166 | LD A,120 | Set the operand of the 'LD D,n' instruction at 36188 (below) to 120
36168 | LD (36189),A
36171 | LD C,0 | C will count 256 tiles
The following loop draws 256 tiles (for either the top half or the bottom half of the room) to the screen buffer at 28672.
36173 | LD E,C | E holds the LSB of the screen buffer address
36174 | LD A,(IX+0) | Pick up an attribute byte from the buffer at 24064; this identifies the type of tile (background, floor, wall, nasty, ramp or conveyor) to be drawn
36177 | LD HL,32928 | Move HL through the attribute bytes and graphic data of the background, floor, wall, nasty, ramp and conveyor tiles starting at 32928 until we find a byte that matches the attribute byte of the tile to be drawn; note that if a graphic data byte matches the attribute byte being searched for, the CPIR instruction can exit early, which is a bug
36180 | LD BC,54
36183 | CPIR
36185 | LD C,E | Restore the value of the tile counter in C
36186 | LD B,8 | There are eight bytes in the tile
36188 | LD D,0 | This instruction is set to either 'LD D,112' or 'LD D,120' above; now DE holds the appropriate address in the screen buffer at 28672
36190 | LD A,(HL) | Copy the tile graphic data to the screen buffer at 28672
36191 | LD (DE),A
36192 | INC HL
36193 | INC D
36194 | DJNZ 36190
36196 | INC IX | Move IX along to the next byte in the attribute buffer
36198 | INC C | Have we drawn 256 tiles yet?
36199 | JP NZ,36173 | If not, jump back to draw the next one
36202 | RET |