Esempio n. 1
0
Sint5 GetINIInt(char *section,char *key,Sint5 def,char *filename)
{
  char buf[80];
  sprintf(buf,"%li",def);
  GetINIString(section,key,buf,buf,80,filename);
  return atol(buf);
}
Esempio n. 2
0
File: ini.c Progetto: sobomax/digger
int32_t GetINIInt(const char *section,const char*key,int32_t def,const char*filename)
{
  char buf[80];
  sprintf(buf,"%i",def);
  GetINIString(section,key,buf,buf,80,filename);
  return atol(buf);
}
Esempio n. 3
0
bool GetINIBool(char *section,char *key,bool def,char *filename)
{
  char buf[80];
  sprintf(buf,"%i",def);
  GetINIString(section,key,buf,buf,80,filename);
  _strupr(buf);
  if (buf[0]=='T')
    return true;
  else
    return atoi(buf);
}
Esempio n. 4
0
void inir(void)
{
  char kbuf[80],vbuf[80];
  int i,j,p;
  bool cgaflag;

  for (i=0;i<17;i++) {
    sprintf(kbuf,"%s%c",keynames[i],(i>=5 && i<10) ? '2' : 0);
    sprintf(vbuf,"%i/%i/%i/%i/%i",keycodes[i][0],keycodes[i][1],
            keycodes[i][2],keycodes[i][3],keycodes[i][4]);
    GetINIString(INI_KEY_SETTINGS,kbuf,vbuf,vbuf,80,ININAME);
    krdf[i]=true;
    p=0;
    for (j=0;j<5;j++) {
      keycodes[i][j]=atoi(vbuf+p);
      while (vbuf[p]!='/' && vbuf[p]!=0)
        p++;
      if (vbuf[p]==0)
        break;
      p++;
    }
  }
  gtime=(int)GetINIInt(INI_GAME_SETTINGS,"GauntletTime",120,ININAME);
  if (ftime == 0) {
      ftime=GetINIInt(INI_GAME_SETTINGS,"Speed",80000l,ININAME);
  }
  gauntlet=GetINIBool(INI_GAME_SETTINGS,"GauntletMode",false,ININAME);
  GetINIString(INI_GAME_SETTINGS,"Players","1",vbuf,80,ININAME);
  strupr(vbuf);
  if (vbuf[0]=='2' && vbuf[1]=='S') {
    diggers=2;
    nplayers=1;
  }
  else {
    diggers=1;
    nplayers=atoi(vbuf);
    if (nplayers<1 || nplayers>2)
      nplayers=1;
  }
  soundflag=GetINIBool(INI_SOUND_SETTINGS,"SoundOn",true,ININAME);
  musicflag=GetINIBool(INI_SOUND_SETTINGS,"MusicOn",true,ININAME);
  sound_device=(int)GetINIInt(INI_SOUND_SETTINGS,"Device",DEF_SND_DEV,ININAME);
  sound_port=(int)GetINIInt(INI_SOUND_SETTINGS,"Port",544,ININAME);
  sound_irq=(int)GetINIInt(INI_SOUND_SETTINGS,"Irq",5,ININAME);
  sound_dma=(int)GetINIInt(INI_SOUND_SETTINGS,"DMA",1,ININAME);
  sound_rate=(int)GetINIInt(INI_SOUND_SETTINGS,"Rate",22050,ININAME);
  sound_length=(int)GetINIInt(INI_SOUND_SETTINGS,"BufferSize",DEFAULT_BUFFER,
                              ININAME);

#if !defined(UNIX) && !defined(_SDL)
  if (sound_device==1) {
#else
  if (!quiet) {
#endif
    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);
  }
  dx_sound_volume=(int)GetINIInt(INI_SOUND_SETTINGS,"SoundVolume",0,ININAME);
  g_bWindowed=true;
  use_640x480_fullscreen=GetINIBool(INI_GRAPHICS_SETTINGS,"640x480",false,
                                    ININAME);
  use_async_screen_updates=GetINIBool(INI_GRAPHICS_SETTINGS,"Async",true,
                                      ININAME);
  synchvid=GetINIBool(INI_GRAPHICS_SETTINGS,"Synch",false,ININAME);
  cgaflag=GetINIBool(INI_GRAPHICS_SETTINGS,"CGA",false,ININAME);
  biosflag=GetINIBool(INI_GRAPHICS_SETTINGS,"BIOSPalette",false,ININAME);
  if (cgaflag || biosflag) {
    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;
    ddap->ginit();
    ddap->gpal(0);
  }
  unlimlives=GetINIBool(INI_GAME_SETTINGS,"UnlimitedLives",false,ININAME);
  startlev=(int)GetINIInt(INI_GAME_SETTINGS,"StartLevel",1,ININAME);
}

void redefkeyb(bool allf)
{
  int i,j,k,l,z,y=0;
  bool f;
  char kbuf[80],vbuf[80];

  maininit();

  if (diggers==2) {
    outtext(ddap, "PLAYER 1:",0,y,3);
    y+=12;
  }

  outtext(ddap, "PRESS NEW KEY FOR",0,y,3);
  y+=12;

/* Step one: redefine keys that are always redefined. */

  for (i=0;i<5;i++) {
    outtext(ddap, keynames[i],0,y,2); /* Red first */
    findkey(i);
    outtext(ddap, keynames[i],0,y,1); /* Green once got */
    y+=12;
    for (j=0;j<i;j++) { /* Note: only check keys just pressed (I hate it when
                           this is done wrong, and it often is.) */
      if (keycodes[i][0]==keycodes[j][0] && keycodes[i][0]!=0) {
        i--;
        y-=12;
        break;
      }
      for (k=2;k<5;k++)
        for (l=2;l<5;l++)
          if (keycodes[i][k]==keycodes[j][l] && keycodes[i][k]!=-2) {
            j=i;
            k=5;
            i--;
            y-=12;
            break; /* Try again if this key already used */
          }
    }
  }

  if (diggers==2) {
    outtext(ddap, "PLAYER 2:",0,y,3);
    y+=12;
    for (i=5;i<10;i++) {
      outtext(ddap, keynames[i],0,y,2); /* Red first */
      findkey(i);
      outtext(ddap, keynames[i],0,y,1); /* Green once got */
      y+=12;
      for (j=0;j<i;j++) { /* Note: only check keys just pressed (I hate it when
                             this is done wrong, and it often is.) */
        if (keycodes[i][0]==keycodes[j][0] && keycodes[i][0]!=0) {
          i--;
          y-=12;
          break;
        }
        for (k=2;k<5;k++)
          for (l=2;l<5;l++)
            if (keycodes[i][k]==keycodes[j][l] && keycodes[i][k]!=-2) {
              j=i;
              k=5;
              i--;
              y-=12;
              break; /* Try again if this key already used */
            }
      }
    }
  }

/* Step two: redefine other keys which step one has caused to conflict */

  z=0;
  y-=12;
  for (i=10;i<17;i++) {
    f=false;
    for (j=0;j<10;j++)
      for (k=0;k<5;k++)
        for (l=2;l<5;l++)
          if (keycodes[i][k]==keycodes[j][l] && keycodes[i][k]!=-2)
            f=true;
    for (j=10;j<i;j++)
      for (k=0;k<5;k++)
        for (l=0;l<5;l++)
          if (keycodes[i][k]==keycodes[j][l] && keycodes[i][k]!=-2)
            f=true;
    if (f || (allf && i!=z)) {
      if (i!=z)
        y+=12;
      outtext(ddap, keynames[i],0,y,2); /* Red first */
      findkey(i);
      outtext(ddap, keynames[i],0,y,1); /* Green once got */
      z=i;
      i--;
    }
  }

/* Step three: save the INI file */

  for (i=0;i<17;i++)
    if (krdf[i]) {
      sprintf(kbuf,"%s%c",keynames[i],(i>=5 && i<10) ? '2' : 0);
      sprintf(vbuf,"%i/%i/%i/%i/%i",keycodes[i][0],keycodes[i][1],
              keycodes[i][2],keycodes[i][3],keycodes[i][4]);
      WriteINIString(INI_KEY_SETTINGS,kbuf,vbuf,ININAME);
    }
}
Esempio n. 5
0
void inir(void)
{
  char kbuf[80],vbuf[80];
  int i,j,p;
  bool cgaflag;

  for (i=0;i<17;i++) {
    sprintf(kbuf,"%s%c",keynames[i],(i>=5 && i<10) ? '2' : 0);
    sprintf(vbuf,"%i/%i/%i/%i/%i",keycodes[i][0],keycodes[i][1],
            keycodes[i][2],keycodes[i][3],keycodes[i][4]);
    GetINIString(INI_KEY_SETTINGS,kbuf,vbuf,vbuf,80,ININAME);
    krdf[i]=true;
    p=0;
    for (j=0;j<5;j++) {
      keycodes[i][j]=atoi(vbuf+p);
      while (vbuf[p]!='/' && vbuf[p]!=0)
        p++;
      if (vbuf[p]==0)
        break;
      p++;
    }
  }
  gtime=(int)GetINIInt(INI_GAME_SETTINGS,"GauntletTime",120,ININAME);
  ftime=GetINIInt(INI_GAME_SETTINGS,"Speed",80000l,ININAME);
  gauntlet=GetINIBool(INI_GAME_SETTINGS,"GauntletMode",false,ININAME);
  GetINIString(INI_GAME_SETTINGS,"Players","1",vbuf,80,ININAME);
  if (vbuf[0]=='2' && toupper(vbuf[1])=='S') {
    diggers=2;
    nplayers=1;
  }
  else {
    diggers=1;
    nplayers=atoi(vbuf);
    if (nplayers<1 || nplayers>2)
      nplayers=1;
  }
  soundflag=GetINIBool(INI_SOUND_SETTINGS,"SoundOn",true,ININAME);
  musicflag=GetINIBool(INI_SOUND_SETTINGS,"MusicOn",true,ININAME);
  sound_device=(int)GetINIInt(INI_SOUND_SETTINGS,"Device",DEF_SND_DEV,ININAME);
  sound_port=(int)GetINIInt(INI_SOUND_SETTINGS,"Port",544,ININAME);
  sound_irq=(int)GetINIInt(INI_SOUND_SETTINGS,"Irq",5,ININAME);
  sound_dma=(int)GetINIInt(INI_SOUND_SETTINGS,"DMA",1,ININAME);
  sound_rate=(int)GetINIInt(INI_SOUND_SETTINGS,"Rate",22050,ININAME);
  sound_length=(int)GetINIInt(INI_SOUND_SETTINGS,"BufferSize",DEFAULT_BUFFER,
                              ININAME);
  if (sound_device==1) {
    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);
  }
  dx_sound_volume=(int)GetINIInt(INI_SOUND_SETTINGS,"SoundVolume",0,ININAME);
  g_bWindowed=true;
  use_640x480_fullscreen=GetINIBool(INI_GRAPHICS_SETTINGS,"640x480",false,
                                    ININAME);
  use_async_screen_updates=GetINIBool(INI_GRAPHICS_SETTINGS,"Async",true,
                                      ININAME);
  synchvid=GetINIBool(INI_GRAPHICS_SETTINGS,"Synch",false,ININAME);
  cgaflag=GetINIBool(INI_GRAPHICS_SETTINGS,"CGA",false,ININAME);
  biosflag=GetINIBool(INI_GRAPHICS_SETTINGS,"BIOSPalette",false,ININAME);
  unlimlives=GetINIBool(INI_GAME_SETTINGS,"UnlimitedLives",false,ININAME);
  startlev=(int)GetINIInt(INI_GAME_SETTINGS,"StartLevel",1,ININAME);
}