Prev: 74EE Up: Map Next: 754A
7534: Calculate Attribute Address
Used by the routines at 5FE1, MenuWriteText, ScoreLabelFlash, PrintString and 74EE.
Input
HL Pixel address co-ordinates
Output
HL Attribute buffer address
Converts a given pixel address to the associated attribute buffer address.
AttributeAddress 7534 LD A,L Horizontal co-ordinate.
7535 RRCA Divide by 08.
7536 RRCA
7537 RRCA
7538 AND %00011111 Keep only bits 0-4 (00-1F / minimum-maximum horizontal screen values).
753A LD L,A Store this back in L.
753B LD A,H Vertical co-ordinate.
753C RLCA Multiply by 04.
753D RLCA
753E LD C,A Store this in C temporarily.
753F AND %11100000 Keep only bits 5-7.
7541 OR L Set the bits from L.
7542 LD L,A L=A.
7543 LD A,C Fetch the stored value from C.
7544 AND %00000011 Keep only bits 0-1.
7546 OR %01011000 Set MSB of the attribute buffer 58. This ensures our value is >= 5800.
7548 LD H,A Store this back in H.
7549 RET Return.
View the equivalent code in;
Prev: 74EE Up: Map Next: 754A