+static void
+setdotcolor (ModeInfo * mi)
+{
+ Display *display = MI_DISPLAY (mi);
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
+
+ XSetForeground (display, pp->stippledGC, MI_WHITE_PIXEL (mi));
+}
+
+static void
+cleardotcolor (ModeInfo * mi)
+{
+ Display *display = MI_DISPLAY (mi);
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
+
+ XSetForeground (display, pp->stippledGC, MI_BLACK_PIXEL (mi));
+}
+
+#if 0
+static void
+draw_position (ModeInfo * mi, int x, int y, int color)
+{
+ Display *display = MI_DISPLAY (mi);
+ Window window = MI_WINDOW (mi);
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
+ XFontStruct *font = NULL;
+ char *f_name = "-*-utopia-*-r-*-*-*-600-*-*-p-*-*-*";
+ char *s = NULL;
+
+ font = load_font_retry (display, f_name);
+ assert (font != NULL);
+
+ s = (char *) malloc (256);
+ assert (s != NULL);
+ sprintf (s, "(%d,%d)", x, y);
+ XSetForeground (display, pp->stippledGC, color);
+ XDrawString (display, window, pp->stippledGC, x, y, s, strlen (s));
+ free (s);
+ free (font);
+}
+#endif
+#if 0
+static void
+draw_number (ModeInfo * mi, int x, int y, int num, int color)
+{
+ Display *display = MI_DISPLAY (mi);
+ Window window = MI_WINDOW (mi);
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
+ XFontStruct *font = NULL;
+ char *f_name = "-*-utopia-*-r-*-*-*-600-*-*-p-*-*-*";
+ char *s = NULL;
+
+ font = load_font_retry (display, f_name);
+ assert (font != NULL);
+
+ s = (char *) malloc (256);
+ assert (s != NULL);
+ sprintf (s, "%d", num);
+ XSetForeground (display, pp->stippledGC, color);
+ XDrawString (display, window, pp->stippledGC, x, y, s, strlen (s));
+ free (s);
+ free (font);
+}
+#endif
+
+#if 0
+/* draw_grid - draws a grid on top of the playing field.
+ * Used so that I can determine if I'm converting from rows and columns to x and y
+ * coordinates correctly.
+ */
+static void
+draw_grid (ModeInfo * mi)
+{
+ Display *display = MI_DISPLAY (mi);
+ Window window = MI_WINDOW (mi);
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
+ int h = MI_HEIGHT (mi);
+ int w = MI_WIDTH (mi);
+ int y = 0;
+ int x = 0;
+ XSetForeground (display, pp->stippledGC, 0xff0000);
+ while (y < h) {
+ while (x < w) {
+ XDrawLine (display, window, pp->stippledGC, x, 0, x, h);
+ x += 10;
+ }
+ x = 0;
+ XDrawLine (display, window, pp->stippledGC, 0, y, w, y);
+ y += 10;
+ }
+}
+#endif
+
+#if 0
+static void
+draw_string (ModeInfo * mi, int x, int y, char *s, int color)
+{
+ Display *display = MI_DISPLAY (mi);
+ Window window = MI_WINDOW (mi);
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
+ XFontStruct *font = NULL;
+ char *f_name = "-*-utopia-*-r-*-*-*-600-*-*-p-*-*-*";
+
+ font = load_font_retry (display, f_name);
+ assert (font != NULL);
+
+ assert (s != NULL);
+ XSetForeground (display, pp->stippledGC, color);
+ XDrawString (display, window, pp->stippledGC, x, y, s, strlen (s));
+ free (font);
+}
+
+/* I think this function has a memory leak. Be careful if you enable it. */
+/* I only used it briefly to help me debug the ghost's aistate. It prints */
+/* the state of each ghost on the left hand side of the screen */
+static void
+print_ghost_stats (ModeInfo *mi, ghoststruct *g , int ghost_num)
+{
+ char s[1024];
+
+ sprintf (s, "GHOST: %d", ghost_num );
+ switch (g->aistate){
+ case inbox:
+ sprintf (s, "%s inbox", s);
+ break;
+ case goingout:
+ sprintf (s, "%s goingout", s);
+ break;
+ case randdir:
+ sprintf (s, "%s randdir", s);
+ break;
+ case chasing:
+ sprintf (s, "%s chasing", s);
+ break;
+ case hiding:
+ sprintf (s, "%s hiding", s);
+ break;
+ case goingin:
+ sprintf (s, "%s goingin",s);
+ break;
+ }
+ draw_string (mi, 0, (ghost_num *3) *10+50, g->last_stat, 0x000000);
+ draw_string (mi, 0, (ghost_num *3) *10+50, s, 0xff0000);
+ strcpy(g->last_stat,s);
+}
+
+/* prints the number of times pacman has died and his aistate on the left hand */
+/* side of the screen */
+static void
+print_pac_stats ( ModeInfo *mi, pacmanstruct *pac )
+{
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
+ char s[1024];
+ sprintf (s, "Pacman, Deaths: %d", pac->deaths );
+ switch ( pac->aistate ){
+ case ps_eating:
+ sprintf(s, "%s ps_eating",s );
+ break;
+ case ps_chasing:
+ sprintf(s, "%s ps_chasing",s );
+ break;
+ case ps_hiding:
+ sprintf(s, "%s ps_hiding",s );
+ break;
+ case ps_random:
+ sprintf(s, "%s ps_random",s );
+ break;
+ case ps_dieing:
+ sprintf(s, "%s ps_dieing",s );
+ break;
+ }
+ draw_string ( mi, 0, 200, pp->last_pac_stat, 0x000000);
+ draw_string ( mi, 0, 200, s, 0xff0000);
+ strcpy(pp->last_pac_stat, s );
+}
+
+#endif
+
+/*Ok, yeah whatever?*/
+/*dot_rc_to_pixel - magic that converts row and columns into
+ *the x and y coordinates of the screen.
+ */
+static void
+dot_rc_to_pixel (ModeInfo * mi, int *x, int *y)
+{
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
+ *x = (pp->xs * *x) +
+ (pp->xs / 2) - (pp->xs > 32 ? (pp->xs / 16) : 1) + pp->xb;
+ *y = (pp->ys * *y) +
+ (pp->ys / 2) - (pp->ys > 32 ? (pp->ys / 16) : 1) + pp->yb;
+}
+
+/* dot_width_height - magic used to get the width and height of
+ * a dot. This dot can also be scaled by a value.
+ */
+static void
+dot_width_height (ModeInfo *mi, int *w, int *h)
+{
+ pacmangamestruct *pp = &pacman_games[MI_SCREEN (mi)];
+ if (pp->xs > 32){
+ *w = *h = (pp->xs / 16 );
+ }else {
+ *w = *h = 1;
+ }
+}
+
+static void
+bonus_dot_width_height (ModeInfo *mi, int *w, int *h )
+{
+ *w = *h = MI_HEIGHT (mi) / 65;
+}
+
+\f
+
+static void
+draw_dot (ModeInfo * mi, pacmangamestruct * pp, int x, int y,
+ void (*width_height)(ModeInfo * mi, int *w, int *h),
+ int (*arc_func) (Display * display, Drawable d, GC gc,
+ int x, int y, unsigned int width,
+ unsigned int height, int angle1,
+ int angle2))
+{
+ Display *display = MI_DISPLAY (mi);
+ Window window = MI_WINDOW (mi);
+ int w, h;
+ dot_rc_to_pixel (mi, &x, &y);
+ width_height(mi, &w, &h);
+ (void) arc_func (display, window, pp->stippledGC,
+ x, y, w, h, 0, 23040);
+}
+
+static void
+draw_bonus_dot (ModeInfo * mi, pacmangamestruct * pp, int x, int y)
+{
+ int x2 = x;
+ int y2 = y;
+ setdotcolor (mi);
+ draw_dot (mi, pp, x, y, bonus_dot_width_height, XFillArc);
+ dot_rc_to_pixel (mi, &x2, &y2);
+#if 0
+ draw_position (mi, x2, y2, 0xff0000);
+#endif
+}
+
+static void
+clear_bonus_dot (ModeInfo * mi, pacmangamestruct * pp, int x, int y)