From 4eed3dbc4d340c703ea00f9c414fc24a39c6879e Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 3 Oct 2022 18:40:07 -0500 Subject: [PATCH] SNES: gain macro --- src/engine/platform/snes.cpp | 23 +++++++++++++++++++++++ src/gui/insEdit.cpp | 25 +++++++++++++++++++------ 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/engine/platform/snes.cpp b/src/engine/platform/snes.cpp index 0edc88aa6..fb278f2a0 100644 --- a/src/engine/platform/snes.cpp +++ b/src/engine/platform/snes.cpp @@ -161,6 +161,29 @@ void DivPlatformSNES::tick(bool sysTick) { if (chan[i].std.vol.had || chan[i].std.panL.had || chan[i].std.panR.had || hasInverted) { writeOutVol(i); } + if (chan[i].std.ex2.had) { + if (chan[i].std.ex2.val&0x80) { + switch (chan[i].std.ex2.val&0x60) { + case 0x00: + chan[i].state.gainMode=DivInstrumentSNES::GAIN_MODE_DEC_LINEAR; + break; + case 0x20: + chan[i].state.gainMode=DivInstrumentSNES::GAIN_MODE_DEC_LOG; + break; + case 0x40: + chan[i].state.gainMode=DivInstrumentSNES::GAIN_MODE_INC_LINEAR; + break; + case 0x60: + chan[i].state.gainMode=DivInstrumentSNES::GAIN_MODE_INC_INVLOG; + break; + } + chan[i].state.gain=chan[i].std.ex2.val&31; + } else { + chan[i].state.gainMode=DivInstrumentSNES::GAIN_MODE_DIRECT; + chan[i].state.gain=chan[i].std.ex2.val&127; + } + writeEnv(i); + } if (chan[i].setPos) { // force keyon chan[i].keyOn=true; diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index a67856bf3..399ff5268 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -342,7 +342,7 @@ String macroHoverNote(int id, float val, void* u) { } String macroHover(int id, float val, void* u) { - return fmt::sprintf("%d: %d",id,val); + return fmt::sprintf("%d: %d",id,(int)val); } String macroHoverLoop(int id, float val, void* u) { @@ -356,6 +356,22 @@ String macroHoverBit30(int id, float val, void* u) { return "Relative"; } +String macroHoverGain(int id, float val, void* u) { + if (val>=224.0f) { + return fmt::sprintf("%d: +%d (exponential)",id,(int)(val-224)); + } + if (val>=192.0f) { + return fmt::sprintf("%d: +%d (linear)",id,(int)(val-192)); + } + if (val>=160.0f) { + return fmt::sprintf("%d: -%d (exponential)",id,(int)(val-160)); + } + if (val>=128.0f) { + return fmt::sprintf("%d: -%d (linear)",id,(int)(val-128)); + } + return fmt::sprintf("%d: %d (direct)",id,(int)val); +} + String macroHoverES5506FilterMode(int id, float val, void* u) { String mode="???"; switch (((int)val)&3) { @@ -4528,7 +4544,7 @@ void FurnaceGUI::drawInsEdit() { } if (ins->type==DIV_INS_SNES) { ex1Max=5; - ex2Max=5; + ex2Max=255; } if (ins->type==DIV_INS_MSM5232) { ex1Max=5; @@ -4704,7 +4720,7 @@ void FurnaceGUI::drawInsEdit() { } else if (ins->type==DIV_INS_QSOUND) { macroList.push_back(FurnaceGUIMacroDesc("Echo Length",&ins->std.ex2Macro,0,ex2Max,160,uiColors[GUI_COLOR_MACRO_OTHER])); } else if (ins->type==DIV_INS_SNES) { - macroList.push_back(FurnaceGUIMacroDesc("Gain Mode",&ins->std.ex2Macro,0,ex2Max,64,uiColors[GUI_COLOR_MACRO_VOLUME],false,NULL,NULL,false,snesGainModes)); + macroList.push_back(FurnaceGUIMacroDesc("Gain",&ins->std.ex2Macro,0,ex2Max,256,uiColors[GUI_COLOR_MACRO_VOLUME],false,NULL,macroHoverGain,false)); } else if (ins->type==DIV_INS_MSM5232) { macroList.push_back(FurnaceGUIMacroDesc("Group Decay",&ins->std.ex2Macro,0,ex2Max,160,uiColors[GUI_COLOR_MACRO_OTHER])); } else { @@ -4746,9 +4762,6 @@ void FurnaceGUI::drawInsEdit() { macroList.push_back(FurnaceGUIMacroDesc("Envelope mode",&ins->std.ex8Macro,0,2,64,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true,es5506EnvelopeModes)); macroList.push_back(FurnaceGUIMacroDesc("Control",&ins->std.algMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true,es5506ControlModes)); } - if (ins->type==DIV_INS_SNES) { - macroList.push_back(FurnaceGUIMacroDesc("Gain Rate",&ins->std.ex3Macro,0,127,160,uiColors[GUI_COLOR_MACRO_VOLUME])); - } if (ins->type==DIV_INS_MSM5232) { macroList.push_back(FurnaceGUIMacroDesc("Noise",&ins->std.ex3Macro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); }