A83: Check this Pixel Routine. =)
[Prev][Next][Index][Thread]
A83: Check this Pixel Routine. =)
I put together this Routine that plots a Pixel to the Graph Buffer. The
purpose I had in "writing" it was to utilize the GetPix Routine that is in
ZLIB. I do not take much credit for it because Joe did the hard part in
writing GetPix, but I wanted to Organize this so that a value could be
inputted to make it either plot the pixel White, plot it Black, or XOR it...
Can somebody look over it and see it will actually work? Also, somebody give
suggestions on a better way to do this, but keep in mind this is the path I
want to take because I like programming for SOS and wanted to make use of that
Library Routine. Thanks in advance for any responses... =)
--Jason K.
;------------------------------------------- ;
; SOS Pixel Plotting Routine - By Jason K. ;
;------------------------------------------- ;
; Input: D = X, E = Y, C = Pixel Color. ;
; (0-Clear, 1-Plot, 2-XOR Pixel). ;
; Output: Pixel is Plotted to Graph Buffer. ;
;------------------------------------------- ;
PIXEL:
push de ; Save the Coordinates
ld a, c ; Load this to check which Color
cp 0
call z, PIXEL_WHITE
cp 1
call z, PIXEL_BLACK
cp 2
call z, PIXEL_XORIT
pop de ; Retrieve Coords for other Routines
ret
PIXEL_WHITE:
ld a, d ; 'a' now has X Coordinate
call GETPIX ; Call the Pixel Routine from ZLIB
AND (hl) ; 'AND' to clear pixel
ld (hl), a ; Write the new byte to Graph Buffer
ld a, 0 ; Reload this for use with the CPs above
ret
PIXEL_BLACK:
ld a, d ; 'a' now has X Coordinate
call GETPIX ; Call the Pixel Routine from ZLIB
OR (hl) ; 'OR' to plot pixel
ld (hl), a ; Write the new byte to Graph Buffer
ld a, 1 ; Reload this for use with the CPs above
ret
PIXEL_XORIT:
ld a, d ; 'a' now has X Coordinate
call GETPIX ; Call the Pixel Routine from ZLIB
XOR (hl) ; 'XOR' to toggle pixel
ld (hl), a ; Write the new byte to Graph Buffer
ret ; No need to reload A, done with CPs.
*NOTE* here is the Information for the GetPix Routine:
Getpix (lib C) - Get byte/bit for a pixel.
Input: a=x coordinate e=y coordinate
Output: a holds bit of pixel
hl->byte of pixel on the graph buffer.
Registers destroyed: af bc de hl