Prev: B8CC Up: Map Next: B8F5
B8DD: 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 B8DD PUSH BC Stash BC on the stack.
B8DE LD A,L Horizontal co-ordinate.
B8DF RRCA Divide by 08.
B8E0 RRCA
B8E1 RRCA
B8E2 AND %00011111 Keep only bits 0-4 (00-1F / minimum-maximum horizontal screen values).
B8E4 LD L,A Store this back in L.
B8E5 LD A,H Vertical co-ordinate.
B8E6 RLCA Multiply by 04.
B8E7 RLCA
B8E8 LD C,A Store this in C temporarily.
B8E9 AND %11100000 Keep only bits 5-7.
B8EB OR L Set the bits from L.
B8EC LD L,A L=A.
B8ED LD A,C Fetch the stored value from C.
B8EE AND %00000011 Keep only bits 0-1.
B8F0 OR %01011000 Set MSB of the attribute buffer 58. This ensures our value is >= 5800.
B8F2 LD H,A Store this back in H.
B8F3 POP BC Restore BC from the stack.
B8F4 RET Return.
View the equivalent code in;
Prev: B8CC Up: Map Next: B8F5