Prev: A9EE Up: Map Next: AA25
A9FE: Get Screen Address
Finds the address in the display file of a position in pixels.
Input
H The y position in pixels from the top of the screen
L The x position in pixels from the left of the screen
Output
HL The screen address
GetScreenAddress A9FE LD A,L Fetch the x position.
A9FF RRC A Divide it by two...
AA01 RRC A ...four...
AA03 RRC A ...and eight to find the column.
AA05 AND %00011111 Keep the column.
AA07 LD L,A Store it in L.
AA08 LD A,H Fetch the y position.
AA09 RLC A Move bits 3-5, the character row within the section, up...
AA0B RLC A ...to bits 5-7.
AA0D AND %11100000 Keep them.
AA0F OR L Add the column.
AA10 LD L,A Store it in L.
AA11 LD A,H Fetch the y position.
AA12 AND %00000111 Use bits 0-2, the pixel line within the character row.
AA14 EX AF,AF' Save it in the alternate A.
AA15 LD A,H Fetch the y position.
AA16 RRC A Move bits 6-7, the section of the screen, down...
AA18 RRC A ...to...
AA1A RRC A ...bits 3-4.
AA1C AND %00011000 Keep them.
AA1E OR %01000000 Add the address of the display file.
AA20 LD H,A Store it in H.
AA21 EX AF,AF' Retrieve the pixel line.
AA22 OR H Add it.
AA23 LD H,A Store it in H.
AA24 RET Return.
View the equivalent code in;
Prev: A9EE Up: Map Next: AA25