~rabbits/noton

92538320b51c8edfbbaf2819783ca51d5c611d92 — neauoire 3 years ago 40c759c
Minor optimization
2 files changed, 13 insertions(+), 16 deletions(-)

M README.md
M noton.c
M README.md => README.md +2 -5
@@ 2,6 2,8 @@

A minimal logic gates playground, written in ANSI C.

Right-click to add nodes, and left-click to add wires. Nodes will emit a positive signal if all the connected wires have the same polarity. The screen has timers to the left, and notes to the right. The default timers are 6 trackers, 4 sequencers and 2 pools.

## Build

To build [noton](https://wiki.xxiivv.com/noton), you must have [SDL2](https://wiki.libsdl.org/) and [PortMidi](http://portmedia.sourceforge.net/portmidi/).


@@ 26,8 28,3 @@ cc noton.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -L/usr/local/lib -lSDL2 -lportmidi

- `mouse1` Stroke
- `mouse1+mouse2` Gate

### TODO

- Don't change polarity twice per frame.
- export image

M noton.c => noton.c +11 -11
@@ 20,7 20,7 @@
#define INPUTMAX 12
#define OUTPUTMAX 12

#define CHANNELS 8
#define CHANNELS 4
#define DEVICE 0

typedef enum {


@@ 450,16 450,16 @@ void
run(Noton *n)
{
	int i;
	n->inputs[0]->polarity = (n->frame / 4) % 2;
	n->inputs[2]->polarity = (n->frame / 8) % 2;
	n->inputs[4]->polarity = (n->frame / 16) % 2;
	n->inputs[6]->polarity = (n->frame / 32) % 2;
	n->inputs[8]->polarity = (n->frame / 64) % 2;
	n->inputs[10]->polarity = (n->frame / 128) % 2;
	n->inputs[1]->polarity = (n->frame / 8) % 4 == 0;
	n->inputs[3]->polarity = (n->frame / 8) % 4 == 1;
	n->inputs[5]->polarity = (n->frame / 8) % 4 == 2;
	n->inputs[7]->polarity = (n->frame / 8) % 4 == 3;
	n->inputs[0]->polarity = (n->frame >> 2) % 2;
	n->inputs[2]->polarity = (n->frame >> 3) % 2;
	n->inputs[4]->polarity = (n->frame >> 4) % 2;
	n->inputs[6]->polarity = (n->frame >> 5) % 2;
	n->inputs[8]->polarity = (n->frame >> 6) % 2;
	n->inputs[10]->polarity = (n->frame >> 7) % 2;
	n->inputs[1]->polarity = (n->frame >> 3) % 4 == 0;
	n->inputs[3]->polarity = (n->frame >> 3) % 4 == 1;
	n->inputs[5]->polarity = (n->frame >> 3) % 4 == 2;
	n->inputs[7]->polarity = (n->frame >> 3) % 4 == 3;
	n->inputs[9]->polarity = 1;
	n->inputs[11]->polarity = 0;
	for(i = 0; i < n->glen; ++i)