Diff for /np2/statsave.c between versions 1.35 and 1.42

version 1.35, 2004/02/03 08:24:40 version 1.42, 2004/07/01 11:42:54
Line 8 Line 8
 #include        "cpucore.h"  #include        "cpucore.h"
 #include        "pccore.h"  #include        "pccore.h"
 #include        "iocore.h"  #include        "iocore.h"
   #include        "gdc_sub.h"
 #include        "cbuscore.h"  #include        "cbuscore.h"
   #include        "ideio.h"
 #include        "sasiio.h"  #include        "sasiio.h"
 #include        "scsiio.h"  #include        "scsiio.h"
 #include        "pc9861k.h"  #include        "pc9861k.h"
Line 29 Line 31
 #include        "keydisp.h"  #include        "keydisp.h"
 #include        "hostdrv.h"  #include        "hostdrv.h"
 #include        "calendar.h"  #include        "calendar.h"
   #include        "keystat.h"
   
 #if defined(MACOS)  #if defined(MACOS)
 #define CRCONST         str_cr  #define CRCONST         str_cr
Line 143  typedef struct { Line 146  typedef struct {
         UINT            stat;          UINT            stat;
         FILEH           fh;          FILEH           fh;
         UINT            secpos;          UINT            secpos;
   
 //      long            pos;  
 //      long            bak;  
 //      long            next;  
         NP2FHDR         f;          NP2FHDR         f;
 //      NP2FENT         p;  } _SFFILEH, *SFFILEH;
 } _NP2FFILE, *NP2FFILE, _SFFILEH, *SFFILEH;  
   
 static SFFILEH statflag_open(const char *filename, char *err, int errlen) {  static SFFILEH statflag_open(const char *filename, char *err, int errlen) {
   
Line 366  void statflag_seterr(STFLAGH sfh, const  Line 364  void statflag_seterr(STFLAGH sfh, const 
 }  }
   
   
   
   
 #if 0  
 static int flagopen(NP2FFILE f, const char *filename, ERR_BUF *e) {  
   
         if (f) {  
                 f->fh = file_open(filename);  
                 if (f->fh == FILEH_INVALID) {  
                         return(STATFLAG_FAILURE);  
                 }  
                 if (file_read(f->fh, &f->f, sizeof(NP2FHDR))  
                                                                                                 != sizeof(NP2FHDR)) {  
                         file_close(f->fh);  
                         return(STATFLAG_FAILURE);  
                 }  
                 f->pos = sizeof(NP2FHDR);  
                 if (strcmp(f->f.name, np2flagdef.name)) {  
                         file_close(f->fh);  
                         return(STATFLAG_FAILURE);  
                 }  
                 if (strcmp(f->f.vername, np2flagdef.vername)) {  
 #if 1  
                         file_close(f->fh);  
                         return(STATFLAG_FAILURE);  
 #else  
                         return(STATFLAG_VERSION);                       // 他形式を読むのであれば…  
 #endif  
                 }  
                 if (f->f.ver != np2flagdef.ver) {  
 #if 1  
                         file_close(f->fh);  
                         return(STATFLAG_FAILURE);  
 #else  
                         return(STATFLAG_VERSION);                       // 他verを読むのであれば…  
 #endif  
                 }  
                 return(STATFLAG_SUCCESS);  
         }  
         (void)e;  
         return(STATFLAG_FAILURE);  
 }  
   
 static int flagcreate(NP2FFILE f, const char *filename) {  
   
         if (f) {  
                 f->fh = file_create(filename);  
                 if (f->fh == FILEH_INVALID) {  
                         return(STATFLAG_FAILURE);  
                 }  
                 if (file_write(f->fh, &np2flagdef, sizeof(NP2FHDR))  
                                                                                                                 != sizeof(NP2FHDR)) {  
                         file_close(f->fh);  
                         return(STATFLAG_FAILURE);  
                 }  
                 f->pos = sizeof(NP2FHDR);  
                 return(STATFLAG_SUCCESS);  
         }  
         return(STATFLAG_FAILURE);  
 }  
   
 static int flagload_create(NP2FFILE f) {  
   
         if (f) {  
                 ZeroMemory(&f->p, sizeof(NP2FENT));  
                 if (f->pos & 15) {  
                         f->pos += 15;  
                         f->pos &= ~0xf;  
                         if (file_seek(f->fh, f->pos, 0) != f->pos) {  
                                 return(STATFLAG_FAILURE);  
                         }  
                 }  
                 if (file_read(f->fh, &f->p, sizeof(NP2FENT)) != sizeof(NP2FENT)) {  
                         return(STATFLAG_FAILURE);  
                 }  
                 f->pos += sizeof(NP2FENT);  
                 f->next = f->pos + f->p.size;  
                 return(STATFLAG_SUCCESS);  
         }  
         return(STATFLAG_FAILURE);  
 }  
   
 static int flagload_load(NP2FFILE f, void *buf, UINT size) {  
   
         if (f && buf && size && (file_read(f->fh, buf, size) == size)) {  
                 f->pos += size;  
                 return(STATFLAG_SUCCESS);  
         }  
         return(STATFLAG_FAILURE);  
 }  
   
 static int flagload_close(NP2FFILE f) {  
   
         if (file_seek(f->fh, f->next, 0) != f->next) {  
                 return(STATFLAG_FAILURE);  
         }  
         f->pos = f->next;  
         return(STATFLAG_SUCCESS);  
 }  
   
 static int flagsave_create(NP2FFILE f, const SFENTRY *t) {  
   
         if (f && t) {  
                 int             len;  
                 ZeroMemory(&f->p, sizeof(NP2FENT));  
                 if (f->pos & 15) {  
                         UINT rem;  
                         rem = 16 - (f->pos & 15);  
                         if (file_write(f->fh, &f->p, rem) != rem) {  
                                 return(STATFLAG_FAILURE);  
                         }  
                         f->pos += rem;  
                 }  
                 f->bak = f->pos;  
   
                 len = strlen(t->index);  
                 if (len >= 10) {  
                         len = 10;  
                 }  
                 if (len) {  
                         CopyMemory(f->p.index, t->index, len);  
                 }  
                 f->p.ver = t->ver;  
                 if (file_write(f->fh, &f->p, sizeof(NP2FENT)) != sizeof(NP2FENT)) {  
                         return(STATFLAG_FAILURE);  
                 }  
                 f->pos += sizeof(NP2FENT);  
                 return(STATFLAG_SUCCESS);  
         }  
         return(STATFLAG_FAILURE);  
 }  
   
 static int flagsave_save(NP2FFILE f, void *buf, UINT size) {  
   
         if (f && buf && size && (file_write(f->fh, buf, size) == size)) {  
                 f->pos += size;  
                 f->p.size += size;  
                 return(STATFLAG_SUCCESS);  
         }  
         return(STATFLAG_FAILURE);  
 }  
   
 static int flagsave_close(NP2FFILE f) {  
   
         if (!f) {  
                 goto fs_closeerr;  
         }  
         if (file_seek(f->fh, f->bak, 0) != f->bak) {  
                 goto fs_closeerr;  
         }  
         if (file_write(f->fh, &f->p, sizeof(NP2FENT)) != sizeof(NP2FENT)) {  
                 goto fs_closeerr;  
         }  
         if (file_seek(f->fh, f->pos, 0) == f->pos) {  
                 return(STATFLAG_SUCCESS);  
         }  
   
 fs_closeerr:  
         return(STATFLAG_FAILURE);  
 }  
   
 static void flagclose(NP2FFILE f) {  
   
         if (f) {  
                 file_close(f->fh);  
         }  
 }  
 #endif  
   
   
 // ---- common  // ---- common
   
 static int flagsave_common(STFLAGH sfh, const SFENTRY *tbl) {  static int flagsave_common(STFLAGH sfh, const SFENTRY *tbl) {
Line 878  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 1077  static int flagload_fm(STFLAGH sfh, cons Line 908  static int flagload_fm(STFLAGH sfh, cons
         }          }
         if (saveflg & FLAG_CS4231) {          if (saveflg & FLAG_CS4231) {
                 ret |= statflag_read(sfh, &cs4231, sizeof(cs4231));                  ret |= statflag_read(sfh, &cs4231, sizeof(cs4231));
                 cs4231.proc = cs4231dec[cs4231.reg.datafmt >> 4];  
         }          }
   
         // 復元。 これ移動すること!          // 復元。 これ移動すること!
         rhythm_update(&rhythm);  
         adpcm_update(&adpcm);          adpcm_update(&adpcm);
         pcm86gen_update();          pcm86gen_update();
         if (saveflg & FLAG_PCM86) {          if (saveflg & FLAG_PCM86) {
Line 1093  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
Line 1400  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 1470  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 1522  const SFENTRY *tblterm; Line 1356  const SFENTRY *tblterm;
         sxsi_trash();          sxsi_trash();
   
         ret |= flagload_common(&sffh->sfh, np2tbl);          ret |= flagload_common(&sffh->sfh, np2tbl);
         nevent_init();  
   
         CPU_RESET();          CPU_RESET();
         CPU_SETEXTSIZE((UINT32)pccore.extmem);          CPU_SETEXTSIZE((UINT32)pccore.extmem);
           nevent_allreset();
   
         sound_changeclock();          sound_changeclock();
         beep_changeclock();          beep_changeclock();
         sound_reset();          sound_reset();
 #if defined(SUPPORT_WAVEMIX)          fddmtrsnd_bind();
         wavemix_bind();  
 #endif  
   
         iocore_reset();                                                         // サウンドでpicを呼ぶので…          iocore_reset();                                                         // サウンドでpicを呼ぶので…
         cbuscore_reset();          cbuscore_reset();
Line 1593  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.35  
changed lines
  Added in v.1.42


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