--- np2/statsave.c 2004/02/18 06:52:33 1.36 +++ np2/statsave.c 2005/03/05 06:02:28 1.46 @@ -8,7 +8,9 @@ #include "cpucore.h" #include "pccore.h" #include "iocore.h" +#include "gdc_sub.h" #include "cbuscore.h" +#include "ideio.h" #include "sasiio.h" #include "scsiio.h" #include "pc9861k.h" @@ -29,6 +31,7 @@ #include "keydisp.h" #include "hostdrv.h" #include "calendar.h" +#include "keystat.h" #if defined(MACOS) #define CRCONST str_cr @@ -93,7 +96,7 @@ extern COMMNG cm_mpu98; extern COMMNG cm_rs232c; typedef struct { - char *buf; + OEMCHAR *buf; int remain; } ERR_BUF; @@ -101,7 +104,7 @@ typedef struct { // ---- // 関数ポインタを intに変更。 -static BOOL proc2num(void *func, const PROCTBL *tbl, int size) { +static BRESULT proc2num(void *func, const PROCTBL *tbl, int size) { int i; @@ -115,7 +118,7 @@ static BOOL proc2num(void *func, const P return(FAILURE); } -static BOOL num2proc(void *func, const PROCTBL *tbl, int size) { +static BRESULT num2proc(void *func, const PROCTBL *tbl, int size) { int i; @@ -146,7 +149,7 @@ typedef struct { NP2FHDR f; } _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; SFFILEH ret; @@ -183,7 +186,7 @@ sfo_err1: static int statflag_closesection(SFFILEH sffh) { UINT leng; - BYTE zero[16]; + UINT8 zero[16]; if (sffh == NULL) { goto sfcs_err1; @@ -258,7 +261,7 @@ sfr_err: return(STATFLAG_FAILURE); } -static SFFILEH statflag_create(const char *filename) { +static SFFILEH statflag_create(const OEMCHAR *filename) { SFFILEH ret; FILEH fh; @@ -352,7 +355,7 @@ 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)) { milstr_ncat(sfh->err, str, sfh->errlen); @@ -544,7 +547,7 @@ static int nevent_write(STFLAGH sfh, int UINT i; ZeroMemory(&nit, sizeof(nit)); - for (i=0; i> 4]; } // 復元。 これ移動すること! - rhythm_update(&rhythm); adpcm_update(&adpcm); pcm86gen_update(); if (saveflg & FLAG_PCM86) { @@ -919,24 +922,25 @@ static int flagload_fm(STFLAGH sfh, cons (void)t; return(ret); } +#endif // ---- disk typedef struct { - char path[MAX_PATH]; + OEMCHAR path[MAX_PATH]; int readonly; DOSDATE date; DOSTIME time; } STATDISK; -static const char str_fddx[] = "FDD%u"; -static const char str_sasix[] = "SASI%u"; -static const char str_scsix[] = "SCSI%u"; -static const char str_updated[] = "%s: updated"; -static const char str_notfound[] = "%s: not found"; +static const OEMCHAR str_fddx[] = OEMTEXT("FDD%u"); +static const OEMCHAR str_sasix[] = OEMTEXT("SASI%u"); +static const OEMCHAR str_scsix[] = OEMTEXT("SCSI%u"); +static const OEMCHAR str_updated[] = OEMTEXT("%s: updated"); +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; FILEH fh; @@ -957,29 +961,29 @@ static int disksave(STFLAGH sfh, const c static int flagsave_disk(STFLAGH sfh, const SFENTRY *tbl) { int ret; - BYTE i; + UINT8 i; - sxsi_flash(); + sxsi_allflash(); ret = STATFLAG_SUCCESS; for (i=0; i<4; i++) { ret |= disksave(sfh, fdd_diskname(i), fdd_diskprotect(i)); } for (i=0x00; i<0x02; i++) { - ret |= disksave(sfh, sxsi_getname(i), 0); + ret |= disksave(sfh, sxsi_getfilename(i), 0); } for (i=0x20; i<0x24; i++) { - ret |= disksave(sfh, sxsi_getname(i), 0); + ret |= disksave(sfh, sxsi_getfilename(i), 0); } (void)tbl; return(ret); } -static int diskcheck(STFLAGH sfh, const char *name) { +static int diskcheck(STFLAGH sfh, const OEMCHAR *name) { int ret; FILEH fh; STATDISK st; - char buf[256]; + OEMCHAR buf[256]; DOSDATE date; DOSTIME time; @@ -992,13 +996,13 @@ static int diskcheck(STFLAGH sfh, const if ((memcmp(&st.date, &date, sizeof(date))) || (memcmp(&st.time, &time, sizeof(time)))) { ret |= STATFLAG_DISKCHG; - SPRINTF(buf, str_updated, name); + OEMSPRINTF(buf, str_updated, name); statflag_seterr(sfh, buf); } } else { ret |= STATFLAG_DISKCHG; - SPRINTF(buf, str_notfound, name); + OEMSPRINTF(buf, str_notfound, name); statflag_seterr(sfh, buf); } } @@ -1009,20 +1013,20 @@ static int flagcheck_disk(STFLAGH sfh, c int ret; int i; - char buf[8]; + OEMCHAR buf[8]; ret = 0; for (i=0; i<4; i++) { - SPRINTF(buf, str_fddx, i+1); + OEMSPRINTF(buf, str_fddx, i+1); ret |= diskcheck(sfh, buf); } - sxsi_flash(); + sxsi_allflash(); for (i=0; i<2; i++) { - SPRINTF(buf, str_sasix, i+1); + OEMSPRINTF(buf, str_sasix, i+1); ret |= diskcheck(sfh, buf); } for (i=0; i<4; i++) { - SPRINTF(buf, str_scsix, i); + OEMSPRINTF(buf, str_scsix, i); ret |= diskcheck(sfh, buf); } (void)tbl; @@ -1045,13 +1049,13 @@ static int flagload_disk(STFLAGH sfh, co for (i=0x00; i<0x02; i++) { ret |= statflag_read(sfh, &st, sizeof(st)); if (st.path[0]) { - sxsi_hddopen(i, st.path); + sxsi_devopen(i, st.path); } } for (i=0x20; i<0x24; i++) { ret |= statflag_read(sfh, &st, sizeof(st)); if (st.path[0]) { - sxsi_hddopen(i, st.path); + sxsi_devopen(i, st.path); } } (void)tbl; @@ -1169,7 +1173,7 @@ static int flagcheck_veronly(STFLAGH sfh // ---- -int statsave_save(const char *filename) { +int statsave_save(const OEMCHAR *filename) { SFFILEH sffh; int ret; @@ -1183,7 +1187,7 @@ const SFENTRY *tblterm; ret = STATFLAG_SUCCESS; tbl = np2tbl; - tblterm = tbl + (sizeof(np2tbl)/sizeof(SFENTRY)); + tblterm = tbl + NELEMENTS(np2tbl); while(tbl < tblterm) { ret |= statflag_createsection(sffh, tbl); switch(tbl->type) { @@ -1226,9 +1230,11 @@ const SFENTRY *tblterm; ret |= flagsave_ext(&sffh->sfh, tbl); break; +#if !defined(DISABLE_SOUND) case STATFLAG_FM: ret |= flagsave_fm(&sffh->sfh, tbl); break; +#endif case STATFLAG_GIJ: ret |= flagsave_gij(&sffh->sfh, tbl); @@ -1250,7 +1256,7 @@ const SFENTRY *tblterm; return(ret); } -int statsave_check(const char *filename, char *buf, int size) { +int statsave_check(const OEMCHAR *filename, OEMCHAR *buf, int size) { SFFILEH sffh; int ret; @@ -1268,7 +1274,7 @@ const SFENTRY *tblterm; while((!done) && (ret != STATFLAG_FAILURE)) { ret |= statflag_readsection(sffh); tbl = np2tbl; - tblterm = tbl + (sizeof(np2tbl)/sizeof(SFENTRY)); + tblterm = tbl + NELEMENTS(np2tbl); while(tbl < tblterm) { if (!memcmp(sffh->sfh.hdr.index, tbl->index, 10)) { break; @@ -1296,7 +1302,9 @@ const SFENTRY *tblterm; case STATFLAG_EVT: case STATFLAG_EXT: case STATFLAG_GIJ: +#if !defined(DISABLE_SOUND) case STATFLAG_FM: +#endif #if defined(SUPPORT_HOSTDRV) case STATFLAG_HDRV: #endif @@ -1320,7 +1328,7 @@ const SFENTRY *tblterm; return(ret); } -int statsave_load(const char *filename) { +int statsave_load(const OEMCHAR *filename) { SFFILEH sffh; int ret; @@ -1345,20 +1353,18 @@ const SFENTRY *tblterm; rs232c_midipanic(); mpu98ii_midipanic(); pc9861k_midipanic(); - sxsi_trash(); + sxsi_alltrash(); ret |= flagload_common(&sffh->sfh, np2tbl); - nevent_init(); CPU_RESET(); CPU_SETEXTSIZE((UINT32)pccore.extmem); + nevent_allreset(); sound_changeclock(); beep_changeclock(); sound_reset(); -#if defined(SUPPORT_WAVEMIX) - wavemix_bind(); -#endif + fddmtrsnd_bind(); iocore_reset(); // サウンドでpicを呼ぶので… cbuscore_reset(); @@ -1368,7 +1374,7 @@ const SFENTRY *tblterm; while((!done) && (ret != STATFLAG_FAILURE)) { ret |= statflag_readsection(sffh); tbl = np2tbl + 1; - tblterm = np2tbl + (sizeof(np2tbl)/sizeof(SFENTRY)); + tblterm = np2tbl + NELEMENTS(np2tbl); while(tbl < tblterm) { if (!memcmp(sffh->sfh.hdr.index, tbl->index, 10)) { break; @@ -1419,9 +1425,11 @@ const SFENTRY *tblterm; ret |= flagload_ext(&sffh->sfh, tbl); break; +#if !defined(DISABLE_SOUND) case STATFLAG_FM: ret |= flagload_fm(&sffh->sfh, tbl); break; +#endif case STATFLAG_GIJ: ret |= flagload_gij(&sffh->sfh, tbl);