// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman // Ken Silverman's official web site: "http://www.advsys.net/ken" // See the included license file "BUILDLIC.TXT" for license info. // // This file has been modified from Ken Silverman's original release // by Jonathon Fowler (jf@jonof.id.au) #include "compat.h" #include "pragmas.h" #define MAXWADS 4096 static int artversion, localtilestart, localtileend; static int fil1, fil2; static char wadata[MAXWADS][8]; static int wadplc[MAXWADS], wadlen[MAXWADS], numwads; static int xoffses[1024], ylookup[256], picanm[MAXWADS]; static short tilesizx[MAXWADS], tilesizy[MAXWADS]; static char pal[768], palookup[8192]; static char screen[65536], tempbuf[131072]; void loadwadheader(void) { int i, j; Bread(fil1,&tempbuf[0],12); numwads = ((int)tempbuf[4])+(((int)tempbuf[5])<<8)+(((int)tempbuf[6])<<16)+(((int)tempbuf[7])<<24); i = ((int)tempbuf[8])+(((int)tempbuf[9])<<8)+(((int)tempbuf[10])<<16)+(((int)tempbuf[11])<<24); Blseek(fil1,i,BSEEK_SET); Bread(fil1,&tempbuf[0],numwads*16); j = 0; for(i=0;i>= 2; i = 0; while (Bstrncasecmp(wadata[i],"COLORMAP",8) != 0) i++; Blseek(fil1,wadplc[i],BSEEK_SET); Bread(fil1,palookup,8192); if ((fil3 = Bopen("palette.dat",BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) { Bprintf("Cannot save palette.dat\n"); exit(0); } Bwrite(fil3,pal,768); danumshades = 32; Bwrite(fil3,&danumshades,2); Bwrite(fil3,palookup,8192); Bclose(fil3); } void saveart (short tilenum, short xlen, short ylen) { int i, x, p, pend; pend = ylookup[ylen]; tilesizx[tilenum] = xlen; tilesizy[tilenum] = ylen; i = 0; for(x=0;x 320) || (ysiz > 200)) goto skipit; i = 8; for(zx=0;zx>2,0xffffffff); for(x=0;x\n"); Bprintf(" Creates TILES000.ART, PALETTE.DAT, and NAMES.H in current directory.\n"); Bprintf(" Ex: wad2art c:\\doom\\doom.wad\n"); exit(0); } strcpy(wadfile,argv[1]); if (strchr(wadfile,'.') == 0) strcat(wadfile,".wad"); if ((fil1 = Bopen(wadfile,BO_BINARY|BO_RDONLY,BS_IREAD)) == -1) { Bprintf("Wad not found\n"); exit(0); } if ((fil2 = Bopen("tiles000.art",BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY,BS_IREAD|BS_IWRITE)) == -1) { Bprintf("Can't open art file\n"); exit(0); } j = 0; for(i=0;i<256;i++) { ylookup[i] = j; j += 320; } Bprintf("Loading wad header...\n"); loadwadheader(); Blseek(fil2,16+(numwads<<3),SEEK_SET); for(i=0;i