Prev: 7450 Up: Map Next: 74A5
748F: 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 748F LD A,L Horizontal co-ordinate.
7490 RRCA Divide by 08.
7491 RRCA
7492 RRCA
7493 AND %00011111 Keep only bits 0-4 (00-1F / minimum-maximum horizontal screen values).
7495 LD L,A Store this back in L.
7496 LD A,H Vertical co-ordinate.
7497 RLCA Multiply by 04.
7498 RLCA
7499 LD C,A Store this in C temporarily.
749A AND %11100000 Keep only bits 5-7.
749C OR L Set the bits from L.
749D LD L,A L=A.
749E LD A,C Fetch the stored value from C.
749F AND %00000011 Keep only bits 0-1.
74A1 OR %01011000 Set MSB of the attribute buffer 58. This ensures our value is >= 5800.
74A3 LD H,A Store this back in H.
74A4 RET Return.
View the equivalent code in;
Prev: 7450 Up: Map Next: 74A5