10 return gets(s); /* Insecure, oh well, who cares, this will get replaced later */
14 char *vname, *var, *sub;
18 int *findvar(char *var, char *sub, struct vars *vars, int n)
22 if (!strcmp(vars[i].var, var) && ((!sub && !vars[i].sub) || !strcmp(vars[i].sub, sub)))
24 printf("Unknown var: %s %s\n", var, sub);
30 struct vars vars[512];
35 if (SDL_Init(SDL_INIT_VIDEO) < 0)
37 printf("SDL init failed: %s\n", SDL_GetError());
41 screen = SDL_SetVideoMode(WIN_X, WIN_Y, 24, SDL_SWSURFACE);
44 printf("Video init failed: %s\n", SDL_GetError());
47 while ((s = readline()))
51 if (!strcmp(s, "$dumpvars"))
54 printf("Var dump begin on %d vars\n", nvars);
55 } else if (!strncmp(s, "$var", 4)) {
57 char *vname, *var, *sub;\
59 t = strtok(NULL, " ");
60 t = strtok(NULL, " ");
61 t = strtok(NULL, " ");
63 t = strtok(NULL, " ");
65 t = strtok(NULL, " ");
66 if (strcmp(t, "$end"))
70 printf("Found: %s -> %s %s\n", vname, var, sub);
72 vars[nvars].vname = strdup(vname);
73 vars[nvars].var = strdup(var);
74 vars[nvars].sub = sub ? strdup(sub) : NULL;
78 } else if (s[0] == '#')
82 int val = (s[0] == '1');
84 int oldclk = *findvar("gclk", NULL, vars, nvars);
86 for (i=0; i<nvars; i++)
88 if (!strcmp(vars[i].vname, s+1))
95 printf("Unknown: %s\n", s);
96 if (*findvar("gclk", NULL, vars, nvars) != oldclk && oldclk == 1 && ((pixn++) % 2))
98 static int x = 0, y = 0;
101 static int *r2 = NULL, *r1 = NULL, *r0 = NULL, *g2 = NULL, *g1 = NULL, *g0 = NULL, *b1 = NULL, *b0 = NULL, *vs = NULL, *hs = NULL;
102 r2 = r2 ? r2 : findvar("red", "[2]", vars, nvars);
103 r1 = r1 ? r1 : findvar("red", "[1]", vars, nvars);
104 r0 = r0 ? r0 : findvar("red", "[0]", vars, nvars);
105 g2 = g2 ? g2 : findvar("green", "[2]", vars, nvars);
106 g1 = g1 ? g1 : findvar("green", "[1]", vars, nvars);
107 g0 = g0 ? g0 : findvar("green", "[0]", vars, nvars);
108 b1 = b1 ? b1 : findvar("blue", "[1]", vars, nvars);
109 b0 = b0 ? b0 : findvar("blue", "[0]", vars, nvars);
110 vs = vs ? vs : findvar("vs", NULL, vars, nvars);
111 hs = hs ? hs : findvar("hs", NULL, vars, nvars);
114 int r = *r2 << 7 | *r1 << 6 | *r0 << 5;
115 int g = *g2 << 7 | *g1 << 6 | *g0 << 5;
116 int b = *b1 << 7 | *b0 << 6;
129 SDL_LockSurface(screen);
130 pixp = screen->pixels + ((WIN_X * y + x) * 3);
131 pixp[0] = b; pixp[1] = g; pixp[2] = r;
132 SDL_UnlockSurface(screen);
134 SDL_UpdateRect(screen, x/5*5, y, 5, 1);