Prev: D7AA Up: Map Next: D826
D811: Calculate Buffer Address
Finds the address in the screen buffer of the byte that holds a pixel. The buffer has the lines of the screen from the bottom, 20 bytes to a line.
Input
B Pixel Y coordinate
C Pixel X coordinate
Output
BC Address in the buffer
Divide the pixel position by eight and add it to ScreenBuffer.
CalculateBufferAddress D811 PUSH HL Stash HL on the stack.
D812 SRL B Divide BC by two.
D814 RR C
D816 SRL B Divide BC by four.
D818 RR C
D81A SRL B Divide BC by eight, to make the number of the byte.
D81C RR C
D81E LD HL,$D8F3 Point HL at ScreenBuffer.
D821 ADD HL,BC Add the two.
D822 LD C,L Copy HL to BC.
D823 LD B,H
D824 POP HL Restore HL from the stack and return.
D825 RET
View the equivalent code in;
Prev: D7AA Up: Map Next: D826