![]() |
Routines |
| Prev: 29767 | Up: Map | Next: 29839 |
| ColouriseSprite | 29776 | EXX | Switch to the shadow registers. | |
| 29777 | LD HL,(24090) | HL'=actor co-ordinates. | ||
| 29780 | CALL AttributeAddress | Call AttributeAddress - HL' now holds the co-ordinates to an attribute file address. | ||
| 29783 | LD A,(24079) | B'=width loop counter (in pixels). | ||
| 29786 | LD B,A | |||
| 29787 | LD A,(24078) | A=24078. | ||
| 29790 | RRCA | A=((A / 4) + 1) / 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 | C=height loop counter (in pixels). | ||
| 29798 | LD D,(IX+3) | D=object colour attribute. | ||
| 29801 | LD E,B | E=width loop counter (in pixels). | ||
| ColouriseSprite_Loop1 | 29802 | PUSH HL | Stash HL on the stack. | |
| ColouriseSprite_Loop2 | 29803 | LD A,H | A=actor Y position. | |
| 29804 | CP 91 | Decrement position if address is outside of attribute file address range. | ||
| 29806 | JR NC,ColouriseSprite_1 | |||
| 29808 | CP 88 | |||
| 29810 | JR C,ColouriseSprite_1 | |||
| 29812 | LD (HL),D | Otherwise, set the colour at this location. | ||
| 29813 | INC L | Next tile column. | ||
| 29814 | LD A,L | Next tile if column < screen width (32 chars). | ||
| 29815 | AND %00011111 | |||
| 29817 | JR NZ,ColouriseSprite_0 | |||
| 29819 | LD A,L | else, wrap-around and continue applying colour. | ||
| 29820 | SUB 32 | |||
| 29822 | LD L,A | L=start of current row. | ||
| ColouriseSprite_0 | 29823 | DJNZ ColouriseSprite_Loop2 | Decrease counter by one and loop back to ColouriseSprite_Loop2 until counter is zero. | |
| ColouriseSprite_1 | 29825 | POP HL | Restore HL from the stack. | |
| 29826 | PUSH BC | Stash BC on the stack. | ||
| 29827 | AND A | Clear the carry flag. | ||
| 29828 | LD BC,32 | HL -= 32 tiles. Places address pointer previous line. | ||
| 29831 | SBC HL,BC | |||
| 29833 | POP BC | Restore BC from the stack. | ||
| 29834 | LD B,E | B=reset to original width counter. | ||
| 29835 | DEC C | Decrement height counter. | ||
| 29836 | JR NZ,ColouriseSprite_Loop1 | Repeat until all tiles have been coloured. | ||
| 29838 | RET | Return. | ||
| Prev: 29767 | Up: Map | Next: 29839 |