| Routines

35445: Draw the current cavern to the screen buffer at 28672

Used by the routine at 34436.
35445 | LD IX,24064 | Point IX at the first byte of the attribute buffer at 24064
35449 | LD A,112 | Set the operand of the 'LD D,n' instruction at 35483 (below) to 112
35451 | LD (35484),A
35454 | CALL 35466 | Draw the tiles for the top half of the cavern to the screen buffer at 28672
35457 | LD IX,24320 | Point IX at the 256th byte of the attribute buffer at 24064 in preparation for drawing the bottom half of the cavern; this instruction is redundant, since IX already holds 24320
35461 | LD A,120 | Set the operand of the 'LD D,n' instruction at 35483 (below) to 120
35463 | LD (35484),A
35466 | 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 cavern) to the screen buffer at 28672.
35468 | LD E,C | E holds the LSB of the screen buffer address
35469 | LD A,(IX+0) | Pick up an attribute byte from the buffer at 24064; this identifies the type of tile to draw
35472 | LD HL,32800 | Move HL through the attribute bytes and graphic data of the background, floor, crumbling floor, wall, conveyor and nasty tiles starting at 32800 until we find a byte that matches the attribute byte of the tile to be drawn
35475 | LD BC,72
35478 | CPIR
35480 | LD C,E | Restore the value of the tile counter in C
35481 | LD B,8 | There are eight bytes in the tile
35483 | 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
35485 | LD A,(HL) | Copy the tile graphic data to the screen buffer at 28672
35486 | LD (DE),A
35487 | INC HL
35488 | INC D
35489 | DJNZ 35485
35491 | INC IX | Move IX along to the next byte in the attribute buffer
35493 | INC C | Have we drawn 256 tiles yet?
35494 | JP NZ,35468 | If not, jump back to draw the next one
The empty cavern has been drawn to the screen buffer at 28672. If we're in The Final Barrier, however, there is further work to do.
35497 | LD A,(33799) | Pick up the number of the current cavern from 33799
35500 | CP 19 | Is it The Final Barrier?
35502 | RET NZ | Return if not
35503 | LD HL,40960 | Copy the graphic data from 40960 to the top half of the screen buffer at 28672
35506 | LD DE,28672
35509 | LD BC,2048
35512 | LDIR
35514 | RET |