-#if 0
- printf("::: CREATING NEW CLIPMASKS ...\n");
-#endif
-#if 1
- clip_mask = Pixmap_to_Mask(pcxBitmapsX2[i]->drawable,
- pcxBitmapsX2[i]->width,
- pcxBitmapsX2[i]->height);
-#endif
-#if 0
- printf("::: CREATING NEW CLIPMASKS DONE\n");
-#endif
-
- pcxBitmapsX2[i]->clip_mask = clip_mask;
-
-#if 0
- printf("::: %ld, %ld, %ld, %ld, %ld, %ld, %ld\n",
- pcxBitmaps[i]->gc,
- pcxBitmaps[i]->clip_mask, pcxBitmapsX2[i]->clip_mask,
- pcxBitmaps[i]->width, pcxBitmaps[i]->height,
- pcxBitmapsX2[i]->width, pcxBitmapsX2[i]->height);
-#endif
-
-#if 0
- ZoomPixmap(display, pcxBitmaps[i]->gc,
- pcxBitmaps[i]->clip_mask, pcxBitmapsX2[i]->clip_mask,
- pcxBitmaps[i]->width, pcxBitmaps[i]->height,
- pcxBitmapsX2[i]->width, pcxBitmapsX2[i]->height);
-#endif
-
-#endif
- }
-
- objBitmap = pcxBitmapsX2[0];
- botBitmap = pcxBitmapsX2[1];
- sprBitmap = pcxBitmapsX2[2];
- ttlBitmap = pcxBitmapsX2[3];
-
- objPixmap = pcxBitmapsX2[0]->drawable;
- botPixmap = pcxBitmapsX2[1]->drawable;
- sprPixmap = pcxBitmapsX2[2]->drawable;
- ttlPixmap = pcxBitmapsX2[3]->drawable;
-#if 1
- objmaskBitmap = pcxBitmapsX2[0]->clip_mask;
- botmaskBitmap = pcxBitmapsX2[1]->clip_mask;
- sprmaskBitmap = pcxBitmapsX2[2]->clip_mask;
- ttlmaskBitmap = pcxBitmapsX2[3]->clip_mask;
-#endif
-#endif
-
-#if 1
- screenBitmap = CreateBitmap(22 * TILEX, 14 * TILEY, DEFAULT_DEPTH);
- scoreBitmap = CreateBitmap(20 * TILEX, SCOREY, DEFAULT_DEPTH);
-#endif
-
- screenPixmap = XCreatePixmap(display, xwindow, 22 * TILEX, 14 * TILEY, screenDepth);
- if(screenPixmap == 0) {
- fprintf(stderr, "%s: \"%s\": %s: %s\n", progname, XDisplayName(arg_display), "failed to create pixmap", strerror(errno));
- return(1);
- }
-
- scorePixmap = XCreatePixmap(display, xwindow, 20 * TILEX, SCOREY, screenDepth);
- if(scorePixmap == 0) {
- fprintf(stderr, "%s: \"%s\": %s: %s\n", progname, XDisplayName(arg_display), "failed to create pixmap", strerror(errno));
- return(1);
- }
-
- spriteBitmap = XCreatePixmap(display, xwindow, TILEX, TILEY, 1);
- if(spriteBitmap == 0) {
- fprintf(stderr, "%s: \"%s\": %s: %s\n", progname, XDisplayName(arg_display), "failed to create pixmap", strerror(errno));
- return(1);
- }
-
- redColour.pixel = screenWhitePixel;
- whiteColour.pixel = screenBlackPixel;
- gotRed = (xpmAllocColourFunc(display, privateColourmap ? privateColourmap : defaultColourmap, "red", &redColour, 0) > 0);
- gotWhite = (xpmAllocColourFunc(display, privateColourmap ? privateColourmap : defaultColourmap, "white", &whiteColour, 0) > 0);
-
- gcValues.graphics_exposures = False;
- screenGC = XCreateGC(display, screenPixmap, GCGraphicsExposures, &gcValues);
- if(screenGC == 0) {
- fprintf(stderr, "%s: \"%s\": %s: %s\n", progname, XDisplayName(arg_display), "failed to create graphics context", strerror(errno));
- return(1);
- }
-
- gcValues.graphics_exposures = False;
- scoreGC = XCreateGC(display, scorePixmap, GCGraphicsExposures, &gcValues);
- if(scoreGC == 0) {
- fprintf(stderr, "%s: \"%s\": %s: %s\n", progname, XDisplayName(arg_display), "failed to create graphics context", strerror(errno));
- return(1);
- }
-
- gcValues.function = objmaskBitmap ? GXcopyInverted : sprmaskBitmap ? GXcopy : GXset;
- gcValues.graphics_exposures = False;
- spriteGC = XCreateGC(display, spriteBitmap, GCFunction | GCGraphicsExposures, &gcValues);
- if(spriteGC == 0) {
- fprintf(stderr, "%s: \"%s\": %s: %s\n", progname, XDisplayName(arg_display), "failed to create graphics context", strerror(errno));
- return(1);
- }
-
- gcValues.foreground = redColour.pixel;
- gcValues.background = whiteColour.pixel;
- gcValues.line_style = LineDoubleDash;
- gcValues.graphics_exposures = False;
- antsGC = XCreateGC(display, screenPixmap, GCForeground | GCBackground | GCLineStyle | GCGraphicsExposures, &gcValues);
- if(antsGC == 0) {
- fprintf(stderr, "%s: \"%s\": %s: %s\n", progname, XDisplayName(arg_display), "failed to create graphics context", strerror(errno));
- return(1);
- }
-
- for(i = 0; i < 16; i++) {
- keycodes[i] = XKeysymToKeycode(display, keysyms[i]);
- }
- for(i = 0; i < 3; i++) northKeyCode[i] = keycodes[i + 0];
- for(i = 0; i < 3; i++) eastKeyCode[i] = keycodes[i + 3];
- for(i = 0; i < 3; i++) southKeyCode[i] = keycodes[i + 6];
- for(i = 0; i < 3; i++) westKeyCode[i] = keycodes[i + 9];
- for(i = 0; i < 3; i++) fireKeyCode[i] = keycodes[i + 12];
- for(i = 0; i < 1; i++) escKeyCode[i] = keycodes[i + 15];
-
- /* ----------------------------------------------------------------- */
-
-#if 0
- {
- Bitmap *bm = pcxBitmaps[2];
- Pixmap clip_mask = bm->clip_mask;
-
- if (clip_mask)
- {
-#if 1
- int width = bm->width;
- int height = bm->height;
-#else
- int width = 16 * 4;
- int height = 16 * 4;
-#endif
- XImage *src_ximage = XGetImage(display, clip_mask, 0, 0,
- width, height, AllPlanes, ZPixmap);
- XImage *dst_ximage = XGetImage(display, xwindow, 0, 0,
- width, height, AllPlanes, ZPixmap);
- int x, y;
-
- if (src_ximage == NULL)
- {
- printf("src_ximage failed\n");
- exit(1);
- }
-
- if (dst_ximage == NULL)
- {
- printf("dst_ximage failed\n");
- exit(1);
- }
-
- printf("::: DISPLAY CLIP MASK ...\n");
-
- for (x=0; x<width; x++)
- {
- for (y=0; y<height; y++)
- {
- unsigned long pixel = XGetPixel(src_ximage, x, y);
-
- if (pixel != BlackPixel(display, screen))
- pixel = WhitePixel(display, screen);
-
- XPutPixel(dst_ximage, x, y, pixel);
- }
- }
-
- printf("::: DISPLAY CLIP MASK NOW\n");
-
- XPutImage(display, xwindow, screenGC, dst_ximage, 0, 0,
- 0, 13 * TILEY, width, height);
-
- printf("::: DISPLAY CLIP MASK DONE\n");
- }
- }
-#endif
-
- /* ----------------------------------------------------------------- */
-
-#if 0
- {
- int ii = 2;
-
- XGCValues clip_gc_values;
- unsigned long clip_gc_valuemask;
-
-#if 1
- GC gc = screenGC;
-#else
-#if 1
- GC gc = pcxBitmaps[ii]->stored_clip_gc;
-#else
- GC gc = pcxBitmaps[ii]->gc;
-#endif
-#endif
- Pixmap src_pixmap = pcxBitmaps[ii]->clip_mask;
- Pixmap dst_pixmap = pcxBitmapsX2[ii]->clip_mask;
- int src_width = pcxBitmaps[ii]->width;
- int src_height = pcxBitmaps[ii]->height;
- int dst_width = pcxBitmapsX2[ii]->width;
- int dst_height = pcxBitmapsX2[ii]->height;
-
- XImage *src_ximage, *dst_ximage;
- byte *src_ptr, *dst_ptr;
- int bits_per_pixel;
- int bytes_per_pixel;
- int x, y, xx, yy, i;
-#if 1
- boolean scale_down = (src_width > dst_width);
- int zoom_factor;
-#else
- int zoom_factor = src_width / dst_width; /* currently very limited! */
-#endif
- int row_skip, col_skip;
-
- printf("::: %d\n", scale_down);
-
- xdebug("::: ZOOM STEP 1");
-
- clip_gc_values.graphics_exposures = False;
- clip_gc_valuemask = GCGraphicsExposures;
- if ((gc = XCreateGC(display, pcxBitmaps[ii]->clip_mask,
- clip_gc_valuemask, &clip_gc_values)) == None)
- {
- printf("XCreateGC failed\n");
- exit(1);
- }
-
- xdebug("::: ZOOM STEP 2");
-
- if (scale_down)
- {
- zoom_factor = src_width / dst_width;
-
- /* adjust source image size to integer multiple of destination size */
- src_width = dst_width * zoom_factor;
- src_height = dst_height * zoom_factor;
- }
- else
- {
- zoom_factor = dst_width / src_width;
-
- /* no adjustment needed when scaling up (some pixels may be left blank) */
- }
-
- /* copy source pixmap to temporary image */
- if ((src_ximage = XGetImage(display, src_pixmap, 0, 0, src_width, src_height,
- AllPlanes, ZPixmap)) == NULL)
- Error(ERR_EXIT, "ZoomPixmap(): XGetImage() failed");
-
- bits_per_pixel = src_ximage->bits_per_pixel;
- bytes_per_pixel = (bits_per_pixel + 7) / 8;
-
- printf("::: bits_per_pixel == %d\n", bits_per_pixel);
-
- if ((dst_ximage = XCreateImage(display, visual, src_ximage->depth, ZPixmap,
- 0, NULL, dst_width, dst_height,
- 8, dst_width * bytes_per_pixel)) == NULL)
- Error(ERR_EXIT, "ZoomPixmap(): XCreateImage() failed");
-
- dst_ximage->data =
- checked_malloc(dst_width * dst_height * bytes_per_pixel);
- dst_ximage->byte_order = src_ximage->byte_order;
-
- src_ptr = (byte *)src_ximage->data;
- dst_ptr = (byte *)dst_ximage->data;
-
- if (scale_down)
- {
- col_skip = (zoom_factor - 1) * bytes_per_pixel;
- row_skip = col_skip * src_width;