![]() |
Routines |
| Prev: 5FD8 | Up: Map | Next: 601B |
|
Used by the routine at DrawCubbyHoleItems.
Draws the item held in one cubby hole. The item type is held in bits 3-7 of the cubby hole and the item colour in bits 0-2. The sprite for the item type is fetched from CubbyHoleItem_Sprites, and the item is drawn standing on the shelf at the position given by the row counter. If bit 7 of the cubby hole is set it holds a bonus item and the hole is emptied using ClearCubbyHole instead.
|
||||||||||||
| DrawCubbyHoleItem | 5FDE | LD A,(DE) | A=*DE (the contents of the cubby hole). | |||||||||
| 5FDF | AND %11111000 | Keep only bits 3-7 (the item type). | ||||||||||
| 5FE1 | RET Z | Return if the cubby hole is empty. | ||||||||||
| 5FE2 | BIT 7,A | Jump to ClearCubbyHole if bit 7 is set. | ||||||||||
| 5FE4 | JR NZ,ClearCubbyHole | |||||||||||
| 5FE6 | LD A,(DE) | A=*DE (the contents of the cubby hole). | ||||||||||
| 5FE7 | PUSH AF | Stash the cubby hole contents on the stack. | ||||||||||
|
Use the item type to look up the sprite.
|
||||||||||||
| 5FE8 | RRCA | Rotate the item type (held in bits 3-7) down into bits 1-5. | ||||||||||
| 5FE9 | RRCA | |||||||||||
| 5FEA | AND %00111110 | Keep only bits 1-5 (the item type multiplied by two, as each sprite pointer is two bytes). | ||||||||||
| 5FEC | LD E,A | Make this the offset into the table in DE. | ||||||||||
| 5FED | LD D,$00 | |||||||||||
| 5FEF | PUSH HL | Stash the X position (in L) on the stack. | ||||||||||
| 5FF0 | LD HL,$601B | HL=CubbyHoleItem_Sprites. | ||||||||||
| 5FF3 | ADD HL,DE | Add the offset to HL. | ||||||||||
| 5FF4 | LD E,(HL) | DE=the sprite address for the item type from the table. | ||||||||||
| 5FF5 | INC HL | |||||||||||
| 5FF6 | LD D,(HL) | |||||||||||
| 5FF7 | POP HL | Restore the X position from the stack. | ||||||||||
|
Work out the Y position from the row counter.
|
||||||||||||
| 5FF8 | LD A,C | Rotate the row counter right three times (multiplying it by 20). | ||||||||||
| 5FF9 | RRCA | |||||||||||
| 5FFA | RRCA | |||||||||||
| 5FFB | RRCA | |||||||||||
| 5FFC | AND %11100000 | Keep only bits 5-7 (so each row of shelves is 20 pixels lower). | ||||||||||
| 5FFE | OR %00010111 | Set bits 0-2 and bit 4 (adding 17 so that the item stands on the shelf). | ||||||||||
| 6000 | LD H,A | Store the Y position in H. | ||||||||||
|
Work out the colour attribute.
|
||||||||||||
| 6001 | POP AF | Restore the cubby hole contents from the stack. | ||||||||||
| 6002 | AND %00000111 | Keep only bits 0-2 (the item colour). | ||||||||||
| 6004 | OR %01000000 | Set bit 6 (BRIGHT). | ||||||||||
| 6006 | LD ($5E12),A | Write the colour attribute to 5E12. | ||||||||||
|
Draw and colour the sprite.
|
||||||||||||
| 6009 | PUSH IX | Stash IX on the stack. | ||||||||||
| 600B | LD IX,$5E0F | IX=NewSprite_Width (so that the colour is fetched from 5E12). | ||||||||||
| 600F | CALL SetUpSprite_Offset | Set up the sprite at the position in HL using SetUpSprite_Offset. | ||||||||||
| 6012 | CALL DrawSprite_ClearPrevious | Draw the sprite using DrawSprite_ClearPrevious. | ||||||||||
| 6015 | CALL ColouriseSprite | Colour the sprite using ColouriseSprite. | ||||||||||
| 6018 | POP IX | Restore IX from the stack. | ||||||||||
| 601A | RET | Return. | ||||||||||
| Prev: 5FD8 | Up: Map | Next: 601B |