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

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