Prev: BD3A Up: Map Next: BD6A
BD4B: 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 BD4B LD A,L Divide the horizontal position by eight...
BD4C RRCA
BD4D RRCA
BD4E RRCA
BD4F AND $1F ...to find the column.
BD51 LD L,A
BD52 LD A,H Find the bits of the character row that are within a third of the display, and shift them up...
BD53 RLCA
BD54 RLCA
BD55 AND $E0 ...combine them with the column and store them in L.
BD57 OR L
BD58 LD L,A
BD59 LD A,H Keep the pixel line within the character row.
BD5A AND $07
BD5C EX AF,AF'
BD5D LD A,H Find the third of the display and add the base address of the display file.
BD5E RRCA
BD5F RRCA
BD60 RRCA
BD61 AND $18
BD63 OR $40
BD65 LD H,A Store it in H.
BD66 EX AF,AF' Add the pixel line within the character row.
BD67 OR H
BD68 LD H,A
BD69 RET Return.
View the equivalent code in;
Prev: BD3A Up: Map Next: BD6A