diff --git a/src/engine/platform/snes.cpp b/src/engine/platform/snes.cpp index 8be1692e..8ea97c93 100644 --- a/src/engine/platform/snes.cpp +++ b/src/engine/platform/snes.cpp @@ -69,14 +69,16 @@ void DivPlatformSNES::acquire(short* bufL, short* bufR, size_t start, size_t len short out[2]; short chOut[16]; for (size_t h=start; hgetSample(chan[i].sample); double off=(s->centerRate>=1)?((double)s->centerRate/8363.0):1.0; @@ -228,6 +232,7 @@ void DivPlatformSNES::tick(bool sysTick) { sampleMem[tabAddr+2]=loop&0xff; sampleMem[tabAddr+3]=loop>>8; kon|=(1<>1; chan[c.chan].panR=c.value2>>1; - writeOutVol(c.chan); + chan[c.chan].shallWriteVol=true; break; case DIV_CMD_PITCH: chan[c.chan].pitch=c.value; @@ -441,7 +462,7 @@ int DivPlatformSNES::dispatch(DivCommand c) { case DIV_CMD_SNES_INVERT: chan[c.chan].invertL=(c.value>>4); chan[c.chan].invertR=c.chan&15; - writeOutVol(c.chan); + chan[c.chan].shallWriteVol=true; break; case DIV_CMD_SNES_GAIN_MODE: if (c.value) { @@ -466,7 +487,7 @@ int DivPlatformSNES::dispatch(DivCommand c) { } else { chan[c.chan].state.useEnv=true; } - writeEnv(c.chan); + chan[c.chan].shallWriteEnv=true; break; case DIV_CMD_SNES_GAIN: if (chan[c.chan].state.gainMode==DivInstrumentSNES::GAIN_MODE_DIRECT) { @@ -474,7 +495,7 @@ int DivPlatformSNES::dispatch(DivCommand c) { } else { chan[c.chan].state.gain=c.value&0x1f; } - if (!chan[c.chan].state.useEnv) writeEnv(c.chan); + if (!chan[c.chan].state.useEnv) chan[c.chan].shallWriteEnv=true; break; case DIV_CMD_STD_NOISE_FREQ: noiseFreq=c.value&0x1f; @@ -482,19 +503,19 @@ int DivPlatformSNES::dispatch(DivCommand c) { break; case DIV_CMD_FM_AR: chan[c.chan].state.a=c.value&15; - if (chan[c.chan].state.useEnv) writeEnv(c.chan); + if (chan[c.chan].state.useEnv) chan[c.chan].shallWriteEnv=true; break; case DIV_CMD_FM_DR: chan[c.chan].state.d=c.value&7; - if (chan[c.chan].state.useEnv) writeEnv(c.chan); + if (chan[c.chan].state.useEnv) chan[c.chan].shallWriteEnv=true; break; case DIV_CMD_FM_SL: chan[c.chan].state.s=c.value&7; - if (chan[c.chan].state.useEnv) writeEnv(c.chan); + if (chan[c.chan].state.useEnv) chan[c.chan].shallWriteEnv=true; break; case DIV_CMD_FM_RR: chan[c.chan].state.r=c.value&0x1f; - if (chan[c.chan].state.useEnv) writeEnv(c.chan); + if (chan[c.chan].state.useEnv) chan[c.chan].shallWriteEnv=true; break; case DIV_CMD_SNES_ECHO: chan[c.chan].echo=c.value; @@ -605,7 +626,7 @@ void DivPlatformSNES::writeEnv(int ch) { void DivPlatformSNES::muteChannel(int ch, bool mute) { isMuted[ch]=mute; - writeOutVol(ch); + chan[ch].shallWriteVol=true; } void DivPlatformSNES::forceIns() { diff --git a/src/engine/platform/snes.h b/src/engine/platform/snes.h index ac53a51f..a21db150 100644 --- a/src/engine/platform/snes.h +++ b/src/engine/platform/snes.h @@ -33,7 +33,7 @@ class DivPlatformSNES: public DivDispatch { int sample, wave, ins; int note; int panL, panR; - bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave, setPos, noise, echo, pitchMod, invertL, invertR; + bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave, setPos, noise, echo, pitchMod, invertL, invertR, shallWriteVol, shallWriteEnv; int vol, outVol; int wtLen; DivInstrumentSNES state; @@ -68,6 +68,8 @@ class DivPlatformSNES: public DivDispatch { pitchMod(false), invertL(false), invertR(false), + shallWriteVol(false), + shallWriteEnv(false), vol(127), outVol(127), wtLen(16) {} @@ -77,6 +79,7 @@ class DivPlatformSNES: public DivDispatch { bool isMuted[8]; int globalVolL, globalVolR; unsigned char noiseFreq; + signed char delay; signed char echoVolL, echoVolR, echoFeedback; signed char echoFIR[8]; unsigned char echoDelay;