Prev: D811 Up: Map Next: D848
D826: Display address of a pixel position
Used by the routines at show_carried_slot, blit_2x8 and wipe_rect.
Turns the game's upward y into the display's line counted from the top by complementing it: 255 - y is that line plus 64, and the extra 64 is one third of the screen too many in the top bits, taken back by adding $38 instead of $40.
Input
C the pixel x
B the pixel y, counted up from the bottom of the screen
DE on exit, the display address of that byte
calc_vram_addr D826 LD A,C E = x / 8, the column
D827 RRCA
D828 RRCA
D829 RRCA
D82A AND $1F
D82C LD E,A
D82D LD A,B the line within the character row, from bits 0 to 2 of 255 - y, kept in A'
D82E CPL
D82F AND $07
D831 EX AF,AF'
D832 LD A,B bits 3 to 5, the character row within the third, into the top of E
D833 CPL
D834 RLCA
D835 RLCA
D836 AND $E0
D838 OR E
D839 LD E,A
D83A LD A,B bits 6 and 7, the third, with the line within the row, and $38 for the extra third
D83B CPL
D83C RRCA
D83D RRCA
D83E RRCA
D83F AND $18
D841 LD D,A
D842 EX AF,AF'
D843 OR D
D844 ADD A,$38
D846 LD D,A
D847 RET
Prev: D811 Up: Map Next: D848