Prev: 71CF Up: Map Next: 7224
720E: Calculate Attribute Address
Input
HL Pixel address co-ordinates
Output
HL Attribute buffer address
Converts a given pixel address to the associated attribute buffer address.
AttributeAddress 720E LD A,L Horizontal co-ordinate.
720F RRCA Divide by 08.
7210 RRCA
7211 RRCA
7212 AND %00011111 Keep only bits 0-4 (00-1F / minimum-maximum horizontal screen values).
7214 LD L,A Store this back in L.
7215 LD A,H Vertical co-ordinate.
7216 RLCA Multiply by 04.
7217 RLCA
7218 LD C,A Store this in C temporarily.
7219 AND %11100000 Keep only bits 5-7.
721B OR L Set the bits from L.
721C LD L,A L=A.
721D LD A,C Fetch the stored value from C.
721E AND %00000011 Keep only bits 0-1.
7220 OR %01011000 Set MSB of the attribute buffer 58. This ensures our value is >= 5800.
7222 LD H,A Store this back in H.
7223 RET Return.
View the equivalent code in;
Prev: 71CF Up: Map Next: 7224