Pixel Manipulation
The first routine is heavily commented so that the others need not be. You should be able to adapt the first comments to the other routines. The chart at the end shows how to use them.
Make sure you have read the Find Pixel Section before reading on. The following code takes for granted that you have the FindPixel routine somewhere in your code so you can reference it.
pixel_on: call FindPixel ;hl=location in $fc00 (screen) ;a=byte containing pixel at hl ; with bit set for pixel ; we want to change or (hl) ;logical op to make bit in ; a that is set be included ; in new a with original byte ld (hl),a ;load modified byte onto screen ret ;done pixel_off: call FindPixel cpl and (hl) ld (hl),a ret pixel_change: call FindPixel xor (hl) ld (hl),a ret pixel_test: call FindPixel and (hl) ;zero flag set if no pixel there ret
To use the above routines
you need to put the coordinates, relative to the diagram below,
into bc
. You do this by ld bc,256*3+3
which puts coordinates
(3,3) into bc
which then can be used when you do call
pixel_on
to put the pixel at (3,3) on. That pixel would be
in the bottom left hand of the screen. Consider the following
representation of the TI86's screen.
PixelOn.asm gives an example of how to turn (blacken) a pixel at certain coordinates on the screen. It takes into account that you have the FindPixel routine in your include directory.
#include "ti86asm.inc" .org _asm_exec_ram call _clrLCD ;clear screen ld bc,256*45+2 ;coords (45,2) call pixel_on ld bc,256*3+62 ;coords (3,62) call pixel_on ld bc,256*100+6 ;coords (100,6) call pixel_on call _getkey ;wait for keypress jp _clrLCD ;clear screen and ret pixel_on: call FindPixel ;hl=location in $fc00 (screen) ;a=byte containing pixel at hl ; with bit set for pixel ; we want to change or (hl) ;logical op to make bit in ; a that is set be included ; in new a with original byte ld (hl),a ;load modified byte onto screen ret ;done #include "findpixel.asm" ;pastes the findpixel routine by clem ; here ;input: (b,c)=(x,y) ;output:hl=byte address in video memory ; bit set in a for offset .end
More from z80 » Graphics
Find a Pixel // Grayscale // Pixel Manipulation // The Screen // Sprites // SDR8 Routine // Tile Maps // TileGen Routine