Prev: 6011 Up: Map Next: 60A4
6017: 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 6017 LD HL,($5C36) Stash the address of the character set (CHARS) on the stack.
601A PUSH HL
601B LD HL,$7B4A Use the pantry tiles as the character set by writing CupboardGraphic to CHARS.
601E LD ($5C36),HL
Make a mask which has a single bit set for the shelf that is highlighted. Shelf 05 is at the top and shelf 01 is at the bottom, so the mask is 20 shifted right by the level (modulo 08).
6021 LD A,($5F2D) Fetch the level of the active player.
6024 AND %00000111 Keep only bits 0-2 (the level within the set of five).
6026 LD B,A Use the level as the counter for moving the highlight down.
6027 LD A,$20 Start with the mask for the top shelf.
6029 JR Z,DrawPantry_SetMask Jump to DrawPantry_SetMask if the top shelf is highlighted.
DrawPantry_Shift_Loop 602B SRL A Move the highlight down by one shelf.
602D 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 602F LD ($5F2A),A Write the mask of the highlighted shelf to PantryHighlightMask.
Print the sign at the top of the pantry; it is in two rows.
6032 LD DE,$613B Point DE at CupboardData.
6035 LD HL,$10D0 Set the position of the top row of the sign (10D0).
6038 CALL PrintStringColour Print the top row of the sign using PrintStringColour.
603B EXX Switch back to the normal registers.
603C INC DE Point DE at the bottom row of the "PANTRY" sign.
603D LD HL,$18D0 Set the position of the bottom row of the sign (18D0).
6040 CALL PrintStringColour Print the bottom row of the sign using PrintStringColour.
6043 EXX Switch back to the normal registers.
Draw the tiles for each of the five shelves, from the top.
6044 LD HL,$20D0 Set the position of the top shelf (20D0).
6047 INC DE Point DE at the tiles for the shelves.
6048 LD B,$05 Set the shelf counter to 05 which is also the number of the top shelf.
DrawPantry_Shelves_Loop 604A CALL DrawShelf Draw a shelf using DrawShelf.
604D 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.
604F LD DE,$616D Point DE at PantryBase.
6052 LD HL,$98D0 Set the position of the base of the pantry (98D0).
6055 CALL PrintStringColour Print the base of the pantry using PrintStringColour.
Colour each of the five shelves, from the top.
6058 LD DE,$6174 Point DE at PantryAttributes.
605B LD HL,$20D0 Set the position of the top shelf (20D0).
605E LD B,$05 Set the shelf counter to 05 which is also the number of the top shelf.
DrawPantry_Colours_Loop 6060 CALL PantryFillColour Set the fill colour for the shelf using PantryFillColour.
6063 CALL ColourShelf Colour the shelf using ColourShelf.
6066 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 20 tiles wide and 04 tiles tall.
6068 LD HL,$A000 Set the position of the mixing bowl and pillars (A000).
606B LD DE,$6198 Point DE at BottomStrip_Tiles.
606E LD C,$04 Set the number of rows to 04.
6070 LD A,$20 Set the width to 20 tiles.
6072 CALL PrintTileBlock Print the mixing bowl and pillars using PrintTileBlock.
Colour the mixing bowl and pillars.
6075 LD DE,$6218 Point DE at BottomStrip_Attributes.
6078 LD HL,$A000 Set the position of the mixing bowl and pillars (A000).
607B LD C,$04 Set the number of rows to 04.
607D CALL WriteAttributeBlock Colour the mixing bowl and pillars using WriteAttributeBlock.
6080 POP HL Restore the address of the original character set from the stack.
6081 LD ($5C36),HL Write it back to CHARS.
Print the number of ingredients which are needed inside the bowl.
6084 LD B,$00 Set the number of ingredients collected to 00.
6086 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.
6089 LD A,($5F30) Fetch the level number of the active player and keep a copy of the level number in C.
608C LD C,A
608D RRA Shift the tens digit into the low four bits.
608E RRA
608F RRA
6090 RRA
6091 AND %00001111 Keep only the tens digit.
6093 ADD A,$30 Convert the digit to an ASCII character.
6095 LD HL,$50FC Set the screen address of the first digit of the level number.
6098 CALL PrintScreen Print the tens digit using PrintScreen.
609B LD A,C Fetch the level number again.
609C AND %00001111 Keep only the units digit.
609E ADD A,$30 Convert the digit to an ASCII character.
60A0 CALL PrintScreen Print the units digit using PrintScreen.
60A3 RET Return.
Prev: 6011 Up: Map Next: 60A4