How To

Draw one pixel on the screen

1

G-9 2021-08-09 16:32

How do I draw 1 pixel on the screen using math and registers and kind of things ?
And also I don’t want to use PXL library.
It’s too big for a simple thing


G-9 2021-08-09 16:33

also offtopic but go check iOS 15 beta it’s pretty cool but Safari changed a lot…


Timo 2021-08-09 16:37

There is no easy way to draw one pixel. Depending on what you want to achieve you might use sprites or cells.

This is because LowRes NX works like old game consoles, and these were also based on sprites and cells only.


nathanielbabiak 2021-08-09 19:54

I'll upload a curated version of the pixel library - it's only 40 lines or so


nathanielbabiak 2021-08-09 20:27 (Edited)

Try this version - it's much shorter than the whole thing! If everything were hard-coded, it'd be around 50 lines total, rather than being 100 lines currently.

I should step back and ask a slightly different question though... Are you trying to plug-and-play? Or are you trying to learn the bit manipulation and display adapter tricks that go into doing this type of thing?


was8bit 2021-08-09 20:53

Check this out... it a bare minimum pixel drawing setup...

It will use ALL of your available character set, so no images allowed... also it used your font memory, so no displaying numbers or text...

Also, you cannot draw to cell 0,0, as it will cause unwanted results...

Otherwise, you get limited 3 color drawing for a screen sized 16x16 and not top left corner...

LowRes NX is NOT designed for pixel drawing, so you mice sacrifice and use ALL graphic characters to create a blank canvas to draw pixels on...

... basically, you are only drawing pixels to each character... simulating a full screen image....


was8bit 2021-08-09 20:54

Mice sacrifice = must sacrifice....


was8bit 2021-08-09 20:54

Look thru my stuff, I also have a 7 color pixel drawer ;)


G-9 2021-08-09 21:46

Thank you all for your interesting replies :D
@nathanielbabiak it’s just for learning first, but I may use it for a game if it works well enough
@was8bit cool idea, gonna check it out


nathanielbabiak 2021-08-09 21:58

Learn was8bit's implementation - it covers the bit manipulation stuff. The other part (display adapter tricks) are only required if you need more 8x8 pixel areas than the system's display can handle.


nathanielbabiak 2021-08-09 22:00 (Edited)

This upload also does the bit manipulation without (raster) display tricks, but is capable of full-screen (at the expense of four colors, it only allows two).


G-9 2021-08-10 08:58

That’s good, because I only need 1 color
1 or 0 - Computer, 1980


rilden 2021-08-10 22:43 (Edited)

In the next example you can choose an x and y coordinate between 0 and 7 to draw a pixel:

for i=0 to 7
  poke $8000+24+i,255
next i
flip 1,0
cell 10,8,1
x=1
y=4
poke $8000+16+y,2^x

From the manual:

A character is an 8x8-pixel image with 2 bits per pixel, with a resulting size of 16 bytes. The video RAM has space for 256 characters.

The first 8 bytes of a character contain the low bits of all its pixels, followed by 8 more bytes containing the high bits of all pixels.

The address of character 0 starts at $8000, character 1 starts at $8000+16.

The first 3 lines set all high bits of character number 1. All pixels of the character become color 2. The next line sets horizontal flip. This makes the x coordinate start from the left. The next line sets the cell in the middle to character number 1. In the next 2 lines you can choose an x,y between 0 and 7. The last line sets the low bit of the pixel at x,y to 1. Because the high bit is already 1 the pixel becomes color 3 (3 is 11 in binary).

There are a few issues I didn't cover in this post:


G-9 2021-08-11 09:54 (Edited)

Thank you !
This is similar to was8bit method I think


Log in to reply.