--- np2/statsave.c 2005/03/05 06:02:28 1.46 +++ np2/statsave.c 2005/03/22 04:03:15 1.47 @@ -61,18 +61,19 @@ enum { STATFLAG_CGW, #endif STATFLAG_COM, - STATFLAG_DISK, STATFLAG_DMA, STATFLAG_EGC, STATFLAG_EPSON, STATFLAG_EVT, STATFLAG_EXT, + STATFLAG_FDD, STATFLAG_FM, STATFLAG_GIJ, #if defined(SUPPORT_HOSTDRV) STATFLAG_HDRV, #endif - STATFLAG_MEM + STATFLAG_MEM, + STATFLAG_SXSI }; typedef struct { @@ -103,38 +104,6 @@ typedef struct { // ---- -// 関数ポインタを intに変更。 -static BRESULT proc2num(void *func, const PROCTBL *tbl, int size) { - - int i; - - for (i=0; iproc) { - *(long *)func = (long)tbl->id; - return(SUCCESS); - } - tbl++; - } - return(FAILURE); -} - -static BRESULT num2proc(void *func, const PROCTBL *tbl, int size) { - - int i; - - for (i=0; iid) { - *(long *)func = (long)tbl->proc; - return(SUCCESS); - } - tbl++; - } - return(FAILURE); -} - - -// ---- - enum { SFFILEH_WRITE = 0x0001, SFFILEH_BLOCK = 0x0002, @@ -364,6 +333,103 @@ void statflag_seterr(STFLAGH sfh, const } +// ---- function + +// 関数ポインタを intに変更。 +static BRESULT proc2num(void *func, const PROCTBL *tbl, int size) { + + int i; + + for (i=0; iproc) { + *(long *)func = (long)tbl->id; + return(SUCCESS); + } + tbl++; + } + return(FAILURE); +} + +static BRESULT num2proc(void *func, const PROCTBL *tbl, int size) { + + int i; + + for (i=0; iid) { + *(long *)func = (long)tbl->proc; + return(SUCCESS); + } + tbl++; + } + return(FAILURE); +} + + +// ---- file + +typedef struct { + OEMCHAR path[MAX_PATH]; + UINT ftype; + int readonly; + DOSDATE date; + DOSTIME time; +} STATPATH; + +static const OEMCHAR str_updated[] = OEMTEXT("%s: updated"); +static const OEMCHAR str_notfound[] = OEMTEXT("%s: not found"); + +static int statflag_writepath(STFLAGH sfh, const OEMCHAR *path, + UINT ftype, int readonly) { + + STATPATH sp; + FILEH fh; + + ZeroMemory(&sp, sizeof(sp)); + if ((path) && (path[0])) { + file_cpyname(sp.path, path, NELEMENTS(sp.path)); + sp.ftype = ftype; + sp.readonly = readonly; + fh = file_open_rb(path); + if (fh != FILEH_INVALID) { + file_getdatetime(fh, &sp.date, &sp.time); + file_close(fh); + } + } + return(statflag_write(sfh, &sp, sizeof(sp))); +} + +static int statflag_checkpath(STFLAGH sfh, const OEMCHAR *devname) { + + int ret; + STATPATH sp; + FILEH fh; + OEMCHAR buf[256]; + DOSDATE date; + DOSTIME time; + + ret = statflag_read(sfh, &sp, sizeof(sp)); + if (sp.path[0]) { + fh = file_open_rb(sp.path); + if (fh != FILEH_INVALID) { + file_getdatetime(fh, &date, &time); + file_close(fh); + if ((memcmp(&sp.date, &date, sizeof(date))) || + (memcmp(&sp.time, &time, sizeof(time)))) { + ret |= STATFLAG_DISKCHG; + OEMSPRINTF(buf, str_updated, devname); + statflag_seterr(sfh, buf); + } + } + else { + ret |= STATFLAG_DISKCHG; + OEMSPRINTF(buf, str_notfound, devname); + statflag_seterr(sfh, buf); + } + } + return(ret); +} + + // ---- common static int flagsave_common(STFLAGH sfh, const SFENTRY *tbl) { @@ -925,137 +991,153 @@ static int flagload_fm(STFLAGH sfh, cons #endif -// ---- disk - -typedef struct { - OEMCHAR path[MAX_PATH]; - int readonly; - DOSDATE date; - DOSTIME time; -} STATDISK; +// ---- fdd 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 OEMCHAR *path, int readonly) { +static int flagsave_fdd(STFLAGH sfh, const SFENTRY *tbl) { - STATDISK st; - FILEH fh; + int ret; + UINT8 i; +const OEMCHAR *path; + UINT ftype; + int ro; - ZeroMemory(&st, sizeof(st)); - if ((path) && (path[0])) { - file_cpyname(st.path, path, sizeof(st.path)); - st.readonly = readonly; - fh = file_open_rb(path); - if (fh != FILEH_INVALID) { - file_getdatetime(fh, &st.date, &st.time); - file_close(fh); - } + ret = STATFLAG_SUCCESS; + for (i=0; i<4; i++) { + path = fdd_getfileex(i, &ftype, &ro); + ret |= statflag_writepath(sfh, path, ftype, ro); } - return(statflag_write(sfh, &st, sizeof(st))); + (void)tbl; + return(ret); } -static int flagsave_disk(STFLAGH sfh, const SFENTRY *tbl) { +static int flagcheck_fdd(STFLAGH sfh, const SFENTRY *tbl) { int ret; - UINT8 i; + int i; + OEMCHAR buf[8]; - 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_getfilename(i), 0); - } - for (i=0x20; i<0x24; i++) { - ret |= disksave(sfh, sxsi_getfilename(i), 0); + OEMSPRINTF(buf, str_fddx, i+1); + ret |= statflag_checkpath(sfh, buf); } (void)tbl; return(ret); } -static int diskcheck(STFLAGH sfh, const OEMCHAR *name) { +static int flagload_fdd(STFLAGH sfh, const SFENTRY *tbl) { int ret; - FILEH fh; - STATDISK st; - OEMCHAR buf[256]; - DOSDATE date; - DOSTIME time; + UINT8 i; + STATPATH sp; - ret = statflag_read(sfh, &st, sizeof(st)); - if (st.path[0]) { - fh = file_open_rb(st.path); - if (fh != FILEH_INVALID) { - file_getdatetime(fh, &date, &time); - file_close(fh); - if ((memcmp(&st.date, &date, sizeof(date))) || - (memcmp(&st.time, &time, sizeof(time)))) { - ret |= STATFLAG_DISKCHG; - OEMSPRINTF(buf, str_updated, name); - statflag_seterr(sfh, buf); - } - } - else { - ret |= STATFLAG_DISKCHG; - OEMSPRINTF(buf, str_notfound, name); - statflag_seterr(sfh, buf); + ret = STATFLAG_SUCCESS; + for (i=0; i<4; i++) { + ret |= statflag_read(sfh, &sp, sizeof(sp)); + if (sp.path[0]) { + fdd_set(i, sp.path, FTYPE_NONE, sp.readonly); } } + (void)tbl; return(ret); } -static int flagcheck_disk(STFLAGH sfh, const SFENTRY *tbl) { - int ret; - int i; - OEMCHAR buf[8]; +// ---- sxsi + +typedef struct { + UINT8 ide[4]; + UINT8 scsi[8]; +} SXSIDEVS; + +static const OEMCHAR str_sasix[] = OEMTEXT("SASI%u"); +static const OEMCHAR str_scsix[] = OEMTEXT("SCSI%u"); + +static int flagsave_sxsi(STFLAGH sfh, const SFENTRY *tbl) { + + int ret; + UINT i; + SXSIDEVS sds; +const OEMCHAR *path; - ret = 0; - for (i=0; i<4; i++) { - OEMSPRINTF(buf, str_fddx, i+1); - ret |= diskcheck(sfh, buf); - } sxsi_allflash(); - for (i=0; i<2; i++) { - OEMSPRINTF(buf, str_sasix, i+1); - ret |= diskcheck(sfh, buf); + ret = STATFLAG_SUCCESS; + for (i=0; isfh, tbl); break; - case STATFLAG_DISK: - ret |= flagsave_disk(&sffh->sfh, tbl); - break; - case STATFLAG_DMA: ret |= flagsave_dma(&sffh->sfh, tbl); break; @@ -1230,6 +1308,10 @@ const SFENTRY *tblterm; ret |= flagsave_ext(&sffh->sfh, tbl); break; + case STATFLAG_FDD: + ret |= flagsave_fdd(&sffh->sfh, tbl); + break; + #if !defined(DISABLE_SOUND) case STATFLAG_FM: ret |= flagsave_fm(&sffh->sfh, tbl); @@ -1249,6 +1331,10 @@ const SFENTRY *tblterm; case STATFLAG_MEM: ret |= flagsave_mem(&sffh->sfh, tbl); break; + + case STATFLAG_SXSI: + ret |= flagsave_sxsi(&sffh->sfh, tbl); + break; } tbl++; } @@ -1311,8 +1397,12 @@ const SFENTRY *tblterm; ret |= flagcheck_veronly(&sffh->sfh, tbl); break; - case STATFLAG_DISK: - ret |= flagcheck_disk(&sffh->sfh, tbl); + case STATFLAG_FDD: + ret |= flagcheck_fdd(&sffh->sfh, tbl); + break; + + case STATFLAG_SXSI: + ret |= flagcheck_sxsi(&sffh->sfh, tbl); break; default: @@ -1401,10 +1491,6 @@ const SFENTRY *tblterm; ret |= flagload_com(&sffh->sfh, tbl); break; - case STATFLAG_DISK: - ret |= flagload_disk(&sffh->sfh, tbl); - break; - case STATFLAG_DMA: ret |= flagload_dma(&sffh->sfh, tbl); break; @@ -1425,6 +1511,10 @@ const SFENTRY *tblterm; ret |= flagload_ext(&sffh->sfh, tbl); break; + case STATFLAG_FDD: + ret |= flagload_fdd(&sffh->sfh, tbl); + break; + #if !defined(DISABLE_SOUND) case STATFLAG_FM: ret |= flagload_fm(&sffh->sfh, tbl); @@ -1445,6 +1535,10 @@ const SFENTRY *tblterm; ret |= flagload_mem(&sffh->sfh, tbl); break; + case STATFLAG_SXSI: + ret |= flagload_sxsi(&sffh->sfh, tbl); + break; + default: ret |= STATFLAG_WARNING; break;