~rabbits/orca-toy

7d153c46a761a56448184af39cdee7386b3f6e8a — neauoire 2 years ago f9f28d0
Minor cleanup
5 files changed, 23 insertions(+), 17 deletions(-)

M README.md
M cli.c
M orca.c
M sim.c
M sim.h
M README.md => README.md +11 -0
@@ 52,3 52,14 @@ To display the list of operators inside of Orca, use `CmdOrCtrl+G`.
- `3` operator
- `4` port(right)
- `5` port(output)

## TODOs

- True clock
	- Display BMP in interface.
	- Add clock controls.
	- Makeup for render time.
- Fix issue with some midi message being incomplete.
- Add save shortcut.
- Limit selection size to CLIPSZ.


M cli.c => cli.c +1 -1
@@ 11,7 11,7 @@ error(char *name)
void
printgrid(Grid *g)
{
	/* TODO: only print once, merge into a buf */
	/* TODO: only print once, merge into a single buf */
	int x, y, i = 0;
	for(y = 0; y < g->h; ++y)
		for(x = 0; x < g->w; ++x) {

M orca.c => orca.c +7 -12
@@ 19,13 19,11 @@ WITH REGARD TO THIS SOFTWARE.
#define VER 16
#define PAD 8
#define SZ (HOR * VER * 16)
#define CLIPSZ 1024
#define DEVICE 0

typedef unsigned char Uint8;

#define PLIMIT 256
#define SZ (HOR * VER * 16)
#define DEVICE 0

typedef struct {
	int x, y, w, h;
} Rect2d;


@@ 34,8 32,8 @@ typedef struct {
	int channel, value, velocity, length;
} Note;

char OCTAVE[] = {'C', 'c', 'D', 'd', 'E', 'F', 'f', 'G', 'g', 'A', 'a', 'B'};

char clip[CLIPSZ];
Note voices[16];
Rect2d cursor;
Grid g;



@@ 136,9 134,6 @@ Uint8 font[][8] = {
	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};

char clip[1024];
Note playing[16];

SDL_Window *gWindow = NULL;
SDL_Renderer *gRenderer = NULL;
SDL_Texture *gTexture = NULL;


@@ 294,7 289,7 @@ sendmidi(int chn, int val, int vel, int len)
{
	int i = 0;
	for(i = 0; i < 16; ++i) {
		Note *n = &playing[i];
		Note *n = &voices[i];
		if(n->length < 1) {
			n->channel = chn;
			n->value = val;


@@ 336,7 331,7 @@ runmsg(void)
	char buf[128];
	/* release */
	for(i = 0; i < 16; ++i) {
		Note *n = &playing[i];
		Note *n = &voices[i];
		if(n->length > 0) {
			n->length--;
			if(n->length == 0)


@@ 454,7 449,7 @@ copyclip(Rect2d *r, char *c)
	int x, y, i = 0;
	for(y = 0; y < r->h; ++y) {
		for(x = 0; x < r->w; ++x)
			if(i < 1024)
			if(i < CLIPSZ)
				c[i++] = get(&g, r->x + x, r->y + y);
		c[i++] = '\n';
	}

M sim.c => sim.c +2 -2
@@ 502,11 502,11 @@ void
opspecial(Grid *g, int x, int y)
{
	int i, b = bang(g, x, y);
	for(i = 0; x + i < MAXMSG; ++i) {
	for(i = 0; x + i < MSGSZ; ++i) {
		char c = getport(g, x + i, y, 1);
		if(c == '.')
			break;
		if(b && g->msglen < MAXMSG)
		if(b && g->msglen < MSGSZ)
			g->msg[g->msglen++] = c;
	}
	settype(g, x, y, b ? 3 : 2);

M sim.h => sim.h +2 -2
@@ 2,13 2,13 @@

#include <stdio.h>

#define MAXMSG 64
#define MSGSZ 64
#define MAXSZ 128 * 128

typedef struct Grid {
	int w, h, l, f, r, msglen;
	int lock[MAXSZ], type[MAXSZ];
	char data[MAXSZ], vars[36], msg[MAXMSG];
	char data[MAXSZ], vars[36], msg[MSGSZ];
} Grid;

int base36(char c);