Prev: 24740 Up: Map Next: 24802
24765: Draw Shelf
Used by the routine at DrawPantry.
Draws the tiles for one shelf of the pantry. A shelf is 6 tiles wide and 3 tiles tall. There are two graphics for a shelf; the normal one and the highlighted one, which is used when the shelf's bit is set in PantryHighlightMask. The example below is for the top shelf (shelf 5). Its colours are set first, so that the tiles can be seen.
Before After
draw-shelf-before draw-shelf-after
Input
B Shelf number
DE Address of the normal graphic
HL Position of the shelf
Output
HL Position of the shelf below
Make the second byte of a BIT command from the shelf number.
DrawShelf 24765 PUSH BC Stash the shelf number and C on the stack.
24766 PUSH DE Stash the address of the normal graphic on the stack.
24767 LD A,B Fetch the shelf number.
24768 RLCA Multiply by 8 so that the shelf number is in bits 3-5.
24769 RLCA
24770 RLCA
24771 AND %00111000 Keep only bits 3-5.
24773 OR %01000111 Set bits 0-2 and bit 6.
24775 LD (24782),A Write A to 24782.
24778 LD A,(24362) Fetch the mask of the highlighted shelf.
Self modifying code; the command which is here is made into BIT n,A, where n is the shelf number, by the instructions above. It is shown as RLC B as that is how it is stored.
DrawShelf_TestBit 24781 RLC B Test the bit for the shelf in the mask.
24783 JR Z,DrawShelf_Print Jump to DrawShelf_Print if this shelf is not highlighted.
24785 PUSH HL Move DE on to the highlighted graphic, which is 18 bytes further on (preserving HL).
24786 LD HL,18
24789 ADD HL,DE
24790 EX DE,HL
24791 POP HL
DrawShelf_Print 24792 LD C,3 Set the number of rows to 3.
24794 LD A,6 Set the width to 6 tiles.
24796 CALL PrintTileBlock Print the tiles for the shelf using PrintTileBlock.
24799 POP DE Restore the address of the normal graphic from the stack.
24800 POP BC Restore the shelf number and C from the stack.
24801 RET Return.
Prev: 24740 Up: Map Next: 24802