commit 6388662beb1ac5661f7b73b4818e2454538f245f
parent 84c1e75aa8eaefbaaf853ca3c4edb48301989189
Author: Louis Burda <quent.burda@gmail.com>
Date: Sun, 25 Sep 2022 19:07:01 +0200
Add flag for starting color
Diffstat:
M | pietp.c | | | 22 | +++++++++++++--------- |
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/pietp.c b/pietp.c
@@ -80,13 +80,14 @@ static const int instructions[][2] = {
};
static const int piet_code[] = {
- PUSH, PUSH, ADD, DUP, DUP, MUL, DUP, DUP, MUL, MUL, MUL, // 128
- PUSH, PUSH, ADD, DUP, MUL, DUP, MUL, SUB, // 112
- PUSH, PUSH, ADD, PUSH, ADD, ADD, // 115
- DUP, DUP, OUTC,
- PUSH, PUSH, ADD, DUP, MUL, SUB, PUSH, SUB, // 110
- DUP, OUTC,
- PUSH, PUSH, ADD, ADD, OUTC
+ PUSH, PUSH, ADD, DUP, MUL, DUP, DUP, DUP, MUL, // 4 4 16
+ DUP, DUP, ADD, DUP, DUP, ADD, ADD, ADD, // 4 4 112
+ DUP, DUP, PUSH, PUSH, ADD, PUSH, ADD, ADD, // 4 4 112 112 115
+ OUTC,
+ PUSH, PUSH, ADD, SUB, // 4 4 112 110
+ OUTC,
+ ADD, ADD, // 120
+ OUTC
};
static int debug = 0;
@@ -137,12 +138,15 @@ main(int argc, const char **argv)
int rotonce;
int i;
+ color = 0;
mappath = NULL;
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-d"))
debug = 1;
+ else if (!strcmp(argv[i], "-s") && i + 1 < argc)
+ color = atoi(argv[++i]);
else if (!strcmp(argv[i], "-h"))
- errx(0, "pietp [-h] [-d] [MAP-IMAGE]");
+ errx(0, "pietp [-h] [-d] [-s COLOR] [MAP-IMAGE]");
else if (mappath)
errx(1, "More than one map specified\n");
else
@@ -164,7 +168,6 @@ main(int argc, const char **argv)
dx = 1;
dy = 0;
- color = 0;
x = y = 0;
setrgb(pix, width * 3, x++, y, color);
@@ -199,6 +202,7 @@ main(int argc, const char **argv)
vis[y * width + x] = 1;
if (debug) printf("[%3i,%3i]: %06X -> %06X | %4s\n", x, y,
colors[color], colors[nextc], inst_names[nexti]);
+ color = nextc;
/* rotate until free */
rotonce = 0;