Prev: 34054 Up: Map Next: 34109
34078: Calculate Screen Address
Converts a pixel address into the matching screen buffer address.
Input
HL Pixel address co-ordinates
Output
HL Screen buffer address
Convert the pixel X/Y in HL into a screen address.
ScreenAddress 34078 LD A,L Fetch the horizontal co-ordinate.
34079 RRCA A=A / 8.
34080 RRCA
34081 RRCA
34082 AND %00011111 Keep only bits 0-4.
34084 LD L,A L=A.
34085 LD A,H A=H.
34086 RLCA A=A * 4.
34087 RLCA
34088 AND %11100000 Keep only bits 5-7.
34090 OR L Merge in the column bits.
34091 LD L,A Store this back in L.
Work out the high byte from the vertical co-ordinate.
34092 LD A,H Fetch the vertical co-ordinate.
34093 AND %00000111 Keep only bits 0-2.
34095 EX AF,AF' Switch to the shadow AF register.
34096 LD A,H Fetch the vertical co-ordinate.
34097 RRCA Divide by 8.
34098 RRCA
34099 RRCA
34100 AND %00011000 Keep only bits 3-4.
34102 OR %01000000 Set the screen-buffer MSB bit.
34104 LD H,A Store this back in H.
34105 EX AF,AF' Switch to the shadow AF register.
34106 OR H Merge in the line bits.
34107 LD H,A Store this back in H.
34108 RET Return.
View the equivalent code in;
Prev: 34054 Up: Map Next: 34109