![]() |
Routines |
| Prev: 29767 | Up: Map | Next: 29839 |
|
Used by the routines at DrawCubbyHoleItem, AnimateExplosion, UpdateStreamer, UpdateLeaf, UpdateFlower, UpdateSprayCan, DrawObject and UpdateBonusItem.
Writes the colour of an actor into the attribute buffer, covering the character cells that its sprite has just been drawn over. The pixels are drawn first (see DisplayEntity), so until this routine runs the sprite is drawn in the attribute that was already there.
|
||||||||
|
||||||||
| ColouriseSprite | 29776 | EXX | Switch to the shadow registers. | |||||
| 29777 | LD HL,(24090) | Fetch the screen position of the sprite from SpritePosition. | ||||||
| 29780 | CALL AttributeAddress | Convert it to an attribute buffer address using AttributeAddress. | ||||||
| 29783 | LD A,(24079) | Set the column counter in B' to the sprite width, from NewSprite_Width. | ||||||
| 29786 | LD B,A | |||||||
| 29787 | LD A,(24078) | Fetch the sprite height in pixels from 24078. | ||||||
| 29790 | RRCA | Divide the height by 4 add 1 then divide by 2. | ||||||
| 29791 | RRCA | |||||||
| 29792 | INC A | |||||||
| 29793 | RRCA | |||||||
| 29794 | AND %00011111 | Keep only bits 0-4. | ||||||
| 29796 | INC A | Increment A by one. | ||||||
| 29797 | LD C,A | Set the row counter in C' to the result. | ||||||
| 29798 | LD D,(IX+3) | Fetch the colour attribute from *IX+3. | ||||||
| 29801 | LD E,B | Remember the sprite width in E' so that the column counter can be reset for each row. | ||||||
|
Colour one row of attribute cells.
|
||||||||
| ColouriseSprite_Loop1 | 29802 | PUSH HL | Stash the address of the start of the row on the stack. | |||||
| ColouriseSprite_Loop2 | 29803 | LD A,H | Fetch the MSB of the attribute buffer address. | |||||
| 29804 | CP 91 | Jump to ColouriseSprite_NextRow if the address is beyond the attribute buffer (H is at least 91). | ||||||
| 29806 | JR NC,ColouriseSprite_NextRow | |||||||
| 29808 | CP 88 | Jump to ColouriseSprite_NextRow if the address is before the attribute buffer (H is less than 88). | ||||||
| 29810 | JR C,ColouriseSprite_NextRow | |||||||
| 29812 | LD (HL),D | Write the colour to the attribute buffer. | ||||||
| 29813 | INC L | Move onto the next column. | ||||||
| 29814 | LD A,L | Fetch the low byte of the address. | ||||||
| 29815 | AND %00011111 | Keep only bits 0-4 (the column). | ||||||
| 29817 | JR NZ,ColouriseSprite_NextColumn | Jump to ColouriseSprite_NextColumn if the column has not wrapped onto the next row. | ||||||
| 29819 | LD A,L | Move back to the start of the same row of attribute cells. | ||||||
| 29820 | SUB 32 | |||||||
| 29822 | LD L,A | |||||||
| ColouriseSprite_NextColumn | 29823 | DJNZ ColouriseSprite_Loop2 | Decrease the column counter by one and loop back to ColouriseSprite_Loop2 until it is zero. | |||||
|
Move up one row of attribute cells.
|
||||||||
| ColouriseSprite_NextRow | 29825 | POP HL | Restore the address of the start of the row from the stack. | |||||
| 29826 | PUSH BC | Subtract 32 from HL, preserving BC. | ||||||
| 29827 | AND A | |||||||
| 29828 | LD BC,32 | |||||||
| 29831 | SBC HL,BC | |||||||
| 29833 | POP BC | |||||||
| 29834 | LD B,E | Reset the column counter from E'. | ||||||
| 29835 | DEC C | Decrease the row counter by one and loop back to ColouriseSprite_Loop1 until it is zero. | ||||||
| 29836 | JR NZ,ColouriseSprite_Loop1 | |||||||
| 29838 | RET | Return. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: 29767 | Up: Map | Next: 29839 |