Prev: 74E2 Up: Map Next: 7534
74EE: Colour Sprite
Colours the character cells covered by the actor sprite prepared by PrepareActorSprite, using the colour in byte 03 of the actor. Cells outside of the attribute buffer, or to the right of the play area, are left alone.
Input
IX Actor
Fetch the address of the first attribute cell, and the size of the area to colour.
ColourSprite 74EE EXX Switch to the shadow registers.
74EF LD HL,($5F1F) Fetch the position of the actor sprite (ActorSprite_Position).
74F2 CALL AttributeAddress Calculate the attribute buffer address using AttributeAddress.
74F5 LD A,($5F18) Fetch the width of the actor sprite (ActorSprite_Width).
74F8 LD B,A
74F9 LD A,($5F17) Fetch the number of rows of the actor sprite (ActorSprite_Rows).
74FC RRCA Divide by 04 (rotating the bits).
74FD RRCA
74FE INC A Increment A by one.
74FF RRCA Divide by 02 (rotating the bits).
7500 AND %00011111 Keep only bits 0-4.
7502 INC A Increment A by one.
7503 LD C,A Store the number of attribute rows to colour in C.
7504 LD D,(IX+$03) Fetch the actor colour.
7507 LD E,B Store the number of columns in E.
ColourSprite_Row 7508 PUSH HL Stash the address of the start of the row on the stack.
ColourSprite_Column 7509 LD A,H Fetch the high byte of the attribute address.
750A CP $5B Jump to ColourSprite_NextRow if the address is beyond the end of the attribute buffer (5B or higher).
750C JR NC,ColourSprite_NextRow
750E CP $58 Jump to ColourSprite_NextRow if the address is before the start of the attribute buffer.
7510 JR C,ColourSprite_NextRow
7512 LD A,L Fetch the low byte of the attribute address.
7513 AND %00011111 Keep only bits 0-4.
Self modifying code; the operand of this command is written by 5FF6 and 6D49, and sets the column which the colouring stops at.
7515 CP $1A Jump to ColourSprite_NextRow if the column is beyond the right edge.
7517 JR NC,ColourSprite_NextRow
7519 LD (HL),D Write the colour to the attribute cell.
751A INC L Move onto the next column.
751B LD A,L Fetch the low byte of the attribute address.
751C AND %00011111 Keep only bits 0-4.
751E JR NZ,ColourSprite_NextColumn Jump to ColourSprite_NextColumn if the row has not wrapped.
7520 LD A,L Move back to the start of the row so it doesn't wrap onto the next one.
7521 SUB $20
7523 LD L,A
ColourSprite_NextColumn 7524 DJNZ ColourSprite_Column Decrease the column counter by one and loop back to ColourSprite_Column until all of the columns have been done.
ColourSprite_NextRow 7526 POP HL Retrieve the address of the start of the row.
7527 PUSH BC Stash the row counter on the stack.
7528 AND A Clear the carry flag.
7529 LD BC,$0020 Set the size of a row of attributes to 20.
752C SBC HL,BC Move up one row.
752E POP BC Restore the row counter.
752F LD B,E Restore the column counter.
7530 DEC C Decrease the row counter by one.
7531 JR NZ,ColourSprite_Row Loop back to ColourSprite_Row until all of the rows have been done.
7533 RET Return.
Prev: 74E2 Up: Map Next: 7534