//------------------------------------------------------------------------- /* 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 - Todd Replogle Prepared for public release: 05/24/2003 - Charlie Wiederhold, 3D Realms Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com) */ //------------------------------------------------------------------------- /* ******************************************************** 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 ******************************************************** */ #include "compat.h" #include "build.h" #include "editor.h" #include "pragmas.h" #include "baselayer.h" #include "names.h" #include "osd.h" #include "cache1d.h" #define TICSPERFRAME 3 //#define VULGARITY /*#pragma aux setvmode =\ "int 0x10",\ parm [eax]\ */ //#include "water.c" char *Myname[1]= {"stryker@metronet.com"}; char *defsfilename = "duke3d.def"; extern char keystatus[]; extern long posx, posy, posz, horiz; extern short ang, cursectnum; extern short ceilingheinum, floorheinum; extern char names[MAXTILES][25]; extern long zlock; extern short editstatus, searchit; extern long searchx, searchy; //search input //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 9 char option[NUMOPTIONS] = {0,0,0,0,0,0,1,0,0}; char keys[NUMBUILDKEYS] = { 0xc8,0xd0,0xcb,0xcd,0x2a,0x9d,0x1d,0x39, 0x1e,0x2c,0xd1,0xc9,0x47,0x49, 0x9c,0x1c,0xd,0xc,0xf,0x45 }; int nextvoxid = 0; //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, hvel, angvel; long xvel, yvel, timoff; static char once=0; void SearchSectorsForward(); void SearchSectorsBackward(); void SpriteName(short spritenum, char *lo2); int ActorMem(int i); void PrintStatus(char *string,int num,char x,char y,char color); void Ver(); void SetBOSS1Palette(); void SetSLIMEPalette(); void SetWATERPalette(); void SetGAMEPalette(); void kensetpalette(char *vgapal); /* #pragma aux mulscale =\ "imul ebx",\ "shrd eax, edx, cl",\ parm [eax][ebx][ecx]\ modify [edx]\ */ void ExtPreLoadMap(void) { } void ExtLoadMap(const char *mapname) { long i; long sky=0; int j; char title[256]; Bsprintf(title, "BUILD Editor for JFDuke3D - %s", mapname); wm_setapptitle(title); // 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 ExtPreSaveMap(void) { } 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 : Bsprintf(lo,"WATER"); break; // case 2 : Bsprintf(lo,"UNDERWATER"); break; // case 3 : Bsprintf(lo,"EARTHQUAKE"); break; default : Bsprintf(lo,"%hu",(unsigned short)sector[sectnum].lotag); break; } Bsprintf(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; Bsprintf(tempbuf,"Grabbed 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 { Bsprintf(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) Bsprintf(tempbuf,"%s-M",lo); else Bsprintf(tempbuf,"%s",lo); } } else /* if( (unsigned short)sprite[spritenum].picnum == 175) { Bsprintf(lo,"%hu",(unsigned short)sprite[spritenum].lotag); Bsprintf(tempbuf,"%hu,%s",(unsigned short)sprite[spritenum].hitag,lo); } else */ { SpriteName(spritenum,lo); Bsprintf(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(); begindrawing(); printext16(1*8,ydim16+4*8,11,-1,"Memory Status",0); enddrawing(); 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,ydim16+(y*6)+2,11,-1,tempbuf,1); x=0; y++; if(y>18) {col++; y=6; xx+=xmax; xmax=0;} } enddrawing(); kclose(fp); }// end Show2dText void Show3dText(char *name) { int i,fp; char x=0,y=4,xmax=0,xx=0,col=0; int t; if((fp=kopen4load(name,0)) == -1) { begindrawing(); printext256(1*4,4*8,11,-1,"ERROR: file not found.",0); enddrawing(); return; } t=65; begindrawing(); while(t!=EOF && col<5) { t = 0; if (kread(fp,&t,1)<=0) t = EOF; while(t!=EOF && t!='\n' && x<250) { tempbuf[x]=t; t = 0; if (kread(fp,&t,1)<=0) t = EOF; 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;} } enddrawing(); kclose(fp); }// end Show3dText void ShowHelpText(char *name) { BFILE *fp; int i,t; char x=0,y=4,xmax=0,xx=0,col=0; if((fp=fopenfrompath("helpdoc.txt","rb")) == NULL) { begindrawing(); printext256(1*4,4*8,11,-1,"ERROR: file not found.",0); enddrawing(); return; } /* Bfgets(tempbuf,80,fp); while(!Bfeof(fp) && Bstrcmp(tempbuf,"SectorEffector")) { Bfgets(tempbuf,80,fp); } */ y=2; Bfgets(tempbuf,80,fp); Bstrcat(tempbuf,"\n"); begindrawing(); while(!Bfeof(fp) && !(Bstrcmp(tempbuf,"SectorEffector")==0)) { Bfgets(tempbuf,80,fp); Bstrcat(tempbuf,"\n"); printext256(x*4,(y*6)+2,11,-1,tempbuf,1); y++; } enddrawing(); Bfclose(fp); }// end ShowHelpText void ExtShowSpriteData(short spritenum) //F6 { if (qsetmode == 200) Show3dText("sehelp.hlp"); else Show2dText("sehelp.hlp"); }// end ExtShowSpriteData void ExtEditSectorData(short sectnum) //F7 { if (qsetmode == 200) Show3dText("sthelp.hlp"); else Show2dText("sthelp.hlp"); }// end ExtEditSectorData void ExtEditWallData(short wallnum) //F8 { if(qsetmode==200) return; wallsprite=1; curwall = wallnum; curwallnum = 0; curspritenum = 0; cursectornum = 0; search_lotag=getnumber16("Enter Wall Search Lo-Tag : ", search_lotag, 65536L,0); search_hitag=getnumber16("Enter Wall Search Hi-Tag : ", search_hitag, 65536L,0); Bsprintf(tempbuf,"Current Wall %d lo=%d hi=%d", curwall,search_lotag,search_hitag); printmessage16(tempbuf); } void ExtEditSpriteData(short spritenum) //F8 { if(qsetmode==200) return; wallsprite=2; cursprite = spritenum; curwallnum = 0; curspritenum = 0; cursectornum = 0; search_lotag=getnumber16("Enter Sprite Search Lo-Tag : ", search_lotag, 65536L,0); search_hitag=getnumber16("Enter Sprite Search Hi-Tag : ", search_hitag, 65536L,0); Bsprintf(tempbuf,"Current Sprite %d %s lo=%d hi=%d", cursprite,names[sprite[cursprite].picnum],search_lotag,search_hitag); printmessage16(tempbuf); } void PrintStatus(char *string,int num,char x,char y,char color) { Bsprintf(tempbuf,"%s %d",string,num); begindrawing(); printext16(x*8,ydim16+y*8,color,-1,tempbuf,0); enddrawing(); } void SpriteName(short spritenum, char *lo2) { Bsprintf(lo2,names[sprite[spritenum].picnum]); }// end SpriteName char GAMEpalette[768]; char WATERpalette[768]; char SLIMEpalette[768]; char TITLEpalette[768]; char REALMSpalette[768]; char BOSS1palette[768]; void 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); } */ begindrawing(); 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; Bsprintf(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); } enddrawing(); 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; Bsprintf(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 char *startwin_labeltext = "Starting Build Editor for Duke Nukem 3D,,,"; int ExtInit(void) { long fil, rv = 0; char *duke3dgrp = "duke3d.grp"; /* char *msg = //"------------------------------------------------------------------------------\n" "BUILD.EXE Copyright (c) 1993 - 1996 Ken Silverman, 3D Realms Entertainment.\n" "This version of BUILD was created for Duke Nukem 3D and parts were modified\n" "by Allen H. Blum III.\n" "\n" "IMPORTANT: The Build Editor and associated tools and utilities are NOT\n" "shareware and may NOT be freely distributed to any BBS, CD, floppy, or\n" "any other media. These tools may NOT be sold or repackaged for sale in\n" "a commercial product.\n" "\n" "Any levels created with these editors and tools may only be used with the\n" "full (registered) copy of Duke Nukem 3D, and not the shareware version.\n" "Please refer to LICENSE.DOC for further information on levels created with\n" "BUILD.EXE.\n" "\n" "Please help us protect against software piracy (which drives up software\n" "prices) by following these simple rules.\n" "\n" "Thank You!\n" //"------------------------------------------------------------------------------\n" ; wm_msgbox("Build Editor for Duke Nukem 3D", msg); */ wm_setapptitle("BUILD Editor for JFDuke3D"); #ifdef _WIN32 if (!access("user_profiles_enabled", F_OK)) #endif { char cwd[BMAX_PATH]; char *homedir; int asperr; #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) addsearchpath("/usr/local/share/duke3d"); addsearchpath("/usr/local/games/jfduke3d"); #endif if (getcwd(cwd,BMAX_PATH)) addsearchpath(cwd); if ((homedir = Bgethomedir())) { Bsnprintf(cwd,sizeof(cwd),"%s/" #if defined(_WIN32) || defined(__APPLE__) "JFDuke3D" #else ".jfduke3d" #endif ,homedir); asperr = addsearchpath(cwd); if (asperr == -2) { if (Bmkdir(cwd,S_IRWXU) == 0) asperr = addsearchpath(cwd); else asperr = -1; } if (asperr == 0) chdir(cwd); free(homedir); } } // JBF 20031220: Because it's annoying renaming GRP files whenever I want to test different game data if (getenv("DUKE3DGRP")) { duke3dgrp = getenv("DUKE3DGRP"); initprintf("Using %s as main GRP file\n", duke3dgrp); } initgroupfile(duke3dgrp); /* 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); } */ bpp = 8; if (loadsetup("build.cfg") < 0) initprintf("Configuration file not found, using defaults.\n"), rv = 1; memcpy((void *)buildkeys,(void *)keys,NUMBUILDKEYS); //Trick to make build use setup.dat keys if (initengine()) { wm_msgbox("Build Engine Initialisation Error", "There was a problem initialising the Build engine: %s", engineerrstr); return -1; } if (initinput()) return -1; // if (option[3] != 0) moustat = initmouse(); kensplayerheight = 40; //32 zmode = 1; zlock = kensplayerheight<<8; defaultspritecstat = 0; ReadPaletteTable(); // InitWater(); return rv; } void ExtUnInit(void) { // setvmode(0x03); uninitgroupfile(); writesetup("build.cfg"); } 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 &= ~4; //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(); rotatesprite(320<<15,200<<15,65536,(horiz-100)<<2,4094,0,0,2+4,0,0,0,0); lockbyte4094 = 0; searchx = ydim-1-searchx; searchx ^= searchy; searchy ^= searchx; searchx ^= searchy; // overwritesprite(160L,170L,1153,0,1+2,0); rotatesprite(160<<16,170<<16,65536,(100-horiz+1024)<<3,1153,0,0,2,0,0,0,0); } 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); timoff = ototalclock; } else { if (ototalclock > timoff+32) ang = ((ang+((timoff+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 > timoff+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; } } void Ver() { Bsprintf(tempbuf,"DUKE NUKEM BUILD: V032696"); if (qsetmode == 200) //In 3D mode { begindrawing(); printext256(60*8,24*8,11,-1,tempbuf,1); enddrawing(); 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 { begindrawing(); printext16(0,ydim16+0,15,-1,tempbuf,0); enddrawing(); } } int 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); } static int acurpalette=0; void SetBOSS1Palette() {int x; if(acurpalette==3) return; acurpalette=3; kensetpalette(BOSS1palette); } void SetSLIMEPalette() {int x; if(acurpalette==2) return; acurpalette=2; kensetpalette(SLIMEpalette); } void SetWATERPalette() {int x; if(acurpalette==1) return; acurpalette=1; kensetpalette(WATERpalette); } void SetGAMEPalette() {int x; if(acurpalette==0) return; acurpalette=0; kensetpalette(GAMEpalette); } void 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; } setpalette(0L,256L,vesapal); } void SearchSectorsForward() { long ii=0; if(cursector_lotag!=0) { if(cursectornum Sector Search : Found"); // cursectornum++; keystatus[0x1b]=0; // ] return; } cursectornum++; } } printmessage16("> Sector Search : none"); } void 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"); }