![]() |
Routines |
| Prev: 24802 | Up: Map | Next: 24887 |
|
Used by the routine at DrawPantry.
Colours the cells of one shelf of the pantry. The cells which have an attribute of 0 are given the colour of the ingredient for the shelf, which was fetched by PantryFillColour. As in DrawShelf there are two sets of attributes; the second is used when the shelf's bit is set in PantryHighlightMask.
|
||||||||||||||||
|
Make the second byte of a BIT command from the shelf number.
|
||||||||||||||||
| ColourShelf | 24829 | PUSH BC | Stash the shelf number and C on the stack. | |||||||||||||
| 24830 | PUSH DE | Stash the address of the normal attributes on the stack. | ||||||||||||||
| 24831 | LD A,B | Fetch the shelf number. | ||||||||||||||
| 24832 | RLCA | Multiply by 8 so that the shelf number is in bits 3-5. | ||||||||||||||
| 24833 | RLCA | |||||||||||||||
| 24834 | RLCA | |||||||||||||||
| 24835 | AND %00111000 | Keep only bits 3-5. | ||||||||||||||
| 24837 | OR %01000111 | Set bits 0-2 and bit 6. | ||||||||||||||
| 24839 | LD (24846),A | Write A to 24846. | ||||||||||||||
| 24842 | 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 stored as BIT 0,A.
|
||||||||||||||||
| ColourShelf_TestBit | 24845 | BIT 0,A | Jump to ColourShelf_Rows if this shelf is not highlighted. | |||||||||||||
| 24847 | JR Z,ColourShelf_Rows | |||||||||||||||
| 24849 | PUSH HL | Move DE on to the highlighted attributes, which are 18 bytes further on (preserving HL). | ||||||||||||||
| 24850 | LD HL,18 | |||||||||||||||
| 24853 | ADD HL,DE | |||||||||||||||
| 24854 | EX DE,HL | |||||||||||||||
| 24855 | POP HL | |||||||||||||||
| ColourShelf_Rows | 24856 | LD C,3 | Set the number of rows to 3. | |||||||||||||
| ColourShelf_Row | 24858 | LD B,6 | Set the column counter to 6 (the width of the shelf). | |||||||||||||
| 24860 | PUSH HL | Stash the position of the row on the stack. | ||||||||||||||
| 24861 | PUSH BC | Stash the counters on the stack. | ||||||||||||||
| 24862 | CALL AttributeAddress | Convert the position to an attribute address using AttributeAddress. | ||||||||||||||
| 24865 | POP BC | Restore the counters from the stack. | ||||||||||||||
| ColourShelf_Loop | 24866 | LD A,(DE) | Fetch the attribute. | |||||||||||||
| 24867 | AND A | Does the attribute need the colour of the ingredient (is it zero)? | ||||||||||||||
| 24868 | CALL Z,FetchShelfColour | Call FetchShelfColour if it is, to get the colour of the ingredient. | ||||||||||||||
| 24871 | LD (HL),A | Write the attribute to the attribute buffer. | ||||||||||||||
| 24872 | INC DE | Move onto the next attribute. | ||||||||||||||
| 24873 | INC HL | Move onto the next column. | ||||||||||||||
| 24874 | DJNZ ColourShelf_Loop | Decrease the column counter by one and loop back to ColourShelf_Loop until the row has been coloured. | ||||||||||||||
| 24876 | POP HL | Restore the position of the row from the stack. | ||||||||||||||
| 24877 | LD A,H | Fetch the vertical position of the row. | ||||||||||||||
| 24878 | ADD A,8 | Add 8 to move down one row of tiles. | ||||||||||||||
| 24880 | LD H,A | Update the vertical position of the row. | ||||||||||||||
| 24881 | DEC C | Decrease the row counter by one. | ||||||||||||||
| 24882 | JR NZ,ColourShelf_Row | Loop back to ColourShelf_Row until all of the rows have been done. | ||||||||||||||
| 24884 | POP DE | Restore the address of the normal attributes from the stack. | ||||||||||||||
| 24885 | POP BC | Restore the shelf number and C from the stack. | ||||||||||||||
| 24886 | RET | Return. | ||||||||||||||
| Prev: 24802 | Up: Map | Next: 24887 |