Prev: 7585 Up: Map Next: 75B9
759A: Calculate Screen Address
Converts a pixel position into an address in the screen buffer.
Input
H Y position (pixel row)
L X position (pixel column)
Output
HL Screen buffer address
ScreenAddress 759A LD A,L A=the X position.
759B RRCA Divide by 08 (to give the character column).
759C RRCA
759D RRCA
759E AND %00011111 Keep only bits 0-4.
75A0 LD L,A Store the column in L.
75A1 LD A,H A=the Y position.
75A2 RLCA Multiply by 04 so that bits 3-5 of the Y position are in bits 5-7.
75A3 RLCA
75A4 AND %11100000 Keep only bits 5-7 (the character row within the third).
75A6 OR L Combine with the column.
75A7 LD L,A Store the result in L.
75A8 LD A,H A=the Y position.
75A9 AND %00000111 Keep only bits 0-2 (the pixel row within the character cell).
75AB EX AF,AF' Switch to the shadow AF register to keep the result.
75AC LD A,H A=the Y position.
75AD RRCA Divide by 08.
75AE RRCA
75AF RRCA
75B0 AND %00011000 Keep only bits 3-4 (the third of the screen).
75B2 OR %01000000 Set bit 6 to point at the screen buffer.
75B4 LD H,A Store the result in H.
75B5 EX AF,AF' Switch back to the saved pixel row.
75B6 OR H Combine with the third of the screen.
75B7 LD H,A Store the result in H.
75B8 RET Return.
Prev: 7585 Up: Map Next: 75B9