SNES: add global volume control effects

This commit is contained in:
tildearrow 2023-05-04 16:49:47 -05:00
parent 1e5163c738
commit b037b07c30
6 changed files with 32 additions and 0 deletions

View file

@ -54,6 +54,10 @@ Furnace also allows the SNES to use wavetables (and the wavetable synthesizer) i
- 80 to FF for -128 to -1. - 80 to FF for -128 to -1.
- setting this to -128 is not recommended as it may cause echo output to overflow and therefore click. - setting this to -128 is not recommended as it may cause echo output to overflow and therefore click.
- `1Dxx`: set noise generator frequency (00 to 1F). - `1Dxx`: set noise generator frequency (00 to 1F).
- `1Exx`: set left dry/global volume.
- this does not affect echo.
- `1Fxx`: set right dry/global volume.
- this does not affect echo.
- `20xx`: set attack (0 to F). - `20xx`: set attack (0 to F).
- only in ADSR envelope mode. - only in ADSR envelope mode.
- `21xx`: set decay (0 to 7). - `21xx`: set decay (0 to 7).

View file

@ -231,6 +231,9 @@ enum DivDispatchCmds {
DIV_CMD_HINT_ARP_TIME, // (value) DIV_CMD_HINT_ARP_TIME, // (value)
DIV_CMD_SNES_GLOBAL_VOL_LEFT,
DIV_CMD_SNES_GLOBAL_VOL_RIGHT,
DIV_ALWAYS_SET_VOLUME, // () -> alwaysSetVol DIV_ALWAYS_SET_VOLUME, // () -> alwaysSetVol
DIV_CMD_MAX DIV_CMD_MAX

View file

@ -300,6 +300,11 @@ void DivPlatformSNES::tick(bool sysTick) {
rWrite(0x4d,echoBits); rWrite(0x4d,echoBits);
writeEcho=false; writeEcho=false;
} }
if (writeDryVol) {
rWrite(0x0c,dryVolL);
rWrite(0x1c,dryVolR);
writeDryVol=false;
}
for (int i=0; i<8; i++) { for (int i=0; i<8; i++) {
if (chan[i].shallWriteEnv) { if (chan[i].shallWriteEnv) {
writeEnv(i); writeEnv(i);
@ -563,6 +568,14 @@ int DivPlatformSNES::dispatch(DivCommand c) {
rWrite(0x3c,echoVolR); rWrite(0x3c,echoVolR);
} }
break; break;
case DIV_CMD_SNES_GLOBAL_VOL_LEFT:
dryVolL=c.value;
writeDryVol=true;
break;
case DIV_CMD_SNES_GLOBAL_VOL_RIGHT:
dryVolR=c.value;
writeDryVol=true;
break;
case DIV_CMD_GET_VOLMAX: case DIV_CMD_GET_VOLMAX:
return 127; return 127;
break; break;
@ -673,6 +686,7 @@ void DivPlatformSNES::forceIns() {
writeNoise=true; writeNoise=true;
writePitchMod=true; writePitchMod=true;
writeEcho=true; writeEcho=true;
writeDryVol=true;
initEcho(); initEcho();
} }
@ -761,6 +775,10 @@ void DivPlatformSNES::reset() {
writeNoise=false; writeNoise=false;
writePitchMod=false; writePitchMod=false;
writeEcho=true; writeEcho=true;
writeDryVol=false;
dryVolL=127;
dryVolR=127;
echoDelay=initEchoDelay; echoDelay=initEchoDelay;
echoFeedback=initEchoFeedback; echoFeedback=initEchoFeedback;

View file

@ -59,6 +59,7 @@ class DivPlatformSNES: public DivDispatch {
unsigned char noiseFreq; unsigned char noiseFreq;
signed char delay; signed char delay;
signed char echoVolL, echoVolR, echoFeedback; signed char echoVolL, echoVolR, echoFeedback;
signed char dryVolL, dryVolR;
signed char echoFIR[8]; signed char echoFIR[8];
unsigned char echoDelay; unsigned char echoDelay;
size_t sampleTableBase; size_t sampleTableBase;
@ -66,6 +67,7 @@ class DivPlatformSNES: public DivDispatch {
bool writeNoise; bool writeNoise;
bool writePitchMod; bool writePitchMod;
bool writeEcho; bool writeEcho;
bool writeDryVol;
bool echoOn; bool echoOn;
bool initEchoOn; bool initEchoOn;

View file

@ -231,6 +231,9 @@ const char* cmdName[]={
"HINT_ARP_TIME", "HINT_ARP_TIME",
"SNES_GLOBAL_VOL_LEFT",
"SNES_GLOBAL_VOL_RIGHT",
"ALWAYS_SET_VOLUME" "ALWAYS_SET_VOLUME"
}; };

View file

@ -911,6 +911,8 @@ void DivEngine::registerSystems() {
{0x1a, {DIV_CMD_SNES_ECHO_VOL_LEFT, "1Axx: Set left echo volume"}}, {0x1a, {DIV_CMD_SNES_ECHO_VOL_LEFT, "1Axx: Set left echo volume"}},
{0x1b, {DIV_CMD_SNES_ECHO_VOL_RIGHT, "1Bxx: Set right echo volume"}}, {0x1b, {DIV_CMD_SNES_ECHO_VOL_RIGHT, "1Bxx: Set right echo volume"}},
{0x1c, {DIV_CMD_SNES_ECHO_FEEDBACK, "1Cxx: Set echo feedback"}}, {0x1c, {DIV_CMD_SNES_ECHO_FEEDBACK, "1Cxx: Set echo feedback"}},
{0x1e, {DIV_CMD_SNES_GLOBAL_VOL_LEFT, "1Exx: Set dry output volume (left)"}},
{0x1f, {DIV_CMD_SNES_GLOBAL_VOL_RIGHT, "1Fxx: Set dry output volume (right)"}},
{0x30, {DIV_CMD_SNES_ECHO_FIR, "30xx: Set echo filter coefficient 0",constVal<0>,effectVal}}, {0x30, {DIV_CMD_SNES_ECHO_FIR, "30xx: Set echo filter coefficient 0",constVal<0>,effectVal}},
{0x31, {DIV_CMD_SNES_ECHO_FIR, "31xx: Set echo filter coefficient 1",constVal<1>,effectVal}}, {0x31, {DIV_CMD_SNES_ECHO_FIR, "31xx: Set echo filter coefficient 1",constVal<1>,effectVal}},
{0x32, {DIV_CMD_SNES_ECHO_FIR, "32xx: Set echo filter coefficient 2",constVal<2>,effectVal}}, {0x32, {DIV_CMD_SNES_ECHO_FIR, "32xx: Set echo filter coefficient 2",constVal<2>,effectVal}},