Prev: 29126 Up: Map Next: 29198
29135: Colourise Sprite
ColouriseSprite 29135 EXX Switch to the shadow registers.
29136 LD HL,(24015) HL'=actor co-ordinates.
29139 CALL AttributeAddress Call AttributeAddress - HL' now holds the co-ordinates to an attribute file address.
29142 LD A,(24004) B'=width loop counter (in pixels).
29145 LD B,A
29146 LD A,(24003) A=24003.
29149 RRCA A=((A / 4) + 1) / 2.
29150 RRCA
29151 INC A
29152 RRCA
29153 AND %00011111 Keep only bits 0-4.
29155 INC A Increment A by one.
29156 LD C,A C=height loop counter (in pixels).
29157 LD D,(IX+3) D=object colour attribute.
29160 LD E,B E=width loop counter (in pixels).
ColouriseSprite_Loop1 29161 PUSH HL Stash HL on the stack.
ColouriseSprite_Loop2 29162 LD A,H A=actor Y position.
29163 CP 91 Decrement position if address is outside of attribute file address range.
29165 JR NC,ColouriseSprite_1
29167 CP 88
29169 JR C,ColouriseSprite_1
29171 LD (HL),D Otherwise, set the colour at this location.
29172 INC L Next tile column.
29173 LD A,L Next tile if column < screen width (32 chars).
29174 AND %00011111
29176 JR NZ,ColouriseSprite_0
29178 LD A,L Else, wrap-around and continue applying colour.
29179 SUB 32
29181 LD L,A L=start of current row.
ColouriseSprite_0 29182 DJNZ ColouriseSprite_Loop2 Decrease counter by one and loop back to ColouriseSprite_Loop2 until counter is zero.
ColouriseSprite_1 29184 POP HL Restore HL from the stack.
29185 PUSH BC Stash BC on the stack.
29186 AND A Clear the carry flag.
29187 LD BC,32 HL -= 32 tiles. Places address pointer previous line.
29190 SBC HL,BC
29192 POP BC Restore BC from the stack.
29193 LD B,E B=reset to original width counter.
29194 DEC C Decrement height counter.
29195 JR NZ,ColouriseSprite_Loop1 Repeat until all tiles have been coloured.
29197 RET Return.
Prev: 29126 Up: Map Next: 29198