Prev: A149 Up: Map Next: A18D
A170: Turn pixel coordinates into an attribute address
The attribute that colours the pixel at (x, y): 22528 + 32 * (y / 8) + x / 8.
Input
L x in pixels
H y in pixels
Output
HL The attribute address
pixel_to_attribute A170 PUSH BC
A171 LD A,L The column, x divided by 8
A172 RRC A
A174 RRC A
A176 RRC A
A178 AND $1F
A17A LD L,A
A17B LD A,H Bits 3-5 of y become bits 5-7 of the low byte
A17C RLC A
A17E RLC A
A180 LD C,A
A181 AND $E0
A183 OR L
A184 LD L,A
A185 LD A,C Bits 6-7 of y become bits 0-1 of the high byte, in the attribute file
A186 AND $03
A188 OR $58
A18A LD H,A
A18B POP BC
A18C RET
Prev: A149 Up: Map Next: A18D