implement volMacroLinger compatibility flag

issue #425
This commit is contained in:
tildearrow 2022-05-31 18:34:23 -05:00
parent a945ee5353
commit b8a0084587
4 changed files with 27 additions and 7 deletions

View file

@ -4,8 +4,9 @@
- CSM - CSM
- MSM6258 pitch and clock select - MSM6258 pitch and clock select
- the last three compat flags - the last three compat flags
- newVolumeScaling
- brokenOutVol
- collapse/expand pattern and song - collapse/expand pattern and song
- add OPL drum instrument type
- Game Boy envelope macro/sequence - Game Boy envelope macro/sequence
- rewrite the system name detection function anyway - rewrite the system name detection function anyway
- volume commands should work on Game Boy - volume commands should work on Game Boy

View file

@ -21,6 +21,12 @@
#include "instrument.h" #include "instrument.h"
#include "engine.h" #include "engine.h"
void DivMacroStruct::prepare(DivInstrumentMacro& source, DivEngine* e) {
has=had=actualHad=will=true;
mode=source.mode;
linger=(source.name=="vol" && e->song.volMacroLinger);
}
void DivMacroStruct::doMacro(DivInstrumentMacro& source, bool released, bool tick) { void DivMacroStruct::doMacro(DivInstrumentMacro& source, bool released, bool tick) {
if (!tick) { if (!tick) {
had=false; had=false;
@ -46,6 +52,8 @@ void DivMacroStruct::doMacro(DivInstrumentMacro& source, bool released, bool tic
if (pos>=source.len) { if (pos>=source.len) {
if (source.loop<source.len && source.loop>=0 && (source.loop>=source.rel || source.rel>=source.len)) { if (source.loop<source.len && source.loop>=0 && (source.loop>=source.rel || source.rel>=source.len)) {
pos=source.loop; pos=source.loop;
} else if (linger) {
pos--;
} else { } else {
has=false; has=false;
} }
@ -228,7 +236,7 @@ void DivMacroInt::init(DivInstrument* which) {
} }
for (size_t i=0; i<macroListLen; i++) { for (size_t i=0; i<macroListLen; i++) {
macroList[i]->prepare(*macroSource[i]); macroList[i]->prepare(*macroSource[i],e);
} }
} }

View file

@ -27,19 +27,17 @@ class DivEngine;
struct DivMacroStruct { struct DivMacroStruct {
int pos; int pos;
int val; int val;
bool has, had, actualHad, finished, will; bool has, had, actualHad, finished, will, linger;
unsigned int mode; unsigned int mode;
void doMacro(DivInstrumentMacro& source, bool released, bool tick); void doMacro(DivInstrumentMacro& source, bool released, bool tick);
void init() { void init() {
pos=mode=0; pos=mode=0;
has=had=actualHad=will=false; has=had=actualHad=will=false;
linger=false;
// TODO: test whether this breaks anything? // TODO: test whether this breaks anything?
val=0; val=0;
} }
void prepare(DivInstrumentMacro& source) { void prepare(DivInstrumentMacro& source, DivEngine* e);
has=had=actualHad=will=true;
mode=source.mode;
}
DivMacroStruct(): DivMacroStruct():
pos(0), pos(0),
val(0), val(0),
@ -48,6 +46,7 @@ struct DivMacroStruct {
actualHad(false), actualHad(false),
finished(false), finished(false),
will(false), will(false),
linger(false),
mode(0) {} mode(0) {}
}; };

View file

@ -123,6 +123,18 @@ void FurnaceGUI::drawCompatFlags() {
if (ImGui::IsItemHovered()) { if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("when enabled, the pitch macro of an instrument is in linear space."); ImGui::SetTooltip("when enabled, the pitch macro of an instrument is in linear space.");
} }
ImGui::Checkbox("Proper volume scaling strategy",&e->song.newVolumeScaling);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("when disabled:\n- log scaling: multiply\n- linear scaling: subtract\nwhen enabled:\n- log scaling: subtract\n- linear scaling: multiply");
}
ImGui::Checkbox("Persist volume macro after it finishes",&e->song.volMacroLinger);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("when disabled, a value in the volume column that happens after the volume macro is done will disregard the macro.");
}
ImGui::Checkbox("Broken output volume on instrument change",&e->song.brokenOutVol);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("if enabled, no checks for the presence of a volume macro will be made.\nthis will cause the last macro value to linger unless a value in the volume column is present.");
}
ImGui::Text("Pitch linearity:"); ImGui::Text("Pitch linearity:");
if (ImGui::RadioButton("None",e->song.linearPitch==0)) { if (ImGui::RadioButton("None",e->song.linearPitch==0)) {