Prev: 9B5D Up: Map Next: 9BC1
9BA2: Convert pixel coordinates to a display file address
The standard 48K display address computation, done in place on HL. Builds $4000 + ((y AND $C0) << 5) + ((y AND $07) << 8) + ((y AND $38) << 2) + (x >> 3).
Input
HL On entry H = y (0-191), L = x. On exit, the display file address of that pixel's character cell.
PIXEL_TO_SCREEN 9BA2 LD A,L x >> 3 gives the character column; (y AND $38) << 2 the row within the third.
9BA3 RRCA
9BA4 RRCA
9BA5 RRCA
9BA6 AND $1F
9BA8 LD L,A
9BA9 LD A,H
9BAA RLCA
9BAB RLCA
9BAC AND $E0
9BAE OR L
9BAF LD L,A
9BB0 LD A,H
9BB1 AND $07
9BB3 EX AF,AF'
9BB4 LD A,H Stash the low three bits of y -- the scan line within the cell.
9BB5 RRCA
9BB6 RRCA
9BB7 RRCA
9BB8 AND $18
9BBA OR $40
9BBC LD H,A Bits 6-7 of y select which third of the screen; OR $40 puts it in the display file.
9BBD EX AF,AF'
9BBE OR H
9BBF LD H,A
9BC0 RET
Prev: 9B5D Up: Map Next: 9BC1