Diff for /np2/win9x/ini.cpp between versions 1.37 and 1.41

version 1.37, 2005/03/20 06:09:16 version 1.41, 2005/05/16 06:08:22
Line 15 Line 15
   
   
   
 static BOOL inigetbmp(const UINT8 *ptr, UINT pos) {  
   
         return((ptr[pos >> 3] >> (pos & 7)) & 1);  // ---- user
 }  
   
 static void inisetbmp(UINT8 *ptr, UINT pos, BOOL set) {  
   
         UINT8   bit;  
   
         ptr += (pos >> 3);  
         bit = 1 << (pos & 7);  
         if (set) {  
                 *ptr |= bit;  
         }  
         else {  
                 *ptr &= ~bit;  
         }  
 }  
   
 static void inirdargs16(const OEMCHAR *src, const PFTBL *ini) {  static void inirdargs16(const OEMCHAR *src, const PFTBL *ini) {
   
Line 61  static void inirdargs16(const OEMCHAR *s Line 45  static void inirdargs16(const OEMCHAR *s
         }          }
 }  }
   
 static void inirdargh8(const OEMCHAR *src, const PFTBL *ini) {  static void inirdbyte3(const OEMCHAR *src, const PFTBL *ini) {
   
         UINT8   *dst;          UINT    i;
         int             dsize;  
         int             i;          for (i=0; i<3; i++) {
                   if (src[i] == '\0') {
                           break;
                   }
                   if ((((src[i] - '0') & 0xff) < 9) ||
                           (((src[i] - 'A') & 0xdf) < 26)) {
                           ((UINT8 *)ini->value)[i] = (UINT8)src[i];
                   }
           }
   }
   
   static void inirdkb(const OEMCHAR *src, const PFTBL *ini) {
   
           if ((!milstr_extendcmp(src, OEMTEXT("PC98"))) ||
                   (!milstr_cmp(src, OEMTEXT("98")))) {
                   *(UINT8 *)ini->value = KEY_PC98;
           }
           else if ((!milstr_extendcmp(src, OEMTEXT("DOS"))) ||
                           (!milstr_cmp(src, OEMTEXT("PCAT"))) ||
                           (!milstr_cmp(src, OEMTEXT("AT")))) {
                   *(UINT8 *)ini->value = KEY_KEY106;
           }
           else if ((!milstr_extendcmp(src, OEMTEXT("KEY101"))) ||
                           (!milstr_cmp(src, OEMTEXT("101")))) {
                   *(UINT8 *)ini->value = KEY_KEY101;
           }
   }
   
   
   // ---- Use WinAPI
   
   #if !defined(_UNICODE)
   static void bitmapset(UINT8 *ptr, UINT pos, BOOL set) {
   
           UINT8   bit;
   
           ptr += (pos >> 3);
           bit = 1 << (pos & 7);
           if (set) {
                   *ptr |= bit;
           }
           else {
                   *ptr &= ~bit;
           }
   }
   
   static BOOL bitmapget(const UINT8 *ptr, UINT pos) {
   
           return((ptr[pos >> 3] >> (pos & 7)) & 1);
   }
   
   static void binset(UINT8 *bin, UINT binlen, const OEMCHAR *src) {
   
           UINT    i;
         UINT8   val;          UINT8   val;
         BOOL    set;          BOOL    set;
         OEMCHAR c;          OEMCHAR c;
   
         dst = (UINT8 *)ini->value;          for (i=0; i<binlen; i++) {
         dsize = ini->arg;  
   
         for (i=0; i<dsize; i++) {  
                 val = 0;                  val = 0;
                 set = FALSE;                  set = FALSE;
                 while(*src == ' ') {                  while(*src == ' ') {
Line 102  static void inirdargh8(const OEMCHAR *sr Line 136  static void inirdargh8(const OEMCHAR *sr
                 if (set == FALSE) {                  if (set == FALSE) {
                         break;                          break;
                 }                  }
                 dst[i] = val;                  bin[i] = val;
         }          }
 }  }
   
 static void iniwrsetargh8(OEMCHAR *work, int size, const PFTBL *ini) {  static void binget(OEMCHAR *work, int size, const UINT8 *bin, UINT binlen) {
   
         UINT    i;          UINT    i;
 const UINT8     *ptr;  
         UINT    arg;  
         OEMCHAR tmp[8];          OEMCHAR tmp[8];
   
         ptr = (UINT8 *)ini->value;          if (binlen) {
         arg = ini->arg;                  OEMSPRINTF(tmp, OEMTEXT("%.2x"), bin[0]);
         if (arg > 0) {  
                 OEMSPRINTF(tmp, OEMTEXT("%.2x"), ptr[0]);  
                 milstr_ncpy(work, tmp, size);                  milstr_ncpy(work, tmp, size);
         }          }
         for (i=1; i<arg; i++) {          for (i=1; i<binlen; i++) {
                 OEMSPRINTF(tmp, OEMTEXT(" %.2x"), ptr[i]);                  OEMSPRINTF(tmp, OEMTEXT(" %.2x"), bin[i]);
                 milstr_ncat(work, tmp, size);                  milstr_ncat(work, tmp, size);
         }          }
 }  }
   
   
 // ---- user  
   
 static void inirdbyte3(const OEMCHAR *src, const PFTBL *ini) {  
   
         UINT    i;  
   
         for (i=0; i<3; i++) {  
                 if (src[i] == '\0') {  
                         break;  
                 }  
                 if ((((src[i] - '0') & 0xff) < 9) ||  
                         (((src[i] - 'A') & 0xdf) < 26)) {  
                         ((UINT8 *)ini->value)[i] = (UINT8)src[i];  
                 }  
         }  
 }  
   
 static void inirdkb(const OEMCHAR *src, const PFTBL *ini) {  
   
         if ((!milstr_extendcmp(src, OEMTEXT("PC98"))) ||  
                 (!milstr_cmp(src, OEMTEXT("98")))) {  
                 *(UINT8 *)ini->value = KEY_PC98;  
         }  
         else if ((!milstr_extendcmp(src, OEMTEXT("DOS"))) ||  
                         (!milstr_cmp(src, OEMTEXT("PCAT"))) ||  
                         (!milstr_cmp(src, OEMTEXT("AT")))) {  
                 *(UINT8 *)ini->value = KEY_KEY106;  
         }  
         else if ((!milstr_extendcmp(src, OEMTEXT("KEY101"))) ||  
                         (!milstr_cmp(src, OEMTEXT("101")))) {  
                 *(UINT8 *)ini->value = KEY_KEY101;  
         }  
 }  
   
   
 // ----  
   
 void ini_read(const OEMCHAR *path, const OEMCHAR *title,  void ini_read(const OEMCHAR *path, const OEMCHAR *title,
                                                                                         const PFTBL *tbl, UINT count) {                                                                                          const PFTBL *tbl, UINT count) {
   
Line 189  const PFTBL *pterm; Line 181  const PFTBL *pterm;
   
                         case PFTYPE_BITMAP:                          case PFTYPE_BITMAP:
                                 GetPrivateProfileString(title, p->item,                                  GetPrivateProfileString(title, p->item,
                                         (inigetbmp((UINT8 *)p->value, p->arg))?str_true:str_false,                                          (bitmapget((UINT8 *)p->value, p->arg))?str_true:str_false,
                                                                                                 work, NELEMENTS(work), path);                                                                                                  work, NELEMENTS(work), path);
                                 inisetbmp((UINT8 *)p->value, p->arg,                                  bitmapset((UINT8 *)p->value, p->arg,
                                                                                 (milstr_cmp(work, str_true) == 0));                                                                                  (milstr_cmp(work, str_true) == 0));
                                 break;                                  break;
   
                         case PFTYPE_ARGS16:                          case PFTYPE_BIN:
                                 GetPrivateProfileString(title, p->item, str_null,                                  GetPrivateProfileString(title, p->item, str_null,
                                                                                                 work, NELEMENTS(work), path);                                                                                                  work, NELEMENTS(work), path);
                                 inirdargs16(work, p);                                  binset((UINT8 *)p->value, p->arg, work);
                                 break;  
   
                         case PFTYPE_ARGH8:  
                                 GetPrivateProfileString(title, p->item, str_null,  
                                                                                                 work, NELEMENTS(work), path);  
                                 inirdargh8(work, p);  
                                 break;                                  break;
   
                         case PFTYPE_SINT8:                          case PFTYPE_SINT8:
Line 252  const PFTBL *pterm; Line 238  const PFTBL *pterm;
                                 *(UINT32 *)p->value = (UINT32)val;                                  *(UINT32 *)p->value = (UINT32)val;
                                 break;                                  break;
   
                           case PFTYPE_ARGS16:
                                   GetPrivateProfileString(title, p->item, str_null,
                                                                                                   work, NELEMENTS(work), path);
                                   inirdargs16(work, p);
                                   break;
   
                         case PFTYPE_BYTE3:                          case PFTYPE_BYTE3:
                                 GetPrivateProfileString(title, p->item, str_null,                                  GetPrivateProfileString(title, p->item, str_null,
                                                                                                 work, NELEMENTS(work), path);                                                                                                  work, NELEMENTS(work), path);
Line 291  const OEMCHAR *set; Line 283  const OEMCHAR *set;
                                         set = (*((UINT8 *)p->value))?str_true:str_false;                                          set = (*((UINT8 *)p->value))?str_true:str_false;
                                         break;                                          break;
   
                                 case PFTYPE_ARGH8:                                  case PFTYPE_BITMAP:
                                         iniwrsetargh8(work, NELEMENTS(work), p);                                          set = (bitmapget((UINT8 *)p->value, p->arg))?
                                                                                                                   str_true:str_false;
                                           break;
   
                                   case PFTYPE_BIN:
                                           binget(work, NELEMENTS(work), (UINT8 *)p->value, p->arg);
                                         break;                                          break;
   
                                 case PFTYPE_SINT8:                                  case PFTYPE_SINT8:
Line 343  const OEMCHAR *set; Line 340  const OEMCHAR *set;
         }          }
 }  }
   
   #else   // !defined(_UNICODE)
   
   // ---- Use profile.c
   
   static void pfread(const PFTBL *item, const OEMCHAR *string) {
   
           switch(item->itemtype & PFTYPE_MASK) {
                   case PFTYPE_ARGS16:
                           inirdargs16(string, item);
                           break;
   
                   case PFTYPE_BYTE3:
                           inirdbyte3(string, item);
                           break;
   
                   case PFTYPE_KB:
                           inirdkb(string, item);
                           break;
           }
   }
   
   void ini_read(const OEMCHAR *path, const OEMCHAR *title,
                                                                                           const PFTBL *tbl, UINT count) {
   
           profile_iniread(path, title, tbl, count, pfread);
   }
   
   void ini_write(const OEMCHAR *path, const OEMCHAR *title,
                                                                                           const PFTBL *tbl, UINT count) {
   
           profile_iniwrite(path, title, tbl, count, NULL);
   }
   
   #endif  // !defined(_UNICODE)
   
   
 // ----  // ----
   
Line 377  static const PFTBL iniitem[] = { Line 409  static const PFTBL iniitem[] = {
         PFSTR("bmap_Dir", PFTYPE_STR,           bmpfilefolder),          PFSTR("bmap_Dir", PFTYPE_STR,           bmpfilefolder),
         PFSTR("fontfile", PFTYPE_STR,           np2cfg.fontfile),          PFSTR("fontfile", PFTYPE_STR,           np2cfg.fontfile),
         PFSTR("biospath", PFRO_STR,                     np2cfg.biospath),          PFSTR("biospath", PFRO_STR,                     np2cfg.biospath),
   
   #if defined(SUPPORT_HOSTDRV)
         PFSTR("hdrvroot", PFRO_STR,                     np2cfg.hdrvroot),          PFSTR("hdrvroot", PFRO_STR,                     np2cfg.hdrvroot),
         PFVAL("hdrv_acc", PFRO_UINT8,           &np2cfg.hdrvacc),          PFVAL("hdrv_acc", PFRO_UINT8,           &np2cfg.hdrvacc),
   #endif
   
         PFSTR("pc_model", PFTYPE_STR,           &np2cfg.model),          PFSTR("pc_model", PFTYPE_STR,           np2cfg.model),
         PFVAL("clk_base", PFTYPE_UINT32,        &np2cfg.baseclock),          PFVAL("clk_base", PFTYPE_UINT32,        &np2cfg.baseclock),
         PFVAL("clk_mult", PFTYPE_UINT32,        &np2cfg.multiple),          PFVAL("clk_mult", PFTYPE_UINT32,        &np2cfg.multiple),
   
         PFEXT("DIPswtch", PFTYPE_ARGH8,         np2cfg.dipsw,                   3),          PFEXT("DIPswtch", PFTYPE_BIN,           np2cfg.dipsw,                   3),
         PFEXT("MEMswtch", PFTYPE_ARGH8,         np2cfg.memsw,                   8),          PFEXT("MEMswtch", PFTYPE_BIN,           np2cfg.memsw,                   8),
         PFMAX("ExMemory", PFTYPE_UINT8,         &np2cfg.EXTMEM,                 63),          PFMAX("ExMemory", PFTYPE_UINT8,         &np2cfg.EXTMEM,                 63),
         PFVAL("ITF_WORK", PFRO_BOOL,            &np2cfg.ITF_WORK),          PFVAL("ITF_WORK", PFRO_BOOL,            &np2cfg.ITF_WORK),
   
Line 404  static const PFTBL iniitem[] = { Line 439  static const PFTBL iniitem[] = {
         PFAND("BEEP_vol", PFTYPE_UINT8,         &np2cfg.BEEP_VOL,               3),          PFAND("BEEP_vol", PFTYPE_UINT8,         &np2cfg.BEEP_VOL,               3),
         PFVAL("xspeaker", PFRO_BOOL,            &np2cfg.snd_x),          PFVAL("xspeaker", PFRO_BOOL,            &np2cfg.snd_x),
   
         PFEXT("SND14vol", PFTYPE_ARGH8,         np2cfg.vol14,                   6),          PFEXT("SND14vol", PFTYPE_BIN,           np2cfg.vol14,                   6),
 //      PFEXT("opt14BRD", PFTYPE_ARGH8,         np2cfg.snd14opt,                3),  //      PFEXT("opt14BRD", PFTYPE_BIN,           np2cfg.snd14opt,                3),
         PFVAL("opt26BRD", PFTYPE_HEX8,          &np2cfg.snd26opt),          PFVAL("opt26BRD", PFTYPE_HEX8,          &np2cfg.snd26opt),
         PFVAL("opt86BRD", PFTYPE_HEX8,          &np2cfg.snd86opt),          PFVAL("opt86BRD", PFTYPE_HEX8,          &np2cfg.snd86opt),
         PFVAL("optSPBRD", PFTYPE_HEX8,          &np2cfg.spbopt),          PFVAL("optSPBRD", PFTYPE_HEX8,          &np2cfg.spbopt),
Line 429  static const PFTBL iniitem[] = { Line 464  static const PFTBL iniitem[] = {
         PFVAL("MS_RAPID", PFTYPE_BOOL,          &np2cfg.MOUSERAPID),          PFVAL("MS_RAPID", PFTYPE_BOOL,          &np2cfg.MOUSERAPID),
   
         PFAND("backgrnd", PFTYPE_UINT8,         &np2oscfg.background,   3),          PFAND("backgrnd", PFTYPE_UINT8,         &np2oscfg.background,   3),
         PFEXT("VRAMwait", PFTYPE_ARGH8,         np2cfg.wait,                    6),          PFEXT("VRAMwait", PFTYPE_BIN,           np2cfg.wait,                    6),
         PFAND("DspClock", PFTYPE_UINT8,         &np2oscfg.DISPCLK,              3),          PFAND("DspClock", PFTYPE_UINT8,         &np2oscfg.DISPCLK,              3),
         PFVAL("DispSync", PFTYPE_BOOL,          &np2cfg.DISPSYNC),          PFVAL("DispSync", PFTYPE_BOOL,          &np2cfg.DISPSYNC),
         PFVAL("Real_Pal", PFTYPE_BOOL,          &np2cfg.RASTER),          PFVAL("Real_Pal", PFTYPE_BOOL,          &np2cfg.RASTER),
Line 446  static const PFTBL iniitem[] = { Line 481  static const PFTBL iniitem[] = {
         PFAND("FG_COLOR", PFRO_HEX32,           &np2cfg.FG_COLOR,               0xffffff),          PFAND("FG_COLOR", PFRO_HEX32,           &np2cfg.FG_COLOR,               0xffffff),
   
         PFVAL("pc9861_e", PFTYPE_BOOL,          &np2cfg.pc9861enable),          PFVAL("pc9861_e", PFTYPE_BOOL,          &np2cfg.pc9861enable),
         PFEXT("pc9861_s", PFTYPE_ARGH8,         np2cfg.pc9861sw,                3),          PFEXT("pc9861_s", PFTYPE_BIN,           np2cfg.pc9861sw,                3),
         PFEXT("pc9861_j", PFTYPE_ARGH8,         np2cfg.pc9861jmp,               6),          PFEXT("pc9861_j", PFTYPE_BIN,           np2cfg.pc9861jmp,               6),
   
         PFVAL("calendar", PFTYPE_BOOL,          &np2cfg.calendar),          PFVAL("calendar", PFTYPE_BOOL,          &np2cfg.calendar),
         PFVAL("USE144FD", PFTYPE_BOOL,          &np2cfg.usefd144),          PFVAL("USE144FD", PFTYPE_BOOL,          &np2cfg.usefd144),
Line 460  static const PFTBL iniitem[] = { Line 495  static const PFTBL iniitem[] = {
         PFVAL("keyboard", PFRO_KB,                      &np2oscfg.KEYBOARD),          PFVAL("keyboard", PFRO_KB,                      &np2oscfg.KEYBOARD),
         PFVAL("F12_COPY", PFTYPE_UINT8,         &np2oscfg.F12COPY),          PFVAL("F12_COPY", PFTYPE_UINT8,         &np2oscfg.F12COPY),
         PFVAL("Joystick", PFTYPE_BOOL,          &np2oscfg.JOYPAD1),          PFVAL("Joystick", PFTYPE_BOOL,          &np2oscfg.JOYPAD1),
         PFEXT("Joy1_btn", PFTYPE_ARGH8,         np2oscfg.JOY1BTN,               4),          PFEXT("Joy1_btn", PFTYPE_BIN,           np2oscfg.JOY1BTN,               4),
   
         PFVAL("clocknow", PFTYPE_UINT8,         &np2oscfg.clk_x),          PFVAL("clocknow", PFTYPE_UINT8,         &np2oscfg.clk_x),
         PFVAL("clockfnt", PFTYPE_UINT8,         &np2oscfg.clk_fnt),          PFVAL("clockfnt", PFTYPE_UINT8,         &np2oscfg.clk_fnt),
Line 513  static const PFTBL iniitem[] = { Line 548  static const PFTBL iniitem[] = {
         PFVAL("I286SAVE", PFRO_BOOL,            &np2oscfg.I286SAVE)};          PFVAL("I286SAVE", PFRO_BOOL,            &np2oscfg.I286SAVE)};
   
   
   static const OEMCHAR ext_ini[] = OEMTEXT(".ini");
   
 void initgetfile(OEMCHAR *path, UINT size) {  void initgetfile(OEMCHAR *path, UINT size) {
   
 const OEMCHAR   *ext;  const OEMCHAR   *ext;
Line 528  const OEMCHAR *ext; Line 565  const OEMCHAR *ext;
                 }                  }
                 ext = file_getext(path);                  ext = file_getext(path);
                 if (ext[0] != '\0') {                  if (ext[0] != '\0') {
                         file_catname(path, OEMTEXT(".ini"), size);                          file_catname(path, ext_ini, size);
                 }                  }
         }          }
         else {          else {
                 file_cutext(path);                  file_cutext(path);
                 file_catname(path, OEMTEXT(".ini"), size);                  file_catname(path, ext_ini, size);
         }          }
 }  }
   

Removed from v.1.37  
changed lines
  Added in v.1.41


RetroPC.NET-CVS <cvs@retropc.net>