![]() |
Routines |
| Prev: 43224 | Up: Map | Next: 43671 |
|
Used by the routine at Controller_DrawRoom.
|
||||
|
Clear the screen to BLACK.
|
||||
| DrawRoom | 43264 | LD A,0 | Write BLACK to *ATTR_P. | |
| 43266 | LD (23693),A | |||
| 43269 | CALL ClearRoomBuffer | Call ClearRoomBuffer. | ||
| 43272 | LD A,(23505) | A=*ActiveRoom_PaperColour. | ||
| 43275 | SLA A | Convert a PAPER value (using bits 3, 4 and 5) to an "INK" value (shifted left to bits 0, 1 and 2). | ||
| 43277 | SLA A | |||
| 43279 | SLA A | |||
| 43281 | LD (23693),A | Write A to *ATTR_P. | ||
| 43284 | LD A,17 | Set PAPER: *ActiveRoom_PaperColour. | ||
| 43286 | RST 16 | |||
| 43287 | LD A,(23505) | |||
| 43290 | RST 16 | |||
|
Set the UDG graphics pointer.
|
||||
| 43291 | LD HL,33656 | Write 33656 to *CHARS. | ||
| 43294 | LD (23606),HL | |||
|
Set the attributes for drawing the room scaffolding (i.e. ceilings and floors).
|
||||
| DrawRoom_SetScaffoldingInk | 43297 | LD A,16 | Set INK: *ActiveRoom_ScaffoldingColour. | |
| 43299 | RST 16 | |||
| 43300 | LD A,(23503) | |||
| 43303 | RST 16 | |||
|
Fetch the address of the current room data buffer.
|
||||
| 43304 | LD HL,(23528) | HL=*PointerCurrentRoomBuffer. | ||
|
Draw the ceilings/ floors.
|
||||
| DrawRoomScaffolding | 43307 | 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. | |
| 43308 | INC HL | |||
| 43309 | LD B,(HL) | |||
| 43310 | INC HL | Increment the current room data buffer by one. | ||
| 43311 | LD A,255 | Jump to DrawRoomLadders if this scaffolding entry is the terminator (255). | ||
| 43313 | CP C | |||
| 43314 | JR Z,DrawRoomLadders | |||
| 43316 | PUSH HL | Stash the current room data buffer on the stack. | ||
| 43317 | CALL ConvertDrawCoordinate | Convert this position into a room-buffer offset using ConvertDrawCoordinate. | ||
|
Set the co-ordinates of where we're going to PRINT AT.
|
||||
| 43320 | CALL 3545 | Call CL_SET. | ||
| 43323 | POP HL | Restore the current room data buffer from the stack. | ||
| 43324 | LD B,(HL) | Fetch the length counter and store it in B. | ||
| 43325 | 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 | 43326 | LD A,33 | A=Graphics_RoomScaffolding_Top1 (33). | |
| 43328 | CALL PopulateRoomBuffer | Write it into the room buffer using PopulateRoomBuffer. | ||
| 43331 | CALL PrintUDG | Print that tile using PrintUDG. | ||
| 43334 | LD A,34 | A=Graphics_RoomScaffolding_Top2 (34). | ||
| 43336 | CALL PopulateRoomBuffer | Write it into the room buffer using PopulateRoomBuffer. | ||
| 43339 | CALL PrintUDG | Print that tile using PrintUDG. | ||
| 43342 | DJNZ DrawRoomScaffolding_Loop | Decrease the remaining length and loop back to DrawRoomScaffolding_Loop until this run is drawn. | ||
| 43344 | JR DrawRoomScaffolding | Jump to DrawRoomScaffolding. | ||
|
Draw the ladders.
|
||||
| DrawRoomLadders | 43346 | LD A,16 | Set INK: *ActiveRoom_LadderColour. | |
| 43348 | RST 16 | |||
| 43349 | LD A,(23506) | |||
| 43352 | RST 16 | |||
| 43353 | LD HL,(23512) | HL=*ReferenceLadders. | ||
| DrawRoomLadders_Loop | 43356 | LD A,(HL) | A=this ladder's column. | |
| 43357 | CP 255 | Jump to DrawRoomDoors if this ladder entry is the terminator (255). | ||
| 43359 | JR Z,DrawRoomDoors | |||
| 43361 | LD C,A | C=the column, then advance to the row. | ||
| 43362 | INC HL | |||
| 43363 | LD B,(HL) | B=the row, then advance past this entry. | ||
| 43364 | INC HL | |||
| 43365 | LD A,47 | Set the ladder graphic, width and height. | ||
| 43367 | LD E,2 | |||
| 43369 | LD D,5 | |||
| 43371 | CALL WriteSpriteBuffer | Write the ladder into the room buffer using WriteSpriteBuffer. | ||
| 43374 | CALL PrintSpriteTiles | Print the ladder using PrintSpriteTiles. | ||
| 43377 | JR DrawRoomLadders_Loop | Jump to DrawRoomLadders_Loop. | ||
|
Draws the front facing doors which lead to other rooms.
|
||||
| DrawRoomDoors | 43379 | LD HL,(23510) | HL=*ReferenceDoors. | |
| DrawRoomDoors_Loop | 43382 | LD C,(HL) | C=the door column, then advance to the row. | |
| 43383 | INC HL | |||
| 43384 | LD B,(HL) | B=the door row, then advance to the colour. | ||
| 43385 | INC HL | |||
| 43386 | LD A,(HL) | A=the door colour, then skip the unused byte. | ||
| 43387 | INC HL | |||
| 43388 | INC HL | |||
| 43389 | PUSH AF | Stash the door colour on the stack. | ||
| 43390 | LD A,255 | Jump to DrawRoomKeysAndLockedDoors if this door entry is the terminator (255). | ||
| 43392 | CP C | |||
| 43393 | JR Z,DrawRoomKeysAndLockedDoors | |||
| 43395 | LD A,16 | Set INK from the door colour. | ||
| 43397 | RST 16 | |||
| 43398 | POP AF | |||
| 43399 | RST 16 | |||
| 43400 | LD A,35 | Set the door graphic, width and height. | ||
| 43402 | LD E,3 | |||
| 43404 | LD D,4 | |||
| 43406 | CALL WriteSpriteBuffer | Write the door into the room buffer using WriteSpriteBuffer. | ||
| 43409 | CALL PrintSpriteTiles | Print the door using PrintSpriteTiles. | ||
| 43412 | JR DrawRoomDoors_Loop | Jump to DrawRoomDoors_Loop. | ||
|
Draws the numbered keys and locked doors which correlate to them.
|
||||
| DrawRoomKeysAndLockedDoors | 43414 | POP AF | Restore AF from the stack. | |
| DrawRoomKeysAndLockedDoors_SetInk | 43415 | LD A,16 | Set INK: *ActiveRoom_ScaffoldingColour. | |
| 43417 | RST 16 | |||
| 43418 | LD A,(23503) | |||
| 43421 | RST 16 | |||
| 43422 | LD IX,(23514) | Point IX at *ReferenceKeysAndLockedDoors. | ||
| DrawRoomKeysAndLockedDoors_Loop | 43426 | LD C,(IX+0) | C=the locked-door column. | |
| 43429 | LD A,255 | Jump to DrawRoomItems if this key entry is the terminator (255). | ||
| 43431 | CP C | |||
| 43432 | JR Z,DrawRoomItems | |||
| 43434 | LD A,(IX+5) | Jump to DrawRoomKeysAndLockedDoors_Next if this key has already been taken. | ||
| 43437 | CP 0 | |||
| 43439 | JR Z,DrawRoomKeysAndLockedDoors_Next | |||
| 43441 | LD (IX+5),3 | Mark this key as present in the room. | ||
| 43445 | LD B,(IX+1) | B=the locked-door row. | ||
| 43448 | PUSH BC | Stash the door position on the stack. | ||
| 43449 | CALL ConvertDrawCoordinate | Convert the door into a room-buffer offset. | ||
| 43452 | CALL 3545 | Call CL_SET. | ||
| DrawRoomKeysAndLockedDoors_SetDoorNumberInk | 43455 | LD A,16 | Set INK: *ActiveRoom_ScaffoldingColour. | |
| 43457 | RST 16 | |||
| 43458 | LD A,(23503) | |||
| 43461 | RST 16 | |||
| 43462 | LD A,(IX+4) | A=this key's ID. | ||
| 43465 | ADD A,56 | A+=56 (door number graphic). | ||
| 43467 | CALL PopulateRoomBuffer | Write the door number into the room buffer using PopulateRoomBuffer. | ||
| 43470 | CALL PrintUDG | Print the door number using PrintUDG. | ||
| DrawRoomKeysAndLockedDoors_SetDoorBodyInk | 43473 | LD A,16 | Set INK: *ActiveRoom_ClosedDoorColour. | |
| 43475 | RST 16 | |||
| 43476 | LD A,(23501) | |||
| 43479 | RST 16 | |||
| 43480 | POP BC | Restore the door position from the stack. | ||
| 43481 | DEC B | Move one row down for the door body. | ||
| 43482 | LD A,76 | A=Graphics_DoorClosed (76). | ||
| 43484 | LD E,1 | E=Sprite width (1). | ||
| 43486 | LD D,4 | D=Sprite height (4). | ||
| 43488 | CALL WriteSpriteBuffer | Write the locked door into the room buffer using WriteSpriteBuffer. | ||
| 43491 | CALL PrintSpriteTiles | Print the locked door using PrintSpriteTiles. | ||
| 43494 | LD C,(IX+2) | C=the key column. | ||
| 43497 | LD B,(IX+3) | B=the key row. | ||
| 43500 | PUSH BC | Stash the key position on the stack. | ||
| 43501 | CALL ConvertDrawCoordinate | Convert the key into a room-buffer offset. | ||
| 43504 | CALL 3545 | Call CL_SET. | ||
| 43507 | LD A,16 | Set INK: *ActiveRoom_KeyColour. | ||
| 43509 | RST 16 | |||
| 43510 | LD A,(23500) | |||
| 43513 | RST 16 | |||
| 43514 | LD A,(IX+4) | A=this key's ID. | ||
| 43517 | ADD A,65 | A+=65 (key letter; see Graphics_KeyLabels). | ||
| 43519 | CALL PopulateRoomBuffer | Write the key letter into the room buffer using PopulateRoomBuffer. | ||
| 43522 | CALL PrintUDG | Print the key letter using PrintUDG. | ||
| 43525 | POP BC | Restore the key position from the stack. | ||
| 43526 | DEC B | Move one row down for the key stem. | ||
| 43527 | CALL ConvertDrawCoordinate | Convert it into a room-buffer offset. | ||
| 43530 | CALL 3545 | Call CL_SET. | ||
|
All the keys share the same bottom half.
|
||||
| 43533 | LD A,75 | A=Graphics_KeyBottom (75). | ||
| 43535 | CALL PopulateRoomBuffer | Write the key stem into the room buffer using PopulateRoomBuffer. | ||
| 43538 | CALL PrintUDG | Print the key stem using PrintUDG. | ||
| DrawRoomKeysAndLockedDoors_Next | 43541 | LD DE,6 | Move IX on to the next six-byte key entry. | |
| 43544 | ADD IX,DE | |||
| 43546 | JR DrawRoomKeysAndLockedDoors_Loop | Jump to DrawRoomKeysAndLockedDoors_Loop. | ||
|
Draw room items.
|
||||
| DrawRoomItems | 43548 | LD IX,(23520) | Point IX at *ReferenceItems. | |
| DrawRoomItems_Loop | 43552 | LD A,(IX+0) | Jump to DrawRoomFurniture if this item entry is the terminator (255). | |
| 43555 | CP 255 | |||
| 43557 | JR Z,DrawRoomFurniture | |||
| 43559 | LD A,(IX+5) | Jump to DrawRoomItems_Next if this item has already been collected. | ||
| 43562 | CP 0 | |||
| 43564 | JR Z,DrawRoomItems_Next | |||
| 43566 | LD A,16 | Set INK from the item colour. | ||
| 43568 | RST 16 | |||
| 43569 | LD A,(IX+4) | |||
| 43572 | RST 16 | |||
| 43573 | LD C,(IX+0) | C=the item column. | ||
| 43576 | LD B,(IX+1) | B=the item row. | ||
| 43579 | LD D,2 | D=Sprite height (2). | ||
| 43581 | LD E,2 | E=Sprite width (2). | ||
| 43583 | LD A,(IX+6) | A=the item UDG. | ||
| 43586 | CALL WriteSpriteBuffer | Write the item into the room buffer using WriteSpriteBuffer. | ||
| 43589 | CALL PrintSpriteTiles | Print the item using PrintSpriteTiles. | ||
| DrawRoomItems_Next | 43592 | LD DE,7 | Move IX on to the next seven-byte item entry. | |
| 43595 | ADD IX,DE | |||
| 43597 | JR DrawRoomItems_Loop | Jump to DrawRoomItems_Loop. | ||
|
Draw all the room "furniture", like the barrels and stacks of crates.
|
||||
| DrawRoomFurniture | 43599 | LD HL,34424 | Write 34424 to *CHARS. | |
| 43602 | LD (23606),HL | |||
| 43605 | LD IX,(23522) | Point IX at *ReferenceFurniture. | ||
| DrawRoomFurniture_Loop | 43609 | LD A,(IX+0) | Jump to WriteRoomAttributes if this furniture entry is the terminator (255). | |
| 43612 | CP 255 | |||
| 43614 | JR Z,WriteRoomAttributes | |||
| 43616 | LD A,16 | Set INK from the furniture colour. | ||
| 43618 | RST 16 | |||
| 43619 | LD A,(IX+3) | |||
| 43622 | RST 16 | |||
| 43623 | LD C,(IX+0) | C=the furniture column. | ||
| 43626 | LD B,(IX+1) | B=the furniture row. | ||
| 43629 | LD D,4 | D=Sprite height (4). | ||
| 43631 | LD E,6 | E=Sprite width (6). | ||
| 43633 | LD A,(IX+2) | A=the furniture UDG. | ||
| 43636 | OR %10000000 | Set bit 7. | ||
| 43638 | CALL WriteSpriteBuffer | Write the furniture into the room buffer using WriteSpriteBuffer. | ||
| 43641 | AND %01111111 | Keep only bits 0-6. | ||
| 43643 | CALL PrintSpriteTiles | Print the furniture using PrintSpriteTiles. | ||
| 43646 | LD DE,4 | IX+=0004. | ||
| 43649 | ADD IX,DE | |||
| 43651 | JR DrawRoomFurniture_Loop | Jump to DrawRoomFurniture_Loop. | ||
|
Copy the room attributes buffer to the screen.
|
||||
| WriteRoomAttributes | 43653 | LD DE,22528 | Copy 768 bytes of data from BufferRoomAttributes to the attribute buffer. | |
| 43656 | LD HL,42212 | |||
| 43659 | LD BC,768 | |||
| 43662 | LDIR | |||
| 43664 | LD A,(23504) | Set the border to *Active_BorderColour using BORDER. | ||
| 43667 | CALL 8859 | |||
| 43670 | RET | Return. | ||
| Prev: 43224 | Up: Map | Next: 43671 |