~rabbits/orca-toy

b02ff7de80a33a10abb08e0cda50f83cde6a83c0 — neauoire 1 year, 28 days ago d02e417
Implemented missing operators
3 files changed, 30 insertions(+), 9 deletions(-)

M build.sh
M demo.orca
M toy.c
M build.sh => build.sh +0 -1
@@ 1,7 1,6 @@
#!/bin/bash

clang-format -i toy.c
clang-format -i library.h

rm -f ./toy


M demo.orca => demo.orca +9 -6
@@ 1,6 1,9 @@
.............
.............
...64Pa......
.............
.............
.............
.....................
.....................
.....................
.......1Ra...........
.....................
.....................
.....................
.....................
.....................

M toy.c => toy.c +21 -2
@@ 1,7 1,7 @@
#include <stdio.h>

typedef struct Grid {
	int w, h, l, f;
	int w, h, l, f, r;
	int lock[256 * 256];
	char vars[36];
	char data[256 * 256];


@@ 69,6 69,13 @@ load(Grid *g, char key)
	return g->vars[cint(key)];
}

int
rand(Grid *g)
{
	g->r *= 1103515245;
	return ((g->r / 65536 * g->f) % 32768) ^ g->f;
}

/* Library */

void


@@ 241,11 248,22 @@ opp(Grid *g, int x, int y)
void
opq(Grid *g, int x, int y)
{
	int tx = cint(get(g, x - 3, y));
	int ty = cint(get(g, x - 2, y));
	int len = cint(get(g, x - 1, y));
	int i;
	for(i = 0; i < len; ++i) {
		set(g, x + 1 - len + i, y + 1, get(g, x + 1 + tx + i, y + ty));
		lock(g, x + 1 - len + i, y + 1);
	}
}

void
opr(Grid *g, int x, int y)
{
	int min = cint(get(g, x - 1, y));
	char max = get(g, x + 1, y);
	set(g, x, y + 1, cchr((rand(g) % (cint(max) - min)) + min, ciuc(max)));
}

void


@@ 398,7 416,8 @@ main(int argc, char *argv[])
{
	FILE *f;
	Grid g;
	g.f = 0;
	g.f = 2034;
	g.r = 1;
	if(argc < 2)
		return error("No input.");
	f = fopen(argv[1], "r");