--- np2/statsave.c 2004/01/22 01:10:03 1.28 +++ np2/statsave.c 2004/02/03 08:24:40 1.35 @@ -9,6 +9,8 @@ #include "pccore.h" #include "iocore.h" #include "cbuscore.h" +#include "sasiio.h" +#include "scsiio.h" #include "pc9861k.h" #include "mpu98ii.h" #include "board14.h" @@ -24,12 +26,9 @@ #include "fddfile.h" #include "fdd_mtr.h" #include "sxsi.h" -#include "calendar.h" #include "keydisp.h" -#include "sasiio.h" -#include "scsiio.h" #include "hostdrv.h" - +#include "calendar.h" #if defined(MACOS) #define CRCONST str_cr @@ -58,7 +57,6 @@ enum { #if defined(CGWND_FONTPTR) STATFLAG_CGW, #endif - STATFLAG_CLOCK, STATFLAG_COM, STATFLAG_DISK, STATFLAG_DMA, @@ -550,19 +548,6 @@ 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 static int flagsave_mem(STFLAGH sfh, const SFENTRY *tbl) { @@ -588,54 +573,6 @@ static int flagload_mem(STFLAGH sfh, con } -// ---- ext memory - -static int flagsave_ext(STFLAGH sfh, const SFENTRY *tbl) { - - int ret; - - ret = statflag_write(sfh, &extmem, sizeof(extmem)); - if (CPU_EXTMEM) { - ret = statflag_write(sfh, CPU_EXTMEM, CPU_EXTMEMSIZE); - } - (void)tbl; - return(ret); -} - -static int flagload_ext(STFLAGH sfh, const SFENTRY *tbl) { - - int ret; - int i; - UINT pagemax = 0; - - ret = statflag_read(sfh, &extmem, sizeof(extmem)); - if (extmem.maxmem) { - if (extmem.maxmem > (13+1)) { - extmem.maxmem = (13+1); - } - if (!extmemmng_realloc(extmem.maxmem - 1)) { - pagemax = (extmem.maxmem - 1) << 8; - if (CPU_EXTMEM) { - ret |= statflag_read(sfh, CPU_EXTMEM, CPU_EXTMEMSIZE); - } - } - else { - extmem.maxmem = 0; - } - } - for (i=0; i<4; i++) { - if (extmem.page[i] < pagemax) { - extmem.pageptr[i] = CPU_EXTMEM + (extmem.page[i] << 12); - } - else { - extmem.pageptr[i] = mem + 0xc0000 + (i << 14); - } - } - (void)tbl; - return(ret); -} - - // ---- cg window #if defined(CGWND_FONTPTR) @@ -665,7 +602,7 @@ static int flagload_cgwnd(STFLAGH sfh, c // ---- dma -static int flagsave_dma(STFLAGH sfh, const SFENTRY *t) { +static int flagsave_dma(STFLAGH sfh, const SFENTRY *tbl) { int i; _DMAC dmabak; @@ -678,6 +615,7 @@ static int flagsave_dma(STFLAGH sfh, con return(STATFLAG_FAILURE); } } + (void)tbl; return(statflag_write(sfh, &dmabak, sizeof(dmabak))); } @@ -870,6 +808,33 @@ static int flagload_evt(STFLAGH sfh, con } +// ---- extmem + +static int flagsave_ext(STFLAGH sfh, const SFENTRY *tbl) { + + int ret; + + ret = STATFLAG_SUCCESS; + if (CPU_EXTMEM) { + ret = statflag_write(sfh, CPU_EXTMEM, CPU_EXTMEMSIZE); + } + (void)tbl; + return(ret); +} + +static int flagload_ext(STFLAGH sfh, const SFENTRY *tbl) { + + int ret; + + ret = STATFLAG_SUCCESS; + if (CPU_EXTMEM) { + ret = statflag_read(sfh, CPU_EXTMEM, CPU_EXTMEMSIZE); + } + (void)tbl; + return(ret); +} + + // ---- gaiji static int flagsave_gij(STFLAGH sfh, const SFENTRY *tbl) { @@ -1019,61 +984,19 @@ static int flagsave_fm(STFLAGH sfh, cons if (saveflg & FLAG_CS4231) { ret |= statflag_write(sfh, &cs4231, sizeof(cs4231)); } + (void)tbl; 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) { int ret; UINT saveflg; 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)); - fmboard_reset((BYTE)usesound); + fmboard_reset(usesound); - fmreg1a = 0x000; - fmreg1b = 0x100; - fmreg2a = 0x200; - fmreg2b = 0x300; switch(usesound) { case 0x01: saveflg = FLAG_MG; @@ -1091,9 +1014,6 @@ static int flagload_fm(STFLAGH sfh, cons case 0x06: saveflg = FLAG_FM1A | FLAG_FM1B | FLAG_FM2A | FLAG_PSG1 | FLAG_PSG2 | FLAG_RHYTHM | FLAG_PCM86; - fmreg1a = 0x200; // 逆転してるのん… - fmreg1b = 0x000; - fmreg2a = 0x100; break; case 0x08: @@ -1160,37 +1080,15 @@ static int flagload_fm(STFLAGH sfh, cons cs4231.proc = cs4231dec[cs4231.reg.datafmt >> 4]; } - // 復元。 + // 復元。 これ移動すること! rhythm_update(&rhythm); adpcm_update(&adpcm); pcm86gen_update(); if (saveflg & FLAG_PCM86) { - fmboard_extenable((BYTE)(pcm86.extfunc & 1)); + fmboard_extenable((REG8)(pcm86.extfunc & 1)); } if (saveflg & FLAG_CS4231) { - fmboard_extenable((BYTE)(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); + fmboard_extenable((REG8)(cs4231.extfunc & 1)); } (void)t; return(ret); @@ -1318,7 +1216,6 @@ static int flagload_disk(STFLAGH sfh, co fdd_set(i, st.path, FTYPE_NONE, st.readonly); } } - sxsi_trash(); for (i=0x00; i<0x02; i++) { ret |= statflag_read(sfh, &st, sizeof(st)); if (st.path[0]) { @@ -1465,7 +1362,6 @@ const SFENTRY *tblterm; ret |= statflag_createsection(sffh, tbl); switch(tbl->type) { case STATFLAG_BIN: - case STATFLAG_CLOCK: case STATFLAG_TERM: ret |= flagsave_common(&sffh->sfh, tbl); break; @@ -1559,7 +1455,6 @@ const SFENTRY *tblterm; #if defined(CGWND_FONTPTR) case STATFLAG_CGW: #endif - case STATFLAG_CLOCK: case STATFLAG_MEM: ret |= flagcheck_versize(&sffh->sfh, tbl); break; @@ -1612,22 +1507,42 @@ const SFENTRY *tblterm; return(STATFLAG_FAILURE); } + // PCCORE read! + ret = statflag_readsection(sffh); + if ((ret != STATFLAG_SUCCESS) || + (memcmp(sffh->sfh.hdr.index, np2tbl[0].index, 10))) { + statflag_close(sffh); + return(STATFLAG_FAILURE); + } + soundmng_stop(); rs232c_midipanic(); mpu98ii_midipanic(); pc9861k_midipanic(); + sxsi_trash(); + + ret |= flagload_common(&sffh->sfh, np2tbl); + nevent_init(); + + CPU_RESET(); + CPU_SETEXTSIZE((UINT32)pccore.extmem); + + sound_changeclock(); + beep_changeclock(); sound_reset(); #if defined(SUPPORT_WAVEMIX) wavemix_bind(); #endif - fmboard_reset(0); + + iocore_reset(); // サウンドでpicを呼ぶので… + cbuscore_reset(); + fmboard_reset(pccore.sound); done = FALSE; - ret = STATFLAG_SUCCESS; while((!done) && (ret != STATFLAG_FAILURE)) { ret |= statflag_readsection(sffh); - tbl = np2tbl; - tblterm = tbl + (sizeof(np2tbl)/sizeof(SFENTRY)); + tbl = np2tbl + 1; + tblterm = np2tbl + (sizeof(np2tbl)/sizeof(SFENTRY)); while(tbl < tblterm) { if (!memcmp(sffh->sfh.hdr.index, tbl->index, 10)) { break; @@ -1650,10 +1565,6 @@ const SFENTRY *tblterm; break; #endif - case STATFLAG_CLOCK: - ret |= flagload_clock(&sffh->sfh, tbl); - break; - case STATFLAG_COM: ret |= flagload_com(&sffh->sfh, tbl); break;