Prev: 28382 Up: Map Next: 28463
28432: Calculate Screen Address
Converts pixel co-ordinates into the matching address in the screen buffer.
Input
HL Pixel co-ordinates (H is the Y position, counting down from the top of the screen, and L is the X position)
Output
HL Screen buffer address
ScreenAddress 28432 LD A,L A=L.
28433 RRCA A=A / 8.
28434 RRCA
28435 RRCA
28436 AND %00011111 Keep only bits 0-4.
28438 LD L,A L=A.
28439 LD A,H A=H.
28440 RLCA A=A * 4.
28441 RLCA
28442 AND %11100000 Keep only bits 5-7.
28444 OR L Set the bits from L.
28445 LD L,A L=A.
28446 LD A,H A=H.
28447 AND %00000111 Keep only bits 0-2.
28449 EX AF,AF' Switch to the shadow AF register.
28450 LD A,H A=H.
28451 RRCA A=A / 8.
28452 RRCA
28453 RRCA
28454 AND %00011000 Keep only bits 3-4.
28456 OR %01000000 Set bit 6.
28458 LD H,A H=A.
28459 EX AF,AF' Switch to the shadow AF register.
28460 OR H Set the bits from H.
28461 LD H,A H=A.
28462 RET Return.
Prev: 28382 Up: Map Next: 28463