Diff for /np2/x11/ini.c between versions 1.22 and 1.26

version 1.22, 2008/04/03 13:52:20 version 1.26, 2012/01/23 04:20:24
Line 1 Line 1
 /*      $Id$    */  
   
 #include "compiler.h"  #include "compiler.h"
   
 #include "np2.h"  #include "np2.h"
Line 17 Line 15
   
 typedef struct {  typedef struct {
         const char      *title;          const char      *title;
         const INITBL    *tbl;          INITBL          *tbl;
         const INITBL    *tblterm;          INITBL          *tblterm;
         UINT            count;          UINT            count;
 } _INIARG, *INIARG;  } _INIARG, *INIARG;
   
Line 45  inisetbmp(BYTE *ptr, UINT pos, BOOL set) Line 43  inisetbmp(BYTE *ptr, UINT pos, BOOL set)
 }  }
   
 static void  static void
 inirdargs16(const char *src, const INITBL *ini)  inirdargs16(const char *src, INITBL *ini)
 {  {
         SINT16 *dst;          SINT16 *dst;
         int dsize;          int dsize;
Line 73  inirdargs16(const char *src, const INITB Line 71  inirdargs16(const char *src, const INITB
 }  }
   
 static void  static void
 inirdargh8(const char *src, const INITBL *ini)  inirdargh8(const char *src, INITBL *ini)
 {  {
         BYTE *dst;          BYTE *dst;
         int dsize;          int dsize;
Line 119  inirdargh8(const char *src, const INITBL Line 117  inirdargh8(const char *src, const INITBL
 }  }
   
 static void  static void
 iniwrsetargh8(char *work, int size, const INITBL *ini)  iniwrsetargh8(char *work, int size, INITBL *ini)
 {  {
         char tmp[8];          char tmp[8];
         const BYTE *ptr;          const BYTE *ptr;
Line 129  iniwrsetargh8(char *work, int size, cons Line 127  iniwrsetargh8(char *work, int size, cons
         ptr = (BYTE *)(ini->value);          ptr = (BYTE *)(ini->value);
         arg = ini->arg;          arg = ini->arg;
         if (arg > 0) {          if (arg > 0) {
                 SPRINTF(tmp, "%.2x ", ptr[0]);                  g_snprintf(tmp, sizeof(tmp), "%.2x ", ptr[0]);
                 milstr_ncpy(work, tmp, size);                  milstr_ncpy(work, tmp, size);
         }          }
         for (i = 1; i < arg; i++) {          for (i = 1; i < arg; i++) {
                 SPRINTF(tmp, "%.2x ", ptr[i]);                  g_snprintf(tmp, sizeof(tmp), "%.2x ", ptr[i]);
                 milstr_ncat(work, tmp, size);                  milstr_ncat(work, tmp, size);
         }          }
 }  }
Line 141  iniwrsetargh8(char *work, int size, cons Line 139  iniwrsetargh8(char *work, int size, cons
 /* ----- user */  /* ----- user */
   
 static void  static void
 inirdbyte3(const char *src, const INITBL *ini)  inirdbyte3(const char *src, INITBL *ini)
 {  {
         UINT i;          UINT i;
   
Line 157  inirdbyte3(const char *src, const INITBL Line 155  inirdbyte3(const char *src, const INITBL
 }  }
   
 static void  static void
 inirdkb(const char *src, const INITBL *ini)  inirdkb(const char *src, INITBL *ini)
 {  {
   
         if ((!milstr_extendcmp(src, "DOS"))          if ((!milstr_extendcmp(src, "DOS"))
Line 177  inirdkb(const char *src, const INITBL *i Line 175  inirdkb(const char *src, const INITBL *i
 }  }
   
 static void  static void
 inirdsnddrv(const char *src, const INITBL *ini)  inirdsnddrv(const char *src, INITBL *ini)
 {  {
   
         *(UINT8 *)ini->value = snddrv_drv2num(src);          *(UINT8 *)ini->value = snddrv_drv2num(src);
 }  }
   
 static void  static void
 inirdinterp(const char *src, const INITBL *ini)  inirdinterp(const char *src, INITBL *ini)
 {  {
   
         if (!milstr_cmp(src, "NEAREST")) {          if (!milstr_cmp(src, "NEAREST")) {
Line 204  static BOOL Line 202  static BOOL
 inireadcb(void *arg, const char *para, const char *key, const char *data)  inireadcb(void *arg, const char *para, const char *key, const char *data)
 {  {
         char work[512];          char work[512];
         const INITBL *p;          INITBL *p;
         BOOL rv;          BOOL rv;
   
         if (arg == NULL) {          if (arg == NULL) {
Line 301  inireadcb(void *arg, const char *para, c Line 299  inireadcb(void *arg, const char *para, c
 }  }
   
 void  void
 ini_read(const char *path, const char *title, const INITBL *tbl, UINT count)  ini_read(const char *path, const char *title, INITBL *tbl, UINT count)
 {  {
         _INIARG iniarg;          _INIARG iniarg;
   
Line 378  iniwrinterp(UINT8 interp) Line 376  iniwrinterp(UINT8 interp)
 static BOOL read_iniread_flag(const INITBL *p);  static BOOL read_iniread_flag(const INITBL *p);
   
 void  void
 ini_write(const char *path, const char *title, const INITBL *tbl, UINT count, BOOL create)  ini_write(const char *path, const char *title, INITBL *tbl, UINT count, BOOL create)
 {  {
         char            work[512];          char    work[512];
         const INITBL    *p;          INITBL  *p;
         const INITBL    *pterm;          INITBL  *pterm;
         FILEH           fh;          FILEH   fh;
         BOOL            set;          BOOL    set;
   
         fh = FILEH_INVALID;          fh = FILEH_INVALID;
         if (!create) {          if (!create) {
Line 427  ini_write(const char *path, const char * Line 425  ini_write(const char *path, const char *
                                 break;                                  break;
   
                         case INITYPE_SINT8:                          case INITYPE_SINT8:
                                 SPRINTF(work, "%d", *((char *)p->value));                                  g_snprintf(work, sizeof(work), "%d", *((char *)p->value));
                                 break;                                  break;
   
                         case INITYPE_SINT16:                          case INITYPE_SINT16:
                                 SPRINTF(work, "%d", *((SINT16 *)p->value));                                  g_snprintf(work, sizeof(work), "%d", *((SINT16 *)p->value));
                                 break;                                  break;
   
                         case INITYPE_SINT32:                          case INITYPE_SINT32:
                                 SPRINTF(work, "%d", *((SINT32 *)p->value));                                  g_snprintf(work, sizeof(work), "%d", *((SINT32 *)p->value));
                                 break;                                  break;
   
                         case INITYPE_UINT8:                          case INITYPE_UINT8:
                                 SPRINTF(work, "%u", *((BYTE *)p->value));                                  g_snprintf(work, sizeof(work), "%u", *((BYTE *)p->value));
                                 break;                                  break;
   
                         case INITYPE_UINT16:                          case INITYPE_UINT16:
                                 SPRINTF(work, "%u", *((UINT16 *)p->value));                                  g_snprintf(work, sizeof(work), "%u", *((UINT16 *)p->value));
                                 break;                                  break;
   
                         case INITYPE_UINT32:                          case INITYPE_UINT32:
                                 SPRINTF(work, "%u", *((UINT32 *)p->value));                                  g_snprintf(work, sizeof(work), "%u", *((UINT32 *)p->value));
                                 break;                                  break;
   
                         case INITYPE_HEX8:                          case INITYPE_HEX8:
                                 SPRINTF(work, "%x", *((BYTE *)p->value));                                  g_snprintf(work, sizeof(work), "%x", *((BYTE *)p->value));
                                 break;                                  break;
   
                         case INITYPE_HEX16:                          case INITYPE_HEX16:
                                 SPRINTF(work, "%x", *((UINT16 *)p->value));                                  g_snprintf(work, sizeof(work), "%x", *((UINT16 *)p->value));
                                 break;                                  break;
   
                         case INITYPE_HEX32:                          case INITYPE_HEX32:
                                 SPRINTF(work, "%x", *((UINT32 *)p->value));                                  g_snprintf(work, sizeof(work), "%x", *((UINT32 *)p->value));
                                 break;                                  break;
   
                         case INITYPE_KB:                          case INITYPE_KB:
Line 470  ini_write(const char *path, const char * Line 468  ini_write(const char *path, const char *
                                 break;                                  break;
   
                         case INITYPE_SNDDRV:                          case INITYPE_SNDDRV:
                                 SPRINTF(work, "%s", snddrv_num2drv(*(UINT8 *)p->value));                                  g_snprintf(work, sizeof(work), "%s", snddrv_num2drv(*(UINT8 *)p->value));
                                 break;                                  break;
   
                         case INITYPE_INTERP:                          case INITYPE_INTERP:
                                 SPRINTF(work, "%s", iniwrinterp(*(UINT8 *)p->value));                                  g_snprintf(work, sizeof(work), "%s", iniwrinterp(*(UINT8 *)p->value));
                                 break;                                  break;
   
                         default:                          default:
Line 493  ini_write(const char *path, const char * Line 491  ini_write(const char *path, const char *
         file_close(fh);          file_close(fh);
 }  }
   
 extern char modulefile[];  static const char ini_title[] =
   #if !defined(CPUCORE_IA32)
 static const char ini_title[] = "NekoProjectII";          "NekoProjectII";
   #else
           "NekoProjectII_IA32";
   #endif
   
 enum {  enum {
         INIRO_STR       = INIFLAG_RO | INITYPE_STR,          INIRO_STR       = INIFLAG_RO | INITYPE_STR,
Line 511  enum { Line 512  enum {
         INIRO_KB        = INIFLAG_RO | INITYPE_KB          INIRO_KB        = INIFLAG_RO | INITYPE_KB
 };  };
   
 static const INITBL iniitem[] = {  static INITBL iniitem[] = {
         {"np2title", INIRO_STR,         np2oscfg.titles,        sizeof(np2oscfg.titles)},          {"np2title", INIRO_STR,         np2oscfg.titles,        sizeof(np2oscfg.titles)},
         {"paddingx", INIROMAX_SINT32,   &np2oscfg.paddingx,     32},          {"paddingx", INIROMAX_SINT32,   &np2oscfg.paddingx,     32},
         {"paddingy", INIROMAX_SINT32,   &np2oscfg.paddingy,     32},          {"paddingy", INIROMAX_SINT32,   &np2oscfg.paddingy,     32},
Line 668  calc_index(const INITBL *p) Line 669  calc_index(const INITBL *p)
         UINT idx;          UINT idx;
   
         if (p) {          if (p) {
                 offset = (char *)p - (char *)iniitem;                  offset = (const char *)p - (const char *)iniitem;
                 if ((offset % sizeof(iniitem[0])) == 0) {                  if ((offset % sizeof(iniitem[0])) == 0) {
                         idx = offset / sizeof(iniitem[0]);                          idx = offset / sizeof(iniitem[0]);
                         if (idx < INIITEMS) {                          if (idx < INIITEMS) {

Removed from v.1.22  
changed lines
  Added in v.1.26


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