Prev: 74EE Up: Map Next: 754A
7534: Calculate Attribute Address
Converts the pixel co-ordinates to the address of the attribute buffer byte for the character cell containing them.
Input
HL Pixel address co-ordinates
Output
HL Attribute buffer address
AttributeAddress 7534 LD A,L Fetch the horizontal co-ordinate.
7535 RRCA Divide by 08 (to get the column).
7536 RRCA
7537 RRCA
7538 AND %00011111 Keep only bits 0-4 (00-1F the range of the columns).
753A LD L,A Store this back in L.
753B LD A,H Fetch the vertical co-ordinate.
753C RLCA Multiply by 04 (the row is the vertical co-ordinate divided by 08 and there are 20 columns in each row).
753D RLCA
753E LD C,A Store this in C temporarily.
753F AND %11100000 Keep only bits 5-7.
7541 OR L Combine with the column in L.
7542 LD L,A Store this back in L.
7543 LD A,C Fetch the stored value from C.
7544 AND %00000011 Keep only bits 0-1.
7546 OR %01011000 Set the MSB of the attribute buffer address (58). This ensures that the address is at least 5800.
7548 LD H,A Store this in H.
7549 RET Return.
Prev: 74EE Up: Map Next: 754A