#include <string.h>
#include <SDL/SDL.h>
-#define WIN_X 1500
-#define WIN_Y 768
+#define WIN_X 800
+#define WIN_Y 600
+
+char getone()
+{
+ unsigned char c;
+ static char ring[2048];
+ static int prod = 0, cons = 0;
+ int oldcons;
+
+ if (prod == cons)
+ {
+ int r;
+ /* Try to read some. */
+ while ((r = read(0, &(ring[prod]), 2048-prod)) == 0)
+ usleep(250000);
+ prod = (prod + r) % 2048;
+ }
+ oldcons = cons;
+ cons = (cons + 1) % 2048;
+ return ring[oldcons];
+}
char *readline()
{
static char s[2048];
- return gets(s); /* Insecure, oh well, who cares, this will get replaced later */
+ int i = 0;
+
+ while (i < 2048)
+ {
+ s[i] = getone();
+ if (s[i] == '\r' || s[i] == '\n')
+ {
+ s[i] = '\0';
+ return s;
+ }
+ i++;
+ }
+ s[2047] = 0;
+ return s;
}
struct vars {
if (!strcmp(vars[i].var, var) && ((!sub && !vars[i].sub) || !strcmp(vars[i].sub, sub)))
return &vars[i].val;
printf("Unknown var: %s %s\n", var, sub);
+ abort();
}
void main()
vars[nvars].val = 0;
nvars++;
}
- } else if (s[0] == '#')
+ } else if (s[0] == '#' || !s[0])
;
- else
+ else if (readingdata)
{
int val = (s[0] == '1');
int i;
{
x = 0;
if (!lasths)
+ {
y++;
+ SDL_Flip(screen);
+ }
} else
x++;
}