+ bordupdate (st);
+ gridupdate (st, False);
+ }
+
+ {
+ Bool alltrap = True;
+ unsigned char thr;
+ for (thr = 1; thr <= st->threads; thr++)
+ if (move (st, thr))
+ alltrap = False;
+ if (alltrap) /* all threads are trapped */
+ st->reset_p = True;
+ if (st->speed != SPEEDMAX)
+ this_delay = waitabit (st);
+ }
+
+ if (tick++ > st->max_ticks && !had_instring)
+ {
+ tick = 0;
+ st->instring = 0;
+ maininit(st);
+ st->reset_p = True;
+ st->autopal = False;
+ }
+
+ if (this_delay == 0 && loop++ < 1000)
+ goto AGAIN;
+
+ return this_delay;
+}
+
+static void *
+vermiculate_init (Display *d, Window w)
+{
+ struct state *st = (struct state *) calloc (1, sizeof(*st));
+ st->dpy = d;
+ st->window = w;
+ st->reset_p = 1;
+ st->instring = get_string_resource (st->dpy, "instring", "Instring");
+ if (st->instring && !*st->instring)
+ st->instring = 0;
+
+ st->max_ticks = get_integer_resource (st->dpy, "ticks", "Integer");
+ {
+ int temp = get_integer_resource (st->dpy, "speed", "Speed");
+ if (temp != 0)
+ st->speed = temp;
+ }
+
+ st->mycolors[0].pixel = BlackPixel (st->dpy, DefaultScreen (st->dpy));
+
+ XSetWindowBackground (st->dpy, st->window,
+ BlackPixel (st->dpy, DefaultScreen (st->dpy)));
+ {
+ XGetWindowAttributes (st->dpy, st->window, &st->xgwa);
+ st->wid = st->xgwa.width;
+ st->hei = st->xgwa.height;
+ st->mycmap = st->xgwa.colormap;
+ }
+ {
+ XGCValues mygcv;
+ st->mygc = XCreateGC (st->dpy, st->window, 0, &mygcv);
+ }
+
+ st->point = (unsigned char *) malloc (st->wid * st->hei);
+ maininit (st);
+ palupdate (st, True);
+ consume_instring(st);
+ return st;
+}
+
+
+static void
+vermiculate_reshape (Display *dpy, Window window, void *closure,
+ unsigned int w, unsigned int h)
+{
+}
+
+static Bool
+vermiculate_event (Display *dpy, Window window, void *closure, XEvent *event)
+{
+ return False;
+}
+
+static void
+consume_instring(struct state *st)
+{
+ char boolop;
+
+ while (wasakeypressed (st))