Prev: 48442 Up: Map Next: 48490
48459: Calculate Screen Address
Finds the address in the display file of a pixel position.
Input
L Horizontal position in pixels (the address is of the byte it is in)
H Vertical position in pixels, from the top
Output
HL Screen address
ScreenAddress 48459 LD A,L Divide the horizontal position by eight...
48460 RRCA
48461 RRCA
48462 RRCA
48463 AND 31 ...to find the column.
48465 LD L,A
48466 LD A,H Find the bits of the character row that are within a third of the display, and shift them up...
48467 RLCA
48468 RLCA
48469 AND 224 ...combine them with the column and store them in L.
48471 OR L
48472 LD L,A
48473 LD A,H Keep the pixel line within the character row.
48474 AND 7
48476 EX AF,AF'
48477 LD A,H Find the third of the display and add the base address of the display file.
48478 RRCA
48479 RRCA
48480 RRCA
48481 AND 24
48483 OR 64
48485 LD H,A Store it in H.
48486 EX AF,AF' Add the pixel line within the character row.
48487 OR H
48488 LD H,A
48489 RET Return.
View the equivalent code in;
Prev: 48442 Up: Map Next: 48490