Annotation of src/bstub.c, revision 1.1

1.1     ! root        1: #include <fcntl.h>
        !             2: #include <io.h>
        !             3: #include <sys\types.h>
        !             4: #include <sys\stat.h>
        !             5: #include "stdio.h"
        !             6: #include "stdlib.h"
        !             7: #include "string.h"
        !             8: #include "build.h"
        !             9: 
        !            10: #define TEKWAR 1
        !            11: 
        !            12: #define AVERAGEFRAMES 16
        !            13: 
        !            14: extern    volatile  char keystatus[256];
        !            15: 
        !            16: static char tempbuf[256];
        !            17: extern long qsetmode;
        !            18: extern short searchsector, searchwall, searchstat;
        !            19: extern long zmode, kensplayerheight;
        !            20: extern short defaultspritecstat;
        !            21: 
        !            22: extern short temppicnum, tempcstat, templotag, temphitag, tempextra;
        !            23: extern char tempshade, temppal, tempxrepeat, tempyrepeat;
        !            24: extern char somethingintab;
        !            25: 
        !            26: static long frameval[AVERAGEFRAMES], framecnt = 0;
        !            27: 
        !            28: #define NUMOPTIONS 8
        !            29: #define NUMKEYS 19
        !            30: 
        !            31: long chainxres[4] = {256,320,360,400};
        !            32: long chainyres[11] = {200,240,256,270,300,350,360,400,480,512,540};
        !            33: long vesares[7][2] = {320,200,640,400,640,480,800,600,1024,768,
        !            34:                                                                          1280,1024,1600,1200};
        !            35: char option[NUMOPTIONS] = {0,0,0,0,0,0,98,0};
        !            36: char keys[NUMKEYS] =
        !            37: {
        !            38:        0xc8,0xd0,0xcb,0xcd,0x2a,0x9d,0x1d,0x39,
        !            39:        0x1e,0x2c,0xd1,0xc9,0x33,0x34,
        !            40:        0x9c,0x1c,0xd,0xc,0xf,
        !            41: };
        !            42: 
        !            43: 
        !            44: #ifdef TEKWAR
        !            45: #include "stdio.h"
        !            46: #include "stdlib.h"
        !            47: #include  "sys\stat.h"
        !            48: #include  "sys\types.h"
        !            49: #include  "fcntl.h"
        !            50: #include  "io.h"
        !            51: 
        !            52: #define   PULSELIGHT     0
        !            53: #define   FLICKERLIGHT   1
        !            54: #define   DELAYEFFECT    2
        !            55: #define   WPANNING       3
        !            56: #define   FPANNING       4
        !            57: #define   CPANNING       5
        !            58: #define   FLICKERDELAY   6
        !            59: #define   BLINKDELAY     7
        !            60: #define   STEADYLIGHT    8
        !            61: 
        !            62: #define   NO_PIC    0
        !            63: 
        !            64: #define   INANIMATE      0       
        !            65: #define   INACTIVE       100     
        !            66: #define   STANDING       201     
        !            67: #define   AMBUSH         202     
        !            68: #define   GUARD          203     
        !            69: #define   STALK          204     
        !            70: #define   FLEE           205     
        !            71: #define   CHASE          206     
        !            72: #define   PATROL         207     
        !            73: #define   CRAWL          208     
        !            74: #define   STROLL         209     
        !            75: #define   PINBALL        403
        !            76: #define   FLY            500     
        !            77: #define   RODENT         502
        !            78: 
        !            79: #define   GUN2FLAG            2
        !            80: #define   GUN3FLAG            3
        !            81: #define   GUN4FLAG            4
        !            82: #define   GUN5FLAG            5
        !            83: #define   GUN6FLAG            6
        !            84: #define   GUN7FLAG            7
        !            85: 
        !            86: #define   CLASS_NULL               0
        !            87: #define   CLASS_FCIAGENT           1
        !            88: #define   CLASS_CIVILLIAN          2
        !            89: #define   CLASS_SPIDERDROID        3
        !            90: #define   CLASS_COP                4
        !            91: #define   CLASS_MECHCOP            5
        !            92: #define   CLASS_TEKBURNOUT         6
        !            93: #define   CLASS_TEKGOON            7
        !            94: #define   CLASS_ASSASSINDROID      8
        !            95: #define   CLASS_SECURITYDROID      9
        !            96: #define   CLASS_TEKBOSS            10
        !            97: #define   CLASS_TEKLORD            11
        !            98: 
        !            99: #define   PTS_CIVILLIAN            10    
        !           100: #define   PTS_SPIDERDROID          15
        !           101: #define   PTS_COP                  50
        !           102: #define   PTS_MECHCOP              100
        !           103: #define   PTS_TEKBURNOUT           25
        !           104: #define   PTS_TEKGOON              50
        !           105: #define   PTS_ASSASSINDROID        100
        !           106: #define   PTS_SECURITYDROID        200
        !           107: #define   PTS_TEKBOSS              100
        !           108: #define   PTS_TEKLORD              200
        !           109: 
        !           110: extern   long posx,posy,posz;
        !           111: extern   short ang,cursectnum;
        !           112: extern   short ceilingheinum,floorheinum;
        !           113: extern   char names[MAXTILES][17];
        !           114: 
        !           115: static   char tempbuf[256];  
        !           116: static   int  numsprite[2000];
        !           117: static   char lo[32];
        !           118: static   char hi[32];
        !           119: static   const char *levelname;
        !           120: static   short curwall=0,wallpicnum=0,curwallnum=0;
        !           121: static   short cursprite=0,curspritenum=0;
        !           122: static   char wallsprite=0;
        !           123: static   helpon=0;
        !           124: static   char once=0;
        !           125: 
        !           126: struct    picattribtype  {
        !           127:      char      numframes;
        !           128:      char      animtype;
        !           129:      signed    char      ycenteroffset,xcenteroffset;
        !           130:      char      animspeed;
        !           131:      };
        !           132: 
        !           133: struct    spriteextension {
        !           134:      char      class;
        !           135:      char      hitpoints;
        !           136:      unsigned  short     target;
        !           137:      unsigned  short     fxmask;  
        !           138:      unsigned  short     aimask;
        !           139:      short     basestat;
        !           140:      unsigned  short     basepic;
        !           141:      unsigned  short     standpic;
        !           142:      unsigned  short     walkpic;
        !           143:      unsigned  short     runpic;
        !           144:      unsigned  short     attackpic;
        !           145:      unsigned  short     deathpic;
        !           146:      unsigned  short     painpic;
        !           147:      unsigned  short     squatpic;
        !           148:      unsigned  short     morphpic;
        !           149:      unsigned  short     specialpic;
        !           150:      char      lock;
        !           151:      char      weapon;
        !           152:      short     ext2;
        !           153:      };
        !           154: struct    spriteextension  spriteXT[MAXSPRITES];
        !           155: 
        !           156: struct    XTsavetype {
        !           157:      short     XTnum;
        !           158:      struct    spriteextension      sprXT;
        !           159: };
        !           160: struct XTsavetype XTsave;
        !           161: 
        !           162: struct    XTtrailertype {
        !           163:      long      numXTs;          
        !           164:      long      start;
        !           165:      char      mapname[13];
        !           166:      char      ID[13];
        !           167: };
        !           168: struct    XTtrailertype  XTtrailer;
        !           169: 
        !           170: #define   TRAILERID "**MAP_EXTS**"
        !           171: 
        !           172: short     recordXT = -1;
        !           173: struct    spriteextension     recXT;
        !           174: 
        !           175: #define   MAXCLASSES     15
        !           176: short     numinclass[MAXCLASSES];
        !           177: 
        !           178: char editvelocity=0;
        !           179: char elapsedtime=0;
        !           180: char copyext=0;
        !           181: char recordext=0;
        !           182: char liststates=0;
        !           183: char matchcstats=0;
        !           184: char docleanup=0;
        !           185: char spriteextmodified=0;
        !           186: long      tickdelay;
        !           187: #endif
        !           188: 
        !           189: #pragma aux wrchar  =         \
        !           190:      "or  eax,0x00000900",    \
        !           191:      "mov ebx,0x0000007F",    \    
        !           192:      "mov ecx,0x00000001",    \
        !           193:      "int 0x10",              \
        !           194:      parm [eax]               \
        !           195: 
        !           196: #pragma aux terminate =       \
        !           197:      "or  eax, 0x00004C00",   \
        !           198:      "int 0x21",              \
        !           199:      parm [eax]               \
        !           200: 
        !           201: #pragma aux scrldn =          \
        !           202:      "mov eax,0x00000701",    \
        !           203:      "mov ebx,0x00007700",    \
        !           204:      "mov ecx,0x00000000",    \
        !           205:      "mov edx,0x00000F4F",    \
        !           206:      "int 0x10"               \
        !           207: 
        !           208: #pragma aux home =            \
        !           209:      "mov eax,0x00000200",    \
        !           210:      "mov ebx,0x00000000",    \
        !           211:      "add edx,0x00000019",    \
        !           212:      "int 0x10",              \
        !           213:      parm [edx]               \
        !           214: 
        !           215: #pragma aux ontherange =      \
        !           216:      "mov eax,0x00000200",    \
        !           217:      "mov ebx,0x00000000",    \
        !           218:      "mov edx,0x00000300",    \
        !           219:      "int 0x10"               \
        !           220: 
        !           221: #pragma aux clrscr =          \
        !           222:      "mov eax,0x00000003",    \
        !           223:      "int 0x10"               \
        !           224: 
        !           225: 
        !           226: void
        !           227: speaker(int freq)
        !           228: {
        !           229:      int            i;
        !           230:      unsigned char  p;
        !           231:      union {
        !           232:           int            divisor;
        !           233:           unsigned char  c[2];
        !           234:      } count;
        !           235: 
        !           236:      count.divisor=1193280/freq;
        !           237:      outp(67,182);
        !           238:      outp(66,count.c[0]);
        !           239:      outp(66,count.c[1]);
        !           240:      p=inp(97);
        !           241:      outp(97,p|3);
        !           242: 
        !           243:      for( i=0; i<640000; i++ ) 
        !           244:           ;
        !           245: 
        !           246:      outp(97, p);
        !           247: }
        !           248: 
        !           249: #ifdef TEKWAR
        !           250: // overrides of engine insert/delete sprite
        !           251: insertsprite(short sectnum, short statnum)
        !           252: {
        !           253:      insertspritestat(statnum);
        !           254:      return(insertspritesect(sectnum));
        !           255: }
        !           256: 
        !           257: deletesprite(short spritenum)
        !           258: {
        !           259:        if( (sprite[spritenum].extra!=-1) ) {
        !           260:           JS_DeleteExt(spritenum);
        !           261:      }
        !           262: 
        !           263:      deletespritestat(spritenum);
        !           264:      return(deletespritesect(spritenum));
        !           265: }
        !           266: 
        !           267: void
        !           268: PrintStatus(char *string,int num,char x,char y,char color)
        !           269: {
        !           270:      sprintf(tempbuf,"%s %d",string,num);
        !           271:      printext16(x*8,y*8,color,-1,tempbuf,0);
        !           272: }
        !           273: 
        !           274: void
        !           275: PrintStatusStr(char *string,char *s,char x,char y,char color)
        !           276: {
        !           277:      sprintf(tempbuf,"%s %s",string,s);
        !           278:      printext16(x*8,y*8,color,-1,tempbuf,0);
        !           279: }
        !           280: 
        !           281: void
        !           282: SpriteName(short spritenum, char *lo2)
        !           283: {
        !           284:      sprintf(lo2,names[sprite[spritenum].picnum]);
        !           285: }
        !           286: 
        !           287: void
        !           288: JS_MatchCstats()
        !           289: {
        !           290:      char      what[50];
        !           291:      int       i,ans;
        !           292: 
        !           293:      putch(0x07);
        !           294:      sprintf(what, "1=YES,MATCH SPR CSTATS. 0 TO CANCEL. ");
        !           295:      ans=getnumber16(what, 0, 2L);
        !           296: 
        !           297:      if( ans != 1 ) {
        !           298:           printmessage16("Cancelled...");
        !           299:           return;
        !           300:      }
        !           301: 
        !           302:      for( i=0; i<MAXSPRITES; i++ ) {
        !           303:           if( sprite[i].cstat & 0x0001 ) {
        !           304:                sprite[i].cstat|=0x0100;
        !           305:           }
        !           306:      }
        !           307: 
        !           308:      printmessage16("All sprite hitscans match blocking...");
        !           309: 
        !           310:  return;
        !           311: }
        !           312: 
        !           313: void
        !           314: JS_CleanupExtensions()
        !           315: {
        !           316:      char      what[50];
        !           317: 
        !           318:      sprintf(what, "Checking extras...");
        !           319:      printmessage16(what);
        !           320:      tickdelay=totalclock;
        !           321:      while ( (totalclock-tickdelay)<50 )
        !           322:           ;
        !           323:      checkextras();
        !           324: }
        !           325: 
        !           326: void
        !           327: JS_RecordExt(int sn)
        !           328: {
        !           329:      char      what[50];
        !           330: 
        !           331:      clearmidstatbar16();
        !           332: 
        !           333:      if( sprite[sn].extra < 0 ) {
        !           334:           sprintf(what, "Sprite has no EXT to record !");
        !           335:           printmessage16(what);
        !           336:           tickdelay=totalclock;
        !           337:           while ( (totalclock-tickdelay)<50 )
        !           338:                ;
        !           339:           return;
        !           340:      }
        !           341: 
        !           342:      recordXT=sprite[sn].extra;
        !           343: 
        !           344:      JS_ShowSpriteExts(sn);
        !           345: 
        !           346:      sprintf(what, "Recording Ext %d for copying...", sn);
        !           347:      printmessage16(what);
        !           348:      tickdelay=totalclock;
        !           349:      while ( (totalclock-tickdelay)<50 )
        !           350:           ;
        !           351: 
        !           352:      memcpy(&recXT, &spriteXT[recordXT], sizeof(struct spriteextension));     
        !           353: }
        !           354: 
        !           355: void
        !           356: JS_CopyExt(int sn)
        !           357: {
        !           358:      char      what[50];
        !           359:      short     j;
        !           360:      int       ans;
        !           361: 
        !           362:      clearmidstatbar16();
        !           363: 
        !           364:      if( (recordXT < 0) || (recordXT > MAXSPRITES) ) {
        !           365:           sprintf(what, "NO current valid copy EXT to copy !");
        !           366:           printmessage16(what);
        !           367:           tickdelay=totalclock;
        !           368:           while ( (totalclock-tickdelay)<50 )
        !           369:                ;
        !           370:           return;
        !           371:      }
        !           372: 
        !           373:      j=sprite[sn].extra;
        !           374: 
        !           375:      if( j < 0 ) {
        !           376:           sprintf(what, "Mapping EXT for sprite %d...", sn);
        !           377:           printmessage16(what);
        !           378:           tickdelay=totalclock;
        !           379:           while ( (totalclock-tickdelay)<50 )
        !           380:                ;
        !           381:           j=JS_FirstFreeExt();
        !           382:           if( j == -1 ) {
        !           383:                printmessage16("ERROR! Not able to map to an extension.");
        !           384:                return;
        !           385:           }
        !           386:           printmessage16("Extension Mapped.");
        !           387:           tickdelay=totalclock;
        !           388:           while ( (totalclock-tickdelay)<50 )
        !           389:                ;
        !           390:           sprite[sn].extra=j;
        !           391:           JS_InitExtension(sn, j);
        !           392:           JS_LockExt(j);
        !           393:           JS_ShowSpriteExts(sn);
        !           394:      }
        !           395:      else {
        !           396:           putch(0x07);
        !           397:           sprintf(what, "Overwrite existing EXT for sprite %d ?  1=YES 0=NO ", sn);
        !           398:           ans=getnumber16(what, 0, 2L);
        !           399:           if( ans != 1 ) {
        !           400:                printmessage16("Not Copied...");
        !           401:                return;
        !           402:           }
        !           403:      }
        !           404: 
        !           405:      memcpy(&spriteXT[j], &recXT, sizeof(struct spriteextension));
        !           406: 
        !           407:      sprintf(what, "Copying Ext %d to sprite %d...", recordXT, sn);
        !           408:      printmessage16(what);
        !           409:      tickdelay=totalclock;
        !           410:      while ( (totalclock-tickdelay)<50 )
        !           411:           ;
        !           412: 
        !           413:      JS_ShowSpriteExts(sn);
        !           414: }
        !           415: 
        !           416: void
        !           417: JS_DeleteExt(short sn)
        !           418: {
        !           419:      short     x=sprite[sn].extra;
        !           420: 
        !           421:      memset(&spriteXT[x], 0, sizeof(struct spriteextension));
        !           422: 
        !           423:      if( qsetmode == 480 ) {
        !           424:           printmessage16("Deleting Extension...");
        !           425:           tickdelay=totalclock;
        !           426:           while ( (totalclock-tickdelay)<60 )
        !           427:                ;
        !           428:      }
        !           429: 
        !           430:      // reset recordXT
        !           431:      if( x == recordXT ) {
        !           432:           recordXT=-1;
        !           433:      }
        !           434: 
        !           435:  return;
        !           436: }
        !           437: 
        !           438: void
        !           439: JS_ClearAllExts(void)
        !           440: {
        !           441:      char      what[50];
        !           442:      int       i,ans;
        !           443: 
        !           444:      putch(0x07);
        !           445:      sprintf(what, "1=YES,DELETE ALL EXTS, 0 TO CANCEL. ");
        !           446:      ans=getnumber16(what, 0, 2L);
        !           447: 
        !           448:      if( ans != 1 ) {
        !           449:           printmessage16("Cancelled...");
        !           450:           return;
        !           451:      }
        !           452: 
        !           453:      sprintf(what, "REALLY DELETE EXTS ? 1=YES  0=NO ");
        !           454:      ans=getnumber16(what, 0, 2L);
        !           455: 
        !           456:      if( ans != 1 ) {
        !           457:           printmessage16("Cancelled...");
        !           458:           return;
        !           459:      }
        !           460: 
        !           461:      for( i=0; i<MAXSPRITES; i++ ) {
        !           462:           memset(&spriteXT[i], 0, sizeof(struct spriteextension));
        !           463:      }
        !           464:      for( i=0; i<MAXSPRITES; i++ ) {
        !           465:           sprite[i].extra=-1;
        !           466:      }
        !           467: 
        !           468:      printmessage16("All sprite EXTS cleared...");
        !           469: 
        !           470:  return;
        !           471: }
        !           472: 
        !           473: void
        !           474: JS_ClearAllSprites(void)
        !           475: {
        !           476:      char      what[50];
        !           477:      int       i,ans;
        !           478: 
        !           479:      putch(0x07);
        !           480:      sprintf(what, "1=YES,DELETE ALL SPRITES, 0 TO CANCEL. ");
        !           481:      ans=getnumber16(what, 0, 2L);
        !           482: 
        !           483:      if( ans != 1 ) {
        !           484:           printmessage16("Cancelled...");
        !           485:           return;
        !           486:      }
        !           487: 
        !           488:      sprintf(what, "REALLY DELETE SPRITES ? 1=YES  0=NO ");
        !           489:      ans=getnumber16(what, 0, 2L);
        !           490: 
        !           491:      if( ans != 1 ) {
        !           492:           printmessage16("Cancelled...");
        !           493:           return;
        !           494:      }
        !           495: 
        !           496:      for( i=0; i<MAXSPRITES; i++ ) {
        !           497:           deletesprite(i);
        !           498:           memset(&spriteXT[i], 0, sizeof(struct spriteextension));
        !           499:           sprite[i].extra=-1;
        !           500:      }
        !           501: 
        !           502:      printmessage16("All sprites gone...");
        !           503: 
        !           504:  return;
        !           505: }
        !           506: 
        !           507: // reads ext info into sprXT array then strips .map file of ext info
        !           508: int
        !           509: JS_LoadSpriteExts(const char *mapname)
        !           510: {
        !           511:      int       fh,i,nr,xn,nex;
        !           512:      int       bh;
        !           513:      long      fsize;
        !           514:      size_t    ssize;
        !           515:      int       nopen=0;
        !           516:      int       res;
        !           517:      long      totr;
        !           518:      struct    stat      st1,st2;
        !           519:      char      buf[40],rdbuf[512];
        !           520: 
        !           521:      nopen=flushall();
        !           522: 
        !           523:      ssize=sizeof(struct spriteextension);
        !           524: 
        !           525:      for (i=0; i<MAXSPRITES; i++) {
        !           526:           memset(&spriteXT[i], 0, ssize);
        !           527:           spriteXT[i].lock=0x00;
        !           528:      }
        !           529: 
        !           530:      ssize=sizeof(struct XTtrailertype);
        !           531: 
        !           532:      fh=open(mapname, O_BINARY | O_RDONLY, S_IREAD | S_IWRITE);
        !           533:      if ( fh == -1 ) {
        !           534:           return(-1);
        !           535:      }
        !           536: 
        !           537:      // check if file is already open
        !           538:      memset(&st1, 0, sizeof( struct stat));
        !           539:      memset(&st2, 0, sizeof( struct stat));
        !           540:      fstat(fh, &st1);
        !           541:      stat(mapname, &st2);
        !           542: 
        !           543:     //#define   DOBACKUPS
        !           544:     #ifdef    DOBACKUPS
        !           545:      // make backup
        !           546:      if( (strcmp(mapname, "backup.map") == 0) || (strcmp(mapname, "BACKUP.MAP") == 0) )
        !           547:           goto backupdone;
        !           548:      bh=open("backup.map", O_CREAT | O_TRUNC | O_BINARY | O_RDWR, S_IREAD | S_IWRITE);
        !           549:      if ( bh == -1 ) {
        !           550:           goto backupdone;
        !           551:      }
        !           552:      totr=nr=0;
        !           553:      while( 1 ) {
        !           554:           nr=0;
        !           555:           nr=read(fh, rdbuf, 512);
        !           556:           totr+=nr;
        !           557:           if( nr > 0 ) {
        !           558:                write(bh, rdbuf, nr);
        !           559:           }
        !           560:           if( nr < 512 ) {
        !           561:                goto endof;
        !           562:           }
        !           563:      }
        !           564: endof:
        !           565:      close(bh);
        !           566:      lseek(fh, 0, SEEK_SET);
        !           567: backupdone:
        !           568:     #endif
        !           569: 
        !           570:      // read in XTtrailer 
        !           571:      lseek(fh, -(sizeof(struct XTtrailertype)), SEEK_END);
        !           572:      memset(&XTtrailer, 0, sizeof(struct XTtrailertype));
        !           573:      read(fh, &XTtrailer, sizeof(struct XTtrailertype));
        !           574: 
        !           575:      // if no previous extension info then continue
        !           576:      if( strcmp(XTtrailer.ID, TRAILERID) != 0 ) {
        !           577:           if (qsetmode == 480) {
        !           578:                printmessage16("New File - No extension information...");
        !           579:                tickdelay=totalclock;
        !           580:                while ( (totalclock-tickdelay)<50 )
        !           581:                     ;
        !           582:           }
        !           583:           goto noext;
        !           584:      }
        !           585: 
        !           586:      if (qsetmode == 480) {
        !           587:           printmessage16("Reading in extensions...");
        !           588:           tickdelay=totalclock;
        !           589:           while ( (totalclock-tickdelay)<40 )
        !           590:                ;
        !           591:      }
        !           592: 
        !           593:      // load and intialize spriteXT array members
        !           594:      lseek(fh, XTtrailer.start, SEEK_SET);
        !           595:      for( i=0; i<XTtrailer.numXTs; i++ ) {
        !           596:           nr=read(fh, &XTsave, sizeof(struct XTsavetype));
        !           597:           if( nr != sizeof(struct XTsavetype) )
        !           598:                break;
        !           599:           spriteXT[XTsave.XTnum]=XTsave.sprXT;  // struct assign
        !           600:      }
        !           601: 
        !           602:      nex=JS_CheckExtras();
        !           603:      if( nex != i ) {
        !           604:           putch(0x07);
        !           605:           if (qsetmode == 480) {
        !           606:                sprintf(buf, "ERROR: %d Sprite Extras != %d Extensions.", nex,i);
        !           607:                printmessage16(buf);
        !           608:                tickdelay=totalclock;
        !           609:                while ( (totalclock-tickdelay)<200 )
        !           610:                     ;
        !           611:           }
        !           612:      }
        !           613:      else {
        !           614:           if (qsetmode == 480) {
        !           615:                sprintf(buf, "Loaded %d extensions.", i);
        !           616:                printmessage16(buf);
        !           617:                tickdelay=totalclock;
        !           618:                while ( (totalclock-tickdelay)<60 )
        !           619:                     ;
        !           620:           }
        !           621:      }
        !           622: 
        !           623:      // strip exension info so build may write map file contiguously
        !           624:      lseek(fh, 0, SEEK_SET);
        !           625:      res=chsize(fh, XTtrailer.start);
        !           626: 
        !           627: noext:
        !           628: 
        !           629:      flushall();
        !           630:      close(fh);
        !           631:      nopen=flushall();
        !           632: 
        !           633:  return(0);
        !           634: }
        !           635: 
        !           636: checkextras()
        !           637: {
        !           638:      int       i,j,ext;
        !           639:      char      what[50];
        !           640:      FILE      *fp;
        !           641: 
        !           642:      fp=fopen("exts", "wt");
        !           643:      if( fp == NULL ) {
        !           644:           return;
        !           645:      }
        !           646: 
        !           647:      fprintf(fp,"\n\t SPR\t\t EXT\n\n");
        !           648:      for( i=0; i<MAXSPRITES; i++ ) {
        !           649:           if( sprite[i].extra != -1 ) {
        !           650:                fprintf(fp,"\t%4d\t\t%4d\n", i,sprite[i].extra);
        !           651:           }
        !           652:      }
        !           653: 
        !           654:      fprintf(fp, "\n");
        !           655:      // check for maps to unlocked XT
        !           656:      for( i=0; i<MAXSPRITES; i++ ) {
        !           657:           ext=sprite[i].extra;
        !           658:           if( ext != -1 ) {
        !           659:                if( spriteXT[ext].lock == 0x00 ) {
        !           660:                     sprite[i].extra=-1;
        !           661:                     sprintf(what, "bad extra for %d", i);
        !           662:                     printmessage16(what);
        !           663:                     fprintf(fp, "Sprite %d at %ld,%ld mapped to unlocked XT %4d\n", i,sprite[i].x,sprite[i].y,ext);
        !           664:                }
        !           665:           }
        !           666:      }
        !           667: 
        !           668:      fprintf(fp, "\n");
        !           669:      // check for locked XT with no mapping
        !           670:      for( i=0; i<MAXSPRITES; i++ ) {
        !           671:           if( spriteXT[i].lock == 0xFF ) {
        !           672:                for( j=0; j<MAXSPRITES; j++ ) {
        !           673:                     if( sprite[j].extra == i ) {
        !           674:                          break;
        !           675:                     }
        !           676:                }
        !           677:                if( j == MAXSPRITES ) {
        !           678:                     spriteXT[i].lock=0x00;
        !           679:                     sprintf(what, "extension %d had no map", i);
        !           680:                     printmessage16(what);
        !           681:                     fprintf(fp, "No mapping for locked XT %4d\n", i);
        !           682:                }
        !           683:           }
        !           684:      }
        !           685: 
        !           686:      fprintf(fp, "\n");
        !           687:      // check for non-unique mapping
        !           688:      for( i=0; i<MAXSPRITES; i++ ) {
        !           689:           ext=sprite[i].extra;
        !           690:           if( ext != -1 ) {
        !           691:                for( j=0; j<MAXSPRITES; j++ ) {
        !           692:                     if( (j != i) && (sprite[j].extra == ext) ) {
        !           693:                          sprintf(what, "non unique map for %d",i);
        !           694:                          printmessage16(what);
        !           695:                          fprintf(fp, "Non unique mapping for %4d at %d,%d\n", i,sprite[i].x,sprite[i].y);
        !           696:                          break;
        !           697:                     }
        !           698:                }
        !           699:           }
        !           700:      }
        !           701: 
        !           702:      fclose(fp);
        !           703: }
        !           704: 
        !           705: // tags on information in sprXT array to end of .map file
        !           706: int
        !           707: JS_SaveSpriteExts(const char *mapname)
        !           708: {
        !           709:      int       fh,i,nr;
        !           710:      int       ssize;
        !           711: 
        !           712:      ssize=sizeof(struct XTtrailertype);
        !           713:      ssize=sizeof(struct XTsavetype);
        !           714: 
        !           715:      if (qsetmode == 480) {
        !           716:           printmessage16("Appending extensions...");
        !           717:           tickdelay=totalclock;
        !           718:           while ( (totalclock-tickdelay)<60 )
        !           719:                ;
        !           720:      }
        !           721: 
        !           722:      fh=open(mapname, O_CREAT | O_BINARY | O_WRONLY, S_IREAD | S_IWRITE);
        !           723:      if ( fh == -1 ) {
        !           724:           return(-1);
        !           725:      }
        !           726: 
        !           727:      //checkextras();
        !           728: 
        !           729:      // prepare trailer
        !           730:      memset(&XTtrailer, 0, sizeof(struct XTtrailertype));
        !           731:      strncpy(XTtrailer.mapname, mapname, 12);
        !           732:      XTtrailer.mapname[12]='\0';
        !           733:      strcpy(XTtrailer.ID, TRAILERID);
        !           734:      XTtrailer.ID[12]='\0';
        !           735:      XTtrailer.numXTs=0L;
        !           736: 
        !           737:      // go to end of map = beginning of eXTensions
        !           738:      XTtrailer.start=lseek(fh, 0, SEEK_END);
        !           739: 
        !           740:      // verify extension then
        !           741:      // write extensions to end of map file
        !           742:      XTtrailer.numXTs=0L;
        !           743:      for (i=0; i<MAXSPRITES; i++) {
        !           744:           if( spriteXT[i].lock == 0xFF ) {
        !           745:                memset(&XTsave, 0, sizeof(struct XTsavetype));
        !           746:                XTtrailer.numXTs++;
        !           747:                XTsave.XTnum=i;
        !           748:                XTsave.sprXT=spriteXT[i];
        !           749:                nr=write(fh, &XTsave, sizeof(struct XTsavetype));
        !           750:           }
        !           751:      }
        !           752: 
        !           753:      // write trailer 
        !           754:      write(fh, &XTtrailer, sizeof(struct XTtrailertype));
        !           755:      flushall();
        !           756:      close(fh);
        !           757: 
        !           758:  return(0);
        !           759: }
        !           760: 
        !           761: int
        !           762: JS_CheckExtras()
        !           763: {
        !           764:      int       i,nse;
        !           765:      spritetype     *sprptr;
        !           766: 
        !           767:      nse=0;
        !           768:      for( i=0; i<MAXSPRITES; i++ ) {
        !           769:           sprptr=&sprite[i];
        !           770:           if( sprite[i].extra != -1 )
        !           771:                nse++;
        !           772:      }
        !           773: 
        !           774:  return(nse);
        !           775: }
        !           776: 
        !           777: int
        !           778: JS_InitExtension(short sn, short en)
        !           779: {
        !           780:  memset(&spriteXT[en], 0, sizeof(struct spriteextension));     
        !           781:  spriteXT[en].basestat=sprite[sn].statnum;
        !           782:  spriteXT[en].basepic=sprite[sn].picnum;
        !           783: 
        !           784:  return(1);
        !           785: }
        !           786: 
        !           787: void
        !           788: JS_GetPicInfo(struct picattribtype *picattr, short picnum)
        !           789: {
        !           790:      long      amask=picanm[picnum];
        !           791: 
        !           792:      memset(picattr, 0, sizeof(struct picattribtype));
        !           793: 
        !           794:      picattr->numframes=amask&0x0000003F;     
        !           795:      picattr->animtype =( amask&0x000000C0 )>>6;
        !           796:      picattr->xcenteroffset=( amask&0x0000FF00 )>>8;
        !           797:      picattr->ycenteroffset=( amask&0x00FF0000 )>>16;
        !           798:      picattr->animspeed=( amask&0x0F000000 )>>24;
        !           799: }
        !           800: 
        !           801: int 
        !           802: JS_ShowSpriteExts(short spritenum)
        !           803: {
        !           804:      short     i=sprite[spritenum].extra;
        !           805:      char      quip[128];
        !           806:      long      nf=0L;
        !           807:      struct    picattribtype  picinfo;
        !           808: 
        !           809:        if (qsetmode == 200)    //In 3D mode
        !           810:           return(0);
        !           811: 
        !           812:      clearmidstatbar16();
        !           813:      printmessage16("                                        ");
        !           814: 
        !           815:      if ( i < 0 ) {
        !           816:           printmessage16("Sprite has NO Mapped Extension !!");
        !           817:           return(-1);
        !           818:      }
        !           819:      if( spriteXT[i].lock != 0xFF ) {
        !           820:           sprite[spritenum].extra=-1;
        !           821:           putch(0x07);
        !           822:           printmessage16("Sprite Mapped to unlocked EXT - repaired.");
        !           823:           return(-1);
        !           824:      }
        !           825: 
        !           826:      memset(quip, '\0', 128);
        !           827: 
        !           828:      PrintStatus("Sprite ", ( int)spritenum,1,4,11);
        !           829:      PrintStatus("Picnum ", sprite[spritenum].picnum,1,5,11);
        !           830:      sprintf(quip, "%s", names[sprite[spritenum].picnum], spritenum);
        !           831:      PrintstatusStr(quip,"", 1,6,3);
        !           832: 
        !           833:      PrintStatus("Status ", sprite[spritenum].statnum,1,7,11);
        !           834:      switch( sprite[spritenum].statnum ) {
        !           835:      case INANIMATE:
        !           836:           PrintStatusStr("","INANIMATE",1,8,3);
        !           837:           break;
        !           838:      case INACTIVE:       
        !           839:           PrintStatusStr("","INACTIVE",1,8,3);
        !           840:           break;                        
        !           841:      case STANDING:
        !           842:           PrintStatusStr("","STANDING",1,8,3);
        !           843:           break;
        !           844:      case AMBUSH:         
        !           845:           PrintStatusStr("","AMBUSH",1,8,3);
        !           846:           break;
        !           847:      case GUARD:         
        !           848:           PrintStatusStr("","GUARD",1,8,3);
        !           849:           break;
        !           850:      case CHASE:          
        !           851:           PrintStatusStr("","CHASE",1,8,3);
        !           852:           break;
        !           853:      case FLEE:        
        !           854:           PrintStatusStr("","FLEE",1,8,3);
        !           855:           break;
        !           856:      case STALK:
        !           857:           PrintStatusStr("","STALK",1,8,3);
        !           858:           break;
        !           859:      case PATROL:         
        !           860:           PrintStatusStr("","PATROL",1,8,3);
        !           861:           break;
        !           862:      case CRAWL:         
        !           863:           PrintStatusStr("","CRAWL",1,8,3);
        !           864:           break;
        !           865:      case STROLL:         
        !           866:           PrintStatusStr("","STROLL",1,8,3);
        !           867:           break;
        !           868:      case FLY:
        !           869:           PrintStatusStr("","FLY",1,8,3);
        !           870:           break;
        !           871:      case RODENT:
        !           872:           PrintStatusStr("","RODENT",1,8,3);
        !           873:           break;
        !           874:      case PINBALL:
        !           875:           PrintStatusStr("","PINBALL",1,8,3);
        !           876:           break;
        !           877:      default:
        !           878:           sprite[spritenum].statnum=INACTIVE;          
        !           879:           PrintStatusStr("","BAD STATNUM",1,8,4);
        !           880:           break;
        !           881:      }
        !           882: 
        !           883:      PrintStatus(        "Extension ", i,1,9,11);
        !           884: 
        !           885:      switch ( ( int)spriteXT[i].lock ) {
        !           886:      case 0x00:
        !           887:           putch(0x07);
        !           888:           PrintStatusStr("ERROR Lock", " OFF" ,1,10,2);
        !           889:           putch(0x07);
        !           890:           break;
        !           891:      case 0xFF:
        !           892:           PrintStatusStr("Lock      ", " ON" ,1,10,3);
        !           893:           break;
        !           894:      default:
        !           895:           PrintStatusStr("BAD LOCK NUM", "" ,1,10,3);
        !           896:           break;
        !           897:      }
        !           898: 
        !           899:      if( spriteXT[i].class != CLASS_NULL ) {
        !           900:           sprintf(quip, "1 of %d ", numinclass[spriteXT[i].class]);
        !           901:           PrintStatusStr(quip,"",1,12,2);
        !           902:           }
        !           903:      switch ( spriteXT[i].class ) {
        !           904:      case CLASS_NULL:
        !           905:           break;
        !           906:      case CLASS_FCIAGENT:
        !           907:           PrintStatusStr("Cosmos Employees","",1,13,2);
        !           908:           break;
        !           909:      case CLASS_CIVILLIAN:     
        !           910:           PrintStatusStr("Civillians","",1,13,2);
        !           911:           break;
        !           912:      case CLASS_SPIDERDROID:     
        !           913:           PrintStatusStr("Spider Droids","",1,13,2);
        !           914:           break;
        !           915:      case CLASS_COP:     
        !           916:           PrintStatusStr("Cops","",1,13,2);
        !           917:           break;
        !           918:      case CLASS_MECHCOP:     
        !           919:           PrintStatusStr("Mech Cops","",1,13,2);
        !           920:           break;            
        !           921:      case CLASS_TEKBURNOUT:     
        !           922:           PrintStatusStr("Tek Burnouts","",1,13,2);
        !           923:           break;
        !           924:      case CLASS_TEKGOON:     
        !           925:           PrintStatusStr("Tek Goons","",1,13,2);
        !           926:           break;
        !           927:      case CLASS_ASSASSINDROID:     
        !           928:           PrintStatusStr("Assasin Droids","",1,13,2);
        !           929:           break;
        !           930:      case CLASS_SECURITYDROID:     
        !           931:           PrintStatusStr("Security Droids","",1,13,2);
        !           932:           break;
        !           933:      case CLASS_TEKBOSS:     
        !           934:           PrintStatusStr("Tek Bosses","",1,13,2);
        !           935:           break;
        !           936:      case CLASS_TEKLORD:                
        !           937:           PrintStatusStr("Tek Lords","",1,13,2);
        !           938:           break;
        !           939:      default:
        !           940:           PrintStatusStr("UNCLASSIFIED","",1,13,2);
        !           941:           break;
        !           942:      }
        !           943: 
        !           944:      PrintStatus("Class     ", ( int)spriteXT[i].class    ,18,4,11);
        !           945:      PrintStatus("Hitpoints ", ( int)spriteXT[i].hitpoints,18,5,11);
        !           946:      PrintStatus("Target    ", ( int)spriteXT[i].target   ,18,6,11);
        !           947:      PrintStatus("BaseStat  ", ( int)spriteXT[i].basestat ,18,7,11);
        !           948:      switch( spriteXT[i].basestat ) {
        !           949:      case INANIMATE:
        !           950:           PrintStatusStr("","INANIMATE",18,8,3);
        !           951:           break;
        !           952:      case INACTIVE:       
        !           953:           PrintStatusStr("","INACTIVE",18,8,3);
        !           954:           break;
        !           955:      case STANDING:
        !           956:           PrintStatusStr("","STANDING",18,8,3);
        !           957:           break;                           
        !           958:      case AMBUSH:         
        !           959:           PrintStatusStr("","AMBUSH",18,8,3);
        !           960:           break;
        !           961:      case GUARD:         
        !           962:           PrintStatusStr("","GUARD",18,8,3);
        !           963:           break;
        !           964:      case CHASE:          
        !           965:           PrintStatusStr("","CHASE",18,8,3);
        !           966:           break;
        !           967:      case FLEE:        
        !           968:           PrintStatusStr("","FLEE",18,8,3);
        !           969:           break;
        !           970:      case STALK:
        !           971:           PrintStatusStr("","STALK",18,8,3);
        !           972:           break;
        !           973:      case PATROL:         
        !           974:           PrintStatusStr("","PATROL",18,8,3);
        !           975:           break;
        !           976:      case CRAWL:         
        !           977:           PrintStatusStr("","CRAWL",18,8,3);
        !           978:           break;
        !           979:      case STROLL:         
        !           980:           PrintStatusStr("","STROLL",18,8,3);
        !           981:           break;
        !           982:      case FLY:
        !           983:           PrintStatusStr("","FLY",18,8,3);
        !           984:           break;
        !           985:      case RODENT:
        !           986:           PrintStatusStr("","RODENT",18,8,3);
        !           987:           break;
        !           988:      case PINBALL:
        !           989:           PrintStatusStr("","PINBALL",18,8,3);
        !           990:           break;
        !           991:      default:
        !           992:           PrintStatusStr("","BAD BASE STAT",18,8,4);
        !           993:           spriteXT[i].basestat=INACTIVE;
        !           994:           break;
        !           995:      }
        !           996: 
        !           997:      PrintStatus("FXMask    ", ( int)spriteXT[i].fxmask ,18,9,11);
        !           998:      PrintStatus("AIMask    ", ( int)spriteXT[i].aimask ,18,10,11);
        !           999: 
        !          1000:      /*
        !          1001: #define   GUN2FLAG            2
        !          1002: #define   GUN3FLAG            3
        !          1003: #define   GUN4FLAG            4
        !          1004: #define   GUN5FLAG            5
        !          1005: #define   GUN6FLAG            6
        !          1006: #define   GUN7FLAG            7
        !          1007:      case 0:                  // bare hands
        !          1008:      case 1:                  // baton
        !          1009:      case 2:                  // stunner
        !          1010:      case 3:                  // shrike DBK pistol
        !          1011:      case 4:                  // kralov CEG machine pistol
        !          1012:      case 5:                  // orlow 34S force gun
        !          1013:      case 6:                  // energy weapon
        !          1014:      case 7:                  // explosives
        !          1015:      case 8:                  // sleeping gas
        !          1016:      case 9:                  // flame thrower
        !          1017:      case 10:                 // rocket launcher
        !          1018:       */
        !          1019:      PrintStatus("Weapon    ", ( int)spriteXT[i].weapon ,18,11,11);
        !          1020:      switch( spriteXT[i].weapon ) {
        !          1021:      case GUN3FLAG:
        !          1022:           PrintStatusStr("","STUNNER",18,12,3);
        !          1023:           break;                           
        !          1024:      case GUN4FLAG:
        !          1025:           PrintStatusStr("","SHRIKE",18,12,3);
        !          1026:           break;
        !          1027:      case GUN5FLAG:
        !          1028:           PrintStatusStr("","KRALOV",18,12,3);
        !          1029:           break;
        !          1030:      case GUN6FLAG:
        !          1031:           PrintStatusStr("","PULSAR",18,12,3);
        !          1032:           break;
        !          1033:      default:
        !          1034:           PrintStatusStr("","BARE HANDS",18,12,4);
        !          1035:           spriteXT[i].weapon=0;
        !          1036:           break;
        !          1037:      }
        !          1038: 
        !          1039:      PrintStatus("Ext2      ", ( int)spriteXT[i].ext2   ,18,13,11);
        !          1040: 
        !          1041:      PrintStatus("BasePic   ", ( int)spriteXT[i].basepic   ,34,4,11);
        !          1042:      PrintStatus("StandPic  ", ( int)spriteXT[i].standpic  ,34,5,11);
        !          1043:      PrintStatus("WalkPic   ", ( int)spriteXT[i].walkpic   ,34,6,11);
        !          1044:      PrintStatus("RunPic    ", ( int)spriteXT[i].runpic    ,34,7,11);
        !          1045:      PrintStatus("AttackPic ", ( int)spriteXT[i].attackpic ,34,8,11);
        !          1046: 
        !          1047:      PrintStatus("DeathPic  ", ( int)spriteXT[i].deathpic  ,34,9,11);
        !          1048:      PrintStatus("PainPic   ", ( int)spriteXT[i].painpic   ,34,10,11);
        !          1049:      PrintStatus("SquatPic  ", ( int)spriteXT[i].squatpic  ,34,11,11);
        !          1050:      PrintStatus("MorphPic  ", ( int)spriteXT[i].morphpic  ,34,12,11);
        !          1051:      PrintStatus("SpecialPic", ( int)spriteXT[i].specialpic,34,13,11);
        !          1052: 
        !          1053:      PrintStatusStr("", names[spriteXT[i].basepic]   ,50,4,3);
        !          1054:      PrintStatusStr("", names[spriteXT[i].standpic]  ,50,5,3);
        !          1055:      PrintStatusStr("", names[spriteXT[i].walkpic]   ,50,6,3);
        !          1056:      PrintStatusStr("", names[spriteXT[i].runpic]    ,50,7,3);
        !          1057:      PrintStatusStr("", names[spriteXT[i].attackpic] ,50,8,3);
        !          1058: 
        !          1059:      PrintStatusStr("", names[spriteXT[i].deathpic]  ,50,9,3);
        !          1060:      PrintStatusStr("", names[spriteXT[i].painpic]   ,50,10,3);
        !          1061:      PrintStatusStr("", names[spriteXT[i].squatpic]  ,50,11,3);
        !          1062:      PrintStatusStr("", names[spriteXT[i].morphpic]  ,50,12,3);
        !          1063:      PrintStatusStr("", names[spriteXT[i].specialpic],50,13,3);
        !          1064: 
        !          1065:      JS_GetPicInfo(&picinfo, spriteXT[i].basepic);
        !          1066:      switch( picinfo.animtype ) {
        !          1067:      case 0: sprintf(quip, "NoANM %2d  %2d", picinfo.numframes, picinfo.animspeed); break;
        !          1068:      case 1: sprintf(quip, "Oscil %2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1069:      case 2: sprintf(quip, "AnmFD %2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1070:      case 3: sprintf(quip, "AnmBK %2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1071:      default:sprintf(quip, "  ???    "); break;
        !          1072:      }
        !          1073:      PrintStatusStr("", quip,64,4,3);
        !          1074: 
        !          1075:      JS_GetPicInfo(&picinfo, spriteXT[i].standpic);
        !          1076:      switch( picinfo.animtype ) {
        !          1077:      case 0: sprintf(quip, "NoANM:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1078:      case 1: sprintf(quip, "Oscil:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1079:      case 2: sprintf(quip, "AnmFD:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1080:      case 3: sprintf(quip, "AnmBK:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1081:      default:sprintf(quip, "  ???    "); break;
        !          1082:      }
        !          1083:      PrintStatusStr("", quip,64,5,3);
        !          1084: 
        !          1085:      JS_GetPicInfo(&picinfo, spriteXT[i].walkpic);
        !          1086:      switch( picinfo.animtype ) {
        !          1087:      case 0: sprintf(quip, "NoANM:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1088:      case 1: sprintf(quip, "Oscil:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1089:      case 2: sprintf(quip, "AnmFD:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1090:      case 3: sprintf(quip, "AnmBK:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1091:      default:sprintf(quip, "  ???    "); break;
        !          1092:      }
        !          1093:      PrintStatusStr("", quip,64,6,3);
        !          1094: 
        !          1095:      JS_GetPicInfo(&picinfo, spriteXT[i].runpic);
        !          1096:      switch( picinfo.animtype ) {
        !          1097:      case 0: sprintf(quip, "NoANM:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1098:      case 1: sprintf(quip, "Oscil:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1099:      case 2: sprintf(quip, "AnmFD:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1100:      case 3: sprintf(quip, "AnmBK:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1101:      default:sprintf(quip, "  ???    "); break;
        !          1102:      }
        !          1103:      PrintStatusStr("", quip,64,7,3);
        !          1104: 
        !          1105:      JS_GetPicInfo(&picinfo, spriteXT[i].attackpic);
        !          1106:      switch( picinfo.animtype ) {
        !          1107:      case 0: sprintf(quip, "NoANM:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1108:      case 1: sprintf(quip, "Oscil:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1109:      case 2: sprintf(quip, "AnmFD:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1110:      case 3: sprintf(quip, "AnmBK:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1111:      default:sprintf(quip, "  ???    "); break;
        !          1112:      }
        !          1113:      PrintStatusStr("", quip,64,8,3);
        !          1114: 
        !          1115:      JS_GetPicInfo(&picinfo, spriteXT[i].deathpic);
        !          1116:      switch( picinfo.animtype ) {
        !          1117:      case 0: sprintf(quip, "NoANM:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1118:      case 1: sprintf(quip, "Oscil:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1119:      case 2: sprintf(quip, "AnmFD:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1120:      case 3: sprintf(quip, "AnmBK:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1121:      default:sprintf(quip, "  ???    "); break;
        !          1122:      }
        !          1123:      PrintStatusStr("", quip,64,9,3);
        !          1124: 
        !          1125:      JS_GetPicInfo(&picinfo, spriteXT[i].painpic);
        !          1126:      switch( picinfo.animtype ) {
        !          1127:      case 0: sprintf(quip, "NoANM:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1128:      case 1: sprintf(quip, "Oscil:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1129:      case 2: sprintf(quip, "AnmFD:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1130:      case 3: sprintf(quip, "AnmBK:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1131:      default:sprintf(quip, "  ???    "); break;
        !          1132:      }
        !          1133:      PrintStatusStr("", quip,64,10,3);
        !          1134: 
        !          1135:      JS_GetPicInfo(&picinfo, spriteXT[i].squatpic);
        !          1136:      switch( picinfo.animtype ) {
        !          1137:      case 0: sprintf(quip, "NoANM:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1138:      case 1: sprintf(quip, "Oscil:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1139:      case 2: sprintf(quip, "AnmFD:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1140:      case 3: sprintf(quip, "AnmBK:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1141:      default:sprintf(quip, "  ???    "); break;
        !          1142:      }
        !          1143:      PrintStatusStr("", quip,64,11,3);
        !          1144: 
        !          1145:      JS_GetPicInfo(&picinfo, spriteXT[i].morphpic);
        !          1146:      switch( picinfo.animtype ) {
        !          1147:      case 0: sprintf(quip, "NoANM:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1148:      case 1: sprintf(quip, "Oscil:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1149:      case 2: sprintf(quip, "AnmFD:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1150:      case 3: sprintf(quip, "AnmBK:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1151:      default:sprintf(quip, "  ???    "); break;
        !          1152:      }
        !          1153:      PrintStatusStr("", quip,64,12,3);
        !          1154: 
        !          1155:      JS_GetPicInfo(&picinfo, spriteXT[i].specialpic);
        !          1156:      switch( picinfo.animtype ) {
        !          1157:      case 0: sprintf(quip, "NoANM:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1158:      case 1: sprintf(quip, "Oscil:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1159:      case 2: sprintf(quip, "AnmFD:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1160:      case 3: sprintf(quip, "AnmBK:%2d  %2d", picinfo.numframes,picinfo.animspeed); break;
        !          1161:      default:sprintf(quip, "  ???    "); break;
        !          1162:      }
        !          1163:      PrintStatusStr("", quip,64,13,3);
        !          1164: 
        !          1165:  return(0);
        !          1166: }
        !          1167: 
        !          1168: int
        !          1169: JS_SpriteXTManual(void)
        !          1170: {
        !          1171:      clearmidstatbar16();
        !          1172:      printmessage16("                                        ");
        !          1173: 
        !          1174:           liststates=0;
        !          1175: 
        !          1176:           printmessage16(" Manual Page: Sprites...");
        !          1177: 
        !          1178:           PrintStatusStr("      Valid State Types","",1,4,11);
        !          1179: 
        !          1180:           PrintStatusStr("  0","INANIMATE",1,6,0);
        !          1181:           PrintStatusStr("100","INACTIVE" ,1,7,0);
        !          1182:           PrintStatusStr("500","FLY"      ,1,8,0);
        !          1183:           PrintStatusStr("500","RODENT"   ,1,9,0);
        !          1184:           PrintStatusStr("201","STANDING" ,1,10,0);
        !          1185:           PrintStatusStr("202","AMBUSH"   ,1,11,0);
        !          1186: 
        !          1187:           PrintStatusStr("203","GUARD"    ,16,6,0);
        !          1188:           PrintStatusStr("204","STALK"    ,16,7,0);
        !          1189:           PrintStatusStr("205","FLEE"     ,16,8,0);
        !          1190:           PrintStatusStr("206","CHASE"    ,16,9,0);
        !          1191:           PrintStatusStr("207","PATROL"   ,16,10,0);
        !          1192:           PrintStatusStr("209","STROLL"   ,16,11,0);
        !          1193:      /*
        !          1194:      case 0:                  // bare hands
        !          1195:      case 1:                  // baton
        !          1196:      case 2:                  // stunner
        !          1197:      case 3:                  // shrike DBK pistol
        !          1198:      case 4:                  // kralov CEG machine pistol
        !          1199:      case 5:                  // orlow 34S force gun
        !          1200:      case 6:                  // energy weapon
        !          1201:      case 7:                  // explosives
        !          1202:      case 8:                  // sleeping gas
        !          1203:      case 9:                  // flame thrower
        !          1204:      case 10:                 // rocket launcher
        !          1205:      */
        !          1206:           PrintStatusStr(" Valid Weapons ","",30,4,11);
        !          1207:                             
        !          1208:           PrintStatusStr(" 3 STUNNER",""     ,30,6,0);
        !          1209:           PrintStatusStr(" 4 SHRIKE",""    ,30,7,0);
        !          1210:           PrintStatusStr(" 5 KRALOW",""    ,30,8,0);
        !          1211:           PrintStatusStr(" 6 PULSAR",""    ,30,9,0);
        !          1212: 
        !          1213:           PrintStatusStr(" Valid Class Types ","",50,4,11);
        !          1214: 
        !          1215:           PrintStatusStr("1 FCIAGENT", ""     ,48,6,0);
        !          1216:           PrintStatusStr("2 CIVILLIAN", ""    ,48,7,0);
        !          1217:           PrintStatusStr("3 SPIDERDROID", ""  ,48,8,0);
        !          1218:           PrintStatusStr("4 COP", ""          ,48,9,0);
        !          1219:           PrintStatusStr("5 MECHCOP", ""      ,48,10,0);
        !          1220:           PrintStatusStr("6 TEKBURNOUT", ""   ,48,11,0);
        !          1221: 
        !          1222:           PrintStatusStr("7  TEKGOON", ""      ,62,6,0);
        !          1223:           PrintStatusStr("8  ASSASSINDROID", "",62,7,0);
        !          1224:           PrintStatusStr("9  SECURITYDROID", "",62,8,0);
        !          1225:           PrintStatusStr("10 TEKBOSS",""       ,62,9,0);
        !          1226:           PrintStatusStr("11 TEKLORD",""       ,62,10,0);
        !          1227:                                                        
        !          1228:  return(0);
        !          1229: }
        !          1230: 
        !          1231: int
        !          1232: JS_FirstFreeExt(void)
        !          1233: {
        !          1234:  short    i;
        !          1235: 
        !          1236:  for ( i=0; i<MAXSPRITES; i++ ) {
        !          1237:      if ( spriteXT[i].lock == 0x00 )
        !          1238:           return(i);
        !          1239:  }
        !          1240: 
        !          1241:  return(-1);   // no free spot found
        !          1242: }
        !          1243: 
        !          1244: int
        !          1245: JS_LockExt(short j)                  
        !          1246: {
        !          1247:      if ( spriteXT[j].lock == 0xFF ) {
        !          1248:           return(-1);
        !          1249:      }
        !          1250:      spriteXT[j].lock=0xFF;
        !          1251: 
        !          1252:  return(0);
        !          1253: }
        !          1254: 
        !          1255: void
        !          1256: JS_GetNumInClass(void)
        !          1257: {
        !          1258:      short i;
        !          1259: 
        !          1260:      for( i=0; i<MAXCLASSES; i++ ) {
        !          1261:           numinclass[i]=0;
        !          1262:      }
        !          1263:      for( i=0; i<MAXSPRITES; i++ ) {
        !          1264:           if( spriteXT[i].lock == 0xFF ) {
        !          1265:                numinclass[spriteXT[i].class]++;
        !          1266:           }
        !          1267:      }
        !          1268: 
        !          1269:  return;
        !          1270: }
        !          1271: 
        !          1272: int
        !          1273: JS_EditSpriteExts(short spritenum)
        !          1274: {
        !          1275:      char      what[50];
        !          1276:      short     j;
        !          1277: 
        !          1278:      spriteextmodified=1;
        !          1279: 
        !          1280:      clearmidstatbar16();
        !          1281: 
        !          1282:      j=sprite[spritenum].extra;
        !          1283: 
        !          1284:      if ( j < 0 ) {        // .extra is initialized to -1 in build.obj
        !          1285:           printmessage16("No Previous Extension.");
        !          1286:           tickdelay=totalclock;
        !          1287:           while ( (totalclock-tickdelay)<50 )
        !          1288:                ;
        !          1289:           j=JS_FirstFreeExt();
        !          1290:           if ( j == -1 ) {
        !          1291:                printmessage16("ERROR! Not able to map to an extension.");
        !          1292:                return(-1);
        !          1293:           }
        !          1294:           printmessage16("Extension Mapped.");
        !          1295:           tickdelay=totalclock;
        !          1296:           while ( (totalclock-tickdelay)<100 )
        !          1297:                ;
        !          1298:           sprite[spritenum].extra=j;
        !          1299:           JS_InitExtension(spritenum, j);
        !          1300:           JS_LockExt(j);
        !          1301:      }
        !          1302:      else {
        !          1303:           printmessage16("Editing Existing Extension.");
        !          1304:           tickdelay=totalclock;
        !          1305:           while ( (totalclock-tickdelay)<100 )
        !          1306:                ;
        !          1307:      }
        !          1308: 
        !          1309:      JS_ShowSpriteExts(spritenum);
        !          1310: 
        !          1311:      sprintf(what, "spriteextra[%d].class     = ", j);
        !          1312:      spriteXT[j].class=getnumber16(what, spriteXT[j].class, 12L);
        !          1313: 
        !          1314:      sprintf(what, "spriteextra[%d].hitpoints = ", j);
        !          1315:      spriteXT[j].hitpoints=getnumber16(what, spriteXT[j].hitpoints, 256L);
        !          1316: 
        !          1317:      sprintf(what, "spriteextra[%d].target    = ", j);
        !          1318:      spriteXT[j].target=getnumber16(what, spriteXT[j].target, 4096L);
        !          1319:                                                    
        !          1320:      sprintf(what, "spriteextra[%d].fxmask    = ", j);
        !          1321:      spriteXT[j].fxmask=getnumber16(what, spriteXT[j].fxmask, 256L);
        !          1322: 
        !          1323:      sprintf(what, "spriteextra[%d].aimask    = ", j);
        !          1324:      spriteXT[j].aimask=getnumber16(what, spriteXT[j].aimask, 256L);
        !          1325: 
        !          1326:      sprintf(what, "spriteextra[%d].basestat  = ", j);
        !          1327:      spriteXT[j].basestat=getnumber16(what, spriteXT[j].basestat, 4096L);
        !          1328: 
        !          1329:      sprintf(what, "spriteextra[%d].basepic   = ", j);
        !          1330:      spriteXT[j].basepic=getnumber16(what, spriteXT[j].basepic, 4096L);
        !          1331: 
        !          1332:      sprintf(what, "spriteextra[%d].standpic = ", j);
        !          1333:      spriteXT[j].standpic=getnumber16(what, spriteXT[j].standpic, 4096L);
        !          1334: 
        !          1335:      sprintf(what, "spriteextra[%d].walkpic = ", j);
        !          1336:      spriteXT[j].walkpic=getnumber16(what, spriteXT[j].walkpic, 4096L);
        !          1337: 
        !          1338:      sprintf(what, "spriteextra[%d].runpic = ", j);
        !          1339:      spriteXT[j].runpic=getnumber16(what, spriteXT[j].runpic, 4096L);
        !          1340: 
        !          1341:      sprintf(what, "spriteextra[%d].attackpic = ", j);
        !          1342:      spriteXT[j].attackpic=getnumber16(what, spriteXT[j].attackpic, 4096L);
        !          1343: 
        !          1344:      sprintf(what, "spriteextra[%d].deathpic  = ", j);
        !          1345:      spriteXT[j].deathpic=getnumber16(what, spriteXT[j].deathpic, 4096L);
        !          1346: 
        !          1347:      sprintf(what, "spriteextra[%d].painpic = ", j);
        !          1348:      spriteXT[j].painpic=getnumber16(what, spriteXT[j].painpic, 4096L);
        !          1349: 
        !          1350:      sprintf(what, "spriteextra[%d].squatpic = ", j);
        !          1351:      spriteXT[j].squatpic=getnumber16(what, spriteXT[j].squatpic, 4096L);
        !          1352: 
        !          1353:      sprintf(what, "spriteextra[%d].morphpic  = ", j);
        !          1354:      spriteXT[j].morphpic=getnumber16(what, spriteXT[j].morphpic, 4096L);
        !          1355: 
        !          1356:      sprintf(what, "spriteextra[%d].specialpic  = ", j);
        !          1357:      spriteXT[j].specialpic=getnumber16(what, spriteXT[j].specialpic, 4096L);
        !          1358: 
        !          1359:      sprintf(what, "spriteextra[%d].weapon  = ", j);
        !          1360:      spriteXT[j].weapon=getnumber16(what, spriteXT[j].weapon, 7L);
        !          1361: 
        !          1362:      sprintf(what, "spriteextra[%d].ext2  = ", j);
        !          1363:      spriteXT[j].ext2=getnumber16(what, spriteXT[j].ext2, 4096L);
        !          1364: 
        !          1365:      printmessage16("Sprite Extensions Saved.");
        !          1366: 
        !          1367:      JS_ShowSpriteExts(spritenum);
        !          1368: 
        !          1369:  return(0);
        !          1370: }
        !          1371: 
        !          1372: int
        !          1373: JS_ChangeVelocity(short sn)
        !          1374: {
        !          1375:      char      what[50];
        !          1376: 
        !          1377:      sprintf(what, "sprite[%d].xvel  = ", sn);
        !          1378:      sprite[sn].xvel=getnumber16(what, sprite[sn].xvel, 10L);
        !          1379: 
        !          1380:      sprintf(what, "sprite[%d].yvel  = ", sn);          
        !          1381:      sprite[sn].yvel=getnumber16(what, sprite[sn].yvel, 10L);
        !          1382: 
        !          1383:      sprintf(what, "sprite[%d].zvel  = ", sn);
        !          1384:      sprite[sn].zvel=getnumber16(what, sprite[sn].zvel, 10L);
        !          1385: 
        !          1386:      tickdelay=totalclock;
        !          1387:      while ( (totalclock-tickdelay)<50 )
        !          1388:           ;
        !          1389: 
        !          1390:      printmessage16("Velocities adjusted");
        !          1391: 
        !          1392:      keystatus[56]=1;
        !          1393:      keystatus[15]=1;
        !          1394: 
        !          1395:  return(0);
        !          1396: }
        !          1397: 
        !          1398: #endif
        !          1399: 
        !          1400: 
        !          1401: //Detecting 2D / 3D mode:
        !          1402: //   qsetmode is 200 in 3D mode
        !          1403: //   qsetmode is 350/480 in 2D mode
        !          1404: //
        !          1405: //You can read these variables when F5-F8 is pressed in 3D mode only:
        !          1406: //
        !          1407: //   If (searchstat == 0)  WALL        searchsector=sector, searchwall=wall
        !          1408: //   If (searchstat == 1)  CEILING     searchsector=sector
        !          1409: //   If (searchstat == 2)  FLOOR       searchsector=sector
        !          1410: //   If (searchstat == 3)  SPRITE      searchsector=sector, searchwall=sprite
        !          1411: //   If (searchstat == 4)  MASKED WALL searchsector=sector, searchwall=wall
        !          1412: //
        !          1413: //   searchsector is the sector of the selected item for all 5 searchstat's
        !          1414: //
        !          1415: //   searchwall is undefined if searchstat is 1 or 2
        !          1416: //   searchwall is the wall if searchstat = 0 or 4
        !          1417: //   searchwall is the sprite if searchstat = 3 (Yeah, I know - it says wall,
        !          1418: //                                      but trust me, it's the sprite number)
        !          1419: 
        !          1420: void ExtInit(void)
        !          1421: {
        !          1422:        long i, fil;
        !          1423: 
        !          1424:     #ifdef TEKWAR
        !          1425:      clrscr();
        !          1426:      scrldn();
        !          1427:      home(0L);
        !          1428:      wrchar('T');
        !          1429:      home(1L);
        !          1430:      wrchar('e');
        !          1431:      home(2L);
        !          1432:      wrchar('k');
        !          1433:      home(3L);
        !          1434:      wrchar('w');
        !          1435:      home(4L);
        !          1436:      wrchar('a');
        !          1437:      home(5L);
        !          1438:      wrchar('r');
        !          1439:      home(7L);
        !          1440:      wrchar('B');
        !          1441:      home(8L);
        !          1442:      wrchar('U');
        !          1443:      home(9L);
        !          1444:      wrchar('I');
        !          1445:      home(10L);
        !          1446:      wrchar('L');
        !          1447:      home(11L);
        !          1448:      wrchar('D');
        !          1449:      home(13L);
        !          1450:      wrchar('V');
        !          1451:      home(14L);
        !          1452:      wrchar('1');
        !          1453:      home(15L);
        !          1454:      wrchar('.');
        !          1455:      home(16L);
        !          1456:      wrchar('2');
        !          1457:      ontherange();
        !          1458:     #endif
        !          1459: 
        !          1460:        initgroupfile("stuff.dat");
        !          1461: 
        !          1462:     #ifdef LOADSETUP
        !          1463:        if ((fil = open("setup.dat",O_BINARY|O_RDWR,S_IREAD)) != -1)
        !          1464:        {
        !          1465:                read(fil,&option[0],NUMOPTIONS);
        !          1466:                read(fil,&keys[0],NUMKEYS);
        !          1467:                memcpy((void *)buildkeys,(void *)keys,NUMKEYS);   //Trick to make build use setup.dat keys
        !          1468:                close(fil);
        !          1469:        }
        !          1470:     #endif
        !          1471: 
        !          1472:        if (option[4] > 0) option[4] = 0;
        !          1473:        initmouse();
        !          1474: 
        !          1475:        switch(option[0])
        !          1476:        {
        !          1477:                case 0: initengine(0,chainxres[option[6]&15],chainyres[option[6]>>4]); break;
        !          1478:                case 1: initengine(1,vesares[option[6]&15][0],vesares[option[6]&15][1]); break;
        !          1479:                case 2: initengine(2,320L,200L); break;
        !          1480:                case 3: initengine(3,320L,200L); break;
        !          1481:                case 4: initengine(4,320L,200L); break;
        !          1482:                case 5: initengine(5,320L,200L); break;
        !          1483:                case 6: initengine(6,320L,200L); break;
        !          1484:        }
        !          1485: 
        !          1486:                //You can load your own palette lookup tables here if you just
        !          1487:                //copy the right code!
        !          1488:        for(i=0;i<256;i++)
        !          1489:                tempbuf[i] = ((i+32)&255);  //remap colors for screwy palette sectors
        !          1490:        makepalookup(16,tempbuf,0,0,0,1);
        !          1491: 
        !          1492:    #ifndef TEKWAR 
        !          1493:        kensplayerheight = 32;
        !          1494:        zmode = 0;
        !          1495:        defaultspritecstat = 0;
        !          1496:    #endif
        !          1497:    #ifdef TEKWAR
        !          1498:        kensplayerheight = 34;
        !          1499:        zmode = 0;
        !          1500:        defaultspritecstat = 0;
        !          1501:    #endif
        !          1502: 
        !          1503:    #ifdef TEKWAR
        !          1504:     parallaxtype=2;
        !          1505:     parallaxyoffs=112;
        !          1506:     pskyoff[0]=0;   
        !          1507:     pskyoff[1]=1;   
        !          1508:     pskyoff[2]=2; 
        !          1509:     pskyoff[3]=3;   
        !          1510:     pskybits=2;     // 4 tiles
        !          1511:     memset(&recXT, 0, sizeof(struct spriteextension));
        !          1512:     recordXT=-1;
        !          1513:    #endif
        !          1514: }
        !          1515: 
        !          1516: void ExtUnInit(void)
        !          1517: {
        !          1518:        uninitgroupfile();
        !          1519: }
        !          1520: 
        !          1521: void ExtPreCheckKeys(void)
        !          1522: {
        !          1523: }
        !          1524: 
        !          1525: void ExtCheckKeys(void)
        !          1526: {
        !          1527:        long i;
        !          1528: 
        !          1529:        if (qsetmode == 200)    //In 3D mode
        !          1530:        {
        !          1531:         #ifdef TEKWAR
        !          1532:          if( somethingintab == 3 )   // prevent extra value copy
        !          1533:               somethingintab = 254;
        !          1534:         #endif
        !          1535: 
        !          1536:                i = totalclock;
        !          1537:                if (i != frameval[framecnt])
        !          1538:                {
        !          1539:                        sprintf(tempbuf,"%ld",(120*AVERAGEFRAMES)/(i-frameval[framecnt]));
        !          1540:                        printext256(0L,0L,31,-1,tempbuf,1);
        !          1541:                        frameval[framecnt] = i;
        !          1542:                }
        !          1543:                framecnt = ((framecnt+1)&(AVERAGEFRAMES-1));
        !          1544:                
        !          1545:                editinput();
        !          1546:        }
        !          1547:        else
        !          1548:        {
        !          1549:         #ifdef TEKWAR 
        !          1550:          if( keystatus[39] == 1 ) {  // ';' to clear all exts 
        !          1551:               keystatus[39]=0;
        !          1552:               JS_ClearAllExts();
        !          1553:          }
        !          1554:          if( keystatus[26] == 1 ) {  // '[' to clear all exts 
        !          1555:               keystatus[26]=0;
        !          1556:               JS_ClearAllSprites();
        !          1557:          }
        !          1558:          if( keystatus[47] == 1 ) {  // 'V' to edit velocity
        !          1559:               keystatus[47]=0;
        !          1560:               editvelocity=1;
        !          1561:               keystatus[66]=1;
        !          1562:          }
        !          1563:          if( keystatus[40] == 1 ) {  // ''' to cleanup from old versions
        !          1564:               keystatus[40]=0;
        !          1565:               docleanup=1;
        !          1566:               keystatus[66]=1;
        !          1567:          }
        !          1568:          if( keystatus[27] == 1 ) {  // ']' match cstats
        !          1569:               keystatus[27]=0;
        !          1570:               JS_MatchCstats();
        !          1571:          }
        !          1572:          if( keystatus[45] == 1 ) {  // XT Copy
        !          1573:               keystatus[45]=0;
        !          1574:               copyext=1;
        !          1575:               keystatus[64]=1;
        !          1576:          }
        !          1577:          if( keystatus[19] == 1 ) {  // XT Record
        !          1578:               keystatus[19]=0;
        !          1579:               recordext=1;
        !          1580:               keystatus[64]=1;
        !          1581:          }
        !          1582:          if( keystatus[50] == 1 ) {  // 'M' for Manual on sprites
        !          1583:               keystatus[50]=0;
        !          1584:               liststates=1;
        !          1585:               JS_SpriteXTManual();
        !          1586:          }
        !          1587:         #endif 
        !          1588:        }
        !          1589: }
        !          1590: 
        !          1591: void ExtCleanUp(void)
        !          1592: {
        !          1593: }
        !          1594: 
        !          1595: void ExtLoadMap(const char *mapname)
        !          1596: {
        !          1597:    #ifdef TEKWAR 
        !          1598:     JS_LoadSpriteExts(mapname);   
        !          1599:    #endif 
        !          1600: }
        !          1601: 
        !          1602: void ExtSaveMap(const char *mapname)
        !          1603: {
        !          1604:    #ifdef TEKWAR 
        !          1605:     JS_SaveSpriteExts(mapname);  
        !          1606:    #endif 
        !          1607: }
        !          1608: 
        !          1609: const char *ExtGetSectorCaption(short sectnum)
        !          1610: {
        !          1611:        if ((sector[sectnum].lotag|sector[sectnum].hitag) == 0)
        !          1612:        {
        !          1613:                tempbuf[0] = 0;
        !          1614:        }
        !          1615:        else
        !          1616:        {
        !          1617:         #ifndef TEKWAR 
        !          1618:                sprintf(tempbuf,"%hu,%hu",(unsigned short)sector[sectnum].hitag,
        !          1619:                                                                                  (unsigned short)sector[sectnum].lotag);
        !          1620:         #endif
        !          1621: 
        !          1622:         #ifdef TEKWAR
        !          1623:           switch((unsigned short)sector[sectnum].lotag) {
        !          1624:           case 1:
        !          1625:                sprintf(lo,"ACTIVATE SECTOR");
        !          1626:                break;
        !          1627:           case 6:
        !          1628:                sprintf(lo,"RISING DOOR");
        !          1629:                break;
        !          1630:           case 7:
        !          1631:                sprintf(lo,"DROP DOOR");
        !          1632:                break;
        !          1633:           case 8:
        !          1634:                sprintf(lo,"HOR SPLIT DOOR");
        !          1635:                break;
        !          1636:           case 9:
        !          1637:                sprintf(lo,"VER SPLIT DOOR");
        !          1638:                break;
        !          1639:           case 1000:
        !          1640:                sprintf(lo,"PLATFORM ELEVATOR");
        !          1641:                break;
        !          1642:           case 1003:
        !          1643:                sprintf(lo,"BOX ELEVATOR");
        !          1644:                break;
        !          1645:           case 1004:
        !          1646:                sprintf(lo,"PLATFORM W/DELAY");
        !          1647:                break;
        !          1648:           case 1005:
        !          1649:                sprintf(lo,"BOX W/DELAY");
        !          1650:                break;
        !          1651:           default:
        !          1652:                sprintf(lo,"%hu",(unsigned short)sector[sectnum].lotag);
        !          1653:                break;
        !          1654:           }
        !          1655:           sprintf(tempbuf,"%hu,%s",(unsigned short)sector[sectnum].hitag,lo);
        !          1656:         #endif 
        !          1657:        }
        !          1658:        return(tempbuf);
        !          1659: }
        !          1660: 
        !          1661: const char *ExtGetWallCaption(short wallnum)
        !          1662: {
        !          1663:    #ifdef TEKWAR
        !          1664:     long i=0;
        !          1665:    #endif  
        !          1666: 
        !          1667:    #ifndef TEKWAR
        !          1668:        if ((wall[wallnum].lotag|wall[wallnum].hitag) == 0)
        !          1669:        {
        !          1670:                tempbuf[0] = 0;
        !          1671:        }
        !          1672:        else
        !          1673:        {
        !          1674:                sprintf(tempbuf,"%hu,%hu",(unsigned short)wall[wallnum].hitag,
        !          1675:                                                                                  (unsigned short)wall[wallnum].lotag);
        !          1676:        }
        !          1677:    #endif
        !          1678: 
        !          1679:    #ifdef TEKWAR
        !          1680:      if (keystatus[0x57] > 0) {    // f11   Grab pic 0x4e +
        !          1681:           wallpicnum=wall[curwall].picnum;
        !          1682:           sprintf(tempbuf,"Grabed Wall Picnum %ld",wallpicnum);
        !          1683:           printmessage16(tempbuf);
        !          1684:      }
        !          1685:      if (keystatus[0x2b] > 0) {    // |
        !          1686:           if (wallsprite == 1) {
        !          1687:                for (i=curwallnum ; i < MAXWALLS ; i++) {
        !          1688:                     if (wall[i].picnum == wall[curwall].picnum) {
        !          1689:                          posx=(wall[i].x)-(((wall[i].x)-(wall[wall[i].point2].x))/2);
        !          1690:                          posy=(wall[i].y)-(( (wall[i].y)-(wall[wall[i].point2].y))/2);
        !          1691:                          printmessage16("Wall Found");
        !          1692:                          curwallnum++;
        !          1693:                          keystatus[0x2b]=0;
        !          1694:                          return(tempbuf);
        !          1695:                     }
        !          1696:                     curwallnum++;
        !          1697:                }
        !          1698:           }
        !          1699:           if (wallsprite == 2) {
        !          1700:                for (i=curspritenum ; i < MAXSPRITES ; i++) {
        !          1701:                     if (sprite[i].picnum == sprite[cursprite].picnum && sprite[i].statnum == 0) {
        !          1702:                          posx=sprite[i].x;
        !          1703:                          posy=sprite[i].y;
        !          1704:                          ang=sprite[i].ang;
        !          1705:                          printmessage16("Sprite Found");
        !          1706:                          curspritenum++;
        !          1707:                          keystatus[0x2b]=0;
        !          1708:                          return(tempbuf);
        !          1709:                     }
        !          1710:                     curspritenum++;
        !          1711:                }
        !          1712:           }
        !          1713:      }
        !          1714:      if ((wall[wallnum].lotag|wall[wallnum].hitag) == 0) {
        !          1715:           tempbuf[0]=0;
        !          1716:      }
        !          1717:      else {
        !          1718:           sprintf(tempbuf,"%hu,%hu",(unsigned short)wall[wallnum].hitag,
        !          1719:                                                                                  (unsigned short)wall[wallnum].lotag);
        !          1720:      }
        !          1721:    #endif  
        !          1722:        return(tempbuf);
        !          1723: }
        !          1724: 
        !          1725: const char *ExtGetSpriteCaption(short spritenum)
        !          1726: {
        !          1727:    #ifndef TEKWAR 
        !          1728:        if ((sprite[spritenum].lotag|sprite[spritenum].hitag) == 0)
        !          1729:        {
        !          1730:                tempbuf[0] = 0;
        !          1731:        }
        !          1732:        else
        !          1733:        {
        !          1734:                sprintf(tempbuf,"%hu,%hu",(unsigned short)sprite[spritenum].hitag,
        !          1735:                                                                                  (unsigned short)sprite[spritenum].lotag);
        !          1736:        }
        !          1737:    #endif
        !          1738: 
        !          1739:    #ifdef TEKWAR
        !          1740:      tempbuf[0]=0;
        !          1741:      if ((sprite[spritenum].lotag|sprite[spritenum].hitag) == 0) {
        !          1742:           SpriteName(spritenum,lo);
        !          1743:           if (lo[0] != 0) {
        !          1744:                sprintf(tempbuf,"%s",lo);
        !          1745:           }
        !          1746:      }
        !          1747:      else if ((unsigned short)sprite[spritenum].picnum == 104) {
        !          1748:           sprintf(hi,"%hu",(unsigned short)sprite[spritenum].hitag);
        !          1749:           switch((unsigned short)sprite[spritenum].lotag) {
        !          1750:           case 1000:
        !          1751:                sprintf(lo,"PULSING");
        !          1752:                break;
        !          1753:           case 1001:
        !          1754:                sprintf(lo,"FLICKERING");
        !          1755:                break;
        !          1756:           case 1002:
        !          1757:                sprintf(lo,"TIC DELAY");
        !          1758:                break;
        !          1759:           case 1003:
        !          1760:                sprintf(hi,"A=%d",sprite[spritenum].ang);
        !          1761:                sprintf(lo,"PANNING WALLS");
        !          1762:                break;
        !          1763:           case 1004:
        !          1764:                sprintf(hi,"A=%d",sprite[spritenum].ang);
        !          1765:                sprintf(lo,"PANNING FLOORS");
        !          1766:                break;
        !          1767:           case 1005:
        !          1768:                sprintf(hi,"A=%d",sprite[spritenum].ang);
        !          1769:                sprintf(lo,"PANNING CEILINGS");
        !          1770:                break;
        !          1771:           case 1006:
        !          1772:                sprintf(lo,"FLICKER W/DELAY");
        !          1773:                break;
        !          1774:           case 1007:
        !          1775:                sprintf(lo,"BLINK W/DELAY");
        !          1776:                break;
        !          1777:           case 1008:
        !          1778:                sprintf(lo,"STEADY LIGHT");
        !          1779:                break;
        !          1780:           case 1009:
        !          1781:                sprintf(lo,"WARP");
        !          1782:                break;
        !          1783:           default:
        !          1784:                sprintf(lo,"%hu",(unsigned short)sprite[spritenum].lotag);
        !          1785:                break;
        !          1786:           }
        !          1787:           sprintf(tempbuf,"%s,%s",hi,lo);
        !          1788:      }
        !          1789:      else {
        !          1790:           SpriteName(spritenum,lo);
        !          1791:           sprintf(tempbuf,"%hu,%hu %s",(unsigned short)sprite[spritenum].hitag,
        !          1792:                                    (unsigned short)sprite[spritenum].lotag,lo);
        !          1793:      }
        !          1794:    #endif 
        !          1795:        return(tempbuf);
        !          1796: }
        !          1797: 
        !          1798: //printext16 parameters:
        !          1799: //printext16(long xpos, long ypos, short col, short backcol,
        !          1800: //           char name[82], char fontsize)
        !          1801: //  xpos 0-639   (top left)
        !          1802: //  ypos 0-479   (top left)
        !          1803: //  col 0-15
        !          1804: //  backcol 0-15, -1 is transparent background
        !          1805: //  name
        !          1806: //  fontsize 0=8*8, 1=3*5
        !          1807: 
        !          1808: //drawline16 parameters:
        !          1809: // drawline16(long x1, long y1, long x2, long y2, char col)
        !          1810: //  x1, x2  0-639
        !          1811: //  y1, y2  0-143  (status bar is 144 high, origin is top-left of STATUS BAR)
        !          1812: //  col     0-15
        !          1813: 
        !          1814: void ExtShowSectorData(short sectnum)   //F5
        !          1815: {
        !          1816:    #ifdef TEKWAR 
        !          1817:     int  i,effect;
        !          1818:     int  delay=0,rotating=0,switches=0,totsprites=0;
        !          1819:     char lighting[16],flooreffect[16],walleffect[16],ceileffect[16];
        !          1820:     char *secttype;
        !          1821:    #endif 
        !          1822: 
        !          1823:    #ifndef TEKWAR 
        !          1824:        if (qsetmode == 200)    //In 3D mode
        !          1825:        {
        !          1826:        }
        !          1827:        else
        !          1828:        {
        !          1829:                clearmidstatbar16();             //Clear middle of status bar
        !          1830: 
        !          1831:                sprintf(tempbuf,"Sector %d",sectnum);
        !          1832:                printext16(8,32,11,-1,tempbuf,0);
        !          1833: 
        !          1834:                printext16(8,48,11,-1,"8*8 font: ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789",0);
        !          1835:                printext16(8,56,11,-1,"3*5 font: ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789",1);
        !          1836: 
        !          1837:                drawline16(320,68,344,80,4);       //Draw house
        !          1838:                drawline16(344,80,344,116,4);
        !          1839:                drawline16(344,116,296,116,4);
        !          1840:                drawline16(296,116,296,80,4);
        !          1841:                drawline16(296,80,320,68,4);
        !          1842:        }
        !          1843:    #endif
        !          1844: 
        !          1845:    #ifdef TEKWAR 
        !          1846:      switch (sector[sectnum].lotag) {
        !          1847:      case 0:
        !          1848:           secttype="NORMAL";
        !          1849:           break;
        !          1850:      case 1:
        !          1851:           secttype="ACTIVATE SECTOR";
        !          1852:           break;
        !          1853:      case 6:
        !          1854:           secttype="RISING DOOR";
        !          1855:           break;
        !          1856:      case 7:
        !          1857:           secttype="DROP DOOR";
        !          1858:           break;
        !          1859:      case 8:
        !          1860:           secttype="HOR SPLIT DOOR";
        !          1861:           break;
        !          1862:      case 9:
        !          1863:           secttype="VER SPLIT DOOR";
        !          1864:           break;
        !          1865:      case 14:
        !          1866:           secttype="ROTATING";
        !          1867:           break;
        !          1868:      case 1000:
        !          1869:           secttype="PLATFORM ELEVATOR";
        !          1870:           break;
        !          1871:      case 1003:
        !          1872:           secttype="BOX ELEVATOR";
        !          1873:           break;
        !          1874:      default:
        !          1875:           secttype="UNDEFINED";
        !          1876:           break;
        !          1877:      }
        !          1878:      memset(lighting,0,sizeof(lighting));
        !          1879:      memset(flooreffect,0,sizeof(flooreffect));
        !          1880:      memset(ceileffect,0,sizeof(ceileffect));
        !          1881:      memset(walleffect,0,sizeof(walleffect));
        !          1882:      i=headspritesect[sectnum];
        !          1883:      while (i != -1) {
        !          1884:           if (sprite[i].picnum == 104) {
        !          1885:                effect=sprite[i].lotag-1000;
        !          1886:                switch (effect) {
        !          1887:                case PULSELIGHT:
        !          1888:                     strcat(lighting,"Pulsing ");
        !          1889:                     break;
        !          1890:                case FLICKERLIGHT:
        !          1891:                     strcat(lighting,"Flickering ");
        !          1892:                     break;
        !          1893:                case DELAYEFFECT:
        !          1894:                     delay=sprite[i].hitag;
        !          1895:                     break;
        !          1896:                case WPANNING:
        !          1897:                     sprintf(walleffect,"Panning (A=%d)",sprite[i].ang);
        !          1898:                     break;
        !          1899:                case FPANNING:
        !          1900:                     sprintf(flooreffect,"Panning (A=%d)",sprite[i].ang);
        !          1901:                     break;
        !          1902:                case CPANNING:
        !          1903:                     sprintf(ceileffect,"Panning (A=%d)",sprite[i].ang);
        !          1904:                     break;
        !          1905:                }
        !          1906:           }
        !          1907:           else if (sprite[i].lotag == 3) {
        !          1908:                rotating++;
        !          1909:           }
        !          1910:           else if (sprite[i].lotag == 4) {
        !          1911:                switches++;
        !          1912:           }
        !          1913:           else {
        !          1914:                totsprites++;
        !          1915:           }
        !          1916:           i=nextspritesect[i];
        !          1917:      }
        !          1918:      clearmidstatbar16();
        !          1919:      sprintf(tempbuf,"Level %s",levelname);
        !          1920:      printmessage16(tempbuf);
        !          1921:      sprintf(tempbuf,"Effects for Sector %d (type=%s)",sectnum,secttype);
        !          1922:      printext16(1*8,4*8,11,-1,tempbuf,0);
        !          1923:      PrintStatusStr("Lighting Effect =",lighting,2,6,11);
        !          1924:      PrintStatus("Tic Delay       =",delay,2,7,11);
        !          1925:      PrintStatusStr("Wall Effects    =",walleffect,2,8,11);
        !          1926:      PrintStatusStr("Floor Effects   =",flooreffect,2,9,11);
        !          1927:      PrintStatusStr("Ceiling Effects =",ceileffect,2,10,11);
        !          1928:      PrintStatus("Rotating Sprites=",rotating,2,11,11);
        !          1929:      PrintStatus("Switches        =",switches,2,12,11);
        !          1930:      PrintStatus("Total Sprites   =",totsprites,2,13,11);
        !          1931:    #endif  
        !          1932: }
        !          1933: 
        !          1934: void ExtShowWallData(short wallnum)       //F6
        !          1935: {
        !          1936:        if (qsetmode == 200)    //In 3D mode
        !          1937:        {
        !          1938:        }
        !          1939:        else
        !          1940:        {
        !          1941:                clearmidstatbar16();             //Clear middle of status bar
        !          1942: 
        !          1943:                sprintf(tempbuf,"Wall %d",wallnum);
        !          1944:                printext16(8,32,11,-1,tempbuf,0);
        !          1945:        }
        !          1946: }
        !          1947: 
        !          1948: void ExtShowSpriteData(short spritenum)   //F6
        !          1949: {
        !          1950:    #ifndef TEKWAR 
        !          1951:        if (qsetmode == 200)    //In 3D mode
        !          1952:        {
        !          1953:        }
        !          1954:        else
        !          1955:        {
        !          1956:                clearmidstatbar16();             //Clear middle of status bar
        !          1957: 
        !          1958:                sprintf(tempbuf,"Sprite %d",spritenum);
        !          1959:                printext16(8,32,11,-1,tempbuf,0);
        !          1960:        }
        !          1961:    #endif 
        !          1962: 
        !          1963:    #ifdef TEKWAR
        !          1964:     if( elapsedtime == 1) {
        !          1965:          elapsedtime=0;
        !          1966:     }
        !          1967:     else if( copyext ) {
        !          1968:          copyext=0;
        !          1969:          JS_CopyExt(spritenum);
        !          1970:     }
        !          1971:     else if( recordext ) {
        !          1972:          recordext=0;
        !          1973:          JS_RecordExt(spritenum);
        !          1974:     }
        !          1975:     else {
        !          1976:          JS_ShowSpriteExts(spritenum);
        !          1977:     }
        !          1978:    #endif
        !          1979: }
        !          1980: 
        !          1981: #ifndef TEKWAR
        !          1982: void ExtEditSectorData(short sectnum)    //F7
        !          1983: {
        !          1984:        short nickdata;
        !          1985: 
        !          1986:        if (qsetmode == 200)    //In 3D mode
        !          1987:        {
        !          1988:                        //Ceiling
        !          1989:                if (searchstat == 1)
        !          1990:                        sector[searchsector].ceilingpicnum++;   //Just a stupid example
        !          1991: 
        !          1992:                        //Floor
        !          1993:                if (searchstat == 2)
        !          1994:                        sector[searchsector].floorshade++;      //Just a stupid example
        !          1995:        }
        !          1996:        else                    //In 2D mode
        !          1997:        {
        !          1998:                sprintf(tempbuf,"Sector (%ld) Nick's variable: ",sectnum);
        !          1999:                nickdata = 0;
        !          2000:                nickdata = getnumber16(tempbuf,nickdata,65536L);
        !          2001: 
        !          2002:                printmessage16("");              //Clear message box (top right of status bar)
        !          2003:                ExtShowSectorData(sectnum);
        !          2004:        }
        !          2005: }
        !          2006: #endif
        !          2007: 
        !          2008: 
        !          2009: #ifdef TEKWAR
        !          2010: void ExtEditSectorData(short sectnum)    //F7
        !          2011: {
        !          2012:        short nickdata;
        !          2013: 
        !          2014:        if (qsetmode == 200)    //In 3D mode
        !          2015:        {
        !          2016:                        //Ceiling
        !          2017:                if (searchstat == 1)
        !          2018:                        sector[searchsector].ceilingpicnum++;   //Just a stupid example
        !          2019: 
        !          2020:                        //Floor
        !          2021:                if (searchstat == 2)
        !          2022:                        sector[searchsector].floorshade++;      //Just a stupid example
        !          2023:        }
        !          2024:        else                    //In 2D mode
        !          2025:        {
        !          2026:                sprintf(tempbuf,"Sector (%ld) visibility: %d.",sectnum, visibility); //sector[sectnum].visibility); oog
        !          2027:                nickdata = 0;
        !          2028:                nickdata = getnumber16(tempbuf,nickdata,65536L);
        !          2029: 
        !          2030:                printmessage16("");              //Clear message box (top right of status bar)
        !          2031:                ExtShowSectorData(sectnum);
        !          2032:        }
        !          2033: }
        !          2034: #endif
        !          2035: 
        !          2036: void ExtEditWallData(short wallnum)       //F8
        !          2037: {
        !          2038:        short nickdata;
        !          2039: 
        !          2040:        if (qsetmode == 200)    //In 3D mode
        !          2041:        {
        !          2042:        }
        !          2043:        else
        !          2044:        {
        !          2045:                sprintf(tempbuf,"Wall (%ld) Nick's variable: ",wallnum);
        !          2046:                nickdata = 0;
        !          2047:                nickdata = getnumber16(tempbuf,nickdata,65536L);
        !          2048: 
        !          2049:                printmessage16("");              //Clear message box (top right of status bar)
        !          2050:                ExtShowWallData(wallnum);
        !          2051:        }
        !          2052: }
        !          2053: 
        !          2054: void ExtEditSpriteData(short spritenum)   //F8
        !          2055: {
        !          2056:    #ifndef TEKWAR 
        !          2057:        short nickdata;
        !          2058: 
        !          2059:        if (qsetmode == 200)    //In 3D mode
        !          2060:        {
        !          2061:        }
        !          2062:        else
        !          2063:        {
        !          2064:                sprintf(tempbuf,"Sprite (%ld) Nick's variable: ",spritenum);
        !          2065:                nickdata = 0;
        !          2066:                nickdata = getnumber16(tempbuf,nickdata,65536L);
        !          2067:                printmessage16("");
        !          2068: 
        !          2069:                printmessage16("");              //Clear message box (top right of status bar)
        !          2070:                ExtShowSpriteData(spritenum);
        !          2071:        }
        !          2072:    #endif
        !          2073: 
        !          2074:    #ifdef TEKWAR
        !          2075:      cursprite=spritenum;
        !          2076:      curspritenum=0;
        !          2077:      if ( editvelocity == 1 ) {
        !          2078:           JS_ChangeVelocity(spritenum);
        !          2079:           editvelocity=0;
        !          2080:           keystatus[0x42]=0;
        !          2081:           return;
        !          2082:      }
        !          2083:      if ( docleanup == 1 ) {
        !          2084:           JS_CleanupExtensions();
        !          2085:           docleanup=0;
        !          2086:           keystatus[0x42]=0;
        !          2087:           return;
        !          2088:      }
        !          2089:      sprintf(tempbuf,"Current Sprite %ld",cursprite);
        !          2090:      printmessage16(tempbuf);
        !          2091:      JS_EditSpriteExts(spritenum);
        !          2092:      keystatus[0x42]=0;
        !          2093:    #endif 
        !          2094: }
        !          2095: 
        !          2096: faketimerhandler()
        !          2097: {
        !          2098: }
        !          2099: 
        !          2100: 
        !          2101: void ExtAnalyzeSprites(void)
        !          2102: {
        !          2103: }
        !          2104: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.