Prev: ADE0 Up: Map Next: AE17
ADF8: Calculate Screen Address
Input
HL Position (L is the x position, H is the y position)
Output
HL Display file address
ScreenAddress ADF8 LD A,L Fetch the x position.
ADF9 RRCA Divide it by 08.
ADFA RRCA
ADFB RRCA
ADFC AND $1F Keep only five bits.
ADFE LD L,A Store the column in L.
ADFF LD A,H Fetch the y position.
AE00 RLCA Multiply it by 04.
AE01 RLCA
AE02 AND $E0 Keep only the bits that give the character row within a third.
AE04 OR L Combine them with the column.
AE05 LD L,A Store the low byte of the address in L.
AE06 LD A,H Fetch the y position.
AE07 AND $07 Keep only the pixel line within the character.
AE09 EX AF,AF' Stash the line in AF'.
AE0A LD A,H Fetch the y position.
AE0B RRCA Divide it by 08.
AE0C RRCA
AE0D RRCA
AE0E AND $18 Keep only the bits that give the third of the screen.
AE10 OR $40 Add the start of the display file.
AE12 LD H,A Store the result in H.
AE13 EX AF,AF' Retrieve the pixel line from AF'.
AE14 OR H Combine it with the high byte of the address.
AE15 LD H,A Store the high byte of the address in H.
AE16 RET Return.
Prev: ADE0 Up: Map Next: AE17