--- xmil/io/sndboard.c 2004/08/01 05:31:30 1.1 +++ xmil/io/sndboard.c 2005/02/04 06:42:11 1.6 @@ -2,41 +2,72 @@ #include "joymng.h" #include "pccore.h" #include "iocore.h" -#include "sndctrl.h" #include "keystat.h" +#include "sound.h" +#include "sndctrl.h" +#include "x1f.h" -void IOOUTCALL sndboard_opmreg(UINT port, REG8 value) { +#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM) +void IOOUTCALL opm_o(UINT port, REG8 dat) { - TRACEOUT(("%.4x, %.2x", port, value)); - sndboard.opmreg = (UINT8)value; -} + REG8 lsb; + REG8 reg; -void IOOUTCALL sndboard_opmdat(UINT port, REG8 value) { - - TRACEOUT(("%.4x, %.2x", port, value)); - opmgen_setreg(sndboard.opmreg, value); + lsb = (UINT8)port; + if (lsb == 0x00) { // 0700 + sndboard.opmreg = (UINT8)dat; + } + else if (lsb == 0x01) { // 0701 + reg = sndboard.opmreg; + sndboard.opmdat[reg] = dat; + x1f_opm(reg, dat); +#if !defined(DISABLE_SOUND) + opmgen_setreg(reg, dat); +#endif + } + else if ((lsb & (~3)) == 0x04) { // 0704-0707 + ctc_o(port, dat); + } } -REG8 IOINPCALL sndboard_opmsta(UINT port) { +REG8 IOINPCALL opm_i(UINT port) { + + REG8 lsb; - if (pccore.SOUND_SW) { - return(0x00); // ゼリアード対策 + lsb = (UINT8)port; + if ((lsb & (~1)) == 0x00) { // 0700/0701 + return(0x00); // ゼリアード + } + else if ((lsb & (~3)) == 0x04) { // 0704-0707 + return(ctc_i(port)); + } + else { + return(0xff); } - return(0xff); } +#endif -void IOOUTCALL sndboard_psgreg(UINT port, REG8 value) { +void IOOUTCALL sndboard_psgreg(UINT port, REG8 dat) { - sndboard.psgreg = value; + sndboard.psgreg = dat; + (void)port; } -void IOOUTCALL sndboard_psgdat(UINT port, REG8 value) { +void IOOUTCALL sndboard_psgdat(UINT port, REG8 dat) { - if (sndboard.psgreg < 0x0e) { - psggen_setreg(&psggen, sndboard.psgreg, value); + REG8 reg; + + reg = sndboard.psgreg; + if (reg < 0x0e) { + sndboard.psgdat[reg] = dat; + x1f_psg(reg, dat); +#if !defined(DISABLE_SOUND) + psggen_setreg(&psggen, reg, dat); +#endif } + (void)port; } REG8 IOINPCALL sndboard_psgsta(UINT port) { @@ -44,7 +75,7 @@ REG8 IOINPCALL sndboard_psgsta(UINT port REG8 ret; if (sndboard.psgreg < 0x0e) { - return(psggen_getreg(&psggen, sndboard.psgreg)); + return(sndboard.psgdat[sndboard.psgreg]); } else if (sndboard.psgreg < 0x10) { ret = 0xff; @@ -64,6 +95,7 @@ REG8 IOINPCALL sndboard_psgsta(UINT port return(ret); } else { + (void)port; return(0xff); } } @@ -71,10 +103,26 @@ REG8 IOINPCALL sndboard_psgsta(UINT port // ---- +#if !defined(DISABLE_SOUND) +void sndboard_update(void) { + + UINT i; + + for (i=0; i<14; i++) { + psggen_setreg(&psggen, (REG8)i, sndboard.psgdat[i]); + } +#if defined(SUPPORT_TURBOZ) || defined(SUPPORT_OPM) + for (i=0x20; i<0x100; i++) { + opmgen_setreg((REG8)i, sndboard.opmdat[i]); + } +#endif +} +#endif + void sndboard_reset(void) { - sndboard.opmreg = 0; - sndboard.psgreg = 0; + ZeroMemory(&sndboard, sizeof(sndboard)); + sndboard.psgdat[0x07] = 0x3f; sndctrl_reset(); }