Fix: SE050 Problem: Slash'EM can only be configured to build _either_ a 32x32 tile set _or_ a 16x16 tile set (by defining BIGTILE in include/config.h and replacing x11tiles in the definition of CNF_SHARE_ND in Makefile.top with x11bigtiles). This is flawed and the whole concept of the BIGTILE configuration switch should be removed so that either x11tiles or x11bigtiles or both can be built if they are included in the definition of CNF_SHARE_ND. I have solved this by replacing the definitions of TILE_X and TILE_Y in win/share/tile.h (which used to specify the fixed tile size) with two new definitions (MAX_TILE_X and MAX_TILE_Y) which specify a maximum tile size. Two new variables (tile_x and tile_y) contain the current tile size. This allows both 16x16 and 32x32 tile sets to be handled by the same programs without needing to re-compile. The major cost of this is that naive programs which simply allocate enough space to hold MAX_GLPYH * MAX_TILE_X * MAX_TILE_Y RGB triplets require a lot of memory (about 4Mb at present). This may well break on smaller machines. Looking forward to the 3D tiles which are 48x64 we would need 12Mb which is out of the reach of many machines. We solve this problem by dealing with tiles in small chunks wherever possible. Where this is not simply done, we use the current values of tile_x and tile_y. In this way, even if the larger tile sets cannot be generated the user still has the choice of generating the smaller sets. tile2x11 falls into this category. The GTK interface used to use the BIGTILE switch to determine whether the big tile set was available for use. This fix modifies the interface so that it scans for the tile files at program startup and disables support for tile sets if they are not present. This also has the nice side effect that the tile set parameters (size etc) can be determined at this point and allows the user full flexibility to resize the tiles should he/she so desire. I have made some guesses at the changes required in tile2bmp, but I have not been able to test these. Compatible with: Slash'EM 0.0.6E0F2+SE049 Author: J. Ali Harlow, ali@avrc.city.ac.uk Date: 2 Mar 2000 diff -Ncar ../slashem-0.0.6E0F2+SE049/include/config.h ./include/config.h *** ../slashem-0.0.6E0F2+SE049/include/config.h Thu Mar 2 19:56:39 2000 --- ./include/config.h Thu Mar 2 20:15:28 2000 *************** *** 97,103 **** # define USE_XPM /* Use XPM format for images (required) */ # define GRAPHIC_TOMBSTONE /* Use graphical tombstone (rip.xpm) */ # define RADAR /* Use radar map */ - /* # define BIGTILE */ /* Build and use 32x32 tiles */ /* # define BIG3DTILE */ /* Build and use 3D tiles (not supported) */ # ifndef DEFAULT_WINDOW_SYS # define DEFAULT_WINDOW_SYS "gtk" --- 97,102 ---- *************** *** 122,128 **** # ifdef USE_XPM # define GRAPHIC_TOMBSTONE /* Use graphical tombstone (rip.xpm) */ # endif - /* # define BIGTILE */ /* Build 32x32 tiles */ #endif /* --- 121,126 ---- diff -Ncar ../slashem-0.0.6E0F2+SE049/include/winGTK.h ./include/winGTK.h *** ../slashem-0.0.6E0F2+SE049/include/winGTK.h Thu Mar 2 19:56:05 2000 --- ./include/winGTK.h Thu Mar 2 20:01:00 2000 *************** *** 116,121 **** --- 116,122 ---- extern void nh_set_map_visual(int); extern int nh_get_map_visual(void); + extern int nh_check_map_visual(int); extern void main_hook(void); extern void quit_hook(void); diff -Ncar ../slashem-0.0.6E0F2+SE049/sys/unix/Makefile.top ./sys/unix/Makefile.top *** ../slashem-0.0.6E0F2+SE049/sys/unix/Makefile.top Thu Mar 2 19:56:39 2000 --- ./sys/unix/Makefile.top Thu Mar 2 20:08:36 2000 *************** *** 74,84 **** # per discussions in Install.X11, Install.Qt and Install.GTK CNF_SHARE_QTND = x11tiles rip.xpm ! CNF_SHARE_X11ND = x11tiles pet_mark.xbm ! # CNF_SHARE_X11ND = x11bigtiles pet_mark.xbm rip.xpm ! CNF_SHARE_GTKND = x11tiles rip.xpm credit.xpm ! # CNF_SHARE_GTKND = x11bigtiles rip.xpm credit.xpm # CNF_SHARE_DATND = $(CNF_SHARE_X11ND) # CNF_SHARE_DATND = $(CNF_SHARE_QTND) --- 74,83 ---- # per discussions in Install.X11, Install.Qt and Install.GTK CNF_SHARE_QTND = x11tiles rip.xpm ! CNF_SHARE_X11ND = x11bigtiles x11tiles pet_mark.xbm ! # CNF_SHARE_X11ND = x11bigtiles x11tiles pet_mark.xbm rip.xpm ! CNF_SHARE_GTKND = x11bigtiles x11tiles rip.xpm credit.xpm # CNF_SHARE_DATND = $(CNF_SHARE_X11ND) # CNF_SHARE_DATND = $(CNF_SHARE_QTND) diff -Ncar ../slashem-0.0.6E0F2+SE049/sys/unix/Makefile.utl ./sys/unix/Makefile.utl *** ../slashem-0.0.6E0F2+SE049/sys/unix/Makefile.utl Thu Mar 2 19:56:39 2000 --- ./sys/unix/Makefile.utl Thu Mar 2 20:01:00 2000 *************** *** 262,267 **** --- 262,269 ---- tileutils: tilemap gif2txt xpm2txt txt2ppm txtfilt tile2x11 magtile txtmerge + magtile: magtile.o $(TEXT_IO) + $(CC) $(LFLAGS) -o magtile magtile.o $(TEXT_IO) gif2txt: $(GIFREADERS) $(TEXT_IO) $(CC) $(LFLAGS) -o gif2txt $(GIFREADERS) $(TEXT_IO) xpm2txt: $(XPMREADERS) $(TEXT_IO) *************** *** 284,292 **** ../include/tile.h: ../win/share/tile.h tilemap ./tilemap ! magtile: ../win/share/magtile.c ../include/config.h ../include/tile.h ! $(CC) $(CFLAGS) -DTILE_X=16 -DTILE_Y=16 $(LFLAGS) -o magtile \ ! ../win/share/magtile.c tiletext.o: ../win/share/tiletext.c ../include/config.h ../include/tile.h $(CC) $(CFLAGS) -c ../win/share/tiletext.c --- 286,293 ---- ../include/tile.h: ../win/share/tile.h tilemap ./tilemap ! magtile.o: ../win/share/magtile.c ../include/config.h ../include/tile.h ! $(CC) $(CFLAGS) -c ../win/share/magtile.c tiletext.o: ../win/share/tiletext.c ../include/config.h ../include/tile.h $(CC) $(CFLAGS) -c ../win/share/tiletext.c diff -Ncar ../slashem-0.0.6E0F2+SE049/win/X11/Install.X11 ./win/X11/Install.X11 *** ../slashem-0.0.6E0F2+SE049/win/X11/Install.X11 Thu Mar 2 19:56:39 2000 --- ./win/X11/Install.X11 Thu Mar 2 20:04:17 2000 *************** *** 28,34 **** for full effect, so you can just as well set windowtype there; also, you or someone else might just possibly be stuck in a situation where you can't use the X version -- over a non-blindingly-fast modem, say.) You may also ! want to define USE_XPM, GRAPHIC_TOMBSTONE or BIGTILE as discussed below. In src/Makefile, add $(WINX11SRC), $(WINX11OBJ), and $(WINX11LIB) to WINSRC, WINOBJ, and WINLIB respectively, and compile. This will give you --- 28,34 ---- for full effect, so you can just as well set windowtype there; also, you or someone else might just possibly be stuck in a situation where you can't use the X version -- over a non-blindingly-fast modem, say.) You may also ! want to define USE_XPM, GRAPHIC_TOMBSTONE as discussed below. In src/Makefile, add $(WINX11SRC), $(WINX11OBJ), and $(WINX11LIB) to WINSRC, WINOBJ, and WINLIB respectively, and compile. This will give you *************** *** 39,46 **** replacement font), you will need to have the win/share files and change the CF_SHARE_DATND setting in the top Makefile to contain the tile files before you do your 'make all'. Include x11tiles for the 16x16 tile set and x11bigtiles ! for the 32x32 set. BIGTILE must be defined in include/config.h in order to ! generate x11bigtiles and undefined in order to generate x11tiles. When using tiles, you have the option of defining USE_XPM in config.h. This causes Slash'EM to use the XPM file format for the "x11(big)tiles" file --- 39,46 ---- replacement font), you will need to have the win/share files and change the CF_SHARE_DATND setting in the top Makefile to contain the tile files before you do your 'make all'. Include x11tiles for the 16x16 tile set and x11bigtiles ! for the 32x32 set. You can generate both and allow the user to select which ! set will be used using the X Resource "SlashEM.tile_file". When using tiles, you have the option of defining USE_XPM in config.h. This causes Slash'EM to use the XPM file format for the "x11(big)tiles" file diff -Ncar ../slashem-0.0.6E0F2+SE049/win/X11/tile2x11.c ./win/X11/tile2x11.c *** ../slashem-0.0.6E0F2+SE049/win/X11/tile2x11.c Thu Mar 2 19:56:39 2000 --- ./win/X11/tile2x11.c Thu Mar 2 20:01:00 2000 *************** *** 15,22 **** x11_header header; ! unsigned char tile_bytes[TILE_X*TILE_Y*MAX_GLYPH]; ! unsigned char *curr_tb = tile_bytes; unsigned char x11_colormap[MAXCOLORMAPSIZE][3]; --- 15,22 ---- x11_header header; ! unsigned char *tile_bytes = NULL; ! unsigned char *curr_tb = NULL; unsigned char x11_colormap[MAXCOLORMAPSIZE][3]; *************** *** 49,61 **** { unsigned char *tb = *tb_ptr; unsigned long count = 0; ! pixel tile[TILE_Y][TILE_X]; int x, y; while (read_text_tile(tile)) { count++; ! for (y = 0; y < TILE_Y; y++) ! for (x = 0; x < TILE_X; x++) *tb++ = pix_to_colormap(tile[y][x]); } --- 49,61 ---- { unsigned char *tb = *tb_ptr; unsigned long count = 0; ! pixel tile[MAX_TILE_Y][MAX_TILE_X]; int x, y; while (read_text_tile(tile)) { count++; ! for (y = 0; y < tile_y; y++) ! for (x = 0; x < tile_x; x++) *tb++ = pix_to_colormap(tile[y][x]); } *************** *** 109,114 **** --- 109,127 ---- Fprintf(stderr, "can't open file \"%s\"\n", fname); exit(1); } + + if (!tile_bytes) { + /* + * Delayed until we open the first input file so that + * we know the size of the tiles we are processing. + */ + tile_bytes = malloc(tile_x*tile_y*MAX_GLYPH); + if (!tile_bytes) { + Fprintf(stderr, "Not enough memory.\n"); + exit(1); + } + curr_tb = tile_bytes; + } merge_text_colormap(); count = convert_tiles(&curr_tb); Fprintf(stderr, "%s: %lu tiles\n", fname, count); *************** *** 134,141 **** /* Fill unused entries with "checkerboard" pattern */ for(i = TILES_PER_COL * TILES_PER_ROW - header.ntiles; i > 0; i--) ! for (y = 0; y < TILE_Y; y++) ! for (x = 0; x < TILE_X; x+=2) { *curr_tb++ = 0; *curr_tb++ = 1; --- 147,154 ---- /* Fill unused entries with "checkerboard" pattern */ for(i = TILES_PER_COL * TILES_PER_ROW - header.ntiles; i > 0; i--) ! for (y = 0; y < tile_y; y++) ! for (x = 0; x < tile_x; x+=2) { *curr_tb++ = 0; *curr_tb++ = 1; *************** *** 229,236 **** header.version = 1; header.ncolors = 0; - header.tile_width = TILE_X; - header.tile_height = TILE_Y; header.ntiles = 0; /* updated as we read in files */ while (argn < argc) { --- 242,247 ---- *************** *** 258,263 **** --- 269,277 ---- process_file(argv[i]); Fprintf(stderr, "Total tiles: %ld\n", header.ntiles); + header.tile_width = tile_x; + header.tile_height = tile_y; + #ifdef USE_XPM if (xpm_write(fp) == 0) { Fprintf(stderr, "can't write XPM file\n"); *************** *** 283,287 **** --- 297,302 ---- #endif fclose(fp); + free(tile_bytes); return 0; } diff -Ncar ../slashem-0.0.6E0F2+SE049/win/gtk/Install.GTK ./win/gtk/Install.GTK *** ../slashem-0.0.6E0F2+SE049/win/gtk/Install.GTK Thu Mar 2 19:56:39 2000 --- ./win/gtk/Install.GTK Thu Mar 2 20:07:23 2000 *************** *** 28,37 **** support multiple windowing ports (and tty as well, if you want) in the same executable if you so desire. - Define BIGTILES if you want to use the 32x32 tile set or undefine - it to use the 16x16 tile set. The definition of CNF_SHARE_GTKND - in the top-level makefile must match -- see below. - 3. ../../src/Makefile add $(WINGTKSRC), $(WINGTKOBJ), and $(WINGTKLIB) to WINSRC, WINOBJ, --- 28,33 ---- *************** *** 50,57 **** If you want to support the other windowing ports, include their $(CNF_SHARE_XXXND) variables also. ! CNF_SHARE_GTKND should include x11bigtiles if BIGTILE is defined ! in include/config.h and x11tiles if it is undefined. 5. Follow all the instructions in ../../sys/unix/Install.unx for the remainder of the installation process. --- 46,56 ---- If you want to support the other windowing ports, include their $(CNF_SHARE_XXXND) variables also. ! CNF_SHARE_GTKND should normally include both x11tiles and ! x11bigtiles to allow the user to select which tile set he/she ! would prefer at runtime. If you will always be using the same ! one however, you can remove the other. The GTK interface will ! default to x11tiles if it exists and x11bigtiles otherwise. 5. Follow all the instructions in ../../sys/unix/Install.unx for the remainder of the installation process. diff -Ncar ../slashem-0.0.6E0F2+SE049/win/gtk/gtkmap.c ./win/gtk/gtkmap.c *** ../slashem-0.0.6E0F2+SE049/win/gtk/gtkmap.c Thu Mar 2 19:56:39 2000 --- ./win/gtk/gtkmap.c Thu Mar 2 20:01:00 2000 *************** *** 8,13 **** --- 8,14 ---- #include #include #include "winGTK.h" + #include "dlb.h" /* if map_click is true, we do gtk_main_quit() when clicking map *************** *** 101,132 **** static TileTab Big3DTile = { "Big 3D tiles", "floor.xpm", ! 960, 2880, /* tile map width height */ ! 48, 64, /* unit_width, unit_height */ ! 16, 32, /* 3d_ofset, 3d_ofsety */ True, True, }; #endif - #ifdef BIGTILE static TileTab BigTile = { "Big tiles", "x11bigtiles", -1, -1, /* tile map width height */ ! 32, 32, /* width, height */ ! 0, 0, True, False, }; - #endif static TileTab SmallTile = { "Small tiles", "x11tiles", -1, -1, /* tile map width height */ ! 16, 16, /* width, height */ ! 0, 0, False, False, }; --- 102,131 ---- static TileTab Big3DTile = { "Big 3D tiles", "floor.xpm", ! -1, -1, /* tile map width height */ ! -1, -1, /* unit_width, unit_height */ ! -1, -1, /* 3d_ofset, 3d_ofsety */ True, True, }; #endif static TileTab BigTile = { "Big tiles", "x11bigtiles", -1, -1, /* tile map width height */ ! -1, -1, /* width, height */ ! -1, -1, True, False, }; static TileTab SmallTile = { "Small tiles", "x11tiles", -1, -1, /* tile map width height */ ! -1, -1, /* width, height */ ! -1, -1, False, False, }; *************** *** 134,154 **** static TileTab *tileTab[] = { NULL, /* dummy */ &SmallTile, - #ifdef BIGTILE &BigTile, - #endif #ifdef BIG3DTILE &Big3DTile #endif }; ! #ifdef BIGTILE ! static TileTab *Tile = &BigTile; ! static int map_visual = 2; ! #else ! static TileTab *Tile = &SmallTile; ! static int map_visual = 1; ! #endif /* from tile.c */ extern int tiles_per_row; --- 133,146 ---- static TileTab *tileTab[] = { NULL, /* dummy */ &SmallTile, &BigTile, #ifdef BIG3DTILE &Big3DTile #endif }; ! static TileTab *Tile; ! static int map_visual = -1; /* from tile.c */ extern int tiles_per_row; *************** *** 165,172 **** static int NH_TILE_CACHE_HEIGHT; static int NH_MAP_WIDTH; static int NH_MAP_HEIGHT; ! static gint NH_TILEMAP_WIDTH; ! static gint NH_TILEMAP_HEIGHT; static int NH_MAP_MAX_WIDTH; static int NH_MAP_MAX_HEIGHT; --- 157,164 ---- static int NH_TILE_CACHE_HEIGHT; static int NH_MAP_WIDTH; static int NH_MAP_HEIGHT; ! static int NH_TILEMAP_WIDTH; ! static int NH_TILEMAP_HEIGHT; static int NH_MAP_MAX_WIDTH; static int NH_MAP_MAX_HEIGHT; *************** *** 245,250 **** --- 237,244 ---- c_map_height = NH_HEIGHT * c_height; } else{ + if(!tileTab[mode]) + panic("Disabled visual!\n"); Tile = tileTab[mode]; nh_map_init(); *************** *** 258,266 **** if (!tile_pixmap) panic("Cannot open tile file %s!",NH_TILE_FILE); - gdk_window_get_size((GdkWindow *)tile_pixmap, - &NH_TILEMAP_WIDTH, &NH_TILEMAP_HEIGHT); - tile_image = gdk_image_get( (GdkWindow *)tile_pixmap, 0, 0, --- 252,257 ---- *************** *** 296,301 **** --- 287,302 ---- return map_visual; } + int + nh_check_map_visual(int mode) + { + if(mode < 0 || mode >= sizeof(tileTab) / sizeof(tileTab[0]) || + mode && !tileTab[mode]) + return -1; + else + return 0; + } + /* fix tile number */ *************** *** 487,492 **** --- 488,495 ---- NH_TILE_CACHE_HEIGHT = (Tile->unit_height); NH_MAP_WIDTH = (Tile->unit_width * NH_WIDTH); NH_MAP_HEIGHT = (Tile->unit_height * NH_HEIGHT); + NH_TILEMAP_WIDTH = (Tile->tilemap_width); + NH_TILEMAP_HEIGHT = (Tile->tilemap_height); } void *************** *** 495,500 **** --- 498,608 ---- map_scroll = NULL; } + /* + * [ALI] + * + * Scan an XPM tile file for its width and height and fill in the + * tile table appropriately. We could use functions from the XPM + * library to do this but that would mean reading the whole file + * into memory. This would take a significant amount of time. The + * XPM format is loosely defined, but this should parse anything + * that sxpm can. It won't reject all invalid XPM files, however. + */ + + static void + tile_scan(void) + { + int i, ch; + int state; + FILE *fp; + + for(i=0 ; i < SIZE(tileTab) ; ++i){ + if(!tileTab[i]) + continue; + #ifdef FILE_AREAS + fp = fopen_area(FILE_AREA_SHARE, tileTab[i]->file, RDTMODE); + #else + fp = fopen(tileTab[i]->file, RDTMODE); + #endif + if(!fp){ + tileTab[i] = NULL; + continue; + } + state = 0; + do + { + ch = getc(fp); + if (ch == EOF) + { + state = 5; + break; + } + switch (state) + { + case 0: + if (ch == '/') + state++; + else if (ch == '"') + state = 4; + break; + case 1: + if (ch == '*') + state++; + else + state--; + break; + case 2: + if (ch == '*') + state++; + break; + case 3: + if (ch == '/') + state = 0; + else + state--; + break; + } + } while(state < 4); + if(state == 5){ + tileTab[i] = NULL; + continue; + } + if(fscanf(fp, "%d %d", &tileTab[i]->tilemap_width, + &tileTab[i]->tilemap_height) != 2){ + tileTab[i] = NULL; + continue; + } + tileTab[i]->unit_width = tileTab[i]->tilemap_width / tiles_per_row; + tileTab[i]->unit_height = tileTab[i]->tilemap_height / tiles_per_col; + if(i == 3){ + tileTab[i]->ofsetx_3d = tileTab[i]->unit_width / 2; + tileTab[i]->ofsety_3d = tileTab[i]->unit_height / 3; + } + else{ + tileTab[i]->ofsetx_3d = 0; + tileTab[i]->ofsety_3d = 0; + } + fclose(fp); + /* + * [ALI] + * + * Default to the first valid tile set + */ + if (map_visual < 0) + map_visual = i; + } + /* + * [ALI] + * + * If no tiles valid, we'd like to use character mode but it + * requires too many changes to nh_map_init and nh_map_new. + * For now, we just abort. + */ + if (map_visual < 0) + panic("No valid tiles found"); + Tile = tileTab[map_visual]; + } + GtkWidget * nh_map_new(GtkWidget *w) { *************** *** 502,512 **** --- 610,624 ---- int width, height; int shmflg; + tile_scan(); nh_map_init(); NH_MAP_MAX_WIDTH = -1; NH_MAP_MAX_HEIGHT = -1; for(i=1 ; i < sizeof(tileTab) / sizeof(tileTab[0]) ; ++i){ + if(!tileTab[i]) + continue; + width = (NH_WIDTH + 1) * (tileTab[i]->unit_width - tileTab[i]->ofsetx_3d) + (NH_HEIGHT + 1) * tileTab[i]->ofsetx_3d; height = (NH_HEIGHT + 1) * (tileTab[i]->unit_height - tileTab[i]->ofsety_3d); *************** *** 575,583 **** if (!tile_pixmap) panic("Cannot open tile file %s!",NH_TILE_FILE); - - gdk_window_get_size((GdkWindow *)tile_pixmap, - &NH_TILEMAP_WIDTH, &NH_TILEMAP_HEIGHT); tile_image = gdk_image_get( (GdkWindow *)tile_pixmap, --- 687,692 ---- diff -Ncar ../slashem-0.0.6E0F2+SE049/win/gtk/gtkmisc.c ./win/gtk/gtkmisc.c *** ../slashem-0.0.6E0F2+SE049/win/gtk/gtkmisc.c Thu Mar 2 19:56:08 2000 --- ./win/gtk/gtkmisc.c Thu Mar 2 20:01:00 2000 *************** *** 568,595 **** gtk_hbox_new(FALSE, 0), vbox, "", FALSE, FALSE, NH_PAD); ! radio_visual_monji = nh_gtk_new_and_pack( ! gtk_radio_button_new_with_label(menu_group, "Characters"), hbox, "", ! FALSE, FALSE, NH_PAD); ! menu_group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_visual_monji)); ! radio_visual_tile = nh_gtk_new_and_pack( ! gtk_radio_button_new_with_label(menu_group, "Tiles"), hbox, "", ! FALSE, FALSE, NH_PAD); ! menu_group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_visual_tile)); ! #ifdef BIGTILE ! radio_visual_bigtile = nh_gtk_new_and_pack( ! gtk_radio_button_new_with_label(menu_group, "Big tiles"), hbox, "", ! FALSE, FALSE, NH_PAD); ! menu_group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_visual_tile)); ! #endif ! #ifdef BIG3DTILE ! radio_visual_big3dtile = nh_gtk_new_and_pack( ! gtk_radio_button_new_with_label(menu_group, "Big 3D tiles"), hbox, "", ! FALSE, FALSE, NH_PAD); ! menu_group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_visual_tile)); ! #endif switch(nh_get_map_visual()){ case 0: --- 568,608 ---- gtk_hbox_new(FALSE, 0), vbox, "", FALSE, FALSE, NH_PAD); ! if (!nh_check_map_visual(0)){ ! radio_visual_monji = nh_gtk_new_and_pack( ! gtk_radio_button_new_with_label(menu_group, "Characters"), hbox, "", ! FALSE, FALSE, NH_PAD); ! menu_group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_visual_monji)); ! } ! else ! radio_visual_monji = NULL; ! if (!nh_check_map_visual(1)){ ! radio_visual_tile = nh_gtk_new_and_pack( ! gtk_radio_button_new_with_label(menu_group, "Tiles"), hbox, "", ! FALSE, FALSE, NH_PAD); ! menu_group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_visual_tile)); ! } ! else ! radio_visual_tile = NULL; ! if (!nh_check_map_visual(2)){ ! radio_visual_bigtile = nh_gtk_new_and_pack( ! gtk_radio_button_new_with_label(menu_group, "Big tiles"), hbox, "", ! FALSE, FALSE, NH_PAD); ! menu_group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_visual_bigtile)); ! } ! else ! radio_visual_bigtile = NULL; ! ! if (!nh_check_map_visual(3)){ ! radio_visual_big3dtile = nh_gtk_new_and_pack( ! gtk_radio_button_new_with_label(menu_group, "Big 3D tiles"), hbox, "", ! FALSE, FALSE, NH_PAD); ! menu_group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_visual_big3dtile)); ! } ! else ! radio_visual_big3dtile = NULL; switch(nh_get_map_visual()){ case 0: *************** *** 780,792 **** } } } ! if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_visual_monji))) nh_set_map_visual(0); ! else if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_visual_tile))) nh_set_map_visual(1); ! else if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_visual_bigtile))) nh_set_map_visual(2); ! else if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_visual_big3dtile))) nh_set_map_visual(3); } nh_status_index_update(); --- 793,809 ---- } } } ! if(radio_visual_monji && ! gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_visual_monji))) nh_set_map_visual(0); ! else if(radio_visual_tile && ! gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_visual_tile))) nh_set_map_visual(1); ! else if(radio_visual_bigtile && ! gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_visual_bigtile))) nh_set_map_visual(2); ! else if(radio_visual_big3dtile && ! gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio_visual_big3dtile))) nh_set_map_visual(3); } nh_status_index_update(); diff -Ncar ../slashem-0.0.6E0F2+SE049/win/share/gifread.c ./win/share/gifread.c *** ../slashem-0.0.6E0F2+SE049/win/share/gifread.c Thu Mar 2 19:56:07 2000 --- ./win/share/gifread.c Thu Mar 2 20:01:00 2000 *************** *** 516,522 **** xpos = 0; ++ypos; } ! if (ypos >= TILE_Y) break; } } --- 516,522 ---- xpos = 0; ++ypos; } ! if (ypos >= tile_y) break; } } *************** *** 542,560 **** } read_header(gif_file); ! if (GifScreen.Width % TILE_X) { Fprintf(stderr, "error: width %d not divisible by %d\n", ! GifScreen.Width, TILE_X); exit(EXIT_FAILURE); } ! tiles_across = GifScreen.Width / TILE_X; curr_tiles_across = 0; ! if (GifScreen.Height % TILE_Y) { Fprintf(stderr, "error: height %d not divisible by %d\n", ! GifScreen.Height, TILE_Y); /* exit(EXIT_FAILURE) */; } ! tiles_down = GifScreen.Height / TILE_Y; curr_tiles_down = 0; if (GifScreen.Interlace) { --- 542,560 ---- } read_header(gif_file); ! if (GifScreen.Width % tile_x) { Fprintf(stderr, "error: width %d not divisible by %d\n", ! GifScreen.Width, tile_x); exit(EXIT_FAILURE); } ! tiles_across = GifScreen.Width / tile_x; curr_tiles_across = 0; ! if (GifScreen.Height % tile_y) { Fprintf(stderr, "error: height %d not divisible by %d\n", ! GifScreen.Height, tile_y); /* exit(EXIT_FAILURE) */; } ! tiles_down = GifScreen.Height / tile_y; curr_tiles_down = 0; if (GifScreen.Interlace) { *************** *** 564,571 **** image[i] = (pixel *) alloc(GifScreen.Width * sizeof(pixel)); } } else { ! image = (pixel **)alloc(TILE_Y * sizeof(pixel *)); ! for (i = 0; i < TILE_Y; i++) { image[i] = (pixel *) alloc(GifScreen.Width * sizeof(pixel)); } } --- 564,571 ---- image[i] = (pixel *) alloc(GifScreen.Width * sizeof(pixel)); } } else { ! image = (pixel **)alloc(tile_y * sizeof(pixel *)); ! for (i = 0; i < tile_y; i++) { image[i] = (pixel *) alloc(GifScreen.Width * sizeof(pixel)); } } *************** *** 596,602 **** /* Read a tile. Returns FALSE when there are no more tiles */ boolean read_gif_tile(pixels) ! pixel (*pixels)[TILE_X]; { int i, j; --- 596,602 ---- /* Read a tile. Returns FALSE when there are no more tiles */ boolean read_gif_tile(pixels) ! pixel (*pixels)[MAX_TILE_X]; { int i, j; *************** *** 609,632 **** ReadTileStrip(gif_file,GifScreen.Width); } if (GifScreen.Interlace) { ! for (j = 0; j < TILE_Y; j++) { ! for (i = 0; i < TILE_X; i++) { ! pixels[j][i] = image[curr_tiles_down*TILE_Y + j] ! [curr_tiles_across*TILE_X + i]; } } } else { ! for (j = 0; j < TILE_Y; j++) { ! for (i = 0; i < TILE_X; i++) { ! pixels[j][i] = image[j][curr_tiles_across*TILE_X + i]; } } } curr_tiles_across++; /* check for "filler" tile */ ! for (j = 0; j < TILE_Y; j++) { ! for (i = 0; i < TILE_X && i < 4; i += 2) { if (pixels[j][i].r != ColorMap[CM_RED][0] || pixels[j][i].g != ColorMap[CM_GREEN][0] || pixels[j][i].b != ColorMap[CM_BLUE][0] || --- 609,632 ---- ReadTileStrip(gif_file,GifScreen.Width); } if (GifScreen.Interlace) { ! for (j = 0; j < tile_y; j++) { ! for (i = 0; i < tile_x; i++) { ! pixels[j][i] = image[curr_tiles_down*tile_y + j] ! [curr_tiles_across*tile_x + i]; } } } else { ! for (j = 0; j < tile_y; j++) { ! for (i = 0; i < tile_x; i++) { ! pixels[j][i] = image[j][curr_tiles_across*tile_x + i]; } } } curr_tiles_across++; /* check for "filler" tile */ ! for (j = 0; j < tile_y; j++) { ! for (i = 0; i < tile_x && i < 4; i += 2) { if (pixels[j][i].r != ColorMap[CM_RED][0] || pixels[j][i].g != ColorMap[CM_GREEN][0] || pixels[j][i].b != ColorMap[CM_BLUE][0] || *************** *** 650,656 **** } free((genericptr_t)image); } else { ! for (i = 0; i < TILE_Y; i++) { free((genericptr_t)image[i]); } free((genericptr_t)image); --- 650,656 ---- } free((genericptr_t)image); } else { ! for (i = 0; i < tile_y; i++) { free((genericptr_t)image[i]); } free((genericptr_t)image); *************** *** 669,675 **** int argc; char *argv[]; { ! pixel pixels[TILE_Y][TILE_X]; if (argc == 1) { argc = SIZE(std_args); --- 669,678 ---- int argc; char *argv[]; { ! pixel pixels[MAX_TILE_Y][MAX_TILE_X]; ! ! tile_x = 16; ! tile_y = 16; if (argc == 1) { argc = SIZE(std_args); diff -Ncar ../slashem-0.0.6E0F2+SE049/win/share/magtile.c ./win/share/magtile.c *** ../slashem-0.0.6E0F2+SE049/win/share/magtile.c Thu Mar 2 19:56:39 2000 --- ./win/share/magtile.c Thu Mar 2 20:01:00 2000 *************** *** 3,10 **** /* Create a set of magnified tiles by duplicating pixels in original */ - /* Ensure that TILE_X and TILE_Y are set to the size of the originals */ - #include "config.h" #include "tile.h" --- 3,8 ---- *************** *** 12,19 **** #include #endif - static char pixels[TILE_Y][TILE_X][3]; - static char *tilefiles[] = { "../win/share/monsters.txt", "../win/share/objects.txt", "../win/share/other.txt"}; --- 10,15 ---- *************** *** 21,113 **** static char *magfiles[] = { "../win/share/monmag.txt", "../win/share/objmag.txt", "../win/share/othmag.txt"}; - static FILE *infile, *outfile; static int tilecount; static int tilecount_per_file; static int filenum; - static int num_colors; - static char comment[BUFSZ]; - - static void - copy_colormap() - { - int i, r, g, b; - char c[3]; - - num_colors=0; - while (fscanf(infile, "%2[_A-Za-z0-9$] = (%d, %d, %d) ", c, &r, &g, &b) - == 4) { - Fprintf(outfile, "%s = (%d, %d, %d)\n", c, r, g, b); - num_colors++; - } - } - - static boolean - read_txttile() - { - int i, j, k; - char buf[BUFSZ]; - const char *p, *fmt_string; - char c[3]; - - - if (fscanf(infile, "# tile %d (%[^)])", &i, buf) <= 0) - return FALSE; - - Sprintf(comment,"# tile %d (%s)", i, buf); - - /* look for non-whitespace at each stage */ - if (fscanf(infile, "%1s", c) < 0) { - Fprintf(stderr, "unexpected EOF\n"); - return FALSE; - } - if (c[0] != '{') { - Fprintf(stderr, "didn't find expected '{'\n"); - return FALSE; - } - fmt_string = num_colors > 64 ? "%2s" : "%1s"; - for (j = 0; j < TILE_Y; j++) { - for (i = 0; i < TILE_X; i++) { - if (fscanf(infile, fmt_string, pixels[j][i]) < 0) { - Fprintf(stderr, "unexpected EOF\n"); - return FALSE; - } - } - } - if (fscanf(infile, "%1s ", c) < 0) { - Fprintf(stderr, "unexpected EOF\n"); - return FALSE; - } - if (c[0] != '}') { - Fprintf(stderr, "didn't find expected '}'\n"); - return FALSE; - } - return TRUE; - } ! static void ! write_magtile() { ! const char *p; ! int i, j, k; ! ! Fprintf(outfile, "%s\n", comment); ! Fprintf(outfile, "{\n"); ! for (j = 0; j < TILE_Y; j++) { ! Fprintf(outfile, " "); ! for (i = 0; i < TILE_X; i++) { ! (void) fputs(pixels[j][i], outfile); ! (void) fputs(pixels[j][i], outfile); ! } ! Fprintf(outfile, "\n "); ! for (i = 0; i < TILE_X; i++) { ! (void) fputs(pixels[j][i], outfile); ! (void) fputs(pixels[j][i], outfile); ! } ! Fprintf(outfile, "\n"); ! } ! Fprintf(outfile, "}\n"); } int --- 17,51 ---- static char *magfiles[] = { "../win/share/monmag.txt", "../win/share/objmag.txt", "../win/share/othmag.txt"}; static int tilecount; static int tilecount_per_file; static int filenum; ! static int ! write_magtile(pixels, ttype, number, name) ! pixel (*pixels)[MAX_TILE_X]; ! const char *ttype; ! int number; ! const char *name; { ! int i, j; ! int retval; ! pixel bigpixels[MAX_TILE_X][MAX_TILE_Y]; ! for(j = 0; j < tile_y; j++) ! for(i = 0; i < tile_x; i++) ! { ! bigpixels[2 * i][2 * j] = pixels[i][j]; ! bigpixels[2 * i + 1][2 * j] = pixels[i][j]; ! bigpixels[2 * i][2 * j + 1] = pixels[i][j]; ! bigpixels[2 * i + 1][2 * j + 1] = pixels[i][j]; ! } ! tile_x *= 2; ! tile_y *= 2; ! retval = write_text_tile_info(bigpixels, ttype, number, name); ! tile_x /= 2; ! tile_y /= 2; ! return retval; } int *************** *** 115,144 **** int argc; char *argv[]; { boolean x; while (filenum < 3) { tilecount_per_file = 0; ! infile = fopen(tilefiles[filenum], RDTMODE); ! if (!infile) ! { ! perror(tilefiles[filenum]); exit(EXIT_FAILURE); ! } ! outfile = fopen(magfiles[filenum], WRTMODE); ! if (!outfile) ! { ! perror(magfiles[filenum]); exit(EXIT_FAILURE); } ! copy_colormap(); ! while (read_txttile()) { ! write_magtile(); ! tilecount_per_file++; ! tilecount++; } ! fclose(outfile); ! fclose(infile); printf("%d tiles processed from %s\n", tilecount_per_file, tilefiles[filenum]); ++filenum; --- 53,79 ---- int argc; char *argv[]; { + int tile_no; + char buf[BUFSZ], ttype[BUFSZ]; + pixel pixels[MAX_TILE_Y][MAX_TILE_X]; boolean x; while (filenum < 3) { tilecount_per_file = 0; ! if (!fopen_text_file(tilefiles[filenum], RDTMODE)) exit(EXIT_FAILURE); ! if (tile_x * 2 > MAX_TILE_X || tile_y * 2 > MAX_TILE_Y) { ! Fprintf(stderr, "tile size too large\n"); exit(EXIT_FAILURE); } ! if (!fopen_text_file(magfiles[filenum], WRTMODE)) ! exit(EXIT_FAILURE); ! while (read_text_tile_info(pixels, ttype, &tile_no, buf)) { ! write_magtile(pixels, ttype, tile_no, buf); ! tilecount_per_file++; ! tilecount++; } ! fclose_text_file(); printf("%d tiles processed from %s\n", tilecount_per_file, tilefiles[filenum]); ++filenum; diff -Ncar ../slashem-0.0.6E0F2+SE049/win/share/ppmwrite.c ./win/share/ppmwrite.c *** ../slashem-0.0.6E0F2+SE049/win/share/ppmwrite.c Thu Mar 2 19:56:40 2000 --- ./win/share/ppmwrite.c Thu Mar 2 20:01:00 2000 *************** *** 40,46 **** { int i, j; ! for (j = 0; j < TILE_Y; j++) { for (i = 0; i < PpmScreen.Width; i++) { (void) fputc((char)image[j][i].r, ppm_file); (void) fputc((char)image[j][i].g, ppm_file); --- 40,46 ---- { int i, j; ! for (j = 0; j < tile_y; j++) { for (i = 0; i < PpmScreen.Width; i++) { (void) fputc((char)image[j][i].r, ppm_file); (void) fputc((char)image[j][i].g, ppm_file); *************** *** 75,81 **** } curr_tiles_across = 0; ! PpmScreen.Width = tiles_across * TILE_X; tiles_down = 0; PpmScreen.Height = 0; /* will be rewritten later */ --- 75,81 ---- } curr_tiles_across = 0; ! PpmScreen.Width = tiles_across * tile_x; tiles_down = 0; PpmScreen.Height = 0; /* will be rewritten later */ *************** *** 83,90 **** if (!write_header()) return FALSE; ! image = (pixel **)alloc(TILE_Y * sizeof(pixel *)); ! for (i = 0; i < TILE_Y; i++) { image[i] = (pixel *) alloc(PpmScreen.Width * sizeof(pixel)); } --- 83,90 ---- if (!write_header()) return FALSE; ! image = (pixel **)alloc(tile_y * sizeof(pixel *)); ! for (i = 0; i < tile_y; i++) { image[i] = (pixel *) alloc(PpmScreen.Width * sizeof(pixel)); } *************** *** 93,105 **** boolean write_ppm_tile(pixels) ! pixel (*pixels)[TILE_X]; { int i, j; ! for (j = 0; j < TILE_Y; j++) { ! for (i = 0; i < TILE_X; i++) { ! image[j][curr_tiles_across*TILE_X + i] = pixels[j][i]; } } curr_tiles_across++; --- 93,105 ---- boolean write_ppm_tile(pixels) ! pixel (*pixels)[MAX_TILE_X]; { int i, j; ! for (j = 0; j < tile_y; j++) { ! for (i = 0; i < tile_x; i++) { ! image[j][curr_tiles_across*tile_x + i] = pixels[j][i]; } } curr_tiles_across++; *************** *** 118,125 **** if (curr_tiles_across) { /* partial row */ /* fill with checkerboard, for lack of a better idea */ ! for (j = 0; j < TILE_Y; j++) { ! for (i = curr_tiles_across * TILE_X; i < PpmScreen.Width; i += 2 ) { image[j][i].r = MainColorMap[CM_RED][0]; image[j][i].g = MainColorMap[CM_GREEN][0]; --- 118,125 ---- if (curr_tiles_across) { /* partial row */ /* fill with checkerboard, for lack of a better idea */ ! for (j = 0; j < tile_y; j++) { ! for (i = curr_tiles_across * tile_x; i < PpmScreen.Width; i += 2 ) { image[j][i].r = MainColorMap[CM_RED][0]; image[j][i].g = MainColorMap[CM_GREEN][0]; *************** *** 134,145 **** tiles_down++; } ! for (i = 0; i < TILE_Y; i++) { free((genericptr_t)image[i]); } free((genericptr_t)image); ! PpmScreen.Height = tiles_down * TILE_Y; rewind(ppm_file); if (!write_header()) /* update size */ return -1; --- 134,145 ---- tiles_down++; } ! for (i = 0; i < tile_y; i++) { free((genericptr_t)image[i]); } free((genericptr_t)image); ! PpmScreen.Height = tiles_down * tile_y; rewind(ppm_file); if (!write_header()) /* update size */ return -1; *************** *** 156,162 **** int fileargs=1; char *ppmfile; ! pixel pixels[TILE_Y][TILE_X]; tiles_across = 20; --- 156,162 ---- int fileargs=1; char *ppmfile; ! pixel pixels[MAX_TILE_Y][MAX_TILE_X]; tiles_across = 20; diff -Ncar ../slashem-0.0.6E0F2+SE049/win/share/thintile.c ./win/share/thintile.c *** ../slashem-0.0.6E0F2+SE049/win/share/thintile.c Thu Mar 2 19:56:40 2000 --- ./win/share/thintile.c Thu Mar 2 20:01:00 2000 *************** *** 11,18 **** #include #endif - static char pixels[TILE_Y][TILE_X][3]; - static char *tilefiles[] = { "../win/share/monsters.txt", "../win/share/objects.txt", "../win/share/other.txt"}; --- 11,16 ---- *************** *** 20,136 **** static char *thinfiles[] = { "../win/share/monthin.txt", "../win/share/objthin.txt", "../win/share/oththin.txt"}; - static FILE *infile, *outfile; static int tilecount; static int tilecount_per_file; static int filenum; - static int num_colors; - static char comment[BUFSZ]; - - static void - copy_colormap() - { - int i, r, g, b; - char c[3]; - - num_colors=0; - while (fscanf(infile, "%2[_A-Za-z0-9$] = (%d, %d, %d) ", c, &r, &g, &b) - == 4) { - Fprintf(outfile, "%s = (%d, %d, %d)\n", c, r, g, b); - num_colors++; - } - } ! static boolean ! read_txttile() { ! int i, j, k; ! char buf[BUFSZ]; ! const char *p, *fmt_string; ! char c[3]; ! ! ! if (fscanf(infile, "# tile %d (%[^)])", &i, buf) <= 0) ! return FALSE; ! ! Sprintf(comment,"# tile %d (%s)", i, buf); ! ! /* look for non-whitespace at each stage */ ! if (fscanf(infile, "%1s", c) < 0) { ! Fprintf(stderr, "unexpected EOF\n"); ! return FALSE; ! } ! if (c[0] != '{') { ! Fprintf(stderr, "didn't find expected '{'\n"); ! return FALSE; ! } ! fmt_string = num_colors > 64 ? "%2s" : "%1s"; ! for (j = 0; j < TILE_Y; j++) { ! for (i = 0; i < TILE_X; i++) { ! if (fscanf(infile, fmt_string, pixels[j][i]) < 0) { ! Fprintf(stderr, "unexpected EOF\n"); ! return FALSE; ! } } ! } ! if (fscanf(infile, "%1s ", c) < 0) { ! Fprintf(stderr, "unexpected EOF\n"); ! return FALSE; ! } ! if (c[0] != '}') { ! Fprintf(stderr, "didn't find expected '}'\n"); ! return FALSE; ! } ! return TRUE; } - static void - write_thintile() - { - const char *p; - int i, j, k; - - - Fprintf(outfile, "%s\n", comment); - Fprintf(outfile, "{\n"); - for (j = 0; j < TILE_Y; j++) { - Fprintf(outfile, " "); - for (i = 0; i < TILE_X; i += 2) { - (void) fputs(pixels[j][i], outfile); - } - Fprintf(outfile, "\n"); - } - Fprintf(outfile, "}\n"); - } int main(argc, argv) int argc; char *argv[]; { boolean x; while (filenum < 3) { tilecount_per_file = 0; ! infile = fopen(tilefiles[filenum], RDTMODE); ! if (!infile) ! { ! perror(tilefiles[filenum]); exit(EXIT_FAILURE); ! } ! outfile = fopen(thinfiles[filenum], WRTMODE); ! if (!outfile) ! { ! perror(thinfiles[filenum]); exit(EXIT_FAILURE); } ! copy_colormap(); ! while (read_txttile()) { ! write_thintile(); ! tilecount_per_file++; ! tilecount++; ! } ! fclose(outfile); ! fclose(infile); printf("%d tiles processed from %s\n", tilecount_per_file, tilefiles[filenum]); ++filenum; --- 18,70 ---- static char *thinfiles[] = { "../win/share/monthin.txt", "../win/share/objthin.txt", "../win/share/oththin.txt"}; static int tilecount; static int tilecount_per_file; static int filenum; ! static int ! write_thintile(pixels, ttype, number, name) ! pixel (*pixels)[MAX_TILE_X]; ! const char *ttype; ! int number; ! const char *name; { ! int i, j; ! int retval; ! pixel thinpixels[MAX_TILE_X][MAX_TILE_Y]; ! ! for (j = 0; j < tile_y; j++) { ! for (i = 0; i < tile_x; i+=2) { ! thinpixels[i/2][j] = pixels[i][j]; } ! tile_x /= 2; ! retval = write_text_tile_info(bigpixels, ttype, number, name); ! tile_x *= 2; ! return retval; } int main(argc, argv) int argc; char *argv[]; { + int tile_no; + char buf[BUFSZ], ttype[BUFSZ]; + pixel pixels[MAX_TILE_Y][MAX_TILE_X]; boolean x; while (filenum < 3) { tilecount_per_file = 0; ! if (!fopen_text_file(tilefiles[filenum], RDTMODE)) exit(EXIT_FAILURE); ! if (!fopen_text_file(magfiles[filenum], WRTMODE)) exit(EXIT_FAILURE); + while (read_text_tile_info(pixels, ttype, &tile_no, buf)) { + write_thintile(pixels, ttype, tile_no, buf); + tilecount_per_file++; + tilecount++; } ! fclose_text_file(); printf("%d tiles processed from %s\n", tilecount_per_file, tilefiles[filenum]); ++filenum; diff -Ncar ../slashem-0.0.6E0F2+SE049/win/share/tile.h ./win/share/tile.h *** ../slashem-0.0.6E0F2+SE049/win/share/tile.h Thu Mar 2 19:56:40 2000 --- ./win/share/tile.h Thu Mar 2 20:01:00 2000 *************** *** 21,37 **** #include "dlb.h" /* for MODEs */ ! /* size of tiles */ ! #ifndef TILE_Y ! #ifdef BIGTILE ! #define TILE_Y 32 ! #else ! #define TILE_Y 16 ! #endif ! #endif ! #ifndef TILE_X ! #define TILE_X TILE_Y ! #endif #define Fprintf (void) fprintf --- 21,30 ---- #include "dlb.h" /* for MODEs */ ! extern int tile_x, tile_y; ! ! #define MAX_TILE_X 32 ! #define MAX_TILE_Y 32 #define Fprintf (void) fprintf *************** *** 41,52 **** const char *overlay_name, const char *type)); extern boolean FDECL(peek_text_tile_info, (char ttype[BUFSZ], int *number, char name[BUFSZ])); ! extern boolean FDECL(read_text_tile_info, (pixel (*)[TILE_X], char *ttype, int *number, char *name)); ! extern boolean FDECL(read_text_tile, (pixel (*)[TILE_X])); ! extern boolean FDECL(write_text_tile_info, (pixel (*)[TILE_X], const char *ttype, int number, const char *name)); ! extern boolean FDECL(write_text_tile, (pixel (*)[TILE_X])); extern boolean NDECL(fclose_text_file); extern void NDECL(init_colormap); --- 34,45 ---- const char *overlay_name, const char *type)); extern boolean FDECL(peek_text_tile_info, (char ttype[BUFSZ], int *number, char name[BUFSZ])); ! extern boolean FDECL(read_text_tile_info, (pixel (*)[MAX_TILE_X], char *ttype, int *number, char *name)); ! extern boolean FDECL(read_text_tile, (pixel (*)[MAX_TILE_X])); ! extern boolean FDECL(write_text_tile_info, (pixel (*)[MAX_TILE_X], const char *ttype, int number, const char *name)); ! extern boolean FDECL(write_text_tile, (pixel (*)[MAX_TILE_X])); extern boolean NDECL(fclose_text_file); extern void NDECL(init_colormap); diff -Ncar ../slashem-0.0.6E0F2+SE049/win/share/tiletext.c ./win/share/tiletext.c *** ../slashem-0.0.6E0F2+SE049/win/share/tiletext.c Thu Mar 2 19:56:40 2000 --- ./win/share/tiletext.c Thu Mar 2 20:01:00 2000 *************** *** 26,60 **** int colorsinmap; pixval MainColorMap[3][MAXCOLORMAPSIZE]; int colorsinmainmap; static short color_index[TEXTCOLORMAPSPACE]; static int num_colors; static char charcolors[MAXCOLORMAPSIZE][3]; static int placeholder_init = 0; ! static pixel placeholder[TILE_Y][TILE_X]; ! static FILE *tile_file; static int tile_set, tile_set_indx; ! static char *text_sets[] = { ! #if (TILE_X==8) "monthin.txt", "objthin.txt", "oththin.txt", "comthin.txt" ! #elif (TILE_X==32 && TILE_Y==32) "mon32.txt", "obj32.txt", "oth32.txt", "com32.txt" ! #else "monsters.txt", "objects.txt", "other.txt", "combined.txt" - #endif }; extern const char *FDECL(tilename, (int, int)); static void FDECL(read_text_colormap, (FILE *)); static boolean FDECL(write_text_colormap, (FILE *)); static boolean FDECL(peek_txttile_info, (FILE *, char *, int *, char *)); ! static boolean FDECL(read_txttile_info, (FILE *, pixel(*)[TILE_X], char *, int *, char *)); ! static boolean FDECL(read_txttile, (FILE *, pixel(*)[TILE_X])); ! static void FDECL(write_txttile_info, (FILE *, pixel(*)[TILE_X], const char *, int, const char *)); ! static void FDECL(write_txttile, (FILE *, pixel(*)[TILE_X])); /* * ALI --- 26,64 ---- int colorsinmap; pixval MainColorMap[3][MAXCOLORMAPSIZE]; int colorsinmainmap; + int tile_x = -1, tile_y = -1; static short color_index[TEXTCOLORMAPSPACE]; static int num_colors; static char charcolors[MAXCOLORMAPSIZE][3]; static int placeholder_init = 0; ! static pixel placeholder[MAX_TILE_Y][MAX_TILE_X]; ! static FILE *in_file, *out_file; static int tile_set, tile_set_indx; ! static char *thin_text_sets[] = { "monthin.txt", "objthin.txt", "oththin.txt", "comthin.txt" ! }; ! static char *big_text_sets[] = { "mon32.txt", "obj32.txt", "oth32.txt", "com32.txt" ! }; ! static char *std_text_sets[] = { "monsters.txt", "objects.txt", "other.txt", "combined.txt" }; + #define TEXT_SETS(i) ( tile_x == 8 ? thin_text_sets[i] : \ + tile_x == 32 && tile_y == 32 ? big_text_sets[i] : \ + std_text_sets[i] ) extern const char *FDECL(tilename, (int, int)); static void FDECL(read_text_colormap, (FILE *)); static boolean FDECL(write_text_colormap, (FILE *)); static boolean FDECL(peek_txttile_info, (FILE *, char *, int *, char *)); ! static boolean FDECL(read_txttile_info, (FILE *, pixel(*)[MAX_TILE_X], char *, int *, char *)); ! static boolean FDECL(read_txttile, (FILE *, pixel(*)[MAX_TILE_X])); ! static void FDECL(write_txttile_info, (FILE *, pixel(*)[MAX_TILE_X], const char *, int, const char *)); ! static void FDECL(write_txttile, (FILE *, pixel(*)[MAX_TILE_X])); /* * ALI *************** *** 192,198 **** static boolean read_txttile_info(txtfile, pixels, ttype, number, name) FILE *txtfile; ! pixel (*pixels)[TILE_X]; char ttype[BUFSZ]; int *number; char name[BUFSZ]; --- 196,202 ---- static boolean read_txttile_info(txtfile, pixels, ttype, number, name) FILE *txtfile; ! pixel (*pixels)[MAX_TILE_X]; char ttype[BUFSZ]; int *number; char name[BUFSZ]; *************** *** 214,221 **** return FALSE; } fmt_string = colorsinmap > 64 ? "%2s" : "%1s"; ! for (j = 0; j < TILE_Y; j++) { ! for (i = 0; i < TILE_X; i++) { if (fscanf(txtfile, fmt_string, c) < 0) { Fprintf(stderr, "unexpected EOF\n"); return FALSE; --- 218,225 ---- return FALSE; } fmt_string = colorsinmap > 64 ? "%2s" : "%1s"; ! for (j = 0; j < tile_y; j++) { ! for (i = 0; i < tile_x; i++) { if (fscanf(txtfile, fmt_string, c) < 0) { Fprintf(stderr, "unexpected EOF\n"); return FALSE; *************** *** 261,267 **** static boolean read_txttile(txtfile, pixels) FILE *txtfile; ! pixel (*pixels)[TILE_X]; { int ph, i; int tile_no; --- 265,271 ---- static boolean read_txttile(txtfile, pixels) FILE *txtfile; ! pixel (*pixels)[MAX_TILE_X]; { int ph, i; int tile_no; *************** *** 285,291 **** p = tilename(tile_set, tile_set_indx); if (p && strcmp(p, buf)) { Fprintf(stderr, "warning: for tile %d (numbered %d) of %s,\n", ! tile_set_indx, i, text_sets[tile_set-1]); Fprintf(stderr, "\tfound '%s' while expecting '%s'\n", buf, p); } --- 289,295 ---- p = tilename(tile_set, tile_set_indx); if (p && strcmp(p, buf)) { Fprintf(stderr, "warning: for tile %d (numbered %d) of %s,\n", ! tile_set_indx, i, TEXT_SETS(tile_set-1)); Fprintf(stderr, "\tfound '%s' while expecting '%s'\n", buf, p); } *************** *** 303,309 **** static void write_txttile_info(txtfile, pixels, type, number, name) FILE *txtfile; ! pixel (*pixels)[TILE_X]; const char *type; int number; const char *name; --- 307,313 ---- static void write_txttile_info(txtfile, pixels, type, number, name) FILE *txtfile; ! pixel (*pixels)[MAX_TILE_X]; const char *type; int number; const char *name; *************** *** 316,324 **** Fprintf(txtfile, "# %s %d (null)\n", type, number); Fprintf(txtfile, "{\n"); ! for (j = 0; j < TILE_Y; j++) { Fprintf(txtfile, " "); ! for (i = 0; i < TILE_X; i++) { for (k = 0; k < colorsinmainmap; k++) { if (MainColorMap[CM_RED][k] == pixels[j][i].r && MainColorMap[CM_GREEN][k] == pixels[j][i].g && --- 320,328 ---- Fprintf(txtfile, "# %s %d (null)\n", type, number); Fprintf(txtfile, "{\n"); ! for (j = 0; j < tile_y; j++) { Fprintf(txtfile, " "); ! for (i = 0; i < tile_x; i++) { for (k = 0; k < colorsinmainmap; k++) { if (MainColorMap[CM_RED][k] == pixels[j][i].r && MainColorMap[CM_GREEN][k] == pixels[j][i].g && *************** *** 337,343 **** static void write_txttile(txtfile, pixels) FILE *txtfile; ! pixel (*pixels)[TILE_X]; { const char *p; const char *type; --- 341,347 ---- static void write_txttile(txtfile, pixels) FILE *txtfile; ! pixel (*pixels)[MAX_TILE_X]; { const char *p; const char *type; *************** *** 397,402 **** --- 401,489 ---- } } + /* + * [ALI] + * + * This function accepts a slightly different syntax than read_txttile(). + * We insist that each line of pixels is encoded as one line in the file. + * This restriction is necessary so that we can detect the tile width. + * We also allow white space inside a two-character colour key, which is + * not actually legal, but there seems little point complicating the code + * just to detect it. + */ + + static boolean + set_tile_size(txtfile) + FILE *txtfile; + { + int i, j, ch; + long pos; + char c[2]; + + pos = ftell(txtfile); + + if (fscanf(txtfile, "# %*s %*d (%*[^)]%c",c) <= 0 || c[0] != ')') { + Fprintf(stderr, "no tiles in file\n"); + return FALSE; + } + + if (fscanf(txtfile, "%1s", c) < 0) { + Fprintf(stderr, "unexpected EOF\n"); + return FALSE; + } + if (c[0] != '{') { + Fprintf(stderr, "didn't find expected '{'\n"); + return FALSE; + } + do + ch = getc(txtfile); + while (ch == '\n' || ch =='\r'); + for (j = 0; ; j++) { + for(i = 0; ; i++) { + while (ch == ' ' || ch == '\t') + ch = getc(txtfile); + if (ch == '_' || ch >= 'A' && ch <= 'Z' || ch >= 'a' && + ch <= 'z' || ch >= '0' && ch <= '9' || ch == '$') + ch = getc(txtfile); + else + break; + } + if (!i && ch == '}') + break; + if (ch != '\n' && ch != '\r') { + Fprintf(stderr, "unexpected character %c\n",ch); + return FALSE; + } + else + ch = getc(txtfile); + if (colorsinmap > 64) { + if (i & 1) { + Fprintf(stderr, "half a pixel?\n"); + return FALSE; + } + i /= 2; + } + if (tile_x < 0) + tile_x = i; + else if (tile_x != i) + { + Fprintf(stderr, "tile width mismatch %d != %d\n", + tile_x, i); + return FALSE; + } + } + if (tile_y < 0) + tile_y = j; + else if (tile_y != j) + { + Fprintf(stderr, "tile height mismatch %d != %d\n", + tile_y, j); + return FALSE; + } + fseek(txtfile, pos, SEEK_SET); + return TRUE; + } + boolean fopen_text_file(filename, type) const char *filename; *************** *** 404,417 **** { const char *p; int i; ! if (tile_file != (FILE *)0) { Fprintf(stderr, "can only open one text file at at time\n"); return FALSE; } ! tile_file = fopen(filename, type); ! if (tile_file == (FILE *)0) { Fprintf(stderr, "cannot open text file %s\n", filename); return FALSE; } --- 491,515 ---- { const char *p; int i; + int write_mode; + FILE *fp; + + if (!strcmp(type, RDTMODE)) + write_mode = FALSE; + else if (!strcmp(type, WRTMODE)) + write_mode = TRUE; + else { + Fprintf(stderr, "bad mode (%s) for fopen_text_file\n", type); + return FALSE; + } ! if ((write_mode ? out_file : in_file) != (FILE *)0) { Fprintf(stderr, "can only open one text file at at time\n"); return FALSE; } ! fp = fopen(filename, type); ! if (fp == (FILE *)0) { Fprintf(stderr, "cannot open text file %s\n", filename); return FALSE; } *************** *** 420,433 **** if (p) p++; else p = filename; ! tile_set = 0; ! for (i = 0; i < SIZE(text_sets); i++) { ! if (!strcmp(p, text_sets[i])) ! tile_set = i+1; ! } ! tile_set_indx = 0; ! ! if (!strcmp(type, RDTMODE)) { /* Fill placeholder with noise */ if ( !placeholder_init ) { placeholder_init++; --- 518,525 ---- if (p) p++; else p = filename; ! if (!write_mode) { ! in_file = fp; /* Fill placeholder with noise */ if ( !placeholder_init ) { placeholder_init++; *************** *** 435,456 **** ((char*)placeholder)[i]=i%256; } ! read_text_colormap(tile_file); if (!colorsinmainmap) init_colormap(); else merge_colormap(); ! return TRUE; ! } else if (!strcmp(type, WRTMODE)) { if (!colorsinmainmap) { Fprintf(stderr, "no colormap set yet\n"); return FALSE; } ! return(write_text_colormap(tile_file)); ! } else { ! Fprintf(stderr, "bad mode (%s) for fopen_text_file\n", type); ! return FALSE; } } boolean --- 527,561 ---- ((char*)placeholder)[i]=i%256; } ! read_text_colormap(in_file); ! if (!set_tile_size(in_file)) ! return FALSE; if (!colorsinmainmap) init_colormap(); else merge_colormap(); ! } else { ! out_file = fp; if (!colorsinmainmap) { Fprintf(stderr, "no colormap set yet\n"); return FALSE; } ! if (tile_x < 0 || tile_y < 0) { ! Fprintf(stderr, "no tile size set yet\n"); ! return FALSE; ! } ! if (!write_text_colormap(out_file)) ! return FALSE; } + + tile_set = 0; + for (i = 0; i < SIZE(std_text_sets); i++) { + if (!strcmp(p, TEXT_SETS(i))) + tile_set = i+1; + } + tile_set_indx = 0; + + return TRUE; } boolean *************** *** 459,508 **** int *number; char name[BUFSZ]; { ! return(peek_txttile_info(tile_file, ttype, number, name)); } boolean read_text_tile_info(pixels, ttype, number, name) ! pixel (*pixels)[TILE_X]; char *ttype; int *number; char *name; { ! return read_txttile_info(tile_file, pixels, ttype, number, name); } boolean read_text_tile(pixels) ! pixel (*pixels)[TILE_X]; { ! return(read_txttile(tile_file, pixels)); } boolean write_text_tile_info(pixels, ttype, number, name) ! pixel (*pixels)[TILE_X]; const char *ttype; int number; const char *name; { ! write_txttile_info(tile_file, pixels, ttype, number, name); return TRUE; } boolean write_text_tile(pixels) ! pixel (*pixels)[TILE_X]; { ! write_txttile(tile_file, pixels); return TRUE; } boolean fclose_text_file() { ! boolean ret; ! ret = !!fclose(tile_file); ! tile_file = (FILE *)0; return ret; } --- 564,621 ---- int *number; char name[BUFSZ]; { ! return(peek_txttile_info(in_file, ttype, number, name)); } boolean read_text_tile_info(pixels, ttype, number, name) ! pixel (*pixels)[MAX_TILE_X]; char *ttype; int *number; char *name; { ! return read_txttile_info(in_file, pixels, ttype, number, name); } boolean read_text_tile(pixels) ! pixel (*pixels)[MAX_TILE_X]; { ! return(read_txttile(in_file, pixels)); } boolean write_text_tile_info(pixels, ttype, number, name) ! pixel (*pixels)[MAX_TILE_X]; const char *ttype; int number; const char *name; { ! write_txttile_info(out_file, pixels, ttype, number, name); return TRUE; } boolean write_text_tile(pixels) ! pixel (*pixels)[MAX_TILE_X]; { ! write_txttile(out_file, pixels); return TRUE; } boolean fclose_text_file() { ! boolean ret = FALSE; ! if (in_file) ! { ! ret |= !!fclose(in_file); ! in_file = (FILE *)0; ! } ! if (out_file) ! { ! ret |= !!fclose(out_file); ! out_file = (FILE *)0; ! } return ret; } diff -Ncar ../slashem-0.0.6E0F2+SE049/win/share/txtfilt.c ./win/share/txtfilt.c *** ../slashem-0.0.6E0F2+SE049/win/share/txtfilt.c Thu Mar 2 19:56:40 2000 --- ./win/share/txtfilt.c Thu Mar 2 20:01:00 2000 *************** *** 9,107 **** #include "config.h" #include "tile.h" - extern char *FDECL((strdup), (const char *)); - - struct tile { - pixel bitmap[TILE_Y][TILE_X]; - char *name; - unsigned char ph, source; - }; - - static struct tile *tiles=NULL; - static int no_tiles=0; - static int alloc_tiles=0; - - static void - read_tiles() - { - char ttype[BUFSZ]; - int number; - char name[BUFSZ]; - while (peek_text_tile_info(ttype, &number, name)) { - if (no_tiles == alloc_tiles) { - if (alloc_tiles) - alloc_tiles *= 2; - else - alloc_tiles = 1024; - if (!tiles) - tiles = (struct tile *)malloc(alloc_tiles * sizeof(*tiles)); - else - tiles = (struct tile *)realloc(tiles, - alloc_tiles * sizeof(*tiles)); - if (!tiles) { - Fprintf(stderr, "Not enough memory\n"); - exit(EXIT_FAILURE); - } - } - if (!read_text_tile(tiles[no_tiles].bitmap)) - break; - tiles[no_tiles].ph = strcmp(ttype, "placeholder") == 0; - tiles[no_tiles].source = 1; - if (!strcmp(name, "null")) - tiles[no_tiles].name = NULL; - else { - tiles[no_tiles].name = strdup(name); - if (!tiles[no_tiles].name) { - Fprintf(stderr, "Not enough memory\n"); - exit(EXIT_FAILURE); - } - } - no_tiles++; - } - } - static boolean low_res_tile(bitmap) ! pixel (*bitmap)[TILE_X]; { int x, y; ! for(y = 0; y < TILE_Y - 1; y += 2) if (memcmp(bitmap[y], bitmap[y + 1], sizeof(*bitmap))) return FALSE; ! for(x = 0; x < TILE_X - 1; x += 2) ! for(y = 0; y < TILE_Y; y++) if (memcmp(&bitmap[y][x],&bitmap[y][x + 1],sizeof(bitmap[y][x]))) return FALSE; return TRUE; } - static void - write_tiles() - { - const char *type; - int i; - - for(i = 0; i < no_tiles; i++) { - if (low_res_tile(tiles[i].bitmap)) - continue; - - if (tiles[i].ph) - type = "placeholder"; - else - type = "tile"; - - write_text_tile_info(tiles[i].bitmap, type, i, tiles[i].name); - } - } - int main(argc, argv) int argc; char **argv; { if (argc != 3) { Fprintf(stderr, "usage: txtfilt infile outfile\n"); exit(EXIT_FAILURE); --- 9,42 ---- #include "config.h" #include "tile.h" static boolean low_res_tile(bitmap) ! pixel (*bitmap)[MAX_TILE_X]; { int x, y; ! for(y = 0; y < tile_y - 1; y += 2) if (memcmp(bitmap[y], bitmap[y + 1], sizeof(*bitmap))) return FALSE; ! for(x = 0; x < tile_x - 1; x += 2) ! for(y = 0; y < tile_y; y++) if (memcmp(&bitmap[y][x],&bitmap[y][x + 1],sizeof(bitmap[y][x]))) return FALSE; return TRUE; } int main(argc, argv) int argc; char **argv; { + char ttype[BUFSZ]; + int number; + char name[BUFSZ]; + pixel pixels[MAX_TILE_Y][MAX_TILE_X]; + if (argc != 3) { Fprintf(stderr, "usage: txtfilt infile outfile\n"); exit(EXIT_FAILURE); *************** *** 109,120 **** if (!fopen_text_file(argv[1], RDTMODE)) exit(EXIT_FAILURE); - read_tiles(); - fclose_text_file(); - if (!fopen_text_file(argv[2], WRTMODE)) exit(EXIT_FAILURE); ! write_tiles(); fclose_text_file(); exit(EXIT_SUCCESS); --- 44,56 ---- if (!fopen_text_file(argv[1], RDTMODE)) exit(EXIT_FAILURE); if (!fopen_text_file(argv[2], WRTMODE)) exit(EXIT_FAILURE); ! ! while (read_text_tile_info(pixels, ttype, &number, name)) { ! if (!low_res_tile(pixels)) ! write_text_tile_info(pixels, ttype, number, name); ! } fclose_text_file(); exit(EXIT_SUCCESS); diff -Ncar ../slashem-0.0.6E0F2+SE049/win/share/txtmerge.c ./win/share/txtmerge.c *** ../slashem-0.0.6E0F2+SE049/win/share/txtmerge.c Thu Mar 2 19:56:40 2000 --- ./win/share/txtmerge.c Thu Mar 2 20:01:00 2000 *************** *** 15,22 **** extern char *FDECL((strdup), (const char *)); struct tile { - pixel bitmap[TILE_Y][TILE_X]; char *name; unsigned char ph, source; }; --- 15,22 ---- extern char *FDECL((strdup), (const char *)); struct tile { char *name; + pixel *bitmap; unsigned char ph, source; }; *************** *** 26,46 **** static pixel file_bg=DEFAULT_BACKGROUND; static void ! set_background(i) ! int i; { int x, y; const pixel bg = DEFAULT_BACKGROUND; if (file_bg.r == bg.r && file_bg.g == bg.g && file_bg.b == bg.b) return; ! for(y = 0; y < TILE_Y; y++) ! for(x = 0; x < TILE_X; x++) ! if (tiles[i].bitmap[y][x].r == file_bg.r && ! tiles[i].bitmap[y][x].g == file_bg.g && ! tiles[i].bitmap[y][x].b == file_bg.b) { ! tiles[i].bitmap[y][x].r = bg.r; ! tiles[i].bitmap[y][x].g = bg.g; ! tiles[i].bitmap[y][x].b = bg.b; } } --- 26,46 ---- static pixel file_bg=DEFAULT_BACKGROUND; static void ! set_background(bitmap) ! pixel (*bitmap)[MAX_TILE_X]; { int x, y; const pixel bg = DEFAULT_BACKGROUND; if (file_bg.r == bg.r && file_bg.g == bg.g && file_bg.b == bg.b) return; ! for(y = 0; y < tile_y; y++) ! for(x = 0; x < tile_x; x++) ! if (bitmap[y][x].r == file_bg.r && ! bitmap[y][x].g == file_bg.g && ! bitmap[y][x].b == file_bg.b) { ! bitmap[y][x].r = bg.r; ! bitmap[y][x].g = bg.g; ! bitmap[y][x].b = bg.b; } } *************** *** 48,56 **** read_tiles() { char ttype[BUFSZ]; ! int number; char name[BUFSZ]; ! while (peek_text_tile_info(ttype, &number, name)) { if (no_tiles == alloc_tiles) { if (alloc_tiles) alloc_tiles *= 2; --- 48,57 ---- read_tiles() { char ttype[BUFSZ]; ! int i, j, number; char name[BUFSZ]; ! pixel pixels[MAX_TILE_Y][MAX_TILE_X], *p; ! while (read_text_tile_info(pixels, ttype, &number, name)) { if (no_tiles == alloc_tiles) { if (alloc_tiles) alloc_tiles *= 2; *************** *** 65,74 **** Fprintf(stderr, "Not enough memory\n"); exit(EXIT_FAILURE); } } - if (!read_text_tile(tiles[no_tiles].bitmap)) - break; - set_background(no_tiles); tiles[no_tiles].ph = strcmp(ttype, "placeholder") == 0; tiles[no_tiles].source = 1; if (!strcmp(name, "null")) --- 66,86 ---- Fprintf(stderr, "Not enough memory\n"); exit(EXIT_FAILURE); } + for(i = no_tiles; i < alloc_tiles; i++) { + tiles[i].bitmap = (pixel *) + malloc(tile_x * tile_y * sizeof(pixel)); + if (!tiles[i].bitmap) { + Fprintf(stderr, "Not enough memory\n"); + exit(EXIT_FAILURE); + } + } + } + set_background(pixels); + p = tiles[no_tiles].bitmap; + for(j = 0; j < tile_y; j++) { + memcpy(p, &pixels[j], tile_x * sizeof(pixel)); + p += tile_x; } tiles[no_tiles].ph = strcmp(ttype, "placeholder") == 0; tiles[no_tiles].source = 1; if (!strcmp(name, "null")) *************** *** 121,128 **** char ttype[BUFSZ]; int number; char name[BUFSZ]; ! pixel tile[TILE_Y][TILE_X]; ! int i; while (read_text_tile_info(tile, ttype, &number, name)) { for(i = 0; i < no_tiles; i++) --- 133,140 ---- char ttype[BUFSZ]; int number; char name[BUFSZ]; ! pixel tile[MAX_TILE_Y][MAX_TILE_X], *p; ! int i, j; while (read_text_tile_info(tile, ttype, &number, name)) { for(i = 0; i < no_tiles; i++) *************** *** 139,146 **** } if (i != no_tiles) { tiles[i].source = source; ! memcpy(tiles[i].bitmap, tile, sizeof(tiles->bitmap)); ! set_background(i); } else Fprintf(stderr, "info: tile %s ignored\n",name); --- 151,162 ---- } if (i != no_tiles) { tiles[i].source = source; ! set_background(tile); ! p = tiles[i].bitmap; ! for(j = 0; j < tile_y; j++) { ! memcpy(p, &tile[j], tile_x * sizeof(pixel)); ! p += tile_x; ! } } else Fprintf(stderr, "info: tile %s ignored\n",name); *************** *** 151,157 **** write_tiles() { const char *type; ! int i; for(i = 0; i < no_tiles; i++) { if (tiles[i].ph) --- 167,174 ---- write_tiles() { const char *type; ! pixel tile[MAX_TILE_Y][MAX_TILE_X], *p; ! int i, j; for(i = 0; i < no_tiles; i++) { if (tiles[i].ph) *************** *** 159,165 **** else type = "tile"; ! write_text_tile_info(tiles[i].bitmap, type, i, tiles[i].name); } } --- 176,187 ---- else type = "tile"; ! p = tiles[i].bitmap; ! for(j = 0; j < tile_y; j++) { ! memcpy(&tile[j], p, tile_x * sizeof(pixel)); ! p += tile_x; ! } ! write_text_tile_info(tile, type, i, tiles[i].name); } } diff -Ncar ../slashem-0.0.6E0F2+SE049/win/share/xpmread.c ./win/share/xpmread.c *** ../slashem-0.0.6E0F2+SE049/win/share/xpmread.c Thu Mar 2 19:56:40 2000 --- ./win/share/xpmread.c Thu Mar 2 20:01:00 2000 *************** *** 41,59 **** return FALSE; } ! if (image.width % TILE_X) { Fprintf(stderr, "error: width %d not divisible by %d\n", ! image.width, TILE_X); exit(EXIT_FAILURE); } ! tiles_across = image.width / TILE_X; curr_tiles_across = 0; ! if (image.height % TILE_Y) { Fprintf(stderr, "error: height %d not divisible by %d\n", ! image.height, TILE_Y); /* exit(EXIT_FAILURE) */; } ! tiles_down = image.height / TILE_Y; curr_tiles_down = 0; for (i = 0; i < image.ncolors; ++i) { --- 41,59 ---- return FALSE; } ! if (image.width % tile_x) { Fprintf(stderr, "error: width %d not divisible by %d\n", ! image.width, tile_x); exit(EXIT_FAILURE); } ! tiles_across = image.width / tile_x; curr_tiles_across = 0; ! if (image.height % tile_y) { Fprintf(stderr, "error: height %d not divisible by %d\n", ! image.height, tile_y); /* exit(EXIT_FAILURE) */; } ! tiles_down = image.height / tile_y; curr_tiles_down = 0; for (i = 0; i < image.ncolors; ++i) { *************** *** 108,114 **** /* Read a tile. Returns FALSE when there are no more tiles */ boolean read_xpm_tile(pixels) ! pixel (*pixels)[TILE_X]; { int i, j; unsigned int *src; --- 108,114 ---- /* Read a tile. Returns FALSE when there are no more tiles */ boolean read_xpm_tile(pixels) ! pixel (*pixels)[MAX_TILE_X]; { int i, j; unsigned int *src; *************** *** 119,128 **** curr_tiles_down++; if (curr_tiles_down >= tiles_down) return FALSE; } ! src = image.data + curr_tiles_down * TILE_Y * image.width + ! curr_tiles_across * TILE_X; ! for (j = 0; j < TILE_Y; j++) { ! for (i = 0; i < TILE_X; i++) { pixels[j][i].r = ColorMap[CM_RED][src[j * image.width + i]]; pixels[j][i].g = ColorMap[CM_GREEN][src[j * image.width + i]]; pixels[j][i].b = ColorMap[CM_BLUE][src[j * image.width + i]]; --- 119,128 ---- curr_tiles_down++; if (curr_tiles_down >= tiles_down) return FALSE; } ! src = image.data + curr_tiles_down * tile_y * image.width + ! curr_tiles_across * tile_x; ! for (j = 0; j < tile_y; j++) { ! for (i = 0; i < tile_x; i++) { pixels[j][i].r = ColorMap[CM_RED][src[j * image.width + i]]; pixels[j][i].g = ColorMap[CM_GREEN][src[j * image.width + i]]; pixels[j][i].b = ColorMap[CM_BLUE][src[j * image.width + i]]; *************** *** 131,138 **** curr_tiles_across++; /* check for "filler" tile */ ! for (j = 0; j < TILE_Y; j++) { ! for (i = 0; i < TILE_X && i < 4; i += 2) { if (pixels[j][i].r != ColorMap[CM_RED][0] || pixels[j][i].g != ColorMap[CM_GREEN][0] || pixels[j][i].b != ColorMap[CM_BLUE][0] || --- 131,138 ---- curr_tiles_across++; /* check for "filler" tile */ ! for (j = 0; j < tile_y; j++) { ! for (i = 0; i < tile_x && i < 4; i += 2) { if (pixels[j][i].r != ColorMap[CM_RED][0] || pixels[j][i].g != ColorMap[CM_GREEN][0] || pixels[j][i].b != ColorMap[CM_BLUE][0] || *************** *** 171,182 **** boolean split_mode = FALSE; int tile_set = 0; const char *name; ! pixel pixels[TILE_Y][TILE_X]; if (argc == 1) { argc = SIZE(std_args); argv = std_args; } while (argn < argc) { if (!strcmp(argv[argn], "-s")) { --- 171,185 ---- boolean split_mode = FALSE; int tile_set = 0; const char *name; ! pixel pixels[MAX_TILE_Y][MAX_TILE_X]; if (argc == 1) { argc = SIZE(std_args); argv = std_args; } + + tile_x = 16; + tile_y = 16; while (argn < argc) { if (!strcmp(argv[argn], "-s")) { diff -Ncar ../slashem-0.0.6E0F2+SE049/win/win32/tile2bmp.c ./win/win32/tile2bmp.c *** ../slashem-0.0.6E0F2+SE049/win/win32/tile2bmp.c Thu Mar 2 19:56:08 2000 --- ./win/win32/tile2bmp.c Thu Mar 2 20:01:00 2000 *************** *** 91,97 **** #if COLORS_IN_USE==16 uchar packtile[MAX_Y][MAX_X]; #else ! uchar packtile[TILE_Y][TILE_X]; #endif } PACK bmp; #pragma pack() --- 91,97 ---- #if COLORS_IN_USE==16 uchar packtile[MAX_Y][MAX_X]; #else ! uchar packtile[MAX_TILE_Y][MAX_TILE_X]; #endif } PACK bmp; #pragma pack() *************** *** 100,110 **** FILE *tibfile2; ! pixel tilepixels[TILE_Y][TILE_X]; static void FDECL(build_bmfh,(BITMAPFILEHEADER *)); static void FDECL(build_bmih,(BITMAPINFOHEADER *)); ! static void FDECL(build_bmptile,(pixel (*)[TILE_X])); char *tilefiles[] = { "../win/share/monsters.txt", "../win/share/objects.txt", --- 100,110 ---- FILE *tibfile2; ! pixel tilepixels[MAX_TILE_Y][MAX_TILE_X]; static void FDECL(build_bmfh,(BITMAPFILEHEADER *)); static void FDECL(build_bmih,(BITMAPINFOHEADER *)); ! static void FDECL(build_bmptile,(pixel (*)[MAX_TILE_X])); char *tilefiles[] = { "../win/share/monsters.txt", "../win/share/objects.txt", *************** *** 180,191 **** build_bmptile(tilepixels); tilecount++; #if BITCOUNT==4 ! xoffset += (TILE_X / 2); #else ! xoffset += TILE_X; #endif if (xoffset >= MAX_X) { ! yoffset += TILE_Y; xoffset = 0; } } --- 180,191 ---- build_bmptile(tilepixels); tilecount++; #if BITCOUNT==4 ! xoffset += (tile_x / 2); #else ! xoffset += tile_x; #endif if (xoffset >= MAX_X) { ! yoffset += tile_y; xoffset = 0; } } *************** *** 242,254 **** static void build_bmptile(pixels) ! pixel (*pixels)[TILE_X]; { int cur_x, cur_y, cur_color; int x,y; ! for (cur_y = 0; cur_y < TILE_Y; cur_y++) { ! for (cur_x = 0; cur_x < TILE_X; cur_x++) { for (cur_color = 0; cur_color < num_colors; cur_color++) { if (ColorMap[CM_RED][cur_color] == pixels[cur_y][cur_x].r && ColorMap[CM_GREEN][cur_color]== pixels[cur_y][cur_x].g && --- 242,254 ---- static void build_bmptile(pixels) ! pixel (*pixels)[MAX_TILE_X]; { int cur_x, cur_y, cur_color; int x,y; ! for (cur_y = 0; cur_y < tile_y; cur_y++) { ! for (cur_x = 0; cur_x < tile_x; cur_x++) { for (cur_color = 0; cur_color < num_colors; cur_color++) { if (ColorMap[CM_RED][cur_color] == pixels[cur_y][cur_x].r && ColorMap[CM_GREEN][cur_color]== pixels[cur_y][cur_x].g && diff -Nacr ../slashem-0.0.6E0F2+SE049/sys/unix/Makefile.src ./sys/unix/Makefile.src *** ../slashem-0.0.6E0F2+SE049/sys/unix/Makefile.src Thu Mar 2 19:56:07 2000 --- ./sys/unix/Makefile.src Fri Mar 3 19:35:33 2000 *************** *** 616,622 **** $(CC) $(CFLAGS) $(WINGTKCFLAGS) -c ../win/gtk/gtkmenu.c gtkyn.o: ../win/gtk/gtkyn.c ../include/winGTK.h $(HACK_H) $(CC) $(CFLAGS) $(WINGTKCFLAGS) -c ../win/gtk/gtkyn.c ! gtkmap.o: ../win/gtk/gtkmap.c ../include/winGTK.h $(HACK_H) $(CC) $(CFLAGS) $(WINGTKCFLAGS) -c ../win/gtk/gtkmap.c gtkmessage.o: ../win/gtk/gtkmessage.c ../include/winGTK.h $(HACK_H) $(CC) $(CFLAGS) $(WINGTKCFLAGS) -c ../win/gtk/gtkmessage.c --- 616,622 ---- $(CC) $(CFLAGS) $(WINGTKCFLAGS) -c ../win/gtk/gtkmenu.c gtkyn.o: ../win/gtk/gtkyn.c ../include/winGTK.h $(HACK_H) $(CC) $(CFLAGS) $(WINGTKCFLAGS) -c ../win/gtk/gtkyn.c ! gtkmap.o: ../win/gtk/gtkmap.c ../include/winGTK.h $(HACK_H) ../include/dlb.h $(CC) $(CFLAGS) $(WINGTKCFLAGS) -c ../win/gtk/gtkmap.c gtkmessage.o: ../win/gtk/gtkmessage.c ../include/winGTK.h $(HACK_H) $(CC) $(CFLAGS) $(WINGTKCFLAGS) -c ../win/gtk/gtkmessage.c