+
+/* Load the ghost pixmaps and their mask. */
+static void
+load_ghost_pixmaps (Display ** dpy, Window window, pacmangamestruct ** ps)
+{
+ pacmangamestruct *pp = *ps;
+ Display *display = *dpy;
+ char *colors[] = {
+ ". c #FF0000", /*Red */
+ ". c #00FFDE", /*Blue */
+ ". c #FFB847", /*Orange */
+ ". c #FFB8DE", /*Pink */
+ };
+
+ char **bits[] = {
+ ghost_u1_xpm, ghost_u2_xpm, ghost_r1_xpm, ghost_r2_xpm,
+ ghost_d1_xpm, ghost_d2_xpm, ghost_l1_xpm, ghost_l2_xpm
+ };
+ char * const *s_bits[] = {
+ ghost_s1_xpm, ghost_s2_xpm,
+ ghost_sf1_xpm, ghost_sf2_xpm
+ };
+ char * const *e_bits[] = {
+ eyes_u_xpm, eyes_r_xpm, eyes_d_xpm, eyes_l_xpm
+ };
+
+ int i, j, k, m;
+ int w = pp->spritexs;
+ int h = pp->spriteys;
+ GC gc = 0;
+ Pixmap temp;
+
+ for (i = 0; i < 4; i++) {
+ m = 0;
+ for (j = 0; j < MAXGDIR; j++) {
+ for (k = 0; k < MAXGWAG; k++) {
+ bits[m][2] = colors[i];
+ pp->ghostPixmap[i][j][k] =
+ xpm_data_to_pixmap (display, window, bits[m], &w, &h,
+ &pp->ghostMask);
+
+ if (!pp->ghostPixmap[i][j][k])
+ pacman_fail ("Cannot load ghost images");
+
+ pp->ghostPixmap[i][j][k] =
+ scale_pixmap (&display, pp->stippledGC,
+ pp->ghostPixmap[i][j][k], pp->spritexs,
+ pp->spriteys);
+
+ if (!pp->ghostPixmap[i][j][k])
+ pacman_fail ("Cannot scale ghost images");
+ m++;
+ }
+ }
+ }
+ /* load the scared ghost */
+ m = 0;
+ for (i = 0; i < MAXGFLASH; i++) {
+ for (j = 0; j < MAXGWAG; j++) {
+ pp->s_ghostPixmap[i][j] =
+ xpm_data_to_pixmap (display, window, s_bits[m++], &w, &h,
+ &pp->ghostMask);
+
+ if (!pp->s_ghostPixmap[i][j])
+ pacman_fail ("Cannot Scare Ghost images");
+ pp->s_ghostPixmap[i][j] = scale_pixmap (&display, pp->stippledGC,
+ pp->s_ghostPixmap[i][j],
+ pp->spritexs,
+ pp->spriteys);
+
+ if (!pp->s_ghostPixmap[i][j])
+ pacman_fail ("Cannot scale Scared Ghost images");
+ }
+ }
+ /* load the ghost eyes */
+ for (i = 0; i < MAXGDIR; i++) {
+ pp->ghostEyes[i] =
+ xpm_data_to_pixmap (display, window, e_bits[i], &w, &h,
+ &pp->ghostMask);
+
+ if (!pp->ghostEyes[i])
+ pacman_fail ("Cannot open ghost eye images");
+
+ pp->ghostEyes[i] = scale_pixmap (&display, pp->stippledGC,
+ pp->ghostEyes[i],
+ pp->spritexs,
+ pp->spriteys);
+
+ if (!pp->ghostEyes[i])
+ pacman_fail ("Cannot open ghost eye images");
+ }
+
+
+
+ /* We really only need a single mask. This saves the headache of getting the
+ * bottom of the ghost to clip just right. What we'll do is mask
+ * the top portion of the ghost, but the bottom of the ghost will be solid.
+ * I did this by setting the pixels between the fringe of their sheets
+ * to black instead of none. -jeremy
+ */
+ temp = xpm_data_to_pixmap (display, window, ghost_mask_xpm,
+ &w, &h, &pp->ghostMask);
+
+ if (!temp)
+ pacman_fail ("Cannot load temporary ghost image");
+
+ temp = scale_pixmap (&display, pp->stippledGC,
+ temp, pp->spritexs, pp->spriteys);
+
+ if (!temp)
+ pacman_fail ("Cannot scale temporary ghost image");
+
+ gc = XCreateGC (display, pp->ghostMask, 0, 0);
+
+ pp->ghostMask = scale_pixmap (&display, gc, pp->ghostMask,
+ pp->spritexs, pp->spriteys);
+ XFreePixmap (display, temp);
+}
+
+/* Load the pacman pixmaps and their mask. */
+static void
+load_pacman_pixmaps (Display ** dpy, Window window, pacmangamestruct ** ps)
+{
+ pacmangamestruct *pp = *ps;
+ Display *display = *dpy;
+
+ char **bits[] = {
+ pacman_0_xpm, pacman_u1_xpm, pacman_u2_xpm,
+ pacman_0_xpm, pacman_r1_xpm, pacman_r2_xpm,
+ pacman_0_xpm, pacman_d1_xpm, pacman_d2_xpm,
+ pacman_0_xpm, pacman_l1_xpm, pacman_l2_xpm
+ };
+
+ char * const *ds_bits[] = {
+ pacman_ds1_xpm, pacman_ds2_xpm, pacman_ds3_xpm, pacman_ds4_xpm,
+ pacman_ds5_xpm, pacman_ds6_xpm, pacman_ds7_xpm, pacman_ds8_xpm
+ };
+
+ int i, j, m;
+ int w = pp->spritexs;
+ int h = pp->spriteys;
+ GC gc = 0;
+
+ m = 0;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < MAXMOUTH; j++) {
+ pp->pacmanPixmap[i][j] =
+ xpm_data_to_pixmap (display, window, bits[m++], &w, &h,
+ &pp->pacmanMask[i][j]);
+
+ if (!pp->pacmanPixmap[i][j])
+ pacman_fail ("Cannot load pacman pixmap.");
+
+ pp->pacmanPixmap[i][j] = scale_pixmap (&display, pp->stippledGC,
+ pp->pacmanPixmap[i][j],
+ pp->spritexs,
+ pp->spriteys);
+
+ if (!pp->pacmanPixmap[i][j])
+ pacman_fail ("Cannot scale pacman pixmap.");
+
+ if (!gc)
+ gc = XCreateGC (display, pp->pacmanMask[i][j], 0, 0);
+
+ pp->pacmanMask[i][j] =
+ scale_pixmap (&display, gc, pp->pacmanMask[i][j],
+ pp->spritexs, pp->spriteys);
+ }
+ }
+
+ /* Load pacman death sequence */
+ for ( i = 0; i < PAC_DEATH_FRAMES; i++ ){
+ pp->pacman_ds[i] =
+ xpm_data_to_pixmap (display, window, ds_bits[i], &w, &h,
+ &pp->pacman_ds_mask[i]);
+
+ if (!pp->pacman_ds[i])
+ pacman_fail ("Cannot load pacman death frame.");
+
+ pp->pacman_ds[i] = scale_pixmap ( &display, pp->stippledGC,
+ pp->pacman_ds[i],
+ pp->spritexs,
+ pp->spriteys);
+
+ if (!pp->pacman_ds[i])
+ pacman_fail ("Cannot scale pixmap.");
+
+ if (!gc)
+ gc = XCreateGC (display, pp->pacman_ds_mask[i], 0, 0);
+
+ pp->pacman_ds_mask[i] =
+ scale_pixmap (&display, gc, pp->pacman_ds_mask[i],
+ pp->spritexs, pp->spriteys);
+ }
+
+}
+#endif /* USE_PIXMAP */