Prev: 34039 Up: Map Next: 34078
34054: Calculate Attribute Address
Input
HL Pixel address co-ordinates
Output
HL Attribute buffer address
Convert the pixel X/Y in HL into an attribute 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.
Merge the vertical co-ordinate into the low byte.
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.
Work out the high byte in the attribute buffer.
34070 LD A,C Fetch the stored value from C.
34071 AND %00000011 Keep only bits 0-1.
34073 OR %01011000 Set the attribute buffer MSB to 88.
34075 LD H,A Store this back in H.
34076 POP BC Restore BC from the stack.
34077 RET Return.
Prev: 34039 Up: Map Next: 34078