Prev: 34039 Up: Map Next: 34078
34054: 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 34054 PUSH BC Stash BC on the stack.
34055 LD A,L Horizontal co-ordinate.
34056 RRCA Divide by 8.
34057 RRCA
34058 RRCA
34059 AND %00011111 Keep only bits 0-4 (0-31 / minimum-maximum horizontal screen values).
34061 LD L,A Store this back in L.
34062 LD A,H Vertical co-ordinate.
34063 RLCA Multiply by 4.
34064 RLCA
34065 LD C,A Store this in C temporarily.
34066 AND %11100000 Keep only bits 5-7.
34068 OR L Set the bits from L.
34069 LD L,A L=A.
34070 LD A,C Fetch the stored value from C.
34071 AND %00000011 Keep only bits 0-1.
34073 OR %01011000 Set MSB of the attribute buffer 88. This ensures our value is >= 22528.
34075 LD H,A Store this back in H.
34076 POP BC Restore BC from the stack.
34077 RET Return.
View the equivalent code in;
Prev: 34039 Up: Map Next: 34078