Fix: SE001 Problem: Double size tiles don't work (non-XPM mode). Either avoid these (by making sure that NetHack.double_tile_size is either not set or set to False in /usr/openwin/lib/app-defaults/NetHack), or use XPM mode (in which case it's ignored anyway) by defining USE_XPM in config.h Compatible with: NetHack 3.2.2 Slash'EM up to 0.0.5E3 Obsoleted by: Slash'EM 0.0.5E4 Author: J. Ali Harlow, ali@avrc.city.ac.uk Date: 29 Jul 1999 *** win/X11/winmap.c.orig Tue Jul 27 16:27:16 1999 --- win/X11/winmap.c Thu Jul 29 18:34:30 1999 *************** *** 205,210 **** --- 205,211 ---- static int tile_width; static int tile_height; static int tile_count; + static int tiles_per_line; /* In tile_image & tile_pixmap, for retrieval */ static XImage *tile_image = 0; /* *************** *** 254,261 **** Display *dpy = XtDisplay(toplevel); unsigned int width, height; ! height = tile_height * tile_count; ! width = tile_width; if (tile_image == 0) return; /* no tiles */ --- 255,262 ---- Display *dpy = XtDisplay(toplevel); unsigned int width, height; ! height = tile_height * ((tile_count+tiles_per_line-1)/tiles_per_line); ! width = tile_width * tiles_per_line; if (tile_image == 0) return; /* no tiles */ *************** *** 264,269 **** --- 265,273 ---- height, DefaultDepth(dpy, DefaultScreen(dpy))); + if (!tile_pixmap) + impossible("post_process_tiles: insufficient memory to create pixmap"); + XPutImage(dpy, tile_pixmap, DefaultGC(dpy, DefaultScreen(dpy)), tile_image, *************** *** 364,369 **** --- 368,383 ---- /* infer tile dimensions from image size */ tile_count=total_tiles_used; + /* + * Only ever one tile per line in XPM mode. + * To change this would require either changing the XPM data file + * (in which case how do we know how many tiles per line?), or + * some fancy reading algorithm which will convert on the fly + * without triggering the X bug which causes the problem in the + * first place. + * For now, just be careful that image height does not exceed 32767. + */ + tiles_per_line=1; tile_width=tile_image->width; tile_height=tile_image->height/tile_count; } *************** *** 463,470 **** tile_height = header.tile_height; } ! image_height = tile_height * tile_count; ! image_width = tile_width; /* calculate bitmap_pad */ if (ddepth > 16) --- 477,490 ---- tile_height = header.tile_height; } ! /* ! * Arrange the tiles in the image (and subsequently on the pixmap) ! * so that we avoid dimensions larger than 32767 which trigger a ! * bug in XPutImage (at least on Solaris 2.5.1). ! */ ! tiles_per_line = 32767/tile_width; ! image_width = tile_width * tiles_per_line; ! image_height = tile_height * ((tile_count+tiles_per_line-1)/tiles_per_line); /* calculate bitmap_pad */ if (ddepth > 16) *************** *** 492,520 **** (char *) alloc((unsigned)tile_image->bytes_per_line * image_height); if (appResources.double_tile_size) { ! unsigned long *expanded_row = ! (unsigned long *)alloc(sizeof(unsigned long)*(unsigned)tile_width); ! ! tb = tile_bytes; ! for (y = 0; y < image_height; y++) { ! for (x = 0; x < header.tile_width; x++) ! expanded_row[2*x] = ! expanded_row[(2*x)+1] = colors[*tb++].pixel; ! ! for (x = 0; x < tile_width; x++) ! XPutPixel(tile_image, x, y, expanded_row[x]); ! ! y++; /* duplicate row */ ! for (x = 0; x < tile_width; x++) ! XPutPixel(tile_image, x, y, expanded_row[x]); } - free((genericptr_t)expanded_row); - } else { ! ! for (tb = tile_bytes, y = 0; y < image_height; y++) ! for (x = 0; x < image_width; x++, tb++) ! XPutPixel(tile_image, x, y, colors[*tb].pixel); } #endif /* USE_XPM */ --- 512,550 ---- (char *) alloc((unsigned)tile_image->bytes_per_line * image_height); if (appResources.double_tile_size) { ! for (tb = tile_bytes, i = 0; i < tile_count; i++) ! { ! for (y = 0; y < header.tile_height; y++) ! for (x = 0; x < header.tile_width; x++, tb++) ! { ! XPutPixel(tile_image, ! (i % tiles_per_line) * tile_width + 2*x, ! (i / tiles_per_line) * tile_height + 2*y, ! colors[*tb].pixel); ! XPutPixel(tile_image, ! (i % tiles_per_line) * tile_width + 2*x, ! (i / tiles_per_line) * tile_height + 2*y+1, ! colors[*tb].pixel); ! XPutPixel(tile_image, ! (i % tiles_per_line) * tile_width + 2*x+1, ! (i / tiles_per_line) * tile_height + 2*y, ! colors[*tb].pixel); ! XPutPixel(tile_image, ! (i % tiles_per_line) * tile_width + 2*x+1, ! (i / tiles_per_line) * tile_height + 2*y+1, ! colors[*tb].pixel); ! } } } else { ! for (tb = tile_bytes, i = 0; i < tile_count; i++) ! { ! for (y = 0; y < header.tile_height; y++) ! for (x = 0; x < header.tile_width; x++, tb++) ! XPutPixel(tile_image, ! (i % tiles_per_line) * tile_width + x, ! (i / tiles_per_line) * tile_height + y, ! colors[*tb].pixel); ! } } #endif /* USE_XPM */ *************** *** 1213,1220 **** XCopyArea(dpy, tile_pixmap, XtWindow(wp->w), tile_map->black_gc, /* no grapics_expose */ ! 0, ! tile * map_info->square_height, tile_width, tile_height, dest_x,dest_y); --- 1243,1250 ---- XCopyArea(dpy, tile_pixmap, XtWindow(wp->w), tile_map->black_gc, /* no grapics_expose */ ! (tile % tiles_per_line) * map_info->square_width, ! (tile / tiles_per_line) * map_info->square_height, tile_width, tile_height, dest_x,dest_y);