Prev: 29135 Up: Map Next: 29220
29198: 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 29198 LD A,L Horizontal co-ordinate.
29199 RRCA Divide by 8.
29200 RRCA
29201 RRCA
29202 AND %00011111 Keep only bits 0-4 (0-31 / minimum-maximum horizontal screen values).
29204 LD L,A Store this back in L.
29205 LD A,H Vertical co-ordinate.
29206 RLCA Multiply by 4.
29207 RLCA
29208 LD C,A Store this in C temporarily.
29209 AND %11100000 Keep only bits 5-7.
29211 OR L Set the bits from L.
29212 LD L,A L=A.
29213 LD A,C Fetch the stored value from C.
29214 AND %00000011 Keep only bits 0-1.
29216 OR %01011000 Set MSB of the attribute buffer 88. This ensures our value is >= 22528.
29218 LD H,A Store this back in H.
29219 RET Return.
View the equivalent code in;
Prev: 29135 Up: Map Next: 29220