![]() |
Routines |
| Prev: 24536 | Up: Map | Next: 24603 |
|
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 | 24542 | LD A,(DE) | A=*DE (the contents of the cubby hole). | |||||||||
| 24543 | AND %11111000 | Keep only bits 3-7 (the item type). | ||||||||||
| 24545 | RET Z | Return if the cubby hole is empty. | ||||||||||
| 24546 | BIT 7,A | Jump to ClearCubbyHole if bit 7 is set. | ||||||||||
| 24548 | JR NZ,ClearCubbyHole | |||||||||||
| 24550 | LD A,(DE) | A=*DE (the contents of the cubby hole). | ||||||||||
| 24551 | PUSH AF | Stash the cubby hole contents on the stack. | ||||||||||
|
Use the item type to look up the sprite.
|
||||||||||||
| 24552 | RRCA | Rotate the item type (held in bits 3-7) down into bits 1-5. | ||||||||||
| 24553 | RRCA | |||||||||||
| 24554 | AND %00111110 | Keep only bits 1-5 (the item type multiplied by two, as each sprite pointer is two bytes). | ||||||||||
| 24556 | LD E,A | Make this the offset into the table in DE. | ||||||||||
| 24557 | LD D,0 | |||||||||||
| 24559 | PUSH HL | Stash the X position (in L) on the stack. | ||||||||||
| 24560 | LD HL,24603 | HL=CubbyHoleItem_Sprites. | ||||||||||
| 24563 | ADD HL,DE | Add the offset to HL. | ||||||||||
| 24564 | LD E,(HL) | DE=the sprite address for the item type from the table. | ||||||||||
| 24565 | INC HL | |||||||||||
| 24566 | LD D,(HL) | |||||||||||
| 24567 | POP HL | Restore the X position from the stack. | ||||||||||
|
Work out the Y position from the row counter.
|
||||||||||||
| 24568 | LD A,C | Rotate the row counter right three times (multiplying it by 32). | ||||||||||
| 24569 | RRCA | |||||||||||
| 24570 | RRCA | |||||||||||
| 24571 | RRCA | |||||||||||
| 24572 | AND %11100000 | Keep only bits 5-7 (so each row of shelves is 32 pixels lower). | ||||||||||
| 24574 | OR %00010111 | Set bits 0-2 and bit 4 (adding 23 so that the item stands on the shelf). | ||||||||||
| 24576 | LD H,A | Store the Y position in H. | ||||||||||
|
Work out the colour attribute.
|
||||||||||||
| 24577 | POP AF | Restore the cubby hole contents from the stack. | ||||||||||
| 24578 | AND %00000111 | Keep only bits 0-2 (the item colour). | ||||||||||
| 24580 | OR %01000000 | Set bit 6 (BRIGHT). | ||||||||||
| 24582 | LD (24082),A | Write the colour attribute to 24082. | ||||||||||
|
Draw and colour the sprite.
|
||||||||||||
| 24585 | PUSH IX | Stash IX on the stack. | ||||||||||
| 24587 | LD IX,24079 | IX=NewSprite_Width (so that the colour is fetched from 24082). | ||||||||||
| 24591 | CALL SetUpSprite_Offset | Set up the sprite at the position in HL using SetUpSprite_Offset. | ||||||||||
| 24594 | CALL DrawSprite_ClearPrevious | Draw the sprite using DrawSprite_ClearPrevious. | ||||||||||
| 24597 | CALL ColouriseSprite | Colour the sprite using ColouriseSprite. | ||||||||||
| 24600 | POP IX | Restore IX from the stack. | ||||||||||
| 24602 | RET | Return. | ||||||||||
| Prev: 24536 | Up: Map | Next: 24603 |