Prev: CF52 Up: Map Next: D004
CFA4: Paint Narrow Entity Attributes
Paints the entity colour attribute across a two-cell-wide, three-row region of the attribute area at the entity's screen position. Uses Screen_Row_Address_Lookup_Table to resolve each pixel row to its attribute address; the colour is read from shadow B'. Called by Process_Entity_Record_Fast, Tick_Entity_Colour_Timer and Process_Cluster_Entity.
Input
HL Entity state byte pointer (Y and X positions follow)
Paint_Narrow_Entity_Attributes CFA4 INC HL Step to the entity Y position and load the attribute colour base into D.
CFA5 LD D,$46
CFA7 LD E,(HL)
CFA8 INC HL
CFA9 SLA E Shift the Y position left to form the row address table index in DE.
CFAB RL D
CFAD LD A,(HL) Rotate the X position right three places to derive the attribute column.
CFAE RRA
CFAF RRA
CFB0 RRA
CFB1 AND %00011111 Keep the attribute column index.
CFB3 LD C,A Store the column index in C.
CFB4 EXX Copy the entity colour attribute from shadow B' into B.
CFB5 LD A,B
CFB6 EXX
CFB7 LD B,A
Write the entity colour to two adjacent attribute cells in each of three consecutive entity rows.
CFB8 LD A,(DE) Look up the first attribute row address and add the column offset.
CFB9 ADD A,C
CFBA LD L,A
CFBB INC DE
CFBC LD A,(DE)
CFBD LD H,A
CFBE INC DE
CFBF LD A,H Isolate the attribute page bits.
CFC0 RRCA
CFC1 RRCA
CFC2 RRCA
CFC3 AND %00000011 Keep only the two attribute page bits.
CFC5 OR %01011000 Combine with the attribute area base address.
CFC7 LD H,A Store the computed attribute high byte.
CFC8 LD (HL),B Write the entity colour to two adjacent attribute cells.
CFC9 INC HL
CFCA LD (HL),B
CFCB INC DE Advance the row address pointer to the second entity row.
CFCC INC DE
CFCD INC DE
CFCE INC DE
CFCF INC DE
CFD0 INC DE
CFD1 INC DE
CFD2 INC DE
CFD3 INC DE
CFD4 INC DE
CFD5 LD A,(DE) Look up the second attribute row address and add the column offset.
CFD6 ADD A,C
CFD7 LD L,A
CFD8 INC DE
CFD9 LD A,(DE)
CFDA LD H,A
CFDB INC DE
CFDC LD A,H Isolate the attribute page bits.
CFDD RRCA
CFDE RRCA
CFDF RRCA
CFE0 AND %00000011 Keep only the two attribute page bits.
CFE2 OR %01011000 Combine with the attribute area base address.
CFE4 LD H,A Store the computed attribute high byte.
CFE5 LD (HL),B Write the entity colour to two adjacent attribute cells.
CFE6 INC HL
CFE7 LD (HL),B
CFE8 INC DE Advance the row address pointer to the third entity row.
CFE9 INC DE
CFEA INC DE
CFEB INC DE
CFEC INC DE
CFED INC DE
CFEE INC DE
CFEF INC DE
CFF0 INC DE
CFF1 INC DE
CFF2 LD A,(DE) Look up the third attribute row address and add the column offset.
CFF3 ADD A,C
CFF4 LD L,A
CFF5 INC DE
CFF6 LD A,(DE)
CFF7 INC DE
CFF8 RRCA Isolate the attribute page bits.
CFF9 RRCA
CFFA RRCA
CFFB AND %00000011 Keep only the two attribute page bits.
CFFD OR %01011000 Combine with the attribute area base address.
CFFF LD H,A Store the computed attribute high byte.
D000 LD (HL),B Write the entity colour to two adjacent attribute cells.
D001 INC HL
D002 LD (HL),B
D003 RET Return.
Prev: CF52 Up: Map Next: D004