@@ 33,6 33,24 @@ printgrid(Grid *g)
}
int
+opengrid(Grid *g, FILE *f)
+{
+ char c;
+ g->l = 0;
+ while((c = fgetc(f)) != EOF && g->l < MAXSZ) {
+ if(c == '\n') {
+ if(g->w == 0)
+ g->w = g->l;
+ g->h = g->l / g->w;
+ } else {
+ g->type[g->l] = 0;
+ g->data[g->l++] = c;
+ }
+ }
+ return g->w > 2 && g->h > 2;
+}
+
+int
main(int argc, char *argv[])
{
FILE *f;
@@ 47,7 65,7 @@ main(int argc, char *argv[])
f = fopen(argv[1], "r");
if(!f)
return error("Missing input.");
- if(!loadgrid(&g, f))
+ if(!opengrid(&g, f))
return error("Invalid grid");
while(g.f < limit) {
rungrid(&g);
@@ 51,8 51,8 @@ Uint32 theme[] = {
0xffb545};
Uint8 icons[][8] = {
- {0x38, 0x7c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x00},
- {0x38, 0x44, 0x82, 0x82, 0x82, 0x44, 0x38, 0x00},
+ {0x86, 0xc6, 0xe6, 0xf6, 0xe6, 0xc6, 0x86, 0x00}, /* play */
+ {0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00}, /* pause */
{0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00},
{0x06, 0x18, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00},
{0x02, 0x02, 0x04, 0x38, 0x40, 0x80, 0x80, 0x00},
@@ 182,7 182,7 @@ void
drawui(Uint32 *dst)
{
int bottom = VER * 8 + 8;
- drawicon(dst, 0, bottom, icons[PAUSE == 1 ? 4 : 0], 1);
+ drawicon(dst, 0, bottom, icons[PAUSE == 1 ? 1 : 0], 1);
}
void
@@ 496,7 496,7 @@ dokey(SDL_Event *event)
case SDLK_5: insert('5'); break;
case SDLK_6: insert('6'); break;
case SDLK_7: insert('7'); break;
- case SDLK_8: insert('8'); break;
+ case SDLK_8: insert(shift ? '*' : '8'); break;
case SDLK_9: insert('9'); break;
case SDLK_a: ctrl ? select(0, 0, g.w, g.h) : insert(shift ? 'A' : 'a'); break;
case SDLK_b: insert(shift ? 'B' : 'b'); break;