Diff for /np2/statsave.c between versions 1.41 and 1.45

version 1.41, 2004/03/30 20:01:29 version 1.45, 2005/02/12 12:40:38
Line 96  extern COMMNG cm_mpu98; Line 96  extern COMMNG cm_mpu98;
 extern  COMMNG  cm_rs232c;  extern  COMMNG  cm_rs232c;
   
 typedef struct {  typedef struct {
         char    *buf;          OEMCHAR *buf;
         int             remain;          int             remain;
 } ERR_BUF;  } ERR_BUF;
   
Line 104  typedef struct { Line 104  typedef struct {
 // ----  // ----
   
 // 関数ポインタを intに変更。  // 関数ポインタを intに変更。
 static BOOL proc2num(void *func, const PROCTBL *tbl, int size) {  static BRESULT proc2num(void *func, const PROCTBL *tbl, int size) {
   
         int             i;          int             i;
   
Line 118  static BOOL proc2num(void *func, const P Line 118  static BOOL proc2num(void *func, const P
         return(FAILURE);          return(FAILURE);
 }  }
   
 static BOOL num2proc(void *func, const PROCTBL *tbl, int size) {  static BRESULT num2proc(void *func, const PROCTBL *tbl, int size) {
   
         int             i;          int             i;
   
Line 149  typedef struct { Line 149  typedef struct {
         NP2FHDR         f;          NP2FHDR         f;
 } _SFFILEH, *SFFILEH;  } _SFFILEH, *SFFILEH;
   
 static SFFILEH statflag_open(const char *filename, char *err, int errlen) {  static SFFILEH statflag_open(const OEMCHAR *filename, OEMCHAR *err, int errlen) {
   
         FILEH   fh;          FILEH   fh;
         SFFILEH ret;          SFFILEH ret;
Line 186  sfo_err1: Line 186  sfo_err1:
 static int statflag_closesection(SFFILEH sffh) {  static int statflag_closesection(SFFILEH sffh) {
   
         UINT    leng;          UINT    leng;
         BYTE    zero[16];          UINT8   zero[16];
   
         if (sffh == NULL) {          if (sffh == NULL) {
                 goto sfcs_err1;                  goto sfcs_err1;
Line 261  sfr_err: Line 261  sfr_err:
         return(STATFLAG_FAILURE);          return(STATFLAG_FAILURE);
 }  }
   
 static SFFILEH statflag_create(const char *filename) {  static SFFILEH statflag_create(const OEMCHAR *filename) {
   
         SFFILEH ret;          SFFILEH ret;
         FILEH   fh;          FILEH   fh;
Line 355  static void statflag_close(SFFILEH sffh) Line 355  static void statflag_close(SFFILEH sffh)
         }          }
 }  }
   
 void statflag_seterr(STFLAGH sfh, const char *str) {  void statflag_seterr(STFLAGH sfh, const OEMCHAR *str) {
   
         if ((sfh) && (sfh->errlen)) {          if ((sfh) && (sfh->errlen)) {
                 milstr_ncat(sfh->err, str, sfh->errlen);                  milstr_ncat(sfh->err, str, sfh->errlen);
Line 547  static int nevent_write(STFLAGH sfh, int Line 547  static int nevent_write(STFLAGH sfh, int
         UINT            i;          UINT            i;
   
         ZeroMemory(&nit, sizeof(nit));          ZeroMemory(&nit, sizeof(nit));
         for (i=0; i<sizeof(evtnum)/sizeof(ENUMTBL); i++) {          for (i=0; i<NELEMENTS(evtnum); i++) {
                 if (evtnum[i].num == num) {                  if (evtnum[i].num == num) {
                         nit.id = evtnum[i].id;                          nit.id = evtnum[i].id;
                         break;                          break;
Line 591  static int nevent_read(STFLAGH sfh, UINT Line 591  static int nevent_read(STFLAGH sfh, UINT
   
         ret = statflag_read(sfh, &nit, sizeof(nit));          ret = statflag_read(sfh, &nit, sizeof(nit));
   
         for (i=0; i<sizeof(evtnum)/sizeof(ENUMTBL); i++) {          for (i=0; i<NELEMENTS(evtnum); i++) {
                 if (nit.id == evtnum[i].id) {                  if (nit.id == evtnum[i].id) {
                         break;                          break;
                 }                  }
         }          }
         if (i < (sizeof(evtnum)/sizeof(ENUMTBL))) {          if (i < NELEMENTS(evtnum)) {
                 num = evtnum[i].num;                  num = evtnum[i].num;
                 nevent.item[num].clock = nit.clock;                  nevent.item[num].clock = nit.clock;
                 nevent.item[num].flag = nit.flag;                  nevent.item[num].flag = nit.flag;
Line 671  static int flagsave_gij(STFLAGH sfh, con Line 671  static int flagsave_gij(STFLAGH sfh, con
         int             ret;          int             ret;
         int             i;          int             i;
         int             j;          int             j;
 const BYTE      *fnt;  const UINT8     *fnt;
   
         ret = STATFLAG_SUCCESS;          ret = STATFLAG_SUCCESS;
         for (i=0; i<2; i++) {          for (i=0; i<2; i++) {
Line 690  static int flagload_gij(STFLAGH sfh, con Line 690  static int flagload_gij(STFLAGH sfh, con
         int             ret;          int             ret;
         int             i;          int             i;
         int             j;          int             j;
         BYTE    *fnt;          UINT8   *fnt;
   
         ret = 0;          ret = 0;
         for (i=0; i<2; i++) {          for (i=0; i<2; i++) {
Line 707  static int flagload_gij(STFLAGH sfh, con Line 707  static int flagload_gij(STFLAGH sfh, con
   
 // ---- FM  // ---- FM
   
   #if !defined(DISABLE_SOUND)
   
 enum {  enum {
         FLAG_MG                 = 0x0001,          FLAG_MG                 = 0x0001,
         FLAG_FM1A               = 0x0002,          FLAG_FM1A               = 0x0002,
Line 723  enum { Line 725  enum {
 };  };
   
 typedef struct {  typedef struct {
         BYTE    keyreg[OPNCH_MAX];          UINT8   keyreg[OPNCH_MAX];
         BYTE    extop[4];          UINT8   extop[4];
 } OPNKEY;  } OPNKEY;
   
 static int flagsave_fm(STFLAGH sfh, const SFENTRY *tbl) {  static int flagsave_fm(STFLAGH sfh, const SFENTRY *tbl) {
Line 920  static int flagload_fm(STFLAGH sfh, cons Line 922  static int flagload_fm(STFLAGH sfh, cons
         (void)t;          (void)t;
         return(ret);          return(ret);
 }  }
   #endif
   
   
 // ---- disk  // ---- disk
   
 typedef struct {  typedef struct {
         char    path[MAX_PATH];          OEMCHAR path[MAX_PATH];
         int             readonly;          int             readonly;
         DOSDATE date;          DOSDATE date;
         DOSTIME time;          DOSTIME time;
 } STATDISK;  } STATDISK;
   
 static const char str_fddx[] = "FDD%u";  static const OEMCHAR str_fddx[] = OEMTEXT("FDD%u");
 static const char str_sasix[] = "SASI%u";  static const OEMCHAR str_sasix[] = OEMTEXT("SASI%u");
 static const char str_scsix[] = "SCSI%u";  static const OEMCHAR str_scsix[] = OEMTEXT("SCSI%u");
 static const char str_updated[] = "%s: updated";  static const OEMCHAR str_updated[] = OEMTEXT("%s: updated");
 static const char str_notfound[] = "%s: not found";  static const OEMCHAR str_notfound[] = OEMTEXT("%s: not found");
   
 static int disksave(STFLAGH sfh, const char *path, int readonly) {  static int disksave(STFLAGH sfh, const OEMCHAR *path, int readonly) {
   
         STATDISK        st;          STATDISK        st;
         FILEH           fh;          FILEH           fh;
Line 958  static int disksave(STFLAGH sfh, const c Line 961  static int disksave(STFLAGH sfh, const c
 static int flagsave_disk(STFLAGH sfh, const SFENTRY *tbl) {  static int flagsave_disk(STFLAGH sfh, const SFENTRY *tbl) {
   
         int             ret;          int             ret;
         BYTE    i;          UINT8   i;
   
         sxsi_flash();          sxsi_flash();
         ret = STATFLAG_SUCCESS;          ret = STATFLAG_SUCCESS;
Line 975  static int flagsave_disk(STFLAGH sfh, co Line 978  static int flagsave_disk(STFLAGH sfh, co
         return(ret);          return(ret);
 }  }
   
 static int diskcheck(STFLAGH sfh, const char *name) {  static int diskcheck(STFLAGH sfh, const OEMCHAR *name) {
   
         int                     ret;          int                     ret;
         FILEH           fh;          FILEH           fh;
         STATDISK        st;          STATDISK        st;
         char            buf[256];          OEMCHAR         buf[256];
         DOSDATE         date;          DOSDATE         date;
         DOSTIME         time;          DOSTIME         time;
   
Line 993  static int diskcheck(STFLAGH sfh, const  Line 996  static int diskcheck(STFLAGH sfh, const 
                         if ((memcmp(&st.date, &date, sizeof(date))) ||                          if ((memcmp(&st.date, &date, sizeof(date))) ||
                                 (memcmp(&st.time, &time, sizeof(time)))) {                                  (memcmp(&st.time, &time, sizeof(time)))) {
                                 ret |= STATFLAG_DISKCHG;                                  ret |= STATFLAG_DISKCHG;
                                 SPRINTF(buf, str_updated, name);                                  OEMSPRINTF(buf, str_updated, name);
                                 statflag_seterr(sfh, buf);                                  statflag_seterr(sfh, buf);
                         }                          }
                 }                  }
                 else {                  else {
                         ret |= STATFLAG_DISKCHG;                          ret |= STATFLAG_DISKCHG;
                         SPRINTF(buf, str_notfound, name);                          OEMSPRINTF(buf, str_notfound, name);
                         statflag_seterr(sfh, buf);                          statflag_seterr(sfh, buf);
                 }                  }
         }          }
Line 1010  static int flagcheck_disk(STFLAGH sfh, c Line 1013  static int flagcheck_disk(STFLAGH sfh, c
   
         int             ret;          int             ret;
         int             i;          int             i;
         char    buf[8];          OEMCHAR buf[8];
   
         ret = 0;          ret = 0;
         for (i=0; i<4; i++) {          for (i=0; i<4; i++) {
                 SPRINTF(buf, str_fddx, i+1);                  OEMSPRINTF(buf, str_fddx, i+1);
                 ret |= diskcheck(sfh, buf);                  ret |= diskcheck(sfh, buf);
         }          }
         sxsi_flash();          sxsi_flash();
         for (i=0; i<2; i++) {          for (i=0; i<2; i++) {
                 SPRINTF(buf, str_sasix, i+1);                  OEMSPRINTF(buf, str_sasix, i+1);
                 ret |= diskcheck(sfh, buf);                  ret |= diskcheck(sfh, buf);
         }          }
         for (i=0; i<4; i++) {          for (i=0; i<4; i++) {
                 SPRINTF(buf, str_scsix, i);                  OEMSPRINTF(buf, str_scsix, i);
                 ret |= diskcheck(sfh, buf);                  ret |= diskcheck(sfh, buf);
         }          }
         (void)tbl;          (void)tbl;
Line 1170  static int flagcheck_veronly(STFLAGH sfh Line 1173  static int flagcheck_veronly(STFLAGH sfh
   
 // ----  // ----
   
 int statsave_save(const char *filename) {  int statsave_save(const OEMCHAR *filename) {
   
         SFFILEH         sffh;          SFFILEH         sffh;
         int                     ret;          int                     ret;
Line 1184  const SFENTRY *tblterm; Line 1187  const SFENTRY *tblterm;
   
         ret = STATFLAG_SUCCESS;          ret = STATFLAG_SUCCESS;
         tbl = np2tbl;          tbl = np2tbl;
         tblterm = tbl + (sizeof(np2tbl)/sizeof(SFENTRY));          tblterm = tbl + NELEMENTS(np2tbl);
         while(tbl < tblterm) {          while(tbl < tblterm) {
                 ret |= statflag_createsection(sffh, tbl);                  ret |= statflag_createsection(sffh, tbl);
                 switch(tbl->type) {                  switch(tbl->type) {
Line 1227  const SFENTRY *tblterm; Line 1230  const SFENTRY *tblterm;
                                 ret |= flagsave_ext(&sffh->sfh, tbl);                                  ret |= flagsave_ext(&sffh->sfh, tbl);
                                 break;                                  break;
   
   #if !defined(DISABLE_SOUND)
                         case STATFLAG_FM:                          case STATFLAG_FM:
                                 ret |= flagsave_fm(&sffh->sfh, tbl);                                  ret |= flagsave_fm(&sffh->sfh, tbl);
                                 break;                                  break;
   #endif
   
                         case STATFLAG_GIJ:                          case STATFLAG_GIJ:
                                 ret |= flagsave_gij(&sffh->sfh, tbl);                                  ret |= flagsave_gij(&sffh->sfh, tbl);
Line 1251  const SFENTRY *tblterm; Line 1256  const SFENTRY *tblterm;
         return(ret);          return(ret);
 }  }
   
 int statsave_check(const char *filename, char *buf, int size) {  int statsave_check(const OEMCHAR *filename, OEMCHAR *buf, int size) {
   
         SFFILEH         sffh;          SFFILEH         sffh;
         int                     ret;          int                     ret;
Line 1269  const SFENTRY *tblterm; Line 1274  const SFENTRY *tblterm;
         while((!done) && (ret != STATFLAG_FAILURE)) {          while((!done) && (ret != STATFLAG_FAILURE)) {
                 ret |= statflag_readsection(sffh);                  ret |= statflag_readsection(sffh);
                 tbl = np2tbl;                  tbl = np2tbl;
                 tblterm = tbl + (sizeof(np2tbl)/sizeof(SFENTRY));                  tblterm = tbl + NELEMENTS(np2tbl);
                 while(tbl < tblterm) {                  while(tbl < tblterm) {
                         if (!memcmp(sffh->sfh.hdr.index, tbl->index, 10)) {                          if (!memcmp(sffh->sfh.hdr.index, tbl->index, 10)) {
                                 break;                                  break;
Line 1297  const SFENTRY *tblterm; Line 1302  const SFENTRY *tblterm;
                                 case STATFLAG_EVT:                                  case STATFLAG_EVT:
                                 case STATFLAG_EXT:                                  case STATFLAG_EXT:
                                 case STATFLAG_GIJ:                                  case STATFLAG_GIJ:
   #if !defined(DISABLE_SOUND)
                                 case STATFLAG_FM:                                  case STATFLAG_FM:
   #endif
 #if defined(SUPPORT_HOSTDRV)  #if defined(SUPPORT_HOSTDRV)
                                 case STATFLAG_HDRV:                                  case STATFLAG_HDRV:
 #endif  #endif
Line 1321  const SFENTRY *tblterm; Line 1328  const SFENTRY *tblterm;
         return(ret);          return(ret);
 }  }
   
 int statsave_load(const char *filename) {  int statsave_load(const OEMCHAR *filename) {
   
         SFFILEH         sffh;          SFFILEH         sffh;
         int                     ret;          int                     ret;
Line 1367  const SFENTRY *tblterm; Line 1374  const SFENTRY *tblterm;
         while((!done) && (ret != STATFLAG_FAILURE)) {          while((!done) && (ret != STATFLAG_FAILURE)) {
                 ret |= statflag_readsection(sffh);                  ret |= statflag_readsection(sffh);
                 tbl = np2tbl + 1;                  tbl = np2tbl + 1;
                 tblterm = np2tbl + (sizeof(np2tbl)/sizeof(SFENTRY));                  tblterm = np2tbl + NELEMENTS(np2tbl);
                 while(tbl < tblterm) {                  while(tbl < tblterm) {
                         if (!memcmp(sffh->sfh.hdr.index, tbl->index, 10)) {                          if (!memcmp(sffh->sfh.hdr.index, tbl->index, 10)) {
                                 break;                                  break;
Line 1418  const SFENTRY *tblterm; Line 1425  const SFENTRY *tblterm;
                                         ret |= flagload_ext(&sffh->sfh, tbl);                                          ret |= flagload_ext(&sffh->sfh, tbl);
                                         break;                                          break;
   
   #if !defined(DISABLE_SOUND)
                                 case STATFLAG_FM:                                  case STATFLAG_FM:
                                         ret |= flagload_fm(&sffh->sfh, tbl);                                          ret |= flagload_fm(&sffh->sfh, tbl);
                                         break;                                          break;
   #endif
   
                                 case STATFLAG_GIJ:                                  case STATFLAG_GIJ:
                                         ret |= flagload_gij(&sffh->sfh, tbl);                                          ret |= flagload_gij(&sffh->sfh, tbl);

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


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