Prev: B37F Up: Map Next: B3B6
B394: Display address of a pixel position
Used by the routines at SHOW_SCORE, RENDER_DYNAMIC_OBJECTS and SHOW_CARRIED.
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, 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. A' is changed. The same as Knight Lore's.
Input
C the pixel x
B the pixel y, counted up from the bottom of the screen
Output
DE the display address of that byte
CALC_VRAM_ADDR B394 LD A,C E = x / 8, the column
B395 RRCA
B396 RRCA
B397 RRCA
B398 AND $1F
B39A LD E,A
B39B LD A,B The line within the character row, from bits 0 to 2 of 255 - y, kept in A'
B39C CPL
B39D AND $07
B39F EX AF,AF'
B3A0 LD A,B Bits 3 to 5, the character row within the third, into the top of E
B3A1 CPL
B3A2 RLCA
B3A3 RLCA
B3A4 AND $E0
B3A6 OR E
B3A7 LD E,A
B3A8 LD A,B Bits 6 and 7, the third, with the line within the row, and 56 for the extra third
B3A9 CPL
B3AA RRCA
B3AB RRCA
B3AC RRCA
B3AD AND $18
B3AF LD D,A
B3B0 EX AF,AF'
B3B1 OR D
B3B2 ADD A,$38
B3B4 LD D,A
B3B5 RET
Prev: B37F Up: Map Next: B3B6