Prev: C96F Up: Map Next: C9B3
C991: Apply a colour patch
Fills a rectangle of attribute cells with one attribute, from a three-byte record: width in cells, height in cells, attribute. The rectangle is given by its bottom-left pixel and filled upwards. Every sprite's colour comes from such a patch: the patch is all the colour a sprite has, so a sprite takes the colour of the cells it is in (colour_sprite works the patches out for the objects).
Input
H The y of the bottom row
L The x
DE The record
Output
DE The byte after it
fill_attributes C991 LD A,(DE) Width in B, height in C, and the attribute address (pixel_to_attribute).
C992 LD B,A
C993 INC DE
C994 LD A,(DE)
C995 LD C,A
C996 CALL pixel_to_attribute
C999 INC DE The attribute in D.
C99A LD A,(DE)
C99B INC DE
C99C PUSH DE
C99D LD D,A
C99E LD E,B
fill_attributes_0 C99F PUSH HL Each row of cells: fill it, then up a row (32 bytes back).
C9A0 LD B,E
fill_attributes_1 C9A1 LD (HL),D
C9A2 INC HL
C9A3 DJNZ fill_attributes_1
C9A5 POP HL
C9A6 PUSH BC
C9A7 LD BC,$0020
C9AA AND A
C9AB SBC HL,BC
C9AD POP BC
C9AE DEC C
C9AF JR NZ,fill_attributes_0
C9B1 POP DE
C9B2 RET
Prev: C96F Up: Map Next: C9B3