Prev: 84F7 Up: Map Next: 851E
8506: 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 8506 PUSH BC Stash BC on the stack.
8507 LD A,L Horizontal co-ordinate.
8508 RRCA Divide by 08.
8509 RRCA
850A RRCA
850B AND %00011111 Keep only bits 0-4 (00-1F / minimum-maximum horizontal screen values).
850D LD L,A Store this back in L.
Merge the vertical co-ordinate into the low byte.
850E LD A,H Vertical co-ordinate.
850F RLCA Multiply by 04.
8510 RLCA
8511 LD C,A Store this in C temporarily.
8512 AND %11100000 Keep only bits 5-7.
8514 OR L Set the bits from L.
8515 LD L,A L=A.
Work out the high byte in the attribute buffer.
8516 LD A,C Fetch the stored value from C.
8517 AND %00000011 Keep only bits 0-1.
8519 OR %01011000 Set the attribute buffer MSB to 58.
851B LD H,A Store this back in H.
851C POP BC Restore BC from the stack.
851D RET Return.
Prev: 84F7 Up: Map Next: 851E