-static float dt = 0.3;
-static float targetVel = 0.03;
-static float targetAcc = 0.02;
-static float maxVel = 0.05;
-static float maxAcc = 0.03;
-static float noise = 0.01;
-static float minVelMultiplier = 0.5;
-
-static int nbugs = -1;
-static int ntargets = -1;
-static int trailLen = -1;
-
-/* vars dependent on those above */
-static float dtInv;
-static float halfDtSq;
-static float targetVelSq;
-static float maxVelSq;
-static float minVelSq;
-static float minVel;
-
-static bug bugs[MAX_BUGS];
-static bug targets[MAX_TARGETS];
-static int head = 0;
-static int tail = 0;
-static int colorScheme = -1;
-static float changeProb = 0.08;
-
-static int grayIndex[MAX_TRAIL_LEN];
-static int redIndex[MAX_TRAIL_LEN];
-static int blueIndex[MAX_TRAIL_LEN];
-static int graySIndex[MAX_TRAIL_LEN];
-static int redSIndex[MAX_TRAIL_LEN];
-static int blueSIndex[MAX_TRAIL_LEN];
-static int randomIndex[MAX_TRAIL_LEN];
-static int numColors;
-static int numRandomColors;
+
+
+struct state {
+ Display *dpy;
+ Window win;
+
+ unsigned char colors[768];
+
+ GC fgc[256];
+ GC cgc;
+ int xsize, ysize;
+ int xc, yc;
+ unsigned long delay;
+ float maxx, maxy;
+
+ float dt;
+ float targetVel;
+ float targetAcc;
+ float maxVel;
+ float maxAcc;
+ float noise;
+ float minVelMultiplier;
+
+ int nbugs;
+ int ntargets;
+ int trailLen;
+
+ float dtInv;
+ float halfDtSq;
+ float targetVelSq;
+ float maxVelSq;
+ float minVelSq;
+ float minVel;
+
+ bug bugs[MAX_BUGS];
+ bug targets[MAX_TARGETS];
+ int head;
+ int tail;
+ int colorScheme;
+ float changeProb;
+
+ int grayIndex[MAX_TRAIL_LEN];
+ int redIndex[MAX_TRAIL_LEN];
+ int blueIndex[MAX_TRAIL_LEN];
+ int graySIndex[MAX_TRAIL_LEN];
+ int redSIndex[MAX_TRAIL_LEN];
+ int blueSIndex[MAX_TRAIL_LEN];
+ int randomIndex[MAX_TRAIL_LEN];
+ int numColors;
+ int numRandomColors;
+
+ int checkIndex;
+ int rsc_callDepth;
+ int rbc_callDepth;
+
+ float draw_fps;
+ float draw_timePerFrame, draw_elapsed;
+ int *draw_targetColorIndex, *draw_colorIndex;
+ int draw_targetStartColor, draw_targetNumColors;
+ int draw_startColor, draw_numColors;
+ double draw_start, draw_end;
+ int draw_cnt;
+ int draw_sleepCount;
+ int draw_delayAccum;
+ int draw_nframes;
+
+ struct timeval startupTime;
+};
+