Prev: 71C6 Up: Map Next: 720E
71CF: Colourise sprite.
Used by the routines at 63DA, 6498, 651F, 6707, 68B1, 6CF5, 6DD3 and JetmanThrust.
ColouriseSprite 71CF EXX Switch to the shadow registers.
71D0 LD HL,($5DCF) HL'=actor co-ordinates.
71D3 CALL AttributeAddress Call AttributeAddress - HL' now holds the co-ordinates to an attribute file address.
71D6 LD A,($5DC4) B'=width loop counter (in pixels).
71D9 LD B,A
71DA LD A,($5DC3) A=5DC3.
71DD RRCA A=((A / 04) + 01) / 02.
71DE RRCA
71DF INC A
71E0 RRCA
71E1 AND %00011111 Keep only bits 0-4.
71E3 INC A Increment A by one.
71E4 LD C,A C=height loop counter (in pixels).
71E5 LD D,(IX+$03) D=object colour attribute.
71E8 LD E,B E=width loop counter (in pixels).
ColouriseSprite_Loop1 71E9 PUSH HL Stash HL on the stack.
ColouriseSprite_Loop2 71EA LD A,H A=actor Y position.
71EB CP $5B Decrement position if address is outside of attribute file address range.
71ED JR NC,ColouriseSprite_1
71EF CP $58
71F1 JR C,ColouriseSprite_1
71F3 LD (HL),D Otherwise, set the colour at this location.
71F4 INC L Next tile column.
71F5 LD A,L Next tile if column < screen width (32 chars).
71F6 AND %00011111
71F8 JR NZ,ColouriseSprite_0
71FA LD A,L Else, wrap-around and continue applying colour.
71FB SUB $20
71FD LD L,A L=start of current row.
ColouriseSprite_0 71FE DJNZ ColouriseSprite_Loop2 Decrease counter by one and loop back to ColouriseSprite_Loop2 until counter is zero.
ColouriseSprite_1 7200 POP HL Restore HL from the stack.
7201 PUSH BC Stash BC on the stack.
7202 AND A Clear the carry flag.
7203 LD BC,$0020 HL -= 32 tiles. Places address pointer previous line.
7206 SBC HL,BC
7208 POP BC Restore BC from the stack.
7209 LD B,E B=reset to original width counter.
720A DEC C Decrement height counter.
720B JR NZ,ColouriseSprite_Loop1 Repeat until all tiles have been coloured.
720D RET Return.
Prev: 71C6 Up: Map Next: 720E