// "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 (jonof@edgenetwk.com) #include "compat.h" #include "pragmas.h" #define MAXWADS 4096 static long artversion, localtilestart, localtileend; static long fil1, fil2; static char wadata[MAXWADS][8]; static long wadplc[MAXWADS], wadlen[MAXWADS], numwads; static long 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) { long i, j; Bread(fil1,&tempbuf[0],12); numwads = ((long)tempbuf[4])+(((long)tempbuf[5])<<8)+(((long)tempbuf[6])<<16)+(((long)tempbuf[7])<<24); i = ((long)tempbuf[8])+(((long)tempbuf[9])<<8)+(((long)tempbuf[10])<<16)+(((long)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) { printf("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) { long i, x, p, pend; pend = ylookup[ylen]; tilesizx[tilenum] = xlen; tilesizy[tilenum] = ylen; i = 0; for(x=0;x= 10000) buffer[j++] = ((i/10000)%10)+48; if (i >= 1000) buffer[j++] = ((i/1000)%10)+48; if (i >= 100) buffer[j++] = ((i/100)%10)+48; if (i >= 10) buffer[j++] = ((i/10)%10)+48; buffer[j++] = (i%10)+48; buffer[j++] = 13; buffer[j++] = 10; Bwrite(fil3,&buffer[0],j); } Bclose(fil3); } void showart (char *part) { char yoff, ylen; short xsiz, ysiz; long i, j, z, zx, zzx, x, y, p, pend, junk, curplc; curplc = -1; if ((Bstrncasecmp(part,"L_START",7) == 0) || (Bstrncasecmp(part,"S_START",7) == 0) || (Bstrncasecmp(part,"P_START",7) == 0)) { if (Bstrncasecmp(part,"L_START",7) == 0) z = 462; else { z = 0; while (Bstrncasecmp(wadata[z],part,7) != 0) z++; z++; } do { if (Bstrncasecmp(wadata[z],"P1_START",8) == 0) z++; if (Bstrncasecmp(wadata[z],"P1_END",6) == 0) z++; if (Bstrncasecmp(wadata[z],"P2_START",8) == 0) z++; if (Bstrncasecmp(wadata[z],"S_START",7) == 0) break; if (Bstrncasecmp(wadata[z],"S_END",5) == 0) break; if (Bstrncasecmp(wadata[z],"P_END",5) == 0) break; if (curplc != wadplc[z]) Blseek(fil1,wadplc[z],BSEEK_SET); read(fil1,&tempbuf[0],wadlen[z]); curplc = wadplc[z]+wadlen[z]; xsiz = (long)tempbuf[0]+(((long)tempbuf[1])<<8); ysiz = (long)tempbuf[2]+(((long)tempbuf[3])<<8); if ((xsiz <= 0) || (ysiz <= 0) || (xsiz > 320) || (ysiz > 200)) goto skipit; i = 8; for(zx=0;zx>2,0xffffffff); for(x=0;x