Prev: 45806 Up: Map Next: 45972
45951: Calculate Buffer Address
Finds the address in the buffer of the byte that holds a pixel. The buffer is 32 bytes wide with its bottom line first, so the address is ScreenBuffer + y * 32 + x / 8.
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 45951 PUSH HL Stash HL on the stack.
Divide the pixel co-ordinates by eight.
45952 SRL B Divide BC by two.
45954 RR C
45956 SRL B Divide BC by four.
45958 RR C
45960 SRL B Divide BC by eight.
45962 RR C
45964 LD HL,55439 Start at the first byte of the buffer, ScreenBuffer.
45967 ADD HL,BC Add BC to HL.
45968 LD C,L Keep the address in the buffer.
45969 LD B,H
45970 POP HL Restore HL from the stack and return.
45971 RET
View the equivalent code in;
Prev: 45806 Up: Map Next: 45972