Prev: 53433 Up: Map Next: 53557
53536: 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, 32 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 53536 PUSH HL Stash HL on the stack.
53537 SRL B Divide BC by two.
53539 RR C
53541 SRL B Divide BC by four.
53543 RR C
53545 SRL B Divide BC by eight.
53547 RR C
53549 LD HL,53760 Point HL at ScreenBuffer.
53552 ADD HL,BC Add BC to HL.
53553 LD C,L Copy HL to BC.
53554 LD B,H
53555 POP HL Restore HL from the stack and return.
53556 RET
View the equivalent code in;
Prev: 53433 Up: Map Next: 53557