//------------------------------------------------------------------------- /* Copyright (C) 1996, 2003 - 3D Realms Entertainment This file is part of Duke Nukem 3D version 1.5 - Atomic Edition Duke Nukem 3D is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Original Source: 1996 - Allen Blum Prepared for public release: 05/24/2003 - Charlie Wiederhold, 3D Realms */ //------------------------------------------------------------------------- /* ******************************************************** ASTUB.C (c) 1996 Allen H. Blum III ******************************************************** Specs: Duke Lookup Table 1 : Blue 2 : Red 3 : Normal for Sky 4 : Black Shadow 5 : 6 : Night Vision 7 : Yellow 8 : Green Duke Sprite 9 : Blue 10 : Red 11 : Green 12 : Grey 13 : Ninja 14 : G.I. Duke 15 : Brown 16 : Postal Duke (Dark Blue) 21 : Blue -> Red 22 : Blue -> Green 23 : Blue -> Yellow ******************************************************** */ #if PLATFORM_DOS #include #endif #include #include #include #include #include #include #include "buildengine/engine.h" #include "buildengine/platform.h" #include "buildengine/build.h" #include "buildengine/pragmas.h" #include "buildengine/bstub.h" #include "buildengine/cache1d.h" /* rcg05232001 need groupfile support. */ #include "buildengine/display.h" /* rcg05232001 need some "vesa" routines. */ #include "names.h" /* defined in build.c ... */ void editinput(void); void clearmidstatbar16(void); short getnumber16(char namestart[80], short num, long maxnumber); void printmessage16(char name[82]); #define TICSPERFRAME 3 //#include "water.c" char *Myname = "stryker@metronet.com"; extern char keystatus[]; extern short defaultspritecstat; extern long posx, posy, posz, horiz, qsetmode; extern short ang, cursectnum; extern short ceilingheinum, floorheinum; extern char names[MAXTILES][17]; extern long zmode, kensplayerheight, zlock; extern short editstatus, searchit; extern long searchx, searchy; //search input extern short searchsector, searchwall, searchstat; //search output static short temppicnum, tempcstat; static char tempshade, tempxrepeat, tempyrepeat, somethingintab = 255; static long temphitag,templotag; static long ototalclock = 0; static long clockval[16], clockcnt = 0; #define NUMOPTIONS 8 #define NUMKEYS 19 static long vesares[13][2] = { {320,200}, {360,200}, {320,240}, {360,240}, {320,400}, {360,400}, {640,350}, {640,400}, {640,480}, {800,600}, {1024,768},{1280,1024}, {1600,1200} }; static char option[NUMOPTIONS] = {0,0,0,0,0,0,1,0}; static char keys[NUMKEYS] = { 0xc8,0xd0,0xcb,0xcd,0x2a,0x9d,0x1d,0x39, 0x1e,0x2c,0xd1,0xc9,0x47,0x49, 0x9c,0x1c,0xd,0xc,0xf, }; extern char buildkeys[NUMKEYS]; //extern void __interrupt __far timerhandler(void); long xoldtimerhandler; #define COKE 52 #define MAXHELP2D 9 char *Help2d[MAXHELP2D]= { " ' M = Memory", " ' 1 = Captions ", // " ' 2 = ", " ' 3 = Captions Toggle", // " ' 4 = MIN FRAMES RATE", // " ' 5 = MOTORCYCLE", " ' 9 = Swap HI LO", // " ' 0 = SHRINK MAP 50", " F8 = Current Wall/Sprite", " F9 = Current Sector", " [ = Search Forward", " ] = Search Backward", " ~ = HELP OFF" }; #define MAXMODE32D 7 char *Mode32d[MAXMODE32D]= { "NONE", "SECTORS", "WALLS", "SPRITES", "ALL", "ITEMS ONLY", "CURRENT SPRITE ONLY" }; #define MAXSKILL 5 char *SKILLMODE[MAXSKILL]= { "BEGINNER", "EASY", "NORMAL", "NOT EASY", "ALL", }; #define MAXNOSPRITES 4 char *ALPHABEASTLOADOMAGA1[MAXNOSPRITES]= { "DISPLAY ALL SPRITES", "NO EFFECTORS", "NO ACTORS", "NONE", }; short MinRate=24, MinD=3; // CTW - MODIFICATION // Good to know Allen has changed in all these years. ;) // CTW END - MODIFICATION char *Slow[8]= { "SALES = 0,000,000 ***********************", "100% OF NOTHING IS !! ********************", "RENDER IN PROGRESS ***********************", "YOUR MOTHER IS A WHORE *******************", "YOU SUCK DONKEY **************************", "FUCKIN PISS ANT **************************", "PISS ANT *********************************", "SLOW *************************************" }; #define MAXHELP3D 15 char *Help3d[MAXHELP3D]= { "3D KEYS HELP", " ", " F1 = HELP TOGGLE", " ' R = FRAMERATE TOGGLE", " ' D = SKILL MODE", " ' W = TOGGLE SPRITE DISPLAY", " ' G = GRAPHIC TOGGLE", " ' Y = TOGGLE PURPLE BACKGROUND", " ' ENTER = COPY GRAPHIC ONLY", " ' T = CHANGE LOTAG", " ' H = CHANGE HITAG", " ' S = CHANGE SHADE", " ' V = CHANGE VISIBILITY", " ' C = CHANGE GLOBAL SHADE", " ' DEL = CSTAT=0", }; /******* VARS ********/ static char tempbuf[1024]; //1024 static int numsprite[MAXSPRITES]; static int multisprite[MAXSPRITES]; static char lo[32]; static const char *levelname; static short curwall=0,wallpicnum=0,curwallnum=0; static short cursprite=0,curspritenum=0; static short cursector_lotag=0,cursectornum=0; static short search_lotag=0,search_hitag=0; static char wallsprite=0; static char helpon=0; static char on2d3d=0; //static char onwater=0; static char onnames=4; static char usedcount=0; long mousxplc,mousyplc; long ppointhighlight; static int counter=0; char nosprites=0,purpleon=0,skill=4; char framerateon=1,tabgraphic=0; static char sidemode=0; extern long vel, svel, angvel; long xvel, yvel, hvel, timeoff; static char once=0; void Ver() { sprintf(tempbuf,"DUKE NUKEM BUILD: V032696"); if (qsetmode == 200) //In 3D mode { printext256(60*8,24*8,11,-1,tempbuf,1); rotatesprite((320-8)<<16,(200-8)<<16,64<<9,0,SPINNINGNUKEICON+(((4-totalclock>>3))&7),0,0,0,0,0,xdim-1,ydim-1); }else { printext16(0,0,15,-1,tempbuf,0); } } void PrintStatus(char *string,int num,char x,char y,char color) { sprintf(tempbuf,"%s %d",string,num); printext16(x*8,y*8,color,-1,tempbuf,0); } void SpriteName(short spritenum, char *lo2) { sprintf(lo2,names[sprite[spritenum].picnum]); }// end SpriteName void ExtLoadMap(const char *mapname) { long i; long sky=0; int j; // PreCache Wall Tiles for(j=0;j=20 && sprite[j].picnum<=59) { if(sprite[j].picnum==26) {sprite[j].xrepeat = 8; sprite[j].yrepeat = 8;} else {sprite[j].xrepeat = 32; sprite[j].yrepeat = 32;} } } levelname=mapname; pskyoff[0]=0; for(i=0;i<8;i++) pskyoff[i]=0; for(i=0;i>2)+((stat&16)>>2)^((stat&8)>>1), windowx1,windowy1,windowx2,windowy2); } void putsprite (long thex, long they, long zoom, short rot, short tilenum, signed char shade, char dapalnum) {char stat=0; rotatesprite(thex<<16,they<<16,65536L-zoom,(rot+(stat&8))<<7,tilenum,shade,dapalnum, ((stat&1^1)<<4)+(stat&2)+((stat&4)>>2)+((stat&16)>>2)^((stat&8)>>1), windowx1,windowy1,windowx2,windowy2); } void ExtSaveMap(const char *mapname) { saveboard("backup.map",&posx,&posy,&posz,&ang,&cursectnum); } const char *ExtGetSectorCaption(short sectnum) { if(!(onnames==1 || onnames==4)) { tempbuf[0] = 0; return(tempbuf); } if ((sector[sectnum].lotag|sector[sectnum].hitag) == 0) { tempbuf[0] = 0; } else { switch((unsigned short)sector[sectnum].lotag) { // case 1 : sprintf(lo,"WATER"); break; // case 2 : sprintf(lo,"UNDERWATER"); break; // case 3 : sprintf(lo,"EARTHQUAKE"); break; default : sprintf(lo,"%hu",(unsigned short)sector[sectnum].lotag); break; } sprintf(tempbuf,"%hu,%s", (unsigned short)sector[sectnum].hitag, lo); } return(tempbuf); } const char *ExtGetWallCaption(short wallnum) { long i=0; if(!(onnames==2 || onnames==4)) { tempbuf[0] = 0; return(tempbuf); } if(keystatus[0x57]>0) // f11 Grab pic 0x4e + { wallpicnum = wall[curwall].picnum; sprintf(tempbuf,"Grabed Wall Picnum %d",wallpicnum); printmessage16(tempbuf); } // HERE if(keystatus[0x1a]>0) // [ search backward { keystatus[0x1a]=0; if(wallsprite==0) { SearchSectorsBackward(); } else if(wallsprite==1) { if(curwallnum>0) curwallnum--; for(i=curwallnum;i>=0;i--) { if( (wall[i].picnum==wall[curwall].picnum) &&((search_lotag==0)|| (search_lotag!=0 && search_lotag==wall[i].lotag)) &&((search_hitag==0)|| (search_hitag!=0 && search_hitag==wall[i].hitag)) ) { posx=(wall[i].x)-(( (wall[i].x)-(wall[wall[i].point2].x) )/2); posy=(wall[i].y)-(( (wall[i].y)-(wall[wall[i].point2].y) )/2); printmessage16("< Wall Search : Found"); // curwallnum--; keystatus[0x1a]=0; return(tempbuf); } curwallnum--; } printmessage16("< Wall Search : none"); } else if(wallsprite==2) { if(curspritenum>0) curspritenum--; for(i=curspritenum;i>=0;i--) { if( (sprite[i].picnum==sprite[cursprite].picnum && sprite[i].statnum==0 ) &&((search_lotag==0)|| (search_lotag!=0 && search_lotag==sprite[i].lotag)) &&((search_hitag==0)|| (search_hitag!=0 && search_hitag==sprite[i].hitag)) ) { posx=sprite[i].x; posy=sprite[i].y; ang= sprite[i].ang; printmessage16("< Sprite Search : Found"); // curspritenum--; keystatus[0x1a]=0; return(tempbuf); } curspritenum--; } printmessage16("< Sprite Search : none"); } } if(keystatus[0x1b]>0) // ] search forward { keystatus[0x1b]=0; if(wallsprite==0) { SearchSectorsForward(); } else if(wallsprite==1) { if(curwallnum Wall Search : Found"); // curwallnum++; keystatus[0x1b]=0; return(tempbuf); } curwallnum++; } printmessage16("> Wall Search : none"); } else if(wallsprite==2) { if(curspritenum Sprite Search : Found"); // curspritenum++; keystatus[0x1b]=0; return(tempbuf); } curspritenum++; } printmessage16("> Sprite Search : none"); } } if ((wall[wallnum].lotag|wall[wallnum].hitag) == 0) { tempbuf[0] = 0; } else { sprintf(tempbuf,"%hu,%hu",(unsigned short)wall[wallnum].hitag, (unsigned short)wall[wallnum].lotag); } return(tempbuf); } //end const char *ExtGetSpriteCaption(short spritenum) { if( onnames!=5 && onnames!=6 && (!(onnames==3 || onnames==4)) ) { tempbuf[0] = 0; return(tempbuf); } if( onnames==5 && ( ((unsigned short)sprite[spritenum].picnum <= 9 ) || ((unsigned short)sprite[spritenum].picnum == SEENINE ) ) ) { tempbuf[0] = 0; return(tempbuf); } if( onnames==6 && (unsigned short)sprite[spritenum].picnum != (unsigned short)sprite[cursprite].picnum ) { tempbuf[0] = 0; return(tempbuf); } tempbuf[0] = 0; if ((sprite[spritenum].lotag|sprite[spritenum].hitag) == 0) { SpriteName(spritenum,lo); if(lo[0]!=0) { if(sprite[spritenum].pal==1) sprintf(tempbuf,"%s-M",lo); else sprintf(tempbuf,"%s",lo); } } else if( (unsigned short)sprite[spritenum].picnum == 175) { sprintf(lo,"%hu",(unsigned short)sprite[spritenum].lotag); sprintf(tempbuf,"%hu,%s",(unsigned short)sprite[spritenum].hitag,lo); } else { SpriteName(spritenum,lo); sprintf(tempbuf,"%hu,%hu %s", (unsigned short)sprite[spritenum].hitag, (unsigned short)sprite[spritenum].lotag, lo); } return(tempbuf); } //end //printext16 parameters: //printext16(long xpos, long ypos, short col, short backcol, // char name[82], char fontsize) // xpos 0-639 (top left) // ypos 0-479 (top left) // col 0-15 // backcol 0-15, -1 is transparent background // name // fontsize 0=8*8, 1=3*5 //drawline16 parameters: // drawline16(long x1, long y1, long x2, long y2, char col) // x1, x2 0-639 // y1, y2 0-143 (status bar is 144 high, origin is top-left of STATUS BAR) // col 0-15 void TotalMem() { char incache[8192]; int i,j,tottiles,totsprites,totactors; for(i=0;i<4096;i++) incache[i] = 0; for(i=0;i= 0) incache[wall[i].overpicnum] = 1; } tottiles = 0; for(i=0;i<4096;i++) if (incache[i] > 0) tottiles += tilesizx[i]*tilesizy[i]; for(i=0;i<4096;i++) incache[i] = 0; for(i=0;i 0) { switch(i) { case LIZTROOP : case LIZTROOPRUNNING : case LIZTROOPSTAYPUT : case LIZTROOPSHOOT : case LIZTROOPJETPACK : case LIZTROOPONTOILET : case LIZTROOPDUCKING : totactors+=ActorMem(LIZTROOP); incache[LIZTROOP]=0; incache[LIZTROOPRUNNING]=0; incache[LIZTROOPSTAYPUT]=0; incache[LIZTROOPSHOOT]=0; incache[LIZTROOPJETPACK]=0; incache[LIZTROOPONTOILET]=0; incache[LIZTROOPDUCKING]=0; break; case OCTABRAIN : case OCTABRAINSTAYPUT: totactors+=ActorMem(OCTABRAIN); incache[OCTABRAIN]=0; incache[OCTABRAINSTAYPUT]=0; break; case DRONE : totactors+=ActorMem(DRONE); incache[DRONE]=0; break; case COMMANDER : totactors+=ActorMem(COMMANDER); incache[COMMANDER]=0; break; case RECON : totactors+=ActorMem(RECON); incache[RECON]=0; break; case PIGCOP : totactors+=ActorMem(COMMANDER); incache[PIGCOP]=0; break; case LIZMAN : case LIZMANSTAYPUT : case LIZMANSPITTING : case LIZMANFEEDING : case LIZMANJUMP : totactors+=ActorMem(LIZMAN); incache[LIZMAN]=0; incache[LIZMANSTAYPUT]=0; incache[LIZMANSPITTING]=0; incache[LIZMANFEEDING]=0; incache[LIZMANJUMP]=0; break; case BOSS1 : totactors+=ActorMem(BOSS1); incache[BOSS1]=0; break; case BOSS2 : totactors+=ActorMem(BOSS2); incache[BOSS2]=0; break; case BOSS3 : totactors+=ActorMem(BOSS3); incache[BOSS3]=0; break; default: totsprites += tilesizx[i]*tilesizy[i]; } } } clearmidstatbar16(); printext16(1*8,4*8,11,-1,"Memory Status",0); PrintStatus("Total Tiles = ",tottiles,2,6,11); PrintStatus("Total Sprites = ",totsprites,2,7,11); PrintStatus("Total Actors = ",totactors,2,8,11); PrintStatus("Total Memory = ",(tottiles+totsprites+totactors),2,10,11); PrintStatus("Total W/Duke = ",(tottiles+totsprites+totactors+ActorMem(APLAYER)),2,12,11); } void ExtShowSectorData(short sectnum) //F5 { short statnum=0; int x,x2,y; int nexti; int i,c=0; int secrets=0; int totalactors1=0,totalactors2=0,totalactors3=0,totalactors4=0; int totalrespawn=0; for(i=0;ixmax) xmax=x; } tempbuf[x]=0; printext16(xx*4,(y*6)+2,11,-1,tempbuf,1); x=0; y++; if(y>18) {col++; y=6; xx+=xmax; xmax=0;} } kclose(fp); }// end Show2dText void Show3dText(char *name) { int i,fp; char x=0,y=4,xmax=0,xx=0,col=0,t; if((fp=kopen4load(name,0)) == -1) { printext256(1*4,4*8,11,-1,"ERROR: file not found.",0); return; } t=65; while(t!=EOF && col<5) { kread(fp,&t,1); while(t!=EOF && t!='\n' && x<250) { tempbuf[x]=t; kread(fp,&t,1); x++; if(x>xmax) xmax=x; } tempbuf[x]=0; printext256(xx*4,(y*6)+2,11,-1,tempbuf,1); x=0; y++; if(y>18) {col++; y=6; xx+=xmax; xmax=0;} } kclose(fp); }// end Show3dText void ShowHelpText(char *name) { FILE *fp; int i,t; char x=0,y=4,xmax=0,xx=0,col=0; if((fp=fopen("helpdoc.txt","rb")) == NULL) { printext256(1*4,4*8,11,-1,"ERROR: file not found.",0); return; } /* fgets(tempbuf,80,fp); while(!feof(fp) && strcmp(tempbuf,"SectorEffector")) { fgets(tempbuf,80,fp); } */ y=2; fgets(tempbuf,80,fp); strcat(tempbuf,"\n"); while(!feof(fp) && !(strcmp(tempbuf,"SectorEffector")==0)) { fgets(tempbuf,80,fp); strcat(tempbuf,"\n"); printext256(x*4,(y*6)+2,11,-1,tempbuf,1); y++; } fclose(fp); }// end ShowHelpText void ExtShowSpriteData(short spritenum) //F6 { Show2dText("sehelp.hlp"); }// end ExtShowSpriteData void ExtEditSectorData(short sectnum) //F7 { Show2dText("sthelp.hlp"); }// end ExtEditSectorData void ExtEditWallData(short wallnum) //F8 { if(qsetmode!=480) return; wallsprite=1; curwall = wallnum; curwallnum = 0; curspritenum = 0; cursectornum = 0; search_lotag=getnumber16("Enter Wall Search Lo-Tag : ", search_lotag, 65536L); search_hitag=getnumber16("Enter Wall Search Hi-Tag : ", search_hitag, 65536L); sprintf(tempbuf,"Current Wall %d lo=%d hi=%d", curwall,search_lotag,search_hitag); printmessage16(tempbuf); } void ExtEditSpriteData(short spritenum) //F8 { if(qsetmode!=480) return; wallsprite=2; cursprite = spritenum; curwallnum = 0; curspritenum = 0; cursectornum = 0; search_lotag=getnumber16("Enter Sprite Search Lo-Tag : ", search_lotag, 65536L); search_hitag=getnumber16("Enter Sprite Search Hi-Tag : ", search_hitag, 65536L); sprintf(tempbuf,"Current Sprite %d %s lo=%d hi=%d", cursprite,names[sprite[cursprite].picnum],search_lotag,search_hitag); printmessage16(tempbuf); } char GAMEpalette[768]; char WATERpalette[768]; char SLIMEpalette[768]; char TITLEpalette[768]; char REALMSpalette[768]; char BOSS1palette[768]; ReadGamePalette() { int i,fp; if((fp=kopen4load("palette.dat",0)) == -1) return; kread(fp,GAMEpalette,768); for(i=0;i<768;++i) GAMEpalette[i]=GAMEpalette[i]; kclose(fp); } void ReadPaletteTable() { int i,j,fp; char num_tables,lookup_num; if((fp=kopen4load("lookup.dat",0)) == -1) return; kread(fp,&num_tables,1); for(j=0;j4) skill=0; sprintf(tempbuf,"%s",SKILLMODE[skill]); printext256(1*4,1*8,11,-1,tempbuf,0); } */ if(keystatus[0x28]==1 && keystatus[0x22]==1) // ' g { keystatus[0x22] = 0; tabgraphic=!tabgraphic; if(tabgraphic) printext256(1*4,1*8,11,-1,"Graphics ON",0); else printext256(1*4,1*8,11,-1,"Graphics OFF",0); } if(keystatus[0x28]==1 && keystatus[0x13]==1) // ' r { keystatus[0x13] = 0; framerateon=!framerateon; if(framerateon) printext256(1*4,1*8,11,-1,"Framerate ON",0); else printext256(1*4,1*8,11,-1,"Framerate OFF",0); } if(keystatus[0x28]==1 && keystatus[0x11]==1) // ' w { keystatus[0x11] = 0; nosprites++; if(nosprites>3) nosprites=0; sprintf(tempbuf,"%s",ALPHABEASTLOADOMAGA1[nosprites]); printext256(1*4,1*8,11,-1,tempbuf,0); } if(keystatus[0x28]==1 && keystatus[0x15]==1) // ' y { keystatus[0x15] = 0; purpleon=!purpleon; if(nosprites>3) nosprites=0; if(purpleon) printext256(1*4,1*8,11,-1,"Purple ON",0); else printext256(1*4,1*8,11,-1,"Purple OFF",0); } if(keystatus[0x28]==1 && keystatus[0x2e]==1) // ' C { keystatus[0x2e] = 0; switch (searchstat) { case 0: case 4: for(i=0;i0) // TAB : USED { usedcount=!usedcount; count=0; for(i=0;i>= 1; sector[i].floorz >>= 1; } for(i=0;i>= 1; wall[i].y >>= 1; wall[i].yrepeat = min(wall[i].yrepeat<<1,255); } for(i=0;i>= 1; sprite[i].y >>= 1; sprite[i].z >>= 1; sprite[i].xrepeat = max(sprite[i].xrepeat>>1,1); sprite[i].yrepeat = max(sprite[i].yrepeat>>1,1); } } /* shrink if(keystatus[0x28]==1 && keystatus[0x0b]==1) // ' 0 { keystatus[0x0b]=0; for(i=0;i>= 1; sector[i].floorz >>= 1; } for(i=0;i>= 1; wall[i].y >>= 1; wall[i].yrepeat = min(wall[i].yrepeat<<1,255); } for(i=0;i>= 1; sprite[i].y >>= 1; sprite[i].z >>= 1; sprite[i].xrepeat = max(sprite[i].xrepeat>>1,1); sprite[i].yrepeat = max(sprite[i].yrepeat>>1,1); } } */ if(keystatus[0x28]==1 && keystatus[0x02]==1) // ' 1 { on2d3d=!on2d3d; keystatus[0x02]=0; } if(keystatus[0x28]==1 && keystatus[0x04]==1) // ' 3 { onnames++; if(onnames>6) onnames=0; keystatus[0x04]=0; sprintf(tempbuf,"Mode %d %s",onnames,Mode32d[onnames]); printmessage16(tempbuf); // clearmidstatbar16(); // for(i=0;i=20 && sprite[i].picnum<=59) { sprite[i].xrepeat = 32; sprite[i].yrepeat = 32; } } } */ /* Motorcycle ha ha ha if(keystatus[0x28]==1 && keystatus[0x06]==1) // ' 5 { keystatus[0x06]=0; sidemode++; if (sidemode > 2) sidemode = 0; if (sidemode == 1) { editstatus = 0; zmode = 2; posz = ((sector[cursectnum].ceilingz+sector[cursectnum].floorz)>>1); } else { editstatus = 1; zmode = 1; } } */ if(keystatus[0x28]==1 && keystatus[0x0a]==1) // ' 9 : swap hilo { keystatus[0x0b]=0; temp=sprite[cursprite].lotag; sprite[cursprite].lotag=sprite[cursprite].hitag; sprite[cursprite].hitag=temp; } if(keystatus[0x28]==1 && keystatus[0x32]==1) // ' m : Memory Usage { keystatus[0x32]=0; TotalMem(); } }// end key2d void ExtInit(void) { long fil; printf("------------------------------------------------------------------------------\n"); printf("BUILD.EXE Copyright (c) 1993 - 1996 Ken Silverman, 3D Realms Entertainment.\n"); printf("This version of BUILD was created for Duke Nukem 3D and parts were modified\n"); printf("by Allen H. Blum III.\n"); printf("\n"); printf("IMPORTANT: The Build Editor and associated tools and utilities are NOT\n"); printf("shareware and may NOT be freely distributed to any BBS, CD, floppy, or\n"); printf("any other media. These tools may NOT be sold or repackaged for sale in\n"); printf("a commercial product.\n"); printf("\n"); printf("Any levels created with these editors and tools may only be used with the\n"); printf("full (registered) copy of Duke Nukem 3D, and not the shareware version.\n"); printf("Please refer to LICENSE.DOC for further information on levels created with\n"); printf("BUILD.EXE.\n"); printf("\n"); printf("Please help us protect against software piracy (which drives up software\n"); printf("prices) by following these simple rules.\n"); printf("\n"); printf("Thank You!\n"); printf("------------------------------------------------------------------------------\n"); //getch(); initgroupfile("duke3d.grp"); if ((fil = kopen4load("setup.dat",0)) != -1) { kread(fil,option,NUMOPTIONS); kread(fil,keys,NUMKEYS); memcpy((void *)buildkeys,(void *)keys,NUMKEYS); //Trick to make build use setup.dat keys kclose(fil); } // if (option[3] != 0) moustat = initmouse(); // CTW - MODIFICATION // I just updated this quickly to force it to work. // You'll want to update it properly to support other video modes. initengine(); setgamemode(2,320L,200L); /* switch(option[0]+1) { case 1: initengine(1,vesares[option[6]&15][0],vesares[option[6]&15][1]); break; default: initengine(option[0]+1,320L,200L); break; }*/ // CTW END - MODIFICATION kensplayerheight = 40; //32 zmode = 1; zlock = kensplayerheight<<8; defaultspritecstat = 0; ReadPaletteTable(); // InitWater(); } void ExtUnInit(void) { uninitgroupfile(); } static char lockbyte4094; void ExtPreCheckKeys(void) // just before drawrooms { if (qsetmode == 200) //In 3D mode { if(purpleon) clearview(255); if (sidemode != 0) { lockbyte4094 = 1; if (waloff[4094] == 0) allocache(&waloff[4094],320L*200L,&lockbyte4094); setviewtotile(4094,320L,200L); searchx ^= searchy; searchy ^= searchx; searchx ^= searchy; searchx = ydim-1-searchx; } } } void ExtAnalyzeSprites(void) { long i, j, k; spritetype *tspr; char frames=0; for(i=0,tspr=&tsprite[0];ipicnum<11) tspr->xrepeat=0; if(nosprites==1||nosprites==3) switch(tspr->picnum) { case SEENINE : tspr->xrepeat=0; } switch(tspr->picnum) { // 5-frame walk case 1550 : // Shark frames=5; // 2-frame walk case 1445 : // duke kick case LIZTROOPSHOOT : case LIZTROOPDUCKING : case 2030 : // pig shot case PIGCOPDIVE : case 2190 : // liz capt shot case BOSS1SHOOT : case BOSS1LOB : if(frames==0) frames=2; // 4-frame walk case 1491 : // duke crawl case LIZTROOP : case LIZTROOPRUNNING : case PIGCOP : case LIZMAN : case BOSS1 : case BOSS2 : case BOSS3 : if(frames==0) frames=4; case LIZTROOPJETPACK : case OCTABRAIN : case DRONE : case COMMANDER : case RECON : if(frames==0) frames=10; case GREENSLIME : case EGG : case PIGCOPSTAYPUT : case LIZMANSTAYPUT: case LIZTROOPSTAYPUT : case LIZMANSPITTING : case LIZMANFEEDING : case LIZMANJUMP : if(skill!=4) { if(tspr->lotag>skill) { tspr->xrepeat=0; break; } } case APLAYER : if(nosprites==2||nosprites==3) { tspr->xrepeat=0; // tspr->cstat|=32768; } // else tspr->cstat&=32767; if(frames!=0) { if(frames==10) frames=0; k = getangle(tspr->x-posx,tspr->y-posy); k = (((tspr->ang+3072+128-k)&2047)>>8)&7; //This guy has only 5 pictures for 8 angles (3 are x-flipped) if (k <= 4) { tspr->picnum += k; tspr->cstat &= 0xfb; //clear x-flipping bit } else { tspr->picnum += 8-k; tspr->cstat |= 4; //set x-flipping bit } } if(frames==2) tspr->picnum+=((((4-totalclock>>6))&1)*5); if(frames==4) tspr->picnum+=((((4-totalclock>>6))&3)*5); if(frames==5) tspr->picnum+=(((totalclock>>6)%5))*5; if(tilesizx[tspr->picnum] == 0) tspr->picnum -= 5; //Hack, for actors break; default: break; } } } int intro=0; void ExtCheckKeys(void) { long i,count,nexti; short statnum=0; if (qsetmode == 200) //In 3D mode { if (sidemode != 0) { setviewback(); // !!! FIXME: This doesn't compile! //rotatesprite(320<<15,200<<15,65536,(horiz-100)<<2,4094,0,0,2+4); lockbyte4094 = 0; searchx = ydim-1-searchx; searchx ^= searchy; searchy ^= searchx; searchx ^= searchy; // overwritesprite(160L,170L,1153,0,1+2,0); // !!! FIXME: This doesn't compile! //rotatesprite(160<<16,170<<16,65536,(100-horiz+1024)<<3,1153,0,0,2); } if(intro<100) { intro++; // rotatesprite((160-8)<<16,(100-8)<<16,(200-intro)<<9,0,SPINNINGNUKEICON+(((4-totalclock>>3))&7),0,0,0,0,0,xdim-1,ydim-1); Ver(); } Keys3d(); if (sidemode != 1) editinput(); if(usedcount) { if(tabgraphic) rotatesprite((320-32)<<16,(64)<<16,64<<9,0,temppicnum,0,0,0,0,0,xdim-1,ydim-1); if(searchstat!=3) { count=0; for(i=0;i=5) counter=0; if (totalclock < ototalclock+TICSPERFRAME) return; if (qsetmode != 200) return; if (sidemode != 1) return; ototalclock = totalclock; oposx = posx; oposy = posy; hitwall = clipmove(&posx,&posy,&posz,&cursectnum,xvel,yvel,128L,4L<<8,4L<<8,0); xvel = ((posx-oposx)<<14); yvel = ((posy-oposy)<<14); yvel += 80000; if ((hitwall&0xc000) == 32768) { hitwall &= (MAXWALLS-1); i = wall[hitwall].point2; daang = getangle(wall[i].x-wall[hitwall].x,wall[i].y-wall[hitwall].y); xvel -= (xvel>>4); if (xvel < 0) xvel++; if (xvel > 0) xvel--; yvel -= (yvel>>4); if (yvel < 0) yvel++; if (yvel > 0) yvel--; i = 4-keystatus[buildkeys[4]]; xvel += mulscale(vel,(long)sintable[(ang+512)&2047],i); yvel += mulscale(vel,(long)sintable[ang&2047],i); if (((daang-ang)&2047) < 1024) ang = ((ang+((((daang-ang)&2047)+24)>>4))&2047); else ang = ((ang-((((ang-daang)&2047)+24)>>4))&2047); timeoff = ototalclock; } else { if (ototalclock > timeoff+32) ang = ((ang+((timeoff+32-ototalclock)>>4))&2047); } getzrange(posx,posy,posz,cursectnum,&hiz,&hihit,&loz,&lohit,128L,0); oposx -= posx; oposy -= posy; dist = ksqrt(oposx*oposx+oposy*oposy); if (ototalclock > timeoff+32) dist = 0; daang = mulscale(dist,angvel,9); posz += (daang<<6); if (posz > loz-(4<<8)) posz = loz-(4<<8), hvel = 0; if (posz < hiz+(4<<8)) posz = hiz+(4<<8), hvel = 0; horiz = ((horiz*7+(100-(daang>>1)))>>3); if (horiz < 100) horiz++; if (horiz > 100) horiz--; if(keystatus[0x28]==1 && keystatus[0x06]==1) // ' 5 { keystatus[0x06]=0; editstatus = 1; sidemode = 2; } } ActorMem(int i) {int total=0,j; switch(i) { case APLAYER : for(j=APLAYER;j<(APLAYER+131);j++) total +=tilesizx[j]*tilesizy[j]; for(j=1780;j<(1780+32);j++) total +=tilesizx[j]*tilesizy[j]; break; case LIZTROOP : case LIZTROOPRUNNING : case LIZTROOPSTAYPUT : case LIZTROOPSHOOT : case LIZTROOPJETPACK : case LIZTROOPONTOILET : case LIZTROOPDUCKING : for(j=LIZTROOP;j<(LIZTROOP+100);j++) total +=tilesizx[j]*tilesizy[j]; break; case OCTABRAIN : for(j=OCTABRAIN;j<(OCTABRAIN+40);j++) total +=tilesizx[j]*tilesizy[j]; break; case DRONE : for(j=DRONE;j<(DRONE+10);j++) total +=tilesizx[j]*tilesizy[j]; break; case COMMANDER : for(j=COMMANDER;j<(COMMANDER+40);j++) total +=tilesizx[j]*tilesizy[j]; break; case RECON : for(j=RECON;j<(RECON+10);j++) total +=tilesizx[j]*tilesizy[j]; break; case PIGCOP : for(j=PIGCOP;j<(PIGCOP+61);j++) total +=tilesizx[j]*tilesizy[j]; break; case LIZMAN : case LIZMANSTAYPUT: case LIZMANSPITTING : case LIZMANFEEDING : case LIZMANJUMP : for(j=LIZMAN;j<(LIZMAN+80);j++) total +=tilesizx[j]*tilesizy[j]; break; case BOSS1 : for(j=BOSS1;j<(BOSS1+60);j++) total +=tilesizx[j]*tilesizy[j]; break; case BOSS2 : for(j=BOSS2;j<(BOSS2+50);j++) total +=tilesizx[j]*tilesizy[j]; break; case BOSS3 : for(j=BOSS3;j<(BOSS3+50);j++) total +=tilesizx[j]*tilesizy[j]; break; default: total += tilesizx[i]*tilesizy[i]; } return(total); } int curpalette=0; SetBOSS1Palette() {int x; if(curpalette==3) return; curpalette=3; kensetpalette(BOSS1palette); } SetSLIMEPalette() {int x; if(curpalette==2) return; curpalette=2; kensetpalette(SLIMEpalette); } SetWATERPalette() {int x; if(curpalette==1) return; curpalette=1; kensetpalette(WATERpalette); } SetGAMEPalette() {int x; if(curpalette==0) return; curpalette=0; kensetpalette(GAMEpalette); } kensetpalette(char *vgapal) { long i; char vesapal[1024]; for(i=0;i<256;i++) { vesapal[i*4+0] = vgapal[i*3+2]; vesapal[i*4+1] = vgapal[i*3+1]; vesapal[i*4+2] = vgapal[i*3+0]; vesapal[i*4+3] = 0; } VBE_setPalette(0L,256L,vesapal); } SearchSectorsForward() { long ii=0; if(cursector_lotag!=0) { if(cursectornum Sector Search : Found"); // cursectornum++; keystatus[0x1b]=0; // ] return; } cursectornum++; } } printmessage16("> Sector Search : none"); } SearchSectorsBackward() { long ii=0; if(cursector_lotag!=0) { if(cursectornum>0) cursectornum--; for(ii=cursectornum;ii>=0;ii--) { if(sector[ii].lotag==cursector_lotag) { posx=wall[sector[ii].wallptr].x; posy=wall[sector[ii].wallptr].y; printmessage16("< Sector Search : Found"); // cursectornum--; keystatus[0x1a]=0; // [ return; } cursectornum--; } } printmessage16("< Sector Search : none"); }