Prev: E53A Up: Map Next: E579
E556: Display address of a pixel position
Used by the routines at PICK_UP_THING, PRINT_TEXT_SINGLE_COLOUR and PRINT_TEXT.
For drawing straight onto the screen: the carried things (PICK_UP_THING) and the text printer's two ways in (PRINT_TEXT_SINGLE_COLOUR, PRINT_TEXT). The y here counts up from the screen's bottom line, 0 at line 191. Turns it into the display's line counted from the top by complementing it: 255 - y is that line plus 64, one third of the screen too many in the top bits, which is taken back by adding 56 rather than 64 to the high byte. The same as Knight Lore's and Pentagram's routine of this name.
Input
L x
H y, upwards from the screen's bottom line
Output
HL The display address
CALC_VRAM_ADDR E556 PUSH DE E = x, D = y; DE kept
E557 EX DE,HL
E558 LD A,E L's low five bits: the column, x / 8
E559 RRCA
E55A RRCA
E55B RRCA
E55C AND $1F
E55E LD L,A
E55F LD A,D L's top three: the character row within the third, from 255 - y
E560 CPL
E561 RLCA
E562 RLCA
E563 AND $E0
E565 OR L
E566 LD L,A
E567 LD A,D H's third
E568 CPL
E569 RRCA
E56A RRCA
E56B RRCA
E56C AND $18
E56E LD H,A
E56F LD A,D H's pixel line within the cell; adding 56 takes back the extra third
E570 CPL
E571 AND $07
E573 OR H
E574 ADD A,$38
E576 LD H,A
E577 POP DE Restore DE
E578 RET
Prev: E53A Up: Map Next: E579