--- np2/statsave.c 2003/10/25 09:08:24 1.13 +++ np2/statsave.c 2003/11/08 21:43:00 1.15 @@ -12,6 +12,7 @@ #include "pc9861k.h" #include "mpu98ii.h" #include "board14.h" +#include "amd98.h" #include "bios.h" #include "vram.h" #include "palettes.h" @@ -654,10 +655,11 @@ enum { FLAG_FM2B = 0x0010, FLAG_PSG1 = 0x0020, FLAG_PSG2 = 0x0040, - FLAG_RHYTHM = 0x0080, - FLAG_ADPCM = 0x0100, - FLAG_PCM86 = 0x0200, - FLAG_CS4231 = 0x0400 + FLAG_PSG3 = 0x0080, + FLAG_RHYTHM = 0x0100, + FLAG_ADPCM = 0x0200, + FLAG_PCM86 = 0x0400, + FLAG_CS4231 = 0x0800 }; typedef struct { @@ -710,6 +712,10 @@ static int flagsave_fm(NP2FFILE f, const FLAG_PSG1 | FLAG_RHYTHM | FLAG_ADPCM; break; + case 0x80: + saveflg = FLAG_PSG1 | FLAG_PSG2 | FLAG_PSG3; + break; + default: saveflg = 0; break; @@ -738,6 +744,9 @@ static int flagsave_fm(NP2FFILE f, const if (saveflg & FLAG_PSG2) { ret |= flagsave_save(f, &psg2.reg, sizeof(PSGREG)); } + if (saveflg & FLAG_PSG3) { + ret |= flagsave_save(f, &psg3.reg, sizeof(PSGREG)); + } if (saveflg & FLAG_ADPCM) { ret |= flagsave_save(f, &adpcm, sizeof(adpcm)); } @@ -752,14 +761,12 @@ static int flagsave_fm(NP2FFILE f, const return(ret); } -static void play_fmreg(BYTE num) { +static void play_fmreg(BYTE num, UINT reg) { UINT chbase; - UINT reg; UINT i; chbase = num * 3; - reg = num * 0x100; for (i=0x30; i<0xa0; i++) { opngen_setreg((BYTE)chbase, (BYTE)i, opn.reg[reg + i]); } @@ -785,6 +792,10 @@ static int flagload_fm(NP2FFILE f, const int ret; UINT saveflg; OPNKEY opnkey; + UINT fmreg1a; + UINT fmreg1b; + UINT fmreg2a; + UINT fmreg2b; opngen_reset(); psggen_reset(&psg1); @@ -798,6 +809,10 @@ static int flagload_fm(NP2FFILE f, const ret = flagload_load(f, &usesound, sizeof(usesound)); fmboard_reset((BYTE)usesound); + fmreg1a = 0x000; + fmreg1b = 0x100; + fmreg2a = 0x200; + fmreg2b = 0x300; switch(usesound) { case 0x01: saveflg = FLAG_MG; @@ -815,6 +830,9 @@ static int flagload_fm(NP2FFILE f, const 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: @@ -837,6 +855,10 @@ static int flagload_fm(NP2FFILE f, const FLAG_PSG1 | FLAG_RHYTHM | FLAG_ADPCM; break; + case 0x80: + saveflg = FLAG_PSG1 | FLAG_PSG2 | FLAG_PSG3; + break; + default: saveflg = 0; break; @@ -863,6 +885,9 @@ static int flagload_fm(NP2FFILE f, const if (saveflg & FLAG_PSG2) { ret |= flagload_load(f, &psg2.reg, sizeof(PSGREG)); } + if (saveflg & FLAG_PSG3) { + ret |= flagload_load(f, &psg3.reg, sizeof(PSGREG)); + } if (saveflg & FLAG_ADPCM) { ret |= flagload_load(f, &adpcm, sizeof(adpcm)); } @@ -886,16 +911,16 @@ static int flagload_fm(NP2FFILE f, const } if (saveflg & FLAG_FM1A) { - play_fmreg(0); + play_fmreg(0, fmreg1a); } if (saveflg & FLAG_FM1B) { - play_fmreg(1); + play_fmreg(1, fmreg1b); } if (saveflg & FLAG_FM2A) { - play_fmreg(2); + play_fmreg(2, fmreg2a); } if (saveflg & FLAG_FM2B) { - play_fmreg(3); + play_fmreg(3, fmreg2b); } if (saveflg & FLAG_PSG1) { play_psgreg(&psg1); @@ -903,6 +928,9 @@ static int flagload_fm(NP2FFILE f, const if (saveflg & FLAG_PSG2) { play_psgreg(&psg2); } + if (saveflg & FLAG_PSG3) { + play_psgreg(&psg3); + } (void)t; return(ret); }