Prev: D0B9 Up: Map Next: D135
D120: Calculate Buffer Address
Finds the address in ScreenBuffer 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 The pixel y position
C The pixel x position
Output
BC The address in the buffer
Work out the byte from the position.
CalculateBufferAddress D120 PUSH HL Stash HL on the stack.
D121 SRL B Divide BC by two.
D123 RR C
D125 SRL B Divide BC by four.
D127 RR C
D129 SRL B Divide BC by eight.
D12B RR C
D12D LD HL,$D200 Point HL at ScreenBuffer.
D130 ADD HL,BC Add BC to HL.
D131 LD C,L Copy HL to BC.
D132 LD B,H
D133 POP HL Restore HL from the stack and return.
D134 RET
View the equivalent code in;
Prev: D0B9 Up: Map Next: D135