Prev: 39914 Up: Map Next: 40057
40033: Plot Pixel
Used by the routine at DrawLine.
Sets one pixel in the screen buffer.
Before After
plot-pixel-before plot-pixel-after
Input
H The Y position
L The X position
PlotPixel 40033 LD A,L Fetch the X position.
40034 AND %00000111 Keep only bits 0-2.
40036 INC A Add one, to get the number of shifts.
40037 LD B,A Keep the number of shifts in B.
40038 XOR A Clear A, ready to make the mask for the pixel.
40039 SCF Set the carry flag.
PlotPixel_Mask 40040 RRA Rotate the carry flag into A.
40041 DJNZ PlotPixel_Mask Decrease the shift counter by one and loop back to PlotPixel_Mask until the pixel is in position.
40043 PUSH HL Stash the position on the stack.
40044 PUSH AF Stash the pixel on the stack.
40045 EX AF,AF' Switch to the shadow AF register.
40046 PUSH AF Stash it on the stack.
40047 CALL ScreenAddress Call ScreenAddress to get the screen buffer address.
40050 POP AF Restore the shadow AF register from the stack.
40051 EX AF,AF' Switch back to the main AF register.
40052 POP AF Restore the pixel from the stack.
40053 OR (HL) Combine it with the byte in the screen buffer.
40054 LD (HL),A Write it back.
40055 POP HL Restore the position from the stack.
40056 RET Return.
Prev: 39914 Up: Map Next: 40057