Prev: 29776 Up: Map Next: 29861
29839: 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 29839 LD A,L Horizontal co-ordinate.
29840 RRCA Divide by 8.
29841 RRCA
29842 RRCA
29843 AND %00011111 Keep only bits 0-4 (0-31 / minimum-maximum horizontal screen values).
29845 LD L,A Store this back in L.
29846 LD A,H Vertical co-ordinate.
29847 RLCA Multiply by 4.
29848 RLCA
29849 LD C,A Store this in C temporarily.
29850 AND %11100000 Keep only bits 5-7.
29852 OR L Set the bits from L.
29853 LD L,A L=A.
29854 LD A,C Fetch the stored value from C.
29855 AND %00000011 Keep only bits 0-1.
29857 OR %01011000 Set MSB of the attribute buffer 88. This ensures our value is >= 22528.
29859 LD H,A Store this back in H.
29860 RET Return.
View the equivalent code in;
Prev: 29776 Up: Map Next: 29861