Ejemplo n.º 1
0
void parsecmd(int argc,char *argv[])
{
  char *word;
  int argch;
  int16_t arg,i=0,j,speedmul;
  bool sf, gs, norepf, hasopt;

  gs = norepf = false;

#if defined(UNIX)
  digger_log = stderr;
#else
  digger_log = fopen("DIGGER.log", "w+");
#endif

  for (arg=1;arg<argc;arg++) {
    word=argv[arg];
    if (word[0]=='/' || word[0]=='-') {
#if defined(UNIX) && defined(_SDL)
      argch = getarg(word[1], "FOUH?QM2BCKVL:R:P:S:E:G:X:A:I:", &hasopt);
#else
      argch = getarg(word[1], "OUH?QM2BCKVL:R:P:S:E:G:A:I:", &hasopt);
#endif
      i = 2;
      if (argch != -1 && hasopt && word[2] == ':') {
        i = 3;
      }
      if (argch == 'L') {
        j=0;
        while (word[i]!=0)
          levfname[j++]=word[i++];
        levfname[j]=word[i];
        levfflag=true;
      }
#if defined(UNIX) && defined(_SDL)
      if (argch == 'X') {
        unsigned int x11_parent;

        x11_parent = strtol (&word[i], 0, 0);
        sdl_set_x11_parent(x11_parent);
      }
      if (argch == 'F') {
        sdl_enable_fullscreen();
      }
#endif
      if (argch =='R')
        recname(word+i);
      if (argch =='P' || argch =='E') {
        maininit();
        openplay(word+i);
        if (escape)
          norepf=true;
      }
      if (argch == 'E') {
        finish();
        if (escape)
          exit(0);
        exit(1);
      }
      if (argch =='O' && !norepf) {
        arg=0;
        continue;
      }
      if (argch == 'S') {
        speedmul=0;
        while (word[i]!=0)
          speedmul=10*speedmul+word[i++]-'0';
        if (speedmul > 0) {
          ftime=speedmul*2000l;
        } else {
          ftime = 1;
        }
        gs=true;
      }
      if (argch == 'I')
        sscanf(word+i,"%hi",&startlev);
      if (argch == 'U')
        unlimlives=true;
      if (argch == '?' || argch == 'H' || argch == -1) {
        if (argch == -1) {
          fprintf(stderr, "Unknown option \"%c%c\"\n", word[0], word[1]);
        }
        finish();
        printf("DIGGER - Copyright (c) 1983 Windmill software\n"
               "Restored 1998 by AJ Software\n"
#ifdef ARM
               "Acorn port by Julian Brown\n"
#endif
               "http://www.digger.org\n"
               "Version: "DIGGER_VERSION"\n\n"

               "Command line syntax:\n"
               "  DIGGER [[/S:]speed] [[/L:]level file] [/C] [/B] [/Q] [/M] "
                                                         "[/P:playback file]\n"
               "         [/E:playback file] [/R:record file] [/O] [/K[A]] "
                                                           "[/G[:time]] [/2]\n"
               "         [/A:device,port,irq,dma,rate,length] [/V] [/U] "
                                                               "[/I:level] "
#if defined(UNIX) && defined(_SDL)
                                                               "[/X:xid]"
#endif
                                                               "\n\n"
#ifndef UNIX
               "/C = Use CGA graphics\n"
               "/B = Use BIOS palette functions for CGA (slow!)\n"
#endif
               "/Q = Quiet mode (no sound at all)       "
               "/M = No music\n"
               "/R = Record graphics to file\n"
               "/P = Playback and restart program       "
               "/E = Playback and exit program\n"
               "/O = Loop to beginning of command line\n"
               "/K = Redefine keyboard\n"
               "/G = Gauntlet mode\n"
               "/2 = Two player simultaneous mode\n"
               "/A = Use alternate sound device\n"
#ifndef UNIX
               "/V = Synchronize timing to vertical retrace\n"
#endif
#if defined(UNIX) && defined(_SDL)
               "/X = Embed in window\n"
#endif
               "/U = Allow unlimited lives\n"
               "/I = Start on a level other than 1\n");
        exit(1);
      }
      if (argch == 'Q')
        soundflag=false;
      if (argch == 'M')
        musicflag=false;
      if (argch == '2')
        diggers=2;
      if (argch == 'B' || argch == 'C') {
        ddap->ginit=cgainit;
        ddap->gpal=cgapal;
        ddap->ginten=cgainten;
        ddap->gclear=cgaclear;
        ddap->ggetpix=cgagetpix;
        ddap->gputi=cgaputi;
        ddap->ggeti=cgageti;
        ddap->gputim=cgaputim;
        ddap->gwrite=cgawrite;
        ddap->gtitle=cgatitle;
        if (argch == 'B')
          biosflag=true;
        ddap->ginit();
        ddap->gpal(0);
      }
      if (argch == 'K') {
        if (word[2]=='A' || word[2]=='a')
          redefkeyb(true);
        else
          redefkeyb(false);
      }
      if (argch =='A')
        sscanf(word+i,"%hu,%hx,%hu,%hu,%hu,%hu",&sound_device,&sound_port,&sound_irq,
               &sound_dma,&sound_rate,&sound_length);
      if (argch == 'Q')
        quiet=true;
      if (argch == 'V')
        synchvid=true;
      if (argch == 'G') {
        gtime=0;
        while (word[i]!=0)
          gtime=10*gtime+word[i++]-'0';
        if (gtime>3599)
          gtime=3599;
        if (gtime==0)
          gtime=120;
        gauntlet=true;
      }
    }
    else {
      i=strlen(word);
      if (i<1)
        continue;
      sf=true;
      if (!gs)
        for (j=0;j<i;j++)
          if (word[j]<'0' || word[j]>'9') {
            sf=false;
            break;
          }
      if (sf) {
        speedmul=0;
        j=0;
        while (word[j]!=0)
          speedmul=10*speedmul+word[j++]-'0';
        gs=true;
        if (speedmul > 0) {
          ftime=speedmul*2000l;
        } else {
          ftime = 1;
        }
      }
      else {
        j=0;
        while (word[j]!=0) {
          levfname[j]=word[j];
          j++;
        }
        levfname[j]=word[j];
        levfflag=true;
      }
    }
  }

  if (levfflag) {
    if (read_levf(levfname) != 0) {
#if defined(DIGGER_DEBUG)
      fprintf(digger_log, "levels load error\n");
#endif
      levfflag = false;
    }
  }
}
Ejemplo n.º 2
0
void parsecmd(int argc,char *argv[])
{
  char *word;
  Sint4 arg,i,j,speedmul;
  bool sf,gs=false,norepf=false;
  FILE *levf;

  for (arg=1;arg<argc;arg++) {
    word=argv[arg];
    if (word[0]=='/' || word[0]=='-') {
      if (word[1]=='L' || word[1]=='l' || word[1]=='R' || word[1]=='r' ||
          word[1]=='P' || word[1]=='p' || word[1]=='S' || word[1]=='s' ||
          word[1]=='E' || word[1]=='e' || word[1]=='G' || word[1]=='g' ||
          word[1]=='A' || word[1]=='a' || word[1]=='I' || word[1]=='i')
        if (word[2]==':')
          i=3;
        else
          i=2;
      if (word[1]=='L' || word[1]=='l') {
        j=0;
        while (word[i]!=0)
          levfname[j++]=word[i++];
        levfname[j]=word[i];
        levfflag=true;
      }
      if (word[1]=='R' || word[1]=='r')
        recname(word+i);
      if (word[1]=='P' || word[1]=='p' || word[1]=='E' || word[1]=='e') {
        openplay(word+i);
        if (escape)
          norepf=true;
      }
      if (word[1]=='E' || word[1]=='e') {
        finish();
        if (escape)
          exit(0);
        exit(1);
      }
      if ((word[1]=='O' || word[1]=='o') && !norepf) {
        arg=0;
        continue;
      }
      if (word[1]=='S' || word[1]=='s') {
        speedmul=0;
        while (word[i]!=0)
          speedmul=10*speedmul+word[i++]-'0';
        ftime=speedmul*2000l;
        gs=true;
      }
      if (word[1]=='I' || word[1]=='i')
        sscanf(word+i,"%u",&startlev);
      if (word[1]=='U' || word[1]=='u')
        unlimlives=true;
      if (word[1]=='?' || word[1]=='h' || word[1]=='H') {
        finish();

        printf("DIGGER - Copyright (c) 1983 Windmill software\n"
               "Restored 1998 by AJ Software\n"
               "http://www.digger.org\n"
               "Version: "DIGGER_VERSION"\n\n"

               "Command line syntax:\n"
               "  DIGGER [[/S:]speed] [[/L:]level file] [/C] [/B] [/Q] [/M] "
                                                         "[/P:playback file]\n"
               "         [/E:playback file] [/R:record file] [/O] [/K[A]] "
                                                           "[/G[:time]] [/2]\n"
               "         [/A:device,port,irq,dma,rate,length] [/V] [/U] "
                                                               "[/I:level]\n\n"
               "/Q = Quiet mode (no sound at all)       "
               "/M = No music\n"
               "/R = Record graphics to file\n"
               "/P = Playback and restart program       "
               "/E = Playback and exit program\n"
               "/O = Loop to beginning of command line\n"
               "/K = Redefine keyboard\n"
               "/G = Gauntlet mode\n"
               "/2 = Two player simultaneous mode\n"
               "/A = Use alternate sound device\n"
               "/U = Allow unlimited lives\n"
               "/I = Start on a level other than 1\n");
        exit(1);
      }
      if (word[1]=='Q' || word[1]=='q')
        soundflag=false;
      if (word[1]=='M' || word[1]=='m')
        musicflag=false;
      if (word[1]=='2')
        diggers=2;
      if (word[1]=='K' || word[1]=='k')
        if (word[2]=='A' || word[2]=='a')
          redefkeyb(true);
        else
          redefkeyb(false);
      if (word[1]=='A' || word[1]=='a') {
        sscanf(word+i,"%u,%x,%u,%u,%u,%u",&sound_device,&sound_port,&sound_irq,
               &sound_dma,&sound_rate,&sound_length);
        killsound();
        volume=1;
        setupsound=s1setupsound;
        killsound=s1killsound;
        fillbuffer=s1fillbuffer;
        initint8=s1initint8;
        restoreint8=s1restoreint8;
        soundoff=s1soundoff;
        setspkrt2=s1setspkrt2;
        settimer0=s1settimer0;
        timer0=s1timer0;
        settimer2=s1settimer2;
        timer2=s1timer2;
        soundinitglob(sound_port,sound_irq,sound_dma,sound_length,sound_rate);
        initsound();
      }
      if (word[1]=='V' || word[1]=='v')
        synchvid=true;
      if (word[1]=='G' || word[1]=='g') {
        gtime=0;
        while (word[i]!=0)
          gtime=10*gtime+word[i++]-'0';
        if (gtime>3599)
          gtime=3599;
        if (gtime==0)
          gtime=120;
        gauntlet=true;
      }
    }
    else {
      i=strlen(word);
      if (i<1)
        continue;
      sf=true;
      if (!gs)
        for (j=0;j<i;j++)
          if (word[j]<'0' || word[j]>'9') {
            sf=false;
            break;
          }
      if (sf) {
        speedmul=0;
        j=0;
        while (word[j]!=0)
          speedmul=10*speedmul+word[j++]-'0';
        gs=true;
        ftime=speedmul*2000l;
      }
      else {
        j=0;
        while (word[j]!=0) {
          levfname[j]=word[j];
          j++;
        }
        levfname[j]=word[j];
        levfflag=true;
      }
    }
  }

  if (levfflag) {
    levf=fopen(levfname,"rb");
    if (levf==NULL) {
      strcat(levfname,".DLF");
      levf=fopen(levfname,"rb");
    }
    if (levf==NULL)
      levfflag=false;
    else {
      fread(&bonusscore,2,1,levf);
      fread(leveldat,1200,1,levf);
      fclose(levf);
    }
  }
}