![]() |
Routines |
| Prev: 99D2 | Up: Map | Next: 9A33 |
|
Used by the routine at Draw_Room.
Draws the ceiling of the room if bit 0 of the frame flags is set, or clears its area if it is not.
The ceiling is made of thirteen tiles of two bytes by 20 lines, which are drawn from left to right starting at x position 18 and y position 10. Each tile is chosen from the table at Ceiling_Tile_Table. The first tile that is used depends on the sum of the room x and the room y, which makes the ceiling look different from room to room, and the next tiles come from the following entries of the table.
Finally the attributes of the area are set (see Set_Area_Attributes). The floor, drawn by Draw_Floor, uses this code too.
|
||||||||||
| Draw_Ceiling | 99F5 | PUSH DE | Stash the frame flags on the stack. | |||||||
| 99F6 | BIT 0,E | Test bit 0 of the frame flags (the ceiling). | ||||||||
| 99F8 | LD HL,$1018 | Set the x position to 18 and the y position to 10 (1018). | ||||||||
| 99FB | LD DE,$9A33 | Point at the table of ceiling tiles (Ceiling_Tile_Table). | ||||||||
|
This entry point is used by the routine at Draw_Floor.
|
||||||||||
| Draw_Ceiling_Check_Present | 99FE | JP Z,Clear_Wide_Panel | Jump to Clear_Wide_Panel if there is no ceiling. | |||||||
|
Draw the row of tiles. The same code draws the floor, which jumps to Draw_Ceiling_Check_Present.
|
||||||||||
| Draw_Row_Of_Tiles | 9A01 | LD B,$0D | Set the number of tiles to 0D. | |||||||
| 9A03 | PUSH HL | Stash the screen position on the stack. | ||||||||
| 9A04 | CALL ScreenAddress | Convert the position into a screen address. | ||||||||
| 9A07 | LD A,(IX+$02) | Fetch the room x of Sabreman. | ||||||||
| 9A0A | ADD A,(IX+$04) | Add the room y of Sabreman. | ||||||||
| 9A0D | RLCA | Double the sum to make an offset into the table of word pointers. | ||||||||
| Draw_Ceiling_Tile_Loop | 9A0E | AND %00011110 | Keep the offset within the table (sixteen entries). | |||||||
| 9A10 | LD C,A | Store the offset in C. | ||||||||
| 9A11 | PUSH BC | Stash the tile counter and the offset on the stack. | ||||||||
| 9A12 | EX DE,HL | Exchange the registers so that HL holds the address of the table. | ||||||||
| 9A13 | PUSH HL | Stash the address of the table on the stack. | ||||||||
| 9A14 | LD B,$00 | Clear the high byte of the offset. | ||||||||
| 9A16 | ADD HL,BC | Add the offset to the address of the table. | ||||||||
| 9A17 | LD A,(HL) | Fetch the low byte of the address of the tile. | ||||||||
| 9A18 | INC HL | Move on to the high byte. | ||||||||
| 9A19 | LD H,(HL) | Fetch the high byte of the address of the tile. | ||||||||
| 9A1A | LD L,A | Copy the low byte to L. | ||||||||
| 9A1B | EX DE,HL | Exchange the registers so that DE holds the address of the tile and HL the screen address. | ||||||||
| 9A1C | PUSH HL | Stash the screen address on the stack. | ||||||||
| 9A1D | CALL Draw_Tile | Draw the tile. | ||||||||
| 9A20 | POP HL | Restore the screen address from the stack. | ||||||||
| 9A21 | INC L | Move on two cells to the right. | ||||||||
| 9A22 | INC L | |||||||||
| 9A23 | POP DE | Restore the address of the table into DE. | ||||||||
| 9A24 | POP BC | Restore the tile counter and the offset. | ||||||||
| 9A25 | LD A,C | Copy the offset to A. | ||||||||
| 9A26 | ADD A,$02 | Move on to the next entry of the table. | ||||||||
| 9A28 | DJNZ Draw_Ceiling_Tile_Loop | Decrease the tile counter and loop back until all of the tiles are drawn. | ||||||||
| 9A2A | POP HL | Restore the position of the area. | ||||||||
| 9A2B | LD BC,$1A20 | Set the size of the area to 1A20. | ||||||||
| 9A2E | CALL Set_Area_Attributes | Set the attributes of the area. | ||||||||
| 9A31 | POP DE | Restore the frame flags from the stack. | ||||||||
| 9A32 | RET | Return. | ||||||||
| Prev: 99D2 | Up: Map | Next: 9A33 |