|
|
| version 1.32, 2004/01/25 05:41:28 | version 1.46, 2005/03/05 06:02:28 |
|---|---|
| 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 57 enum { | Line 60 enum { |
| #if defined(CGWND_FONTPTR) | #if defined(CGWND_FONTPTR) |
| STATFLAG_CGW, | STATFLAG_CGW, |
| #endif | #endif |
| STATFLAG_CLOCK, | |
| STATFLAG_COM, | STATFLAG_COM, |
| STATFLAG_DISK, | STATFLAG_DISK, |
| STATFLAG_DMA, | STATFLAG_DMA, |
| Line 94 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 102 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 116 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 144 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 OEMCHAR *filename, OEMCHAR *err, int errlen) { |
| FILEH fh; | FILEH fh; |
| SFFILEH ret; | SFFILEH ret; |
| Line 189 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 264 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 358 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 367 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 549 static int flagload_common(STFLAGH sfh, | Line 377 static int flagload_common(STFLAGH sfh, |
| } | } |
| // ----- clock | |
| static int flagload_clock(STFLAGH sfh, const SFENTRY *tbl) { | |
| int ret; | |
| ret = statflag_read(sfh, tbl->arg1, tbl->arg2); | |
| sound_changeclock(); | |
| beep_changeclock(); | |
| return(ret); | |
| } | |
| // ---- memory | // ---- memory |
| static int flagsave_mem(STFLAGH sfh, const SFENTRY *tbl) { | static int flagsave_mem(STFLAGH sfh, const SFENTRY *tbl) { |
| Line 732 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 776 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 856 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 875 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 892 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 908 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 1002 static int flagsave_fm(STFLAGH sfh, cons | Line 819 static int flagsave_fm(STFLAGH sfh, cons |
| return(ret); | return(ret); |
| } | } |
| static void play_fmreg(BYTE num, UINT reg) { | |
| UINT chbase; | |
| UINT i; | |
| chbase = num * 3; | |
| for (i=0x30; i<0xa0; i++) { | |
| opngen_setreg((BYTE)chbase, (BYTE)i, opn.reg[reg + i]); | |
| } | |
| for (i=0xb7; i>=0xa0; i--) { | |
| opngen_setreg((BYTE)chbase, (BYTE)i, opn.reg[reg + i]); | |
| } | |
| for (i=0; i<3; i++) { | |
| opngen_keyon(chbase + i, opngen.keyreg[chbase + i]); | |
| } | |
| } | |
| static void play_psgreg(PSGGEN psg) { | |
| BYTE i; | |
| for (i=0; i<0x0e; i++) { | |
| psggen_setreg(psg, i, ((BYTE *)&psg->reg)[i]); | |
| } | |
| } | |
| static int flagload_fm(STFLAGH sfh, const SFENTRY *t) { | static int flagload_fm(STFLAGH sfh, const SFENTRY *t) { |
| int ret; | int ret; |
| UINT saveflg; | UINT saveflg; |
| OPNKEY opnkey; | OPNKEY opnkey; |
| UINT fmreg1a; | |
| UINT fmreg1b; | |
| UINT fmreg2a; | |
| UINT fmreg2b; | |
| opngen_reset(); | |
| psggen_reset(&psg1); | |
| psggen_reset(&psg2); | |
| psggen_reset(&psg3); | |
| rhythm_reset(&rhythm); | |
| adpcm_reset(&adpcm); | |
| pcm86_reset(); | |
| cs4231_reset(); | |
| ret = statflag_read(sfh, &usesound, sizeof(usesound)); | ret = statflag_read(sfh, &usesound, sizeof(usesound)); |
| fmboard_reset(usesound); | fmboard_reset(usesound); |
| fmreg1a = 0x000; | |
| fmreg1b = 0x100; | |
| fmreg2a = 0x200; | |
| fmreg2b = 0x300; | |
| switch(usesound) { | switch(usesound) { |
| case 0x01: | case 0x01: |
| saveflg = FLAG_MG; | saveflg = FLAG_MG; |
| Line 1071 static int flagload_fm(STFLAGH sfh, cons | Line 845 static int flagload_fm(STFLAGH sfh, cons |
| case 0x06: | case 0x06: |
| saveflg = FLAG_FM1A | FLAG_FM1B | FLAG_FM2A | FLAG_PSG1 | | saveflg = FLAG_FM1A | FLAG_FM1B | FLAG_FM2A | FLAG_PSG1 | |
| FLAG_PSG2 | FLAG_RHYTHM | FLAG_PCM86; | FLAG_PSG2 | FLAG_RHYTHM | FLAG_PCM86; |
| fmreg1a = 0x200; // 逆転してるのん… | |
| fmreg1b = 0x000; | |
| fmreg2a = 0x100; | |
| break; | break; |
| case 0x08: | case 0x08: |
| Line 1137 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) { |
| fmboard_extenable((BYTE)(pcm86.extfunc & 1)); | fmboard_extenable((REG8)(pcm86.extfunc & 1)); |
| } | } |
| if (saveflg & FLAG_CS4231) { | if (saveflg & FLAG_CS4231) { |
| fmboard_extenable((BYTE)(cs4231.extfunc & 1)); | fmboard_extenable((REG8)(cs4231.extfunc & 1)); |
| } | |
| if (saveflg & FLAG_FM1A) { | |
| play_fmreg(0, fmreg1a); | |
| } | |
| if (saveflg & FLAG_FM1B) { | |
| play_fmreg(1, fmreg1b); | |
| } | |
| if (saveflg & FLAG_FM2A) { | |
| play_fmreg(2, fmreg2a); | |
| } | |
| if (saveflg & FLAG_FM2B) { | |
| play_fmreg(3, fmreg2b); | |
| } | |
| if (saveflg & FLAG_PSG1) { | |
| play_psgreg(&psg1); | |
| } | |
| if (saveflg & FLAG_PSG2) { | |
| play_psgreg(&psg2); | |
| } | |
| if (saveflg & FLAG_PSG3) { | |
| play_psgreg(&psg3); | |
| } | } |
| (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 1213 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_allflash(); |
| ret = STATFLAG_SUCCESS; | ret = STATFLAG_SUCCESS; |
| for (i=0; i<4; i++) { | for (i=0; i<4; i++) { |
| ret |= disksave(sfh, fdd_diskname(i), fdd_diskprotect(i)); | ret |= disksave(sfh, fdd_diskname(i), fdd_diskprotect(i)); |
| } | } |
| for (i=0x00; i<0x02; 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++) { | for (i=0x20; i<0x24; i++) { |
| ret |= disksave(sfh, sxsi_getname(i), 0); | ret |= disksave(sfh, sxsi_getfilename(i), 0); |
| } | } |
| (void)tbl; | (void)tbl; |
| 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 1248 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 1265 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_allflash(); |
| 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 1298 static int flagload_disk(STFLAGH sfh, co | Line 1046 static int flagload_disk(STFLAGH sfh, co |
| fdd_set(i, st.path, FTYPE_NONE, st.readonly); | fdd_set(i, st.path, FTYPE_NONE, st.readonly); |
| } | } |
| } | } |
| sxsi_trash(); | |
| for (i=0x00; i<0x02; i++) { | for (i=0x00; i<0x02; i++) { |
| ret |= statflag_read(sfh, &st, sizeof(st)); | ret |= statflag_read(sfh, &st, sizeof(st)); |
| if (st.path[0]) { | if (st.path[0]) { |
| sxsi_hddopen(i, st.path); | sxsi_devopen(i, st.path); |
| } | } |
| } | } |
| for (i=0x20; i<0x24; i++) { | for (i=0x20; i<0x24; i++) { |
| ret |= statflag_read(sfh, &st, sizeof(st)); | ret |= statflag_read(sfh, &st, sizeof(st)); |
| if (st.path[0]) { | if (st.path[0]) { |
| sxsi_hddopen(i, st.path); | sxsi_devopen(i, st.path); |
| } | } |
| } | } |
| (void)tbl; | (void)tbl; |
| Line 1426 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 1440 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) { |
| case STATFLAG_BIN: | case STATFLAG_BIN: |
| case STATFLAG_CLOCK: | |
| case STATFLAG_TERM: | case STATFLAG_TERM: |
| ret |= flagsave_common(&sffh->sfh, tbl); | ret |= flagsave_common(&sffh->sfh, tbl); |
| break; | break; |
| Line 1484 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 1508 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 1526 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 1539 const SFENTRY *tblterm; | Line 1287 const SFENTRY *tblterm; |
| #if defined(CGWND_FONTPTR) | #if defined(CGWND_FONTPTR) |
| case STATFLAG_CGW: | case STATFLAG_CGW: |
| #endif | #endif |
| case STATFLAG_CLOCK: | |
| case STATFLAG_MEM: | case STATFLAG_MEM: |
| ret |= flagcheck_versize(&sffh->sfh, tbl); | ret |= flagcheck_versize(&sffh->sfh, tbl); |
| break; | break; |
| Line 1553 const SFENTRY *tblterm; | Line 1300 const SFENTRY *tblterm; |
| case STATFLAG_EGC: | case STATFLAG_EGC: |
| case STATFLAG_EPSON: | case STATFLAG_EPSON: |
| case STATFLAG_EVT: | case STATFLAG_EVT: |
| 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 1578 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 1603 const SFENTRY *tblterm; | Line 1353 const SFENTRY *tblterm; |
| rs232c_midipanic(); | rs232c_midipanic(); |
| mpu98ii_midipanic(); | mpu98ii_midipanic(); |
| pc9861k_midipanic(); | pc9861k_midipanic(); |
| sxsi_alltrash(); | |
| 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(); |
| fmboard_reset(pccore.sound); | fmboard_reset(pccore.sound); |
| done = FALSE; | done = FALSE; |
| 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 1649 const SFENTRY *tblterm; | Line 1397 const SFENTRY *tblterm; |
| break; | break; |
| #endif | #endif |
| case STATFLAG_CLOCK: | |
| ret |= flagload_clock(&sffh->sfh, tbl); | |
| break; | |
| case STATFLAG_COM: | case STATFLAG_COM: |
| ret |= flagload_com(&sffh->sfh, tbl); | ret |= flagload_com(&sffh->sfh, tbl); |
| break; | break; |
| Line 1681 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); |