# Number to binary?

1

The Emerald Derp Leader 2018-11-08 20:53

So now that I understand how to use PEEK and POKE, I now want to be able to change individual pixels of a character. My problem is that I want to be able to read from PEEK and then check to see if the pixel I want to add is already there. This is so I can add to the character if it is not there.

However, I can’t find any sources online on how to convert a number (In this case, it is a byte) into binary so I can check if the pixel is already there. I think the character designer has this somewhere, but I can’t find it.

Timo 2018-11-08 21:03

You do this with binary operators, which in BASIC are the same as logical operators: AND, OR and NOT.
Maybe this helps to explain some stuff, but it's coded in C:
https://bits.stephan-brumme.com/basics.html
I'll give examples in BASIC another day (I'm tired now)...

was8bit 2018-11-08 22:39 (Edited)

Binary operations still kinda confuse me... I do it manually...

https://lowresnx.inutilis.com/topic.php?id=101

2018-11-08 22:58

The Emerald Derp Leader 2018-11-09 00:36 (Edited)

I figured it out. I have created a project on original LowRes for 4 bits numbers.

Edit: After optimizing it—and it was terribly optimized before hand—, I realized it is very easy (involves three constants) to change the size. So I decided to make it allow 6-bit numbers instead. It was actually much simpler than I thought :P

was8bit 2018-11-09 01:49

If you figure out the binary operators for this situation, post a simple demo here for me, eh ? :)

The Emerald Derp Leader 2018-11-09 22:52

I’m confused on what binary operators have to do with this.
Anyway, I finished the basic part of it, now I need to do this for multiple cells, then more than 256 cell— because NX supports 20x16, and then making a basic drawer.

Timo 2018-11-09 23:12

You use binary operators to set or clear single bits of a byte. For example:
A=%11110000
B=%00000001
C=(A OR B)
The value of C is then %11110001

To clear the last bit:
D=(C AND NOT B)
The value of D is then %11110000

The Emerald Derp Leader 2018-11-10 00:35 (Edited)

I understand binary operators, but how is it significant in what I am doing? I have used a few AND operators, but not for specifically changing values.

Additionally, I completed support for multiple cells. Also, I made the origin at the bottom left rather than top left, LOL.

was8bit 2018-11-10 05:09 (Edited)

@ TIMO that is so clear, i love it :) is there an equally easy binary way READ a specific bit??

was8bit 2018-11-10 05:21

Would you use A AND B an be is 0 if the corresponding bit in A is zero, and would be >0 if the corresponding bit is one...

was8bit 2018-11-10 10:40

Yep, that works :)

The Emerald Derp Leader 2018-11-10 18:00 (Edited)

First version of it.

***************************************************
- Use d-pad to move and a to switch color
- There are only 2 colors for now
- Max of 127 for X and Y
- Top right cell is not assigned because only 255 sprites are allowed
- Bottom left is origin (0,0)
- Debug mode shows coordinates
- DRAW , is now called PIX and takes (X,Y,COLOUR)
***************************************************

=Find how to add more than 255 sprites
=four colors
=five colors by synchronizing Palettes and ATTR

2018-11-10 18:00

Timo 2018-11-10 18:26

Nice! The code could be optimized a bit by using binary operators, I will post an update one of these days.

was8bit 2018-11-11 05:27

Very cool :)

I was kinda working on something like that, I called it a "Splash Screen" .. never finished it though...

The Emerald Derp Leader 2018-11-17 02:00

True Draw Thing 0.2: Now With Wings has been released.

The Emerald Derp Leader 2018-11-17 02:12

I think I might use this for a game when I finish it. Ever heard of the game Auralux—free game that had insanely high priced IAP despite the game being seemingly so simple to make—, yes that Auralux. Of course, I will probably have to cut down on visuals and extremely optimize the code, but it might be possible. And I can’t be sued for it, hopefully. :)

The Emerald Derp Leader 2018-11-19 00:32

I’m directing all discussion regarding recreating DRAW to the program’s page itself.