Prev: 43502 Up: Map Next: 43557
43518: 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 43518 LD A,L Fetch the x position.
43519 RRC A Divide it by two...
43521 RRC A ...four...
43523 RRC A ...and eight to find the column.
43525 AND %00011111 Keep the column.
43527 LD L,A Store it in L.
43528 LD A,H Fetch the y position.
43529 RLC A Move bits 3-5, the character row within the section, up...
43531 RLC A ...to bits 5-7.
43533 AND %11100000 Keep them.
43535 OR L Add the column.
43536 LD L,A Store it in L.
43537 LD A,H Fetch the y position.
43538 AND %00000111 Use bits 0-2, the pixel line within the character row.
43540 EX AF,AF' Save it in the alternate A.
43541 LD A,H Fetch the y position.
43542 RRC A Move bits 6-7, the section of the screen, down...
43544 RRC A ...to...
43546 RRC A ...bits 3-4.
43548 AND %00011000 Keep them.
43550 OR %01000000 Add the address of the display file.
43552 LD H,A Store it in H.
43553 EX AF,AF' Retrieve the pixel line.
43554 OR H Add it.
43555 LD H,A Store it in H.
43556 RET Return.
View the equivalent code in;
Prev: 43502 Up: Map Next: 43557