Prev: 24593 Up: Map Next: 24740
24599: Draw Pantry
Used by the routine at StartLevel.
Draws the pantry down the right hand side of the screen, and the mixing bowl and pillars along the bottom. The scenery is built from the tiles at CupboardGraphic, which are printed as if they were a font.
The pantry has five shelves, each with a drawer. The drawer for the current level's ingredient is drawn highlighted, and has the colour of the ingredient inside it. The level number is printed in the bottom right corner.
pantry
The pantry is constructed like it is a font.
DrawPantry 24599 LD HL,(23606) Stash the address of the character set (CHARS) on the stack.
24602 PUSH HL
24603 LD HL,31562 Use the pantry tiles as the character set by writing CupboardGraphic to CHARS.
24606 LD (23606),HL
Make a mask which has a single bit set for the shelf that is highlighted. Shelf 5 is at the top and shelf 1 is at the bottom, so the mask is 32 shifted right by the level (modulo 8).
24609 LD A,(24365) Fetch the level of the active player.
24612 AND %00000111 Keep only bits 0-2 (the level within the set of five).
24614 LD B,A Use the level as the counter for moving the highlight down.
24615 LD A,32 Start with the mask for the top shelf.
24617 JR Z,DrawPantry_SetMask Jump to DrawPantry_SetMask if the top shelf is highlighted.
DrawPantry_Shift_Loop 24619 SRL A Move the highlight down by one shelf.
24621 DJNZ DrawPantry_Shift_Loop Decrease the level counter by one and loop back to DrawPantry_Shift_Loop until the highlight is on the shelf for this level.
DrawPantry_SetMask 24623 LD (24362),A Write the mask of the highlighted shelf to PantryHighlightMask.
Print the sign at the top of the pantry; it is in two rows.
24626 LD DE,24891 Point DE at CupboardData.
24629 LD HL,4304 Set the position of the top row of the sign (4304).
24632 CALL PrintStringColour Print the top row of the sign using PrintStringColour.
24635 EXX Switch back to the normal registers.
24636 INC DE Point DE at the bottom row of the "PANTRY" sign.
24637 LD HL,6352 Set the position of the bottom row of the sign (6352).
24640 CALL PrintStringColour Print the bottom row of the sign using PrintStringColour.
24643 EXX Switch back to the normal registers.
Draw the tiles for each of the five shelves, from the top.
24644 LD HL,8400 Set the position of the top shelf (8400).
24647 INC DE Point DE at the tiles for the shelves.
24648 LD B,5 Set the shelf counter to 5 which is also the number of the top shelf.
DrawPantry_Shelves_Loop 24650 CALL DrawShelf Draw a shelf using DrawShelf.
24653 DJNZ DrawPantry_Shelves_Loop Decrease the shelf counter by one and loop back to DrawPantry_Shelves_Loop until all five shelves have been drawn.
Print the base of the pantry.
24655 LD DE,24941 Point DE at PantryBase.
24658 LD HL,39120 Set the position of the base of the pantry (39120).
24661 CALL PrintStringColour Print the base of the pantry using PrintStringColour.
Colour each of the five shelves, from the top.
24664 LD DE,24948 Point DE at PantryAttributes.
24667 LD HL,8400 Set the position of the top shelf (8400).
24670 LD B,5 Set the shelf counter to 5 which is also the number of the top shelf.
DrawPantry_Colours_Loop 24672 CALL PantryFillColour Set the fill colour for the shelf using PantryFillColour.
24675 CALL ColourShelf Colour the shelf using ColourShelf.
24678 DJNZ DrawPantry_Colours_Loop Decrease the shelf counter by one and loop back to DrawPantry_Colours_Loop until all five shelves have been coloured.
Draw the mixing bowl and pillars along the bottom of the screen; this is 32 tiles wide and 4 tiles tall.
24680 LD HL,40960 Set the position of the mixing bowl and pillars (40960).
24683 LD DE,24984 Point DE at BottomStrip_Tiles.
24686 LD C,4 Set the number of rows to 4.
24688 LD A,32 Set the width to 32 tiles.
24690 CALL PrintTileBlock Print the mixing bowl and pillars using PrintTileBlock.
Colour the mixing bowl and pillars.
24693 LD DE,25112 Point DE at BottomStrip_Attributes.
24696 LD HL,40960 Set the position of the mixing bowl and pillars (40960).
24699 LD C,4 Set the number of rows to 4.
24701 CALL WriteAttributeBlock Colour the mixing bowl and pillars using WriteAttributeBlock.
24704 POP HL Restore the address of the original character set from the stack.
24705 LD (23606),HL Write it back to CHARS.
Print the number of ingredients which are needed inside the bowl.
24708 LD B,0 Set the number of ingredients collected to 0.
24710 CALL TakeIngredients Print the number of ingredients needed inside the bowl using TakeIngredients.
Print the level number, which is in BCD, in the bottom right corner of the screen.
24713 LD A,(24368) Fetch the level number of the active player and keep a copy of the level number in C.
24716 LD C,A
24717 RRA Shift the tens digit into the low four bits.
24718 RRA
24719 RRA
24720 RRA
24721 AND %00001111 Keep only the tens digit.
24723 ADD A,48 Convert the digit to an ASCII character.
24725 LD HL,20732 Set the screen address of the first digit of the level number.
24728 CALL PrintScreen Print the tens digit using PrintScreen.
24731 LD A,C Fetch the level number again.
24732 AND %00001111 Keep only the units digit.
24734 ADD A,48 Convert the digit to an ASCII character.
24736 CALL PrintScreen Print the units digit using PrintScreen.
24739 RET Return.
Prev: 24593 Up: Map Next: 24740