From d3e5efe834fb1d88d66684a93eb41d4c1f3ad195 Mon Sep 17 00:00:00 2001 From: cam900 Date: Sun, 10 Apr 2022 14:01:55 +0900 Subject: [PATCH] Prepare for macro refactoring --- src/engine/engine.h | 2 +- src/engine/fileOps.cpp | 134 ++-- src/engine/fileOpsIns.cpp | 78 +- src/engine/instrument.cpp | 1197 +++++++++++++++++------------ src/engine/instrument.h | 363 +++------ src/engine/macroInt.cpp | 563 ++++++-------- src/engine/macroInt.h | 357 +++------ src/engine/platform/amiga.cpp | 26 +- src/engine/platform/arcade.cpp | 100 +-- src/engine/platform/ay.cpp | 40 +- src/engine/platform/ay8930.cpp | 54 +- src/engine/platform/bubsyswsg.cpp | 26 +- src/engine/platform/c64.cpp | 50 +- src/engine/platform/fds.cpp | 48 +- src/engine/platform/gb.cpp | 30 +- src/engine/platform/genesis.cpp | 78 +- src/engine/platform/lynx.cpp | 32 +- src/engine/platform/mmc5.cpp | 22 +- src/engine/platform/n163.cpp | 74 +- src/engine/platform/nes.cpp | 28 +- src/engine/platform/opl.cpp | 78 +- src/engine/platform/opll.cpp | 82 +- src/engine/platform/pce.cpp | 34 +- src/engine/platform/pcspkr.cpp | 18 +- src/engine/platform/pet.cpp | 26 +- src/engine/platform/qsound.cpp | 22 +- src/engine/platform/saa.cpp | 28 +- src/engine/platform/segapcm.cpp | 16 +- src/engine/platform/sms.cpp | 38 +- src/engine/platform/swan.cpp | 32 +- src/engine/platform/tia.cpp | 22 +- src/engine/platform/tx81z.cpp | 100 +-- src/engine/platform/vera.cpp | 38 +- src/engine/platform/vic20.cpp | 24 +- src/engine/platform/vrc6.cpp | 24 +- src/engine/platform/x1_010.cpp | 60 +- src/engine/platform/ym2610.cpp | 94 +-- src/engine/platform/ym2610b.cpp | 94 +-- src/engine/safeReader.cpp | 36 + src/engine/safeReader.h | 6 + src/engine/safeWriter.cpp | 33 + src/engine/safeWriter.h | 1 + src/gui/insEdit.cpp | 438 ++++++----- 43 files changed, 2337 insertions(+), 2309 deletions(-) diff --git a/src/engine/engine.h b/src/engine/engine.h index 890056758..bf9fe07ec 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -43,7 +43,7 @@ #define BUSY_END isBusy.unlock(); softLocked=false; #define DIV_VERSION "dev80" -#define DIV_ENGINE_VERSION 80 +#define DIV_ENGINE_VERSION (80/*Test*/|0x80) // for imports #define DIV_VERSION_MOD 0xff01 diff --git a/src/engine/fileOps.cpp b/src/engine/fileOps.cpp index 37964c682..63cc15361 100644 --- a/src/engine/fileOps.cpp +++ b/src/engine/fileOps.cpp @@ -307,12 +307,12 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) { if (!ins->mode) { ins->type=DIV_INS_AY; } - ins->std.dutyMacroHeight=31; - ins->std.waveMacroHeight=7; + ins->std.dutyMacro.height=31; + ins->std.waveMacro.height=7; } if (ds.system[0]==DIV_SYSTEM_PCE) { ins->type=DIV_INS_PCE; - ins->std.volMacroHeight=31; + ins->std.volMacro.height=31; } if ((ds.system[0]==DIV_SYSTEM_SMS_OPLL || ds.system[0]==DIV_SYSTEM_NES_VRC7) && ins->type==DIV_INS_FM) { ins->type=DIV_INS_OPLL; @@ -425,76 +425,76 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) { } } else { // STD if (ds.system[0]!=DIV_SYSTEM_GB || ds.version<0x12) { - ins->std.volMacroLen=reader.readC(); - for (int j=0; jstd.volMacroLen; j++) { + ins->std.volMacro.len=reader.readC(); + for (int j=0; jstd.volMacro.len; j++) { if (ds.version<0x0e) { - ins->std.volMacro[j]=reader.readC(); + ins->std.volMacro.val[j]=reader.readC(); } else { - ins->std.volMacro[j]=reader.readI(); + ins->std.volMacro.val[j]=reader.readI(); } } - if (ins->std.volMacroLen>0) { - ins->std.volMacroOpen=true; - ins->std.volMacroLoop=reader.readC(); + if (ins->std.volMacro.len>0) { + ins->std.volMacro.open=true; + ins->std.volMacro.loop=reader.readC(); } else { - ins->std.volMacroOpen=false; + ins->std.volMacro.open=false; } } - ins->std.arpMacroLen=reader.readC(); - for (int j=0; jstd.arpMacroLen; j++) { + ins->std.arpMacro.len=reader.readC(); + for (int j=0; jstd.arpMacro.len; j++) { if (ds.version<0x0e) { - ins->std.arpMacro[j]=reader.readC(); + ins->std.arpMacro.val[j]=reader.readC(); } else { - ins->std.arpMacro[j]=reader.readI(); + ins->std.arpMacro.val[j]=reader.readI(); } } - if (ins->std.arpMacroLen>0) { - ins->std.arpMacroLoop=reader.readC(); - ins->std.arpMacroOpen=true; + if (ins->std.arpMacro.len>0) { + ins->std.arpMacro.loop=reader.readC(); + ins->std.arpMacro.open=true; } else { - ins->std.arpMacroOpen=false; + ins->std.arpMacro.open=false; } if (ds.version>0x0f) { - ins->std.arpMacroMode=reader.readC(); + ins->std.arpMacro.mode=reader.readC(); } - if (!ins->std.arpMacroMode) { - for (int j=0; jstd.arpMacroLen; j++) { - ins->std.arpMacro[j]-=12; + if (!ins->std.arpMacro.mode) { + for (int j=0; jstd.arpMacro.len; j++) { + ins->std.arpMacro.val[j]-=12; } } - ins->std.dutyMacroLen=reader.readC(); - for (int j=0; jstd.dutyMacroLen; j++) { + ins->std.dutyMacro.len=reader.readC(); + for (int j=0; jstd.dutyMacro.len; j++) { if (ds.version<0x0e) { - ins->std.dutyMacro[j]=reader.readC(); + ins->std.dutyMacro.val[j]=reader.readC(); } else { - ins->std.dutyMacro[j]=reader.readI(); + ins->std.dutyMacro.val[j]=reader.readI(); } - if ((ds.system[0]==DIV_SYSTEM_C64_8580 || ds.system[0]==DIV_SYSTEM_C64_6581) && ins->std.dutyMacro[j]>24) { - ins->std.dutyMacro[j]=24; + if ((ds.system[0]==DIV_SYSTEM_C64_8580 || ds.system[0]==DIV_SYSTEM_C64_6581) && ins->std.dutyMacro.val[j]>24) { + ins->std.dutyMacro.val[j]=24; } } - if (ins->std.dutyMacroLen>0) { - ins->std.dutyMacroOpen=true; - ins->std.dutyMacroLoop=reader.readC(); + if (ins->std.dutyMacro.len>0) { + ins->std.dutyMacro.open=true; + ins->std.dutyMacro.loop=reader.readC(); } else { - ins->std.dutyMacroOpen=false; + ins->std.dutyMacro.open=false; } - ins->std.waveMacroLen=reader.readC(); - for (int j=0; jstd.waveMacroLen; j++) { + ins->std.waveMacro.len=reader.readC(); + for (int j=0; jstd.waveMacro.len; j++) { if (ds.version<0x0e) { - ins->std.waveMacro[j]=reader.readC(); + ins->std.waveMacro.val[j]=reader.readC(); } else { - ins->std.waveMacro[j]=reader.readI(); + ins->std.waveMacro.val[j]=reader.readI(); } } - if (ins->std.waveMacroLen>0) { - ins->std.waveMacroOpen=true; - ins->std.waveMacroLoop=reader.readC(); + if (ins->std.waveMacro.len>0) { + ins->std.waveMacro.open=true; + ins->std.waveMacro.loop=reader.readC(); } else { - ins->std.waveMacroOpen=false; + ins->std.waveMacro.open=false; } if (ds.system[0]==DIV_SYSTEM_C64_6581 || ds.system[0]==DIV_SYSTEM_C64_8580) { @@ -533,18 +533,18 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) { ins->gb.envDir=reader.readC(); ins->gb.envLen=reader.readC(); ins->gb.soundLen=reader.readC(); - ins->std.volMacroOpen=false; + ins->std.volMacro.open=false; logD("GB data: vol %d dir %d len %d sl %d\n",ins->gb.envVol,ins->gb.envDir,ins->gb.envLen,ins->gb.soundLen); } else if (ds.system[0]==DIV_SYSTEM_GB) { // try to convert macro to envelope - if (ins->std.volMacroLen>0) { - ins->gb.envVol=ins->std.volMacro[0]; - if (ins->std.volMacro[0]std.volMacro[1]) { + if (ins->std.volMacro.len>0) { + ins->gb.envVol=ins->std.volMacro.val[0]; + if (ins->std.volMacro.val[0]std.volMacro.val[1]) { ins->gb.envDir=true; } - if (ins->std.volMacro[ins->std.volMacroLen-1]==0) { - ins->gb.soundLen=ins->std.volMacroLen*2; + if (ins->std.volMacro.val[ins->std.volMacro.len-1]==0) { + ins->gb.soundLen=ins->std.volMacro.len*2; } } addWarning("Game Boy volume macros converted to envelopes. may not be perfect!"); @@ -2446,36 +2446,36 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) { } } else { // STD if (sys!=DIV_SYSTEM_GB) { - w->writeC(i->std.volMacroLen); - w->write(i->std.volMacro,4*i->std.volMacroLen); - if (i->std.volMacroLen>0) { - w->writeC(i->std.volMacroLoop); + w->writeC(i->std.volMacro.len); + w->write(i->std.volMacro.val,4*i->std.volMacro.len); + if (i->std.volMacro.len>0) { + w->writeC(i->std.volMacro.loop); } } - w->writeC(i->std.arpMacroLen); - if (i->std.arpMacroMode) { - w->write(i->std.arpMacro,4*i->std.arpMacroLen); + w->writeC(i->std.arpMacro.len); + if (i->std.arpMacro.mode) { + w->write(i->std.arpMacro.val,4*i->std.arpMacro.len); } else { - for (int j=0; jstd.arpMacroLen; j++) { - w->writeI(i->std.arpMacro[j]+12); + for (int j=0; jstd.arpMacro.len; j++) { + w->writeI(i->std.arpMacro.val[j]+12); } } - if (i->std.arpMacroLen>0) { - w->writeC(i->std.arpMacroLoop); + if (i->std.arpMacro.len>0) { + w->writeC(i->std.arpMacro.loop); } - w->writeC(i->std.arpMacroMode); + w->writeC(i->std.arpMacro.mode); - w->writeC(i->std.dutyMacroLen); - w->write(i->std.dutyMacro,4*i->std.dutyMacroLen); - if (i->std.dutyMacroLen>0) { - w->writeC(i->std.dutyMacroLoop); + w->writeC(i->std.dutyMacro.len); + w->write(i->std.dutyMacro.val,4*i->std.dutyMacro.len); + if (i->std.dutyMacro.len>0) { + w->writeC(i->std.dutyMacro.loop); } - w->writeC(i->std.waveMacroLen); - w->write(i->std.waveMacro,4*i->std.waveMacroLen); - if (i->std.waveMacroLen>0) { - w->writeC(i->std.waveMacroLoop); + w->writeC(i->std.waveMacro.len); + w->write(i->std.waveMacro.val,4*i->std.waveMacro.len); + if (i->std.waveMacro.len>0) { + w->writeC(i->std.waveMacro.loop); } if (sys==DIV_SYSTEM_C64_6581 || sys==DIV_SYSTEM_C64_8580) { diff --git a/src/engine/fileOpsIns.cpp b/src/engine/fileOpsIns.cpp index 6689c5547..6658eea95 100644 --- a/src/engine/fileOpsIns.cpp +++ b/src/engine/fileOpsIns.cpp @@ -181,79 +181,79 @@ void DivEngine::loadDMP(SafeReader& reader, std::vector& ret, St } else { // STD logD("reading STD data...\n"); if (ins->type!=DIV_INS_GB) { - ins->std.volMacroLen=reader.readC(); + ins->std.volMacro.len=reader.readC(); if (version>5) { - for (int i=0; istd.volMacroLen; i++) { - ins->std.volMacro[i]=reader.readI(); + for (int i=0; istd.volMacro.len; i++) { + ins->std.volMacro.val[i]=reader.readI(); } } else { - for (int i=0; istd.volMacroLen; i++) { - ins->std.volMacro[i]=reader.readC(); + for (int i=0; istd.volMacro.len; i++) { + ins->std.volMacro.val[i]=reader.readC(); } } - if (version<11) for (int i=0; istd.volMacroLen; i++) { - if (ins->std.volMacro[i]>15 && ins->type==DIV_INS_STD) ins->type=DIV_INS_PCE; + if (version<11) for (int i=0; istd.volMacro.len; i++) { + if (ins->std.volMacro.val[i]>15 && ins->type==DIV_INS_STD) ins->type=DIV_INS_PCE; } - if (ins->std.volMacroLen>0) { - ins->std.volMacroOpen=true; - ins->std.volMacroLoop=reader.readC(); + if (ins->std.volMacro.len>0) { + ins->std.volMacro.open=true; + ins->std.volMacro.loop=reader.readC(); } else { - ins->std.volMacroOpen=false; + ins->std.volMacro.open=false; } } - ins->std.arpMacroLen=reader.readC(); + ins->std.arpMacro.len=reader.readC(); if (version>5) { - for (int i=0; istd.arpMacroLen; i++) { - ins->std.arpMacro[i]=reader.readI(); + for (int i=0; istd.arpMacro.len; i++) { + ins->std.arpMacro.val[i]=reader.readI(); } } else { - for (int i=0; istd.arpMacroLen; i++) { - ins->std.arpMacro[i]=reader.readC(); + for (int i=0; istd.arpMacro.len; i++) { + ins->std.arpMacro.val[i]=reader.readC(); } } - if (ins->std.arpMacroLen>0) { - ins->std.arpMacroOpen=true; - ins->std.arpMacroLoop=reader.readC(); + if (ins->std.arpMacro.len>0) { + ins->std.arpMacro.open=true; + ins->std.arpMacro.loop=reader.readC(); } else { - ins->std.arpMacroOpen=false; + ins->std.arpMacro.open=false; } if (version>8) { // TODO: when? - ins->std.arpMacroMode=reader.readC(); + ins->std.arpMacro.mode=reader.readC(); } - ins->std.dutyMacroLen=reader.readC(); + ins->std.dutyMacro.len=reader.readC(); if (version>5) { - for (int i=0; istd.dutyMacroLen; i++) { - ins->std.dutyMacro[i]=reader.readI(); + for (int i=0; istd.dutyMacro.len; i++) { + ins->std.dutyMacro.val[i]=reader.readI(); } } else { - for (int i=0; istd.dutyMacroLen; i++) { - ins->std.dutyMacro[i]=reader.readC(); + for (int i=0; istd.dutyMacro.len; i++) { + ins->std.dutyMacro.val[i]=reader.readC(); } } - if (ins->std.dutyMacroLen>0) { - ins->std.dutyMacroOpen=true; - ins->std.dutyMacroLoop=reader.readC(); + if (ins->std.dutyMacro.len>0) { + ins->std.dutyMacro.open=true; + ins->std.dutyMacro.loop=reader.readC(); } else { - ins->std.dutyMacroOpen=false; + ins->std.dutyMacro.open=false; } - ins->std.waveMacroLen=reader.readC(); + ins->std.waveMacro.len=reader.readC(); if (version>5) { - for (int i=0; istd.waveMacroLen; i++) { - ins->std.waveMacro[i]=reader.readI(); + for (int i=0; istd.waveMacro.len; i++) { + ins->std.waveMacro.val[i]=reader.readI(); } } else { - for (int i=0; istd.waveMacroLen; i++) { - ins->std.waveMacro[i]=reader.readC(); + for (int i=0; istd.waveMacro.len; i++) { + ins->std.waveMacro.val[i]=reader.readC(); } } - if (ins->std.waveMacroLen>0) { - ins->std.waveMacroOpen=true; - ins->std.waveMacroLoop=reader.readC(); + if (ins->std.waveMacro.len>0) { + ins->std.waveMacro.open=true; + ins->std.waveMacro.loop=reader.readC(); } else { - ins->std.waveMacroOpen=false; + ins->std.waveMacro.open=false; } if (ins->type==DIV_INS_C64) { diff --git a/src/engine/instrument.cpp b/src/engine/instrument.cpp index 60ce6810b..9369df9db 100644 --- a/src/engine/instrument.cpp +++ b/src/engine/instrument.cpp @@ -23,13 +23,37 @@ #include "../ta-log.h" #include "../fileutils.h" +void DivInstrument::putMacroData(DivInstrumentMacro m, SafeWriter* w) { + w->write("MACR",4); + w->writeI(0); + + w->writeS(DIV_ENGINE_VERSION); + + w->writeS(type); + w->writeC(0); + + w->writeString(m.name,false); + + w->writeI(m.len); + w->writeI(m.loop); + w->writeI(m.rel); + w->writeI(m.mode); + w->writeC(m.open); + for (int v=0; vwriteI(m.val[v]); + w->writeI(0); // reserved + w->writeI(0); // reserved + } +} + void DivInstrument::putInsData(SafeWriter* w) { w->write("INST",4); w->writeI(0); w->writeS(DIV_ENGINE_VERSION); - w->writeC(type); + w->writeS(type); + //w->writeC(type); w->writeC(0); w->writeString(name,false); @@ -101,7 +125,7 @@ void DivInstrument::putInsData(SafeWriter* w) { w->writeC(c64.hp); w->writeC(c64.ch3off); w->writeS(c64.cut); - w->writeC(c64.dutyIsAbs); + //w->writeC(std.dutyMacro.mode); w->writeC(c64.filterIsAbs); // Amiga @@ -111,266 +135,326 @@ void DivInstrument::putInsData(SafeWriter* w) { } // standard - w->writeI(std.volMacroLen); - w->writeI(std.arpMacroLen); - w->writeI(std.dutyMacroLen); - w->writeI(std.waveMacroLen); - w->writeI(std.pitchMacroLen); - w->writeI(std.ex1MacroLen); - w->writeI(std.ex2MacroLen); - w->writeI(std.ex3MacroLen); - w->writeI(std.volMacroLoop); - w->writeI(std.arpMacroLoop); - w->writeI(std.dutyMacroLoop); - w->writeI(std.waveMacroLoop); - w->writeI(std.pitchMacroLoop); - w->writeI(std.ex1MacroLoop); - w->writeI(std.ex2MacroLoop); - w->writeI(std.ex3MacroLoop); - w->writeC(std.arpMacroMode); + putMacroData(std.volMacro,w); + putMacroData(std.arpMacro,w); + putMacroData(std.dutyMacro,w); + putMacroData(std.waveMacro,w); + putMacroData(std.pitchMacro,w); + putMacroData(std.ex1Macro,w); + putMacroData(std.ex2Macro,w); + putMacroData(std.ex3Macro,w); + putMacroData(std.algMacro,w); + putMacroData(std.fbMacro,w); + putMacroData(std.fmsMacro,w); + putMacroData(std.fms2Macro,w); + putMacroData(std.amsMacro,w); + putMacroData(std.ams2Macro,w); + putMacroData(std.panLMacro,w); + putMacroData(std.panRMacro,w); + putMacroData(std.phaseResetMacro,w); + putMacroData(std.ex4Macro,w); + putMacroData(std.ex5Macro,w); + putMacroData(std.ex6Macro,w); + putMacroData(std.ex7Macro,w); + putMacroData(std.ex8Macro,w); + // FM macros + for (int i=0; i<4; i++) { + DivInstrumentSTD::OpMacro& op=std.opMacros[i]; + putMacroData(op.amMacro,w); + putMacroData(op.arMacro,w); + putMacroData(op.drMacro,w); + putMacroData(op.multMacro,w); + putMacroData(op.rrMacro,w); + putMacroData(op.slMacro,w); + putMacroData(op.tlMacro,w); + putMacroData(op.dt2Macro,w); + putMacroData(op.rsMacro,w); + putMacroData(op.dtMacro,w); + putMacroData(op.d2rMacro,w); + putMacroData(op.ssgMacro,w); + putMacroData(op.damMacro,w); + putMacroData(op.dvbMacro,w); + putMacroData(op.egtMacro,w); + putMacroData(op.kslMacro,w); + putMacroData(op.susMacro,w); + putMacroData(op.vibMacro,w); + putMacroData(op.wsMacro,w); + putMacroData(op.ksrMacro,w); + } + // wavesynth macros + putMacroData(std.ws.wave1Macro,w); + putMacroData(std.ws.wave2Macro,w); + putMacroData(std.ws.rateDividerMacro,w); + putMacroData(std.ws.effectMacro,w); + putMacroData(std.ws.oneShotMacro,w); + putMacroData(std.ws.enabledMacro,w); + putMacroData(std.ws.globalMacro,w); + putMacroData(std.ws.speedMacro,w); + putMacroData(std.ws.param1Macro,w); + putMacroData(std.ws.param2Macro,w); + putMacroData(std.ws.param3Macro,w); + putMacroData(std.ws.param4Macro,w); + /* + w->writeI(std.volMacro.len); + w->writeI(std.arpMacro.len); + w->writeI(std.dutyMacro.len); + w->writeI(std.waveMacro.len); + w->writeI(std.pitchMacro.len); + w->writeI(std.ex1Macro.len); + w->writeI(std.ex2Macro.len); + w->writeI(std.ex3Macro.len); + w->writeI(std.volMacro.loop); + w->writeI(std.arpMacro.loop); + w->writeI(std.dutyMacro.loop); + w->writeI(std.waveMacro.loop); + w->writeI(std.pitchMacro.loop); + w->writeI(std.ex1Macro.loop); + w->writeI(std.ex2Macro.loop); + w->writeI(std.ex3Macro.loop); + w->writeC(std.arpMacro.mode); w->writeC(0); // reserved w->writeC(0); w->writeC(0); - for (int j=0; jwriteI(std.volMacro[j]); + for (int j=0; jwriteI(std.volMacro.val[j]); } - for (int j=0; jwriteI(std.arpMacro[j]); + for (int j=0; jwriteI(std.arpMacro.val[j]); } - for (int j=0; jwriteI(std.dutyMacro[j]); + for (int j=0; jwriteI(std.dutyMacro.val[j]); } - for (int j=0; jwriteI(std.waveMacro[j]); + for (int j=0; jwriteI(std.waveMacro.val[j]); } - for (int j=0; jwriteI(std.pitchMacro[j]); + for (int j=0; jwriteI(std.pitchMacro.val[j]); } - for (int j=0; jwriteI(std.ex1Macro[j]); + for (int j=0; jwriteI(std.ex1Macro.val[j]); } - for (int j=0; jwriteI(std.ex2Macro[j]); + for (int j=0; jwriteI(std.ex2Macro.val[j]); } - for (int j=0; jwriteI(std.ex3Macro[j]); + for (int j=0; jwriteI(std.ex3Macro.val[j]); } // FM macros and open status - w->writeI(std.algMacroLen); - w->writeI(std.fbMacroLen); - w->writeI(std.fmsMacroLen); - w->writeI(std.amsMacroLen); - w->writeI(std.algMacroLoop); - w->writeI(std.fbMacroLoop); - w->writeI(std.fmsMacroLoop); - w->writeI(std.amsMacroLoop); + w->writeI(std.algMacro.len); + w->writeI(std.fbMacro.len); + w->writeI(std.fmsMacro.len); + w->writeI(std.amsMacro.len); + w->writeI(std.algMacro.loop); + w->writeI(std.fbMacro.loop); + w->writeI(std.fmsMacro.loop); + w->writeI(std.amsMacro.loop); - w->writeC(std.volMacroOpen); - w->writeC(std.arpMacroOpen); - w->writeC(std.dutyMacroOpen); - w->writeC(std.waveMacroOpen); - w->writeC(std.pitchMacroOpen); - w->writeC(std.ex1MacroOpen); - w->writeC(std.ex2MacroOpen); - w->writeC(std.ex3MacroOpen); - w->writeC(std.algMacroOpen); - w->writeC(std.fbMacroOpen); - w->writeC(std.fmsMacroOpen); - w->writeC(std.amsMacroOpen); + w->writeC(std.volMacro.open); + w->writeC(std.arpMacro.open); + w->writeC(std.dutyMacro.open); + w->writeC(std.waveMacro.open); + w->writeC(std.pitchMacro.open); + w->writeC(std.ex1Macro.open); + w->writeC(std.ex2Macro.open); + w->writeC(std.ex3Macro.open); + w->writeC(std.algMacro.open); + w->writeC(std.fbMacro.open); + w->writeC(std.fmsMacro.open); + w->writeC(std.amsMacro.open); - for (int j=0; jwriteI(std.algMacro[j]); + for (int j=0; jwriteI(std.algMacro.val[j]); } - for (int j=0; jwriteI(std.fbMacro[j]); + for (int j=0; jwriteI(std.fbMacro.val[j]); } - for (int j=0; jwriteI(std.fmsMacro[j]); + for (int j=0; jwriteI(std.fmsMacro.val[j]); } - for (int j=0; jwriteI(std.amsMacro[j]); + for (int j=0; jwriteI(std.amsMacro.val[j]); } for (int i=0; i<4; i++) { DivInstrumentSTD::OpMacro& op=std.opMacros[i]; - w->writeI(op.amMacroLen); - w->writeI(op.arMacroLen); - w->writeI(op.drMacroLen); - w->writeI(op.multMacroLen); - w->writeI(op.rrMacroLen); - w->writeI(op.slMacroLen); - w->writeI(op.tlMacroLen); - w->writeI(op.dt2MacroLen); - w->writeI(op.rsMacroLen); - w->writeI(op.dtMacroLen); - w->writeI(op.d2rMacroLen); - w->writeI(op.ssgMacroLen); - w->writeI(op.amMacroLoop); - w->writeI(op.arMacroLoop); - w->writeI(op.drMacroLoop); - w->writeI(op.multMacroLoop); - w->writeI(op.rrMacroLoop); - w->writeI(op.slMacroLoop); - w->writeI(op.tlMacroLoop); - w->writeI(op.dt2MacroLoop); - w->writeI(op.rsMacroLoop); - w->writeI(op.dtMacroLoop); - w->writeI(op.d2rMacroLoop); - w->writeI(op.ssgMacroLoop); - w->writeC(op.amMacroOpen); - w->writeC(op.arMacroOpen); - w->writeC(op.drMacroOpen); - w->writeC(op.multMacroOpen); - w->writeC(op.rrMacroOpen); - w->writeC(op.slMacroOpen); - w->writeC(op.tlMacroOpen); - w->writeC(op.dt2MacroOpen); - w->writeC(op.rsMacroOpen); - w->writeC(op.dtMacroOpen); - w->writeC(op.d2rMacroOpen); - w->writeC(op.ssgMacroOpen); + w->writeI(op.amMacro.len); + w->writeI(op.arMacro.len); + w->writeI(op.drMacro.len); + w->writeI(op.multMacro.len); + w->writeI(op.rrMacro.len); + w->writeI(op.slMacro.len); + w->writeI(op.tlMacro.len); + w->writeI(op.dt2Macro.len); + w->writeI(op.rsMacro.len); + w->writeI(op.dtMacro.len); + w->writeI(op.d2rMacro.len); + w->writeI(op.ssgMacro.len); + w->writeI(op.amMacro.loop); + w->writeI(op.arMacro.loop); + w->writeI(op.drMacro.loop); + w->writeI(op.multMacro.loop); + w->writeI(op.rrMacro.loop); + w->writeI(op.slMacro.loop); + w->writeI(op.tlMacro.loop); + w->writeI(op.dt2Macro.loop); + w->writeI(op.rsMacro.loop); + w->writeI(op.dtMacro.loop); + w->writeI(op.d2rMacro.loop); + w->writeI(op.ssgMacro.loop); + w->writeC(op.amMacro.open); + w->writeC(op.arMacro.open); + w->writeC(op.drMacro.open); + w->writeC(op.multMacro.open); + w->writeC(op.rrMacro.open); + w->writeC(op.slMacro.open); + w->writeC(op.tlMacro.open); + w->writeC(op.dt2Macro.open); + w->writeC(op.rsMacro.open); + w->writeC(op.dtMacro.open); + w->writeC(op.d2rMacro.open); + w->writeC(op.ssgMacro.open); } for (int i=0; i<4; i++) { DivInstrumentSTD::OpMacro& op=std.opMacros[i]; - for (int j=0; jwriteC(op.amMacro[j]); + for (int j=0; jwriteC(op.amMacro.val[j]); } - for (int j=0; jwriteC(op.arMacro[j]); + for (int j=0; jwriteC(op.arMacro.val[j]); } - for (int j=0; jwriteC(op.drMacro[j]); + for (int j=0; jwriteC(op.drMacro.val[j]); } - for (int j=0; jwriteC(op.multMacro[j]); + for (int j=0; jwriteC(op.multMacro.val[j]); } - for (int j=0; jwriteC(op.rrMacro[j]); + for (int j=0; jwriteC(op.rrMacro.val[j]); } - for (int j=0; jwriteC(op.slMacro[j]); + for (int j=0; jwriteC(op.slMacro.val[j]); } - for (int j=0; jwriteC(op.tlMacro[j]); + for (int j=0; jwriteC(op.tlMacro.val[j]); } - for (int j=0; jwriteC(op.dt2Macro[j]); + for (int j=0; jwriteC(op.dt2Macro.val[j]); } - for (int j=0; jwriteC(op.rsMacro[j]); + for (int j=0; jwriteC(op.rsMacro.val[j]); } - for (int j=0; jwriteC(op.dtMacro[j]); + for (int j=0; jwriteC(op.dtMacro.val[j]); } - for (int j=0; jwriteC(op.d2rMacro[j]); + for (int j=0; jwriteC(op.d2rMacro.val[j]); } - for (int j=0; jwriteC(op.ssgMacro[j]); + for (int j=0; jwriteC(op.ssgMacro.val[j]); } } // release points - w->writeI(std.volMacroRel); - w->writeI(std.arpMacroRel); - w->writeI(std.dutyMacroRel); - w->writeI(std.waveMacroRel); - w->writeI(std.pitchMacroRel); - w->writeI(std.ex1MacroRel); - w->writeI(std.ex2MacroRel); - w->writeI(std.ex3MacroRel); - w->writeI(std.algMacroRel); - w->writeI(std.fbMacroRel); - w->writeI(std.fmsMacroRel); - w->writeI(std.amsMacroRel); + w->writeI(std.volMacro.rel); + w->writeI(std.arpMacro.rel); + w->writeI(std.dutyMacro.rel); + w->writeI(std.waveMacro.rel); + w->writeI(std.pitchMacro.rel); + w->writeI(std.ex1Macro.rel); + w->writeI(std.ex2Macro.rel); + w->writeI(std.ex3Macro.rel); + w->writeI(std.algMacro.rel); + w->writeI(std.fbMacro.rel); + w->writeI(std.fmsMacro.rel); + w->writeI(std.amsMacro.rel); for (int i=0; i<4; i++) { DivInstrumentSTD::OpMacro& op=std.opMacros[i]; - w->writeI(op.amMacroRel); - w->writeI(op.arMacroRel); - w->writeI(op.drMacroRel); - w->writeI(op.multMacroRel); - w->writeI(op.rrMacroRel); - w->writeI(op.slMacroRel); - w->writeI(op.tlMacroRel); - w->writeI(op.dt2MacroRel); - w->writeI(op.rsMacroRel); - w->writeI(op.dtMacroRel); - w->writeI(op.d2rMacroRel); - w->writeI(op.ssgMacroRel); + w->writeI(op.amMacro.rel); + w->writeI(op.arMacro.rel); + w->writeI(op.drMacro.rel); + w->writeI(op.multMacro.rel); + w->writeI(op.rrMacro.rel); + w->writeI(op.slMacro.rel); + w->writeI(op.tlMacro.rel); + w->writeI(op.dt2Macro.rel); + w->writeI(op.rsMacro.rel); + w->writeI(op.dtMacro.rel); + w->writeI(op.d2rMacro.rel); + w->writeI(op.ssgMacro.rel); } // extended op macros for (int i=0; i<4; i++) { DivInstrumentSTD::OpMacro& op=std.opMacros[i]; - w->writeI(op.damMacroLen); - w->writeI(op.dvbMacroLen); - w->writeI(op.egtMacroLen); - w->writeI(op.kslMacroLen); - w->writeI(op.susMacroLen); - w->writeI(op.vibMacroLen); - w->writeI(op.wsMacroLen); - w->writeI(op.ksrMacroLen); + w->writeI(op.damMacro.len); + w->writeI(op.dvbMacro.len); + w->writeI(op.egtMacro.len); + w->writeI(op.kslMacro.len); + w->writeI(op.susMacro.len); + w->writeI(op.vibMacro.len); + w->writeI(op.wsMacro.len); + w->writeI(op.ksrMacro.len); - w->writeI(op.damMacroLoop); - w->writeI(op.dvbMacroLoop); - w->writeI(op.egtMacroLoop); - w->writeI(op.kslMacroLoop); - w->writeI(op.susMacroLoop); - w->writeI(op.vibMacroLoop); - w->writeI(op.wsMacroLoop); - w->writeI(op.ksrMacroLoop); + w->writeI(op.damMacro.loop); + w->writeI(op.dvbMacro.loop); + w->writeI(op.egtMacro.loop); + w->writeI(op.kslMacro.loop); + w->writeI(op.susMacro.loop); + w->writeI(op.vibMacro.loop); + w->writeI(op.wsMacro.loop); + w->writeI(op.ksrMacro.loop); - w->writeI(op.damMacroRel); - w->writeI(op.dvbMacroRel); - w->writeI(op.egtMacroRel); - w->writeI(op.kslMacroRel); - w->writeI(op.susMacroRel); - w->writeI(op.vibMacroRel); - w->writeI(op.wsMacroRel); - w->writeI(op.ksrMacroRel); + w->writeI(op.damMacro.rel); + w->writeI(op.dvbMacro.rel); + w->writeI(op.egtMacro.rel); + w->writeI(op.kslMacro.rel); + w->writeI(op.susMacro.rel); + w->writeI(op.vibMacro.rel); + w->writeI(op.wsMacro.rel); + w->writeI(op.ksrMacro.rel); - w->writeC(op.damMacroOpen); - w->writeC(op.dvbMacroOpen); - w->writeC(op.egtMacroOpen); - w->writeC(op.kslMacroOpen); - w->writeC(op.susMacroOpen); - w->writeC(op.vibMacroOpen); - w->writeC(op.wsMacroOpen); - w->writeC(op.ksrMacroOpen); + w->writeC(op.damMacro.open); + w->writeC(op.dvbMacro.open); + w->writeC(op.egtMacro.open); + w->writeC(op.kslMacro.open); + w->writeC(op.susMacro.open); + w->writeC(op.vibMacro.open); + w->writeC(op.wsMacro.open); + w->writeC(op.ksrMacro.open); } for (int i=0; i<4; i++) { DivInstrumentSTD::OpMacro& op=std.opMacros[i]; - for (int j=0; jwriteC(op.damMacro[j]); + for (int j=0; jwriteC(op.damMacro.val[j]); } - for (int j=0; jwriteC(op.dvbMacro[j]); + for (int j=0; jwriteC(op.dvbMacro.val[j]); } - for (int j=0; jwriteC(op.egtMacro[j]); + for (int j=0; jwriteC(op.egtMacro.val[j]); } - for (int j=0; jwriteC(op.kslMacro[j]); + for (int j=0; jwriteC(op.kslMacro.val[j]); } - for (int j=0; jwriteC(op.susMacro[j]); + for (int j=0; jwriteC(op.susMacro.val[j]); } - for (int j=0; jwriteC(op.vibMacro[j]); + for (int j=0; jwriteC(op.vibMacro.val[j]); } - for (int j=0; jwriteC(op.wsMacro[j]); + for (int j=0; jwriteC(op.wsMacro.val[j]); } - for (int j=0; jwriteC(op.ksrMacro[j]); + for (int j=0; jwriteC(op.ksrMacro.val[j]); } - } + }*/ // OPL drum data w->writeC(fm.fixedDrums); @@ -394,66 +478,67 @@ void DivInstrument::putInsData(SafeWriter* w) { w->writeC(0); // reserved // more macros - w->writeI(std.panLMacroLen); - w->writeI(std.panRMacroLen); - w->writeI(std.phaseResetMacroLen); - w->writeI(std.ex4MacroLen); - w->writeI(std.ex5MacroLen); - w->writeI(std.ex6MacroLen); - w->writeI(std.ex7MacroLen); - w->writeI(std.ex8MacroLen); + /* + w->writeI(std.panLMacro.len); + w->writeI(std.panRMacro.len); + w->writeI(std.phaseResetMacro.len); + w->writeI(std.ex4Macro.len); + w->writeI(std.ex5Macro.len); + w->writeI(std.ex6Macro.len); + w->writeI(std.ex7Macro.len); + w->writeI(std.ex8Macro.len); - w->writeI(std.panLMacroLoop); - w->writeI(std.panRMacroLoop); - w->writeI(std.phaseResetMacroLoop); - w->writeI(std.ex4MacroLoop); - w->writeI(std.ex5MacroLoop); - w->writeI(std.ex6MacroLoop); - w->writeI(std.ex7MacroLoop); - w->writeI(std.ex8MacroLoop); + w->writeI(std.panLMacro.loop); + w->writeI(std.panRMacro.loop); + w->writeI(std.phaseResetMacro.loop); + w->writeI(std.ex4Macro.loop); + w->writeI(std.ex5Macro.loop); + w->writeI(std.ex6Macro.loop); + w->writeI(std.ex7Macro.loop); + w->writeI(std.ex8Macro.loop); - w->writeI(std.panLMacroRel); - w->writeI(std.panRMacroRel); - w->writeI(std.phaseResetMacroRel); - w->writeI(std.ex4MacroRel); - w->writeI(std.ex5MacroRel); - w->writeI(std.ex6MacroRel); - w->writeI(std.ex7MacroRel); - w->writeI(std.ex8MacroRel); + w->writeI(std.panLMacro.rel); + w->writeI(std.panRMacro.rel); + w->writeI(std.phaseResetMacro.rel); + w->writeI(std.ex4Macro.rel); + w->writeI(std.ex5Macro.rel); + w->writeI(std.ex6Macro.rel); + w->writeI(std.ex7Macro.rel); + w->writeI(std.ex8Macro.rel); - w->writeC(std.panLMacroOpen); - w->writeC(std.panRMacroOpen); - w->writeC(std.phaseResetMacroOpen); - w->writeC(std.ex4MacroOpen); - w->writeC(std.ex5MacroOpen); - w->writeC(std.ex6MacroOpen); - w->writeC(std.ex7MacroOpen); - w->writeC(std.ex8MacroOpen); + w->writeC(std.panLMacro.open); + w->writeC(std.panRMacro.open); + w->writeC(std.phaseResetMacro.open); + w->writeC(std.ex4Macro.open); + w->writeC(std.ex5Macro.open); + w->writeC(std.ex6Macro.open); + w->writeC(std.ex7Macro.open); + w->writeC(std.ex8Macro.open); - for (int j=0; jwriteI(std.panLMacro[j]); + for (int j=0; jwriteI(std.panLMacro.val[j]); } - for (int j=0; jwriteI(std.panRMacro[j]); + for (int j=0; jwriteI(std.panRMacro.val[j]); } - for (int j=0; jwriteI(std.phaseResetMacro[j]); + for (int j=0; jwriteI(std.phaseResetMacro.val[j]); } - for (int j=0; jwriteI(std.ex4Macro[j]); + for (int j=0; jwriteI(std.ex4Macro.val[j]); } - for (int j=0; jwriteI(std.ex5Macro[j]); + for (int j=0; jwriteI(std.ex5Macro.val[j]); } - for (int j=0; jwriteI(std.ex6Macro[j]); + for (int j=0; jwriteI(std.ex6Macro.val[j]); } - for (int j=0; jwriteI(std.ex7Macro[j]); - } - for (int j=0; jwriteI(std.ex8Macro[j]); + for (int j=0; jwriteI(std.ex7Macro.val[j]); } + for (int j=0; jwriteI(std.ex8Macro.val[j]); + }*/ // FDS w->writeI(fds.modSpeed); @@ -482,7 +567,35 @@ void DivInstrument::putInsData(SafeWriter* w) { w->writeC(ws.param4); } +void readMacroData(DivInstrumentMacro &m, SafeReader& reader, short version) { + char magic[4]; + reader.read(magic,4); + if (memcmp(magic,"MACR",4)!=0) { + logE("invalid macro header!\n"); + return /*DIV_DATA_INVALID_HEADER*/; + } + reader.readI(); + + reader.readS(); // format version. ignored. + /*type=(DivInstrumentType)*/reader.readS(); // instrument type + reader.readC(); + m.name=reader.readString(); + + m.len=reader.readI(); + m.loop=reader.readI(); + m.rel=reader.readI(); + m.mode=reader.readI(); + m.open=reader.readC(); + for (int v=0; v=17) { - std.pitchMacroLen=reader.readI(); - std.ex1MacroLen=reader.readI(); - std.ex2MacroLen=reader.readI(); - std.ex3MacroLen=reader.readI(); - } - std.volMacroLoop=reader.readI(); - std.arpMacroLoop=reader.readI(); - std.dutyMacroLoop=reader.readI(); - std.waveMacroLoop=reader.readI(); - if (version>=17) { - std.pitchMacroLoop=reader.readI(); - std.ex1MacroLoop=reader.readI(); - std.ex2MacroLoop=reader.readI(); - std.ex3MacroLoop=reader.readI(); - } - std.arpMacroMode=reader.readC(); - std.volMacroHeight=reader.readC(); - std.dutyMacroHeight=reader.readC(); - std.waveMacroHeight=reader.readC(); - if (std.volMacroHeight==0) std.volMacroHeight=15; - if (std.dutyMacroHeight==0) std.dutyMacroHeight=3; - if (std.waveMacroHeight==0) std.waveMacroHeight=63; - reader.read(std.volMacro,4*std.volMacroLen); - reader.read(std.arpMacro,4*std.arpMacroLen); - reader.read(std.dutyMacro,4*std.dutyMacroLen); - reader.read(std.waveMacro,4*std.waveMacroLen); - if (version<31) { - if (!std.arpMacroMode) for (int j=0; j=17) { - reader.read(std.pitchMacro,4*std.pitchMacroLen); - reader.read(std.ex1Macro,4*std.ex1MacroLen); - reader.read(std.ex2Macro,4*std.ex2MacroLen); - reader.read(std.ex3Macro,4*std.ex3MacroLen); - } else { - if (type==DIV_INS_STD) { - if (std.volMacroHeight==31) { - type=DIV_INS_PCE; - } - if (std.dutyMacroHeight==31) { - type=DIV_INS_AY; + if (!istest) { + // standard + std.volMacro.len=reader.readI(); + std.arpMacro.len=reader.readI(); + std.dutyMacro.len=reader.readI(); + std.waveMacro.len=reader.readI(); + if (version>=17) { + std.pitchMacro.len=reader.readI(); + std.ex1Macro.len=reader.readI(); + std.ex2Macro.len=reader.readI(); + std.ex3Macro.len=reader.readI(); + } + std.volMacro.loop=reader.readI(); + std.arpMacro.loop=reader.readI(); + std.dutyMacro.loop=reader.readI(); + std.waveMacro.loop=reader.readI(); + if (version>=17) { + std.pitchMacro.loop=reader.readI(); + std.ex1Macro.loop=reader.readI(); + std.ex2Macro.loop=reader.readI(); + std.ex3Macro.loop=reader.readI(); + } + std.arpMacro.mode=reader.readC(); + std.volMacro.height=reader.readC(); + std.dutyMacro.height=reader.readC(); + std.waveMacro.height=reader.readC(); + if (std.volMacro.height==0) std.volMacro.height=15; + if (std.dutyMacro.height==0) std.dutyMacro.height=3; + if (std.waveMacro.height==0) std.waveMacro.height=63; + reader.read(std.volMacro.val,4*std.volMacro.len); + reader.read(std.arpMacro.val,4*std.arpMacro.len); + reader.read(std.dutyMacro.val,4*std.dutyMacro.len); + reader.read(std.waveMacro.val,4*std.waveMacro.len); + if (version<31) { + if (!std.arpMacro.mode) for (int j=0; j=29) { - std.algMacroLen=reader.readI(); - std.fbMacroLen=reader.readI(); - std.fmsMacroLen=reader.readI(); - std.amsMacroLen=reader.readI(); - std.algMacroLoop=reader.readI(); - std.fbMacroLoop=reader.readI(); - std.fmsMacroLoop=reader.readI(); - std.amsMacroLoop=reader.readI(); - std.volMacroOpen=reader.readC(); - std.arpMacroOpen=reader.readC(); - std.dutyMacroOpen=reader.readC(); - std.waveMacroOpen=reader.readC(); - std.pitchMacroOpen=reader.readC(); - std.ex1MacroOpen=reader.readC(); - std.ex2MacroOpen=reader.readC(); - std.ex3MacroOpen=reader.readC(); - std.algMacroOpen=reader.readC(); - std.fbMacroOpen=reader.readC(); - std.fmsMacroOpen=reader.readC(); - std.amsMacroOpen=reader.readC(); - - reader.read(std.algMacro,4*std.algMacroLen); - reader.read(std.fbMacro,4*std.fbMacroLen); - reader.read(std.fmsMacro,4*std.fmsMacroLen); - reader.read(std.amsMacro,4*std.amsMacroLen); - - for (int i=0; i<4; i++) { - DivInstrumentSTD::OpMacro& op=std.opMacros[i]; - - op.amMacroLen=reader.readI(); - op.arMacroLen=reader.readI(); - op.drMacroLen=reader.readI(); - op.multMacroLen=reader.readI(); - op.rrMacroLen=reader.readI(); - op.slMacroLen=reader.readI(); - op.tlMacroLen=reader.readI(); - op.dt2MacroLen=reader.readI(); - op.rsMacroLen=reader.readI(); - op.dtMacroLen=reader.readI(); - op.d2rMacroLen=reader.readI(); - op.ssgMacroLen=reader.readI(); - - op.amMacroLoop=reader.readI(); - op.arMacroLoop=reader.readI(); - op.drMacroLoop=reader.readI(); - op.multMacroLoop=reader.readI(); - op.rrMacroLoop=reader.readI(); - op.slMacroLoop=reader.readI(); - op.tlMacroLoop=reader.readI(); - op.dt2MacroLoop=reader.readI(); - op.rsMacroLoop=reader.readI(); - op.dtMacroLoop=reader.readI(); - op.d2rMacroLoop=reader.readI(); - op.ssgMacroLoop=reader.readI(); - - op.amMacroOpen=reader.readC(); - op.arMacroOpen=reader.readC(); - op.drMacroOpen=reader.readC(); - op.multMacroOpen=reader.readC(); - op.rrMacroOpen=reader.readC(); - op.slMacroOpen=reader.readC(); - op.tlMacroOpen=reader.readC(); - op.dt2MacroOpen=reader.readC(); - op.rsMacroOpen=reader.readC(); - op.dtMacroOpen=reader.readC(); - op.d2rMacroOpen=reader.readC(); - op.ssgMacroOpen=reader.readC(); + if (version>=17) { + reader.read(std.pitchMacro.val,4*std.pitchMacro.len); + reader.read(std.ex1Macro.val,4*std.ex1Macro.len); + reader.read(std.ex2Macro.val,4*std.ex2Macro.len); + reader.read(std.ex3Macro.val,4*std.ex3Macro.len); + } else { + if (type==DIV_INS_STD) { + if (std.volMacro.height==31) { + type=DIV_INS_PCE; + } + if (std.dutyMacro.height==31) { + type=DIV_INS_AY; + } + } } - for (int i=0; i<4; i++) { - DivInstrumentSTD::OpMacro& op=std.opMacros[i]; - reader.read(op.amMacro,op.amMacroLen); - reader.read(op.arMacro,op.arMacroLen); - reader.read(op.drMacro,op.drMacroLen); - reader.read(op.multMacro,op.multMacroLen); - reader.read(op.rrMacro,op.rrMacroLen); - reader.read(op.slMacro,op.slMacroLen); - reader.read(op.tlMacro,op.tlMacroLen); - reader.read(op.dt2Macro,op.dt2MacroLen); - reader.read(op.rsMacro,op.rsMacroLen); - reader.read(op.dtMacro,op.dtMacroLen); - reader.read(op.d2rMacro,op.d2rMacroLen); - reader.read(op.ssgMacro,op.ssgMacroLen); - } - } + // FM macros + if (version>=29) { + std.algMacro.len=reader.readI(); + std.fbMacro.len=reader.readI(); + std.fmsMacro.len=reader.readI(); + std.amsMacro.len=reader.readI(); + std.algMacro.loop=reader.readI(); + std.fbMacro.loop=reader.readI(); + std.fmsMacro.loop=reader.readI(); + std.amsMacro.loop=reader.readI(); + std.volMacro.open=reader.readC(); + std.arpMacro.open=reader.readC(); + std.dutyMacro.open=reader.readC(); + std.waveMacro.open=reader.readC(); + std.pitchMacro.open=reader.readC(); + std.ex1Macro.open=reader.readC(); + std.ex2Macro.open=reader.readC(); + std.ex3Macro.open=reader.readC(); + std.algMacro.open=reader.readC(); + std.fbMacro.open=reader.readC(); + std.fmsMacro.open=reader.readC(); + std.amsMacro.open=reader.readC(); - // release points - if (version>=44) { - std.volMacroRel=reader.readI(); - std.arpMacroRel=reader.readI(); - std.dutyMacroRel=reader.readI(); - std.waveMacroRel=reader.readI(); - std.pitchMacroRel=reader.readI(); - std.ex1MacroRel=reader.readI(); - std.ex2MacroRel=reader.readI(); - std.ex3MacroRel=reader.readI(); - std.algMacroRel=reader.readI(); - std.fbMacroRel=reader.readI(); - std.fmsMacroRel=reader.readI(); - std.amsMacroRel=reader.readI(); + reader.read(std.algMacro.val,4*std.algMacro.len); + reader.read(std.fbMacro.val,4*std.fbMacro.len); + reader.read(std.fmsMacro.val,4*std.fmsMacro.len); + reader.read(std.amsMacro.val,4*std.amsMacro.len); - for (int i=0; i<4; i++) { - DivInstrumentSTD::OpMacro& op=std.opMacros[i]; + for (int i=0; i<4; i++) { + DivInstrumentSTD::OpMacro& op=std.opMacros[i]; - op.amMacroRel=reader.readI(); - op.arMacroRel=reader.readI(); - op.drMacroRel=reader.readI(); - op.multMacroRel=reader.readI(); - op.rrMacroRel=reader.readI(); - op.slMacroRel=reader.readI(); - op.tlMacroRel=reader.readI(); - op.dt2MacroRel=reader.readI(); - op.rsMacroRel=reader.readI(); - op.dtMacroRel=reader.readI(); - op.d2rMacroRel=reader.readI(); - op.ssgMacroRel=reader.readI(); - } - } + op.amMacro.len=reader.readI(); + op.arMacro.len=reader.readI(); + op.drMacro.len=reader.readI(); + op.multMacro.len=reader.readI(); + op.rrMacro.len=reader.readI(); + op.slMacro.len=reader.readI(); + op.tlMacro.len=reader.readI(); + op.dt2Macro.len=reader.readI(); + op.rsMacro.len=reader.readI(); + op.dtMacro.len=reader.readI(); + op.d2rMacro.len=reader.readI(); + op.ssgMacro.len=reader.readI(); - // extended op macros - if (version>=61) { - for (int i=0; i<4; i++) { - DivInstrumentSTD::OpMacro& op=std.opMacros[i]; + op.amMacro.loop=reader.readI(); + op.arMacro.loop=reader.readI(); + op.drMacro.loop=reader.readI(); + op.multMacro.loop=reader.readI(); + op.rrMacro.loop=reader.readI(); + op.slMacro.loop=reader.readI(); + op.tlMacro.loop=reader.readI(); + op.dt2Macro.loop=reader.readI(); + op.rsMacro.loop=reader.readI(); + op.dtMacro.loop=reader.readI(); + op.d2rMacro.loop=reader.readI(); + op.ssgMacro.loop=reader.readI(); - op.damMacroLen=reader.readI(); - op.dvbMacroLen=reader.readI(); - op.egtMacroLen=reader.readI(); - op.kslMacroLen=reader.readI(); - op.susMacroLen=reader.readI(); - op.vibMacroLen=reader.readI(); - op.wsMacroLen=reader.readI(); - op.ksrMacroLen=reader.readI(); + op.amMacro.open=reader.readC(); + op.arMacro.open=reader.readC(); + op.drMacro.open=reader.readC(); + op.multMacro.open=reader.readC(); + op.rrMacro.open=reader.readC(); + op.slMacro.open=reader.readC(); + op.tlMacro.open=reader.readC(); + op.dt2Macro.open=reader.readC(); + op.rsMacro.open=reader.readC(); + op.dtMacro.open=reader.readC(); + op.d2rMacro.open=reader.readC(); + op.ssgMacro.open=reader.readC(); + } - op.damMacroLoop=reader.readI(); - op.dvbMacroLoop=reader.readI(); - op.egtMacroLoop=reader.readI(); - op.kslMacroLoop=reader.readI(); - op.susMacroLoop=reader.readI(); - op.vibMacroLoop=reader.readI(); - op.wsMacroLoop=reader.readI(); - op.ksrMacroLoop=reader.readI(); - - op.damMacroRel=reader.readI(); - op.dvbMacroRel=reader.readI(); - op.egtMacroRel=reader.readI(); - op.kslMacroRel=reader.readI(); - op.susMacroRel=reader.readI(); - op.vibMacroRel=reader.readI(); - op.wsMacroRel=reader.readI(); - op.ksrMacroRel=reader.readI(); - - op.damMacroOpen=reader.readC(); - op.dvbMacroOpen=reader.readC(); - op.egtMacroOpen=reader.readC(); - op.kslMacroOpen=reader.readC(); - op.susMacroOpen=reader.readC(); - op.vibMacroOpen=reader.readC(); - op.wsMacroOpen=reader.readC(); - op.ksrMacroOpen=reader.readC(); + for (int i=0; i<4; i++) { + DivInstrumentSTD::OpMacro& op=std.opMacros[i]; + reader.readByte(op.amMacro.val,op.amMacro.len,1); + reader.readByte(op.arMacro.val,op.arMacro.len,1); + reader.readByte(op.drMacro.val,op.drMacro.len,1); + reader.readByte(op.multMacro.val,op.multMacro.len,1); + reader.readByte(op.rrMacro.val,op.rrMacro.len,1); + reader.readByte(op.slMacro.val,op.slMacro.len,1); + reader.readByte(op.tlMacro.val,op.tlMacro.len,1); + reader.readByte(op.dt2Macro.val,op.dt2Macro.len,1); + reader.readByte(op.rsMacro.val,op.rsMacro.len,1); + reader.readByte(op.dtMacro.val,op.dtMacro.len,1); + reader.readByte(op.d2rMacro.val,op.d2rMacro.len,1); + reader.readByte(op.ssgMacro.val,op.ssgMacro.len,1); + } } - for (int i=0; i<4; i++) { - DivInstrumentSTD::OpMacro& op=std.opMacros[i]; - reader.read(op.damMacro,op.damMacroLen); - reader.read(op.dvbMacro,op.dvbMacroLen); - reader.read(op.egtMacro,op.egtMacroLen); - reader.read(op.kslMacro,op.kslMacroLen); - reader.read(op.susMacro,op.susMacroLen); - reader.read(op.vibMacro,op.vibMacroLen); - reader.read(op.wsMacro,op.wsMacroLen); - reader.read(op.ksrMacro,op.ksrMacroLen); + // release points + if (version>=44) { + std.volMacro.rel=reader.readI(); + std.arpMacro.rel=reader.readI(); + std.dutyMacro.rel=reader.readI(); + std.waveMacro.rel=reader.readI(); + std.pitchMacro.rel=reader.readI(); + std.ex1Macro.rel=reader.readI(); + std.ex2Macro.rel=reader.readI(); + std.ex3Macro.rel=reader.readI(); + std.algMacro.rel=reader.readI(); + std.fbMacro.rel=reader.readI(); + std.fmsMacro.rel=reader.readI(); + std.amsMacro.rel=reader.readI(); + + for (int i=0; i<4; i++) { + DivInstrumentSTD::OpMacro& op=std.opMacros[i]; + + op.amMacro.rel=reader.readI(); + op.arMacro.rel=reader.readI(); + op.drMacro.rel=reader.readI(); + op.multMacro.rel=reader.readI(); + op.rrMacro.rel=reader.readI(); + op.slMacro.rel=reader.readI(); + op.tlMacro.rel=reader.readI(); + op.dt2Macro.rel=reader.readI(); + op.rsMacro.rel=reader.readI(); + op.dtMacro.rel=reader.readI(); + op.d2rMacro.rel=reader.readI(); + op.ssgMacro.rel=reader.readI(); + } + } + + // extended op macros + if (version>=61) { + for (int i=0; i<4; i++) { + DivInstrumentSTD::OpMacro& op=std.opMacros[i]; + + op.damMacro.len=reader.readI(); + op.dvbMacro.len=reader.readI(); + op.egtMacro.len=reader.readI(); + op.kslMacro.len=reader.readI(); + op.susMacro.len=reader.readI(); + op.vibMacro.len=reader.readI(); + op.wsMacro.len=reader.readI(); + op.ksrMacro.len=reader.readI(); + + op.damMacro.loop=reader.readI(); + op.dvbMacro.loop=reader.readI(); + op.egtMacro.loop=reader.readI(); + op.kslMacro.loop=reader.readI(); + op.susMacro.loop=reader.readI(); + op.vibMacro.loop=reader.readI(); + op.wsMacro.loop=reader.readI(); + op.ksrMacro.loop=reader.readI(); + + op.damMacro.rel=reader.readI(); + op.dvbMacro.rel=reader.readI(); + op.egtMacro.rel=reader.readI(); + op.kslMacro.rel=reader.readI(); + op.susMacro.rel=reader.readI(); + op.vibMacro.rel=reader.readI(); + op.wsMacro.rel=reader.readI(); + op.ksrMacro.rel=reader.readI(); + + op.damMacro.open=reader.readC(); + op.dvbMacro.open=reader.readC(); + op.egtMacro.open=reader.readC(); + op.kslMacro.open=reader.readC(); + op.susMacro.open=reader.readC(); + op.vibMacro.open=reader.readC(); + op.wsMacro.open=reader.readC(); + op.ksrMacro.open=reader.readC(); + } + + for (int i=0; i<4; i++) { + DivInstrumentSTD::OpMacro& op=std.opMacros[i]; + reader.readByte(op.damMacro.val,op.damMacro.len,1); + reader.readByte(op.dvbMacro.val,op.dvbMacro.len,1); + reader.readByte(op.egtMacro.val,op.egtMacro.len,1); + reader.readByte(op.kslMacro.val,op.kslMacro.len,1); + reader.readByte(op.susMacro.val,op.susMacro.len,1); + reader.readByte(op.vibMacro.val,op.vibMacro.len,1); + reader.readByte(op.wsMacro.val,op.wsMacro.len,1); + reader.readByte(op.ksrMacro.val,op.ksrMacro.len,1); + } } } @@ -814,16 +997,16 @@ DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) { // clear noise macro if PCE instrument and version<63 if (version<63 && type==DIV_INS_PCE) { - std.dutyMacroLen=0; - std.dutyMacroLoop=-1; - std.dutyMacroRel=-1; + std.dutyMacro.len=0; + std.dutyMacro.loop=-1; + std.dutyMacro.rel=-1; } // clear wave macro if OPLL instrument and version<70 if (version<70 && type==DIV_INS_OPLL) { - std.waveMacroLen=0; - std.waveMacroLoop=-1; - std.waveMacroRel=-1; + std.waveMacro.len=0; + std.waveMacro.loop=-1; + std.waveMacro.rel=-1; } // sample map @@ -845,51 +1028,53 @@ DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) { } // more macros - if (version>=76) { - std.panLMacroLen=reader.readI(); - std.panRMacroLen=reader.readI(); - std.phaseResetMacroLen=reader.readI(); - std.ex4MacroLen=reader.readI(); - std.ex5MacroLen=reader.readI(); - std.ex6MacroLen=reader.readI(); - std.ex7MacroLen=reader.readI(); - std.ex8MacroLen=reader.readI(); + if (!istest) { + if (version>=76) { + std.panLMacro.len=reader.readI(); + std.panRMacro.len=reader.readI(); + std.phaseResetMacro.len=reader.readI(); + std.ex4Macro.len=reader.readI(); + std.ex5Macro.len=reader.readI(); + std.ex6Macro.len=reader.readI(); + std.ex7Macro.len=reader.readI(); + std.ex8Macro.len=reader.readI(); - std.panLMacroLoop=reader.readI(); - std.panRMacroLoop=reader.readI(); - std.phaseResetMacroLoop=reader.readI(); - std.ex4MacroLoop=reader.readI(); - std.ex5MacroLoop=reader.readI(); - std.ex6MacroLoop=reader.readI(); - std.ex7MacroLoop=reader.readI(); - std.ex8MacroLoop=reader.readI(); + std.panLMacro.loop=reader.readI(); + std.panRMacro.loop=reader.readI(); + std.phaseResetMacro.loop=reader.readI(); + std.ex4Macro.loop=reader.readI(); + std.ex5Macro.loop=reader.readI(); + std.ex6Macro.loop=reader.readI(); + std.ex7Macro.loop=reader.readI(); + std.ex8Macro.loop=reader.readI(); - std.panLMacroRel=reader.readI(); - std.panRMacroRel=reader.readI(); - std.phaseResetMacroRel=reader.readI(); - std.ex4MacroRel=reader.readI(); - std.ex5MacroRel=reader.readI(); - std.ex6MacroRel=reader.readI(); - std.ex7MacroRel=reader.readI(); - std.ex8MacroRel=reader.readI(); + std.panLMacro.rel=reader.readI(); + std.panRMacro.rel=reader.readI(); + std.phaseResetMacro.rel=reader.readI(); + std.ex4Macro.rel=reader.readI(); + std.ex5Macro.rel=reader.readI(); + std.ex6Macro.rel=reader.readI(); + std.ex7Macro.rel=reader.readI(); + std.ex8Macro.rel=reader.readI(); - std.panLMacroOpen=reader.readC(); - std.panRMacroOpen=reader.readC(); - std.phaseResetMacroOpen=reader.readC(); - std.ex4MacroOpen=reader.readC(); - std.ex5MacroOpen=reader.readC(); - std.ex6MacroOpen=reader.readC(); - std.ex7MacroOpen=reader.readC(); - std.ex8MacroOpen=reader.readC(); + std.panLMacro.open=reader.readC(); + std.panRMacro.open=reader.readC(); + std.phaseResetMacro.open=reader.readC(); + std.ex4Macro.open=reader.readC(); + std.ex5Macro.open=reader.readC(); + std.ex6Macro.open=reader.readC(); + std.ex7Macro.open=reader.readC(); + std.ex8Macro.open=reader.readC(); - reader.read(std.panLMacro,4*std.panLMacroLen); - reader.read(std.panRMacro,4*std.panRMacroLen); - reader.read(std.phaseResetMacro,4*std.phaseResetMacroLen); - reader.read(std.ex4Macro,4*std.ex4MacroLen); - reader.read(std.ex5Macro,4*std.ex5MacroLen); - reader.read(std.ex6Macro,4*std.ex6MacroLen); - reader.read(std.ex7Macro,4*std.ex7MacroLen); - reader.read(std.ex8Macro,4*std.ex8MacroLen); + reader.read(std.panLMacro.val,4*std.panLMacro.len); + reader.read(std.panRMacro.val,4*std.panRMacro.len); + reader.read(std.phaseResetMacro.val,4*std.phaseResetMacro.len); + reader.read(std.ex4Macro.val,4*std.ex4Macro.len); + reader.read(std.ex5Macro.val,4*std.ex5Macro.len); + reader.read(std.ex6Macro.val,4*std.ex6Macro.len); + reader.read(std.ex7Macro.val,4*std.ex7Macro.len); + reader.read(std.ex8Macro.val,4*std.ex8Macro.len); + } } // FDS diff --git a/src/engine/instrument.h b/src/engine/instrument.h index 8109030ed..dd56ef84c 100644 --- a/src/engine/instrument.h +++ b/src/engine/instrument.h @@ -26,7 +26,7 @@ // NOTICE! // before adding new instrument types to this struct, please ask me first. // absolutely zero support granted to conflicting formats. -enum DivInstrumentType { +enum DivInstrumentType : unsigned short { DIV_INS_STD=0, DIV_INS_FM=1, DIV_INS_GB=2, @@ -77,6 +77,7 @@ struct DivInstrumentFM { bool fixedDrums; unsigned short kickFreq, snareHatFreq, tomTopFreq; struct Operator { + bool enable; unsigned char am, ar, dr, mult, rr, sl, tl, dt2, rs, dt, d2r, ssgEnv; unsigned char dam, dvb, egt, ksl, sus, vib, ws, ksr; // YMU759/OPL/OPZ Operator(): @@ -151,248 +152,122 @@ struct DivInstrumentFM { }; // this is getting out of hand +struct DivInstrumentMacro { + String name; + int val[256]; + int height; + unsigned int mode; + bool open; + unsigned char len; + signed char loop; + signed char rel; + DivInstrumentMacro(String n, int h=~0, bool initOpen=false): + name(n), + val{0}, + height(h), + mode(0), + open(initOpen), + len(0), + loop(-1), + rel(-1) {} +}; + struct DivInstrumentSTD { - int volMacro[256]; - int arpMacro[256]; - int dutyMacro[256]; - int waveMacro[256]; - int pitchMacro[256]; - int ex1Macro[256]; - int ex2Macro[256]; - int ex3Macro[256]; - int algMacro[256]; - int fbMacro[256]; - int fmsMacro[256]; - int amsMacro[256]; - int panLMacro[256]; - int panRMacro[256]; - int phaseResetMacro[256]; - int ex4Macro[256]; - int ex5Macro[256]; - int ex6Macro[256]; - int ex7Macro[256]; - int ex8Macro[256]; + DivInstrumentMacro volMacro; + DivInstrumentMacro arpMacro; + DivInstrumentMacro dutyMacro; + DivInstrumentMacro waveMacro; + DivInstrumentMacro pitchMacro; + DivInstrumentMacro ex1Macro; + DivInstrumentMacro ex2Macro; + DivInstrumentMacro ex3Macro; + DivInstrumentMacro algMacro; + DivInstrumentMacro fbMacro; + DivInstrumentMacro fmsMacro; + DivInstrumentMacro fms2Macro; + DivInstrumentMacro amsMacro; + DivInstrumentMacro ams2Macro; + DivInstrumentMacro panLMacro; + DivInstrumentMacro panRMacro; + DivInstrumentMacro phaseResetMacro; + DivInstrumentMacro ex4Macro; + DivInstrumentMacro ex5Macro; + DivInstrumentMacro ex6Macro; + DivInstrumentMacro ex7Macro; + DivInstrumentMacro ex8Macro; - bool arpMacroMode; - unsigned char volMacroHeight, dutyMacroHeight, waveMacroHeight; - - bool volMacroOpen, arpMacroOpen, dutyMacroOpen, waveMacroOpen; - bool pitchMacroOpen, ex1MacroOpen, ex2MacroOpen, ex3MacroOpen; - bool algMacroOpen, fbMacroOpen, fmsMacroOpen, amsMacroOpen; - bool panLMacroOpen, panRMacroOpen, phaseResetMacroOpen, ex4MacroOpen; - bool ex5MacroOpen, ex6MacroOpen, ex7MacroOpen, ex8MacroOpen; - - unsigned char volMacroLen, arpMacroLen, dutyMacroLen, waveMacroLen; - unsigned char pitchMacroLen, ex1MacroLen, ex2MacroLen, ex3MacroLen; - unsigned char algMacroLen, fbMacroLen, fmsMacroLen, amsMacroLen; - unsigned char panLMacroLen, panRMacroLen, phaseResetMacroLen, ex4MacroLen; - unsigned char ex5MacroLen, ex6MacroLen, ex7MacroLen, ex8MacroLen; - - signed char volMacroLoop, arpMacroLoop, dutyMacroLoop, waveMacroLoop; - signed char pitchMacroLoop, ex1MacroLoop, ex2MacroLoop, ex3MacroLoop; - signed char algMacroLoop, fbMacroLoop, fmsMacroLoop, amsMacroLoop; - signed char panLMacroLoop, panRMacroLoop, phaseResetMacroLoop, ex4MacroLoop; - signed char ex5MacroLoop, ex6MacroLoop, ex7MacroLoop, ex8MacroLoop; - - signed char volMacroRel, arpMacroRel, dutyMacroRel, waveMacroRel; - signed char pitchMacroRel, ex1MacroRel, ex2MacroRel, ex3MacroRel; - signed char algMacroRel, fbMacroRel, fmsMacroRel, amsMacroRel; - signed char panLMacroRel, panRMacroRel, phaseResetMacroRel, ex4MacroRel; - signed char ex5MacroRel, ex6MacroRel, ex7MacroRel, ex8MacroRel; struct OpMacro { // ar, dr, mult, rr, sl, tl, dt2, rs, dt, d2r, ssgEnv; - unsigned char amMacro[256]; - unsigned char arMacro[256]; - unsigned char drMacro[256]; - unsigned char multMacro[256]; - unsigned char rrMacro[256]; - unsigned char slMacro[256]; - unsigned char tlMacro[256]; - unsigned char dt2Macro[256]; - unsigned char rsMacro[256]; - unsigned char dtMacro[256]; - unsigned char d2rMacro[256]; - unsigned char ssgMacro[256]; - unsigned char damMacro[256]; - unsigned char dvbMacro[256]; - unsigned char egtMacro[256]; - unsigned char kslMacro[256]; - unsigned char susMacro[256]; - unsigned char vibMacro[256]; - unsigned char wsMacro[256]; - unsigned char ksrMacro[256]; - bool amMacroOpen, arMacroOpen, drMacroOpen, multMacroOpen; - bool rrMacroOpen, slMacroOpen, tlMacroOpen, dt2MacroOpen; - bool rsMacroOpen, dtMacroOpen, d2rMacroOpen, ssgMacroOpen; - bool damMacroOpen, dvbMacroOpen, egtMacroOpen, kslMacroOpen; - bool susMacroOpen, vibMacroOpen, wsMacroOpen, ksrMacroOpen; - unsigned char amMacroLen, arMacroLen, drMacroLen, multMacroLen; - unsigned char rrMacroLen, slMacroLen, tlMacroLen, dt2MacroLen; - unsigned char rsMacroLen, dtMacroLen, d2rMacroLen, ssgMacroLen; - unsigned char damMacroLen, dvbMacroLen, egtMacroLen, kslMacroLen; - unsigned char susMacroLen, vibMacroLen, wsMacroLen, ksrMacroLen; - signed char amMacroLoop, arMacroLoop, drMacroLoop, multMacroLoop; - signed char rrMacroLoop, slMacroLoop, tlMacroLoop, dt2MacroLoop; - signed char rsMacroLoop, dtMacroLoop, d2rMacroLoop, ssgMacroLoop; - signed char damMacroLoop, dvbMacroLoop, egtMacroLoop, kslMacroLoop; - signed char susMacroLoop, vibMacroLoop, wsMacroLoop, ksrMacroLoop; - signed char amMacroRel, arMacroRel, drMacroRel, multMacroRel; - signed char rrMacroRel, slMacroRel, tlMacroRel, dt2MacroRel; - signed char rsMacroRel, dtMacroRel, d2rMacroRel, ssgMacroRel; - signed char damMacroRel, dvbMacroRel, egtMacroRel, kslMacroRel; - signed char susMacroRel, vibMacroRel, wsMacroRel, ksrMacroRel; + DivInstrumentMacro amMacro; + DivInstrumentMacro arMacro; + DivInstrumentMacro drMacro; + DivInstrumentMacro multMacro; + DivInstrumentMacro rrMacro; + DivInstrumentMacro slMacro; + DivInstrumentMacro tlMacro; + DivInstrumentMacro dt2Macro; + DivInstrumentMacro rsMacro; + DivInstrumentMacro dtMacro; + DivInstrumentMacro d2rMacro; + DivInstrumentMacro ssgMacro; + DivInstrumentMacro damMacro; + DivInstrumentMacro dvbMacro; + DivInstrumentMacro egtMacro; + DivInstrumentMacro kslMacro; + DivInstrumentMacro susMacro; + DivInstrumentMacro vibMacro; + DivInstrumentMacro wsMacro; + DivInstrumentMacro ksrMacro; OpMacro(): - amMacroOpen(false), arMacroOpen(false), drMacroOpen(false), multMacroOpen(false), - rrMacroOpen(false), slMacroOpen(false), tlMacroOpen(true), dt2MacroOpen(false), - rsMacroOpen(false), dtMacroOpen(false), d2rMacroOpen(false), ssgMacroOpen(false), - damMacroOpen(false), dvbMacroOpen(false), egtMacroOpen(false), kslMacroOpen(false), - susMacroOpen(false), vibMacroOpen(false), wsMacroOpen(false), ksrMacroOpen(false), - amMacroLen(0), arMacroLen(0), drMacroLen(0), multMacroLen(0), - rrMacroLen(0), slMacroLen(0), tlMacroLen(0), dt2MacroLen(0), - rsMacroLen(0), dtMacroLen(0), d2rMacroLen(0), ssgMacroLen(0), - damMacroLen(0), dvbMacroLen(0), egtMacroLen(0), kslMacroLen(0), - susMacroLen(0), vibMacroLen(0), wsMacroLen(0), ksrMacroLen(0), - amMacroLoop(-1), arMacroLoop(-1), drMacroLoop(-1), multMacroLoop(-1), - rrMacroLoop(-1), slMacroLoop(-1), tlMacroLoop(-1), dt2MacroLoop(-1), - rsMacroLoop(-1), dtMacroLoop(-1), d2rMacroLoop(-1), ssgMacroLoop(-1), - damMacroLoop(-1), dvbMacroLoop(-1), egtMacroLoop(-1), kslMacroLoop(-1), - susMacroLoop(-1), vibMacroLoop(-1), wsMacroLoop(-1), ksrMacroLoop(-1), - amMacroRel(-1), arMacroRel(-1), drMacroRel(-1), multMacroRel(-1), - rrMacroRel(-1), slMacroRel(-1), tlMacroRel(-1), dt2MacroRel(-1), - rsMacroRel(-1), dtMacroRel(-1), d2rMacroRel(-1), ssgMacroRel(-1), - damMacroRel(-1), dvbMacroRel(-1), egtMacroRel(-1), kslMacroRel(-1), - susMacroRel(-1), vibMacroRel(-1), wsMacroRel(-1), ksrMacroRel(-1) { - memset(amMacro,0,256); - memset(arMacro,0,256); - memset(drMacro,0,256); - memset(multMacro,0,256); - memset(rrMacro,0,256); - memset(slMacro,0,256); - memset(tlMacro,0,256); - memset(dt2Macro,0,256); - memset(rsMacro,0,256); - memset(dtMacro,0,256); - memset(d2rMacro,0,256); - memset(ssgMacro,0,256); - memset(damMacro,0,256); - memset(dvbMacro,0,256); - memset(egtMacro,0,256); - memset(kslMacro,0,256); - memset(susMacro,0,256); - memset(vibMacro,0,256); - memset(wsMacro,0,256); - memset(ksrMacro,0,256); - } + amMacro("am"), arMacro("ar"), drMacro("dr"), multMacro("mult"), + rrMacro("rr"), slMacro("sl"), tlMacro("tl",~0,true), dt2Macro("dt2"), + rsMacro("rs"), dtMacro("dt"), d2rMacro("d2r"), ssgMacro("ssg"), + damMacro("dam"), dvbMacro("dvb"), egtMacro("egt"), kslMacro("ksl"), + susMacro("sus"), vibMacro("vib"), wsMacro("ws"), ksrMacro("ksr") {} } opMacros[4]; + struct WaveSynthMacro { + DivInstrumentMacro wave1Macro, wave2Macro; + DivInstrumentMacro rateDividerMacro; + DivInstrumentMacro effectMacro; + DivInstrumentMacro oneShotMacro, enabledMacro, globalMacro; + DivInstrumentMacro speedMacro, param1Macro, param2Macro, param3Macro, param4Macro; + WaveSynthMacro(): + wave1Macro("wave1"), + wave2Macro("wave2"), + rateDividerMacro("rateDivider"), + effectMacro("effect"), + oneShotMacro("oneShot"), + enabledMacro("enabled"), + globalMacro("global"), + speedMacro("speed"), + param1Macro("param1"), + param2Macro("param2"), + param3Macro("param3"), + param4Macro("param4") {} + } ws; DivInstrumentSTD(): - arpMacroMode(false), - volMacroHeight(15), - dutyMacroHeight(3), - waveMacroHeight(63), - volMacroOpen(true), - arpMacroOpen(false), - dutyMacroOpen(false), - waveMacroOpen(false), - pitchMacroOpen(false), - ex1MacroOpen(false), - ex2MacroOpen(false), - ex3MacroOpen(false), - algMacroOpen(false), - fbMacroOpen(false), - fmsMacroOpen(false), - amsMacroOpen(false), - panLMacroOpen(false), - panRMacroOpen(false), - phaseResetMacroOpen(false), - ex4MacroOpen(false), - ex5MacroOpen(false), - ex6MacroOpen(false), - ex7MacroOpen(false), - ex8MacroOpen(false), - - volMacroLen(0), - arpMacroLen(0), - dutyMacroLen(0), - waveMacroLen(0), - pitchMacroLen(0), - ex1MacroLen(0), - ex2MacroLen(0), - ex3MacroLen(0), - algMacroLen(0), - fbMacroLen(0), - fmsMacroLen(0), - amsMacroLen(0), - panLMacroLen(0), - panRMacroLen(0), - phaseResetMacroLen(0), - ex4MacroLen(0), - ex5MacroLen(0), - ex6MacroLen(0), - ex7MacroLen(0), - ex8MacroLen(0), - - volMacroLoop(-1), - arpMacroLoop(-1), - dutyMacroLoop(-1), - waveMacroLoop(-1), - pitchMacroLoop(-1), - ex1MacroLoop(-1), - ex2MacroLoop(-1), - ex3MacroLoop(-1), - algMacroLoop(-1), - fbMacroLoop(-1), - fmsMacroLoop(-1), - amsMacroLoop(-1), - panLMacroLoop(-1), - panRMacroLoop(-1), - phaseResetMacroLoop(-1), - ex4MacroLoop(-1), - ex5MacroLoop(-1), - ex6MacroLoop(-1), - ex7MacroLoop(-1), - ex8MacroLoop(-1), - - volMacroRel(-1), - arpMacroRel(-1), - dutyMacroRel(-1), - waveMacroRel(-1), - pitchMacroRel(-1), - ex1MacroRel(-1), - ex2MacroRel(-1), - ex3MacroRel(-1), - algMacroRel(-1), - fbMacroRel(-1), - fmsMacroRel(-1), - amsMacroRel(-1), - panLMacroRel(-1), - panRMacroRel(-1), - phaseResetMacroRel(-1), - ex4MacroRel(-1), - ex5MacroRel(-1), - ex6MacroRel(-1), - ex7MacroRel(-1), - ex8MacroRel(-1) { - memset(volMacro,0,256*sizeof(int)); - memset(arpMacro,0,256*sizeof(int)); - memset(dutyMacro,0,256*sizeof(int)); - memset(waveMacro,0,256*sizeof(int)); - memset(pitchMacro,0,256*sizeof(int)); - memset(ex1Macro,0,256*sizeof(int)); - memset(ex2Macro,0,256*sizeof(int)); - memset(ex3Macro,0,256*sizeof(int)); - memset(algMacro,0,256*sizeof(int)); - memset(fbMacro,0,256*sizeof(int)); - memset(fmsMacro,0,256*sizeof(int)); - memset(amsMacro,0,256*sizeof(int)); - memset(panLMacro,0,256*sizeof(int)); - memset(panRMacro,0,256*sizeof(int)); - memset(phaseResetMacro,0,256*sizeof(int)); - memset(ex4Macro,0,256*sizeof(int)); - memset(ex5Macro,0,256*sizeof(int)); - memset(ex6Macro,0,256*sizeof(int)); - memset(ex7Macro,0,256*sizeof(int)); - memset(ex8Macro,0,256*sizeof(int)); - } + volMacro("vol",15,true), + arpMacro("arp"), + dutyMacro("duty",3), + waveMacro("wave",63), + pitchMacro("pitch"), + ex1Macro("ex1"), + ex2Macro("ex2"), + ex3Macro("ex3"), + algMacro("alg"), + fbMacro("fb"), + fmsMacro("fms"), + fms2Macro("fms2"), + amsMacro("ams"), + ams2Macro("ams2"), + panLMacro("panL"), + panRMacro("panR"), + phaseResetMacro("phaseReset"), + ex4Macro("ex4"), + ex5Macro("ex5"), + ex6Macro("ex6"), + ex7Macro("ex7"), + ex8Macro("ex8") {} }; struct DivInstrumentGB { @@ -540,6 +415,13 @@ struct DivInstrument { */ void putInsData(SafeWriter* w); + /** + * save the macro to a SafeWriter. + * @param m the macro. + * @param w the SafeWriter in question. + */ + void putMacroData(DivInstrumentMacro m, SafeWriter* w); + /** * read instrument data in .fui format. * @param reader the reader. @@ -548,6 +430,15 @@ struct DivInstrument { */ DivDataErrors readInsData(SafeReader& reader, short version); + /** + * read macro data in .fui format. + * @param m the macro. + * @param reader the reader. + * @param version the format version. + * @return a DivDataErrors. + */ + void readMacroData(DivInstrumentMacro& m, SafeReader& reader, short version); + /** * save this instrument to a file. * @param path file path. diff --git a/src/engine/macroInt.cpp b/src/engine/macroInt.cpp index d74b59a6c..9a8789427 100644 --- a/src/engine/macroInt.cpp +++ b/src/engine/macroInt.cpp @@ -20,85 +20,39 @@ #include "macroInt.h" #include "instrument.h" -#define doMacro(finished,had,has,val,pos,source,sourceLen,sourceLoop,sourceRel) \ - if (finished) finished=false; \ - if (had!=has) { \ - finished=true; \ - } \ - had=has; \ - if (has) { \ - val=source[pos++]; \ - if (sourceRel>=0 && pos>sourceRel && !released) { \ - if (sourceLoop=0 && sourceLoop=sourceLen) { \ - if (sourceLoop=0 && (sourceLoop>=sourceRel || sourceRel>=sourceLen)) { \ - pos=sourceLoop; \ - } else { \ - has=false; \ - } \ - } \ +void DivMacroStruct::doMacro(DivInstrumentMacro& source, bool released) { + if (finished) finished=false; + if (had!=has) { + finished=true; } + had=has; + if (has) { + val=source.val[pos++]; + if (source.rel>=0 && pos>source.rel && !released) { + if (source.loop=0 && source.loop=source.len) { + if (source.loop=0 && (source.loop>=source.rel || source.rel>=source.len)) { + pos=source.loop; + } else { + has=false; + } + } + } +} // CPU hell void DivMacroInt::next() { if (ins==NULL) return; - - doMacro(finishedVol,hadVol,hasVol,vol,volPos,ins->std.volMacro,ins->std.volMacroLen,ins->std.volMacroLoop,ins->std.volMacroRel); - doMacro(finishedArp,hadArp,hasArp,arp,arpPos,ins->std.arpMacro,ins->std.arpMacroLen,ins->std.arpMacroLoop,ins->std.arpMacroRel); - doMacro(finishedDuty,hadDuty,hasDuty,duty,dutyPos,ins->std.dutyMacro,ins->std.dutyMacroLen,ins->std.dutyMacroLoop,ins->std.dutyMacroRel); - doMacro(finishedWave,hadWave,hasWave,wave,wavePos,ins->std.waveMacro,ins->std.waveMacroLen,ins->std.waveMacroLoop,ins->std.waveMacroRel); - - doMacro(finishedPitch,hadPitch,hasPitch,pitch,pitchPos,ins->std.pitchMacro,ins->std.pitchMacroLen,ins->std.pitchMacroLoop,ins->std.pitchMacroRel); - doMacro(finishedEx1,hadEx1,hasEx1,ex1,ex1Pos,ins->std.ex1Macro,ins->std.ex1MacroLen,ins->std.ex1MacroLoop,ins->std.ex1MacroRel); - doMacro(finishedEx2,hadEx2,hasEx2,ex2,ex2Pos,ins->std.ex2Macro,ins->std.ex2MacroLen,ins->std.ex2MacroLoop,ins->std.ex2MacroRel); - doMacro(finishedEx3,hadEx3,hasEx3,ex3,ex3Pos,ins->std.ex3Macro,ins->std.ex3MacroLen,ins->std.ex3MacroLoop,ins->std.ex3MacroRel); - - doMacro(finishedAlg,hadAlg,hasAlg,alg,algPos,ins->std.algMacro,ins->std.algMacroLen,ins->std.algMacroLoop,ins->std.algMacroRel); - doMacro(finishedFb,hadFb,hasFb,fb,fbPos,ins->std.fbMacro,ins->std.fbMacroLen,ins->std.fbMacroLoop,ins->std.fbMacroRel); - doMacro(finishedFms,hadFms,hasFms,fms,fmsPos,ins->std.fmsMacro,ins->std.fmsMacroLen,ins->std.fmsMacroLoop,ins->std.fmsMacroRel); - doMacro(finishedAms,hadAms,hasAms,ams,amsPos,ins->std.amsMacro,ins->std.amsMacroLen,ins->std.amsMacroLoop,ins->std.amsMacroRel); - - doMacro(finishedPanL,hadPanL,hasPanL,panL,panLPos,ins->std.panLMacro,ins->std.panLMacroLen,ins->std.panLMacroLoop,ins->std.panLMacroRel); - doMacro(finishedPanR,hadPanR,hasPanR,panR,panRPos,ins->std.panRMacro,ins->std.panRMacroLen,ins->std.panRMacroLoop,ins->std.panRMacroRel); - doMacro(finishedPhaseReset,hadPhaseReset,hasPhaseReset,phaseReset,phaseResetPos,ins->std.phaseResetMacro,ins->std.phaseResetMacroLen,ins->std.phaseResetMacroLoop,ins->std.phaseResetMacroRel); - doMacro(finishedEx4,hadEx4,hasEx4,ex4,ex4Pos,ins->std.ex4Macro,ins->std.ex4MacroLen,ins->std.ex4MacroLoop,ins->std.ex4MacroRel); - doMacro(finishedEx5,hadEx5,hasEx5,ex5,ex5Pos,ins->std.ex5Macro,ins->std.ex5MacroLen,ins->std.ex5MacroLoop,ins->std.ex5MacroRel); - doMacro(finishedEx6,hadEx6,hasEx6,ex6,ex6Pos,ins->std.ex6Macro,ins->std.ex6MacroLen,ins->std.ex6MacroLoop,ins->std.ex6MacroRel); - doMacro(finishedEx7,hadEx7,hasEx7,ex7,ex7Pos,ins->std.ex7Macro,ins->std.ex7MacroLen,ins->std.ex7MacroLoop,ins->std.ex7MacroRel); - doMacro(finishedEx8,hadEx8,hasEx8,ex8,ex8Pos,ins->std.ex8Macro,ins->std.ex8MacroLen,ins->std.ex8MacroLoop,ins->std.ex8MacroRel); - - for (int i=0; i<4; i++) { - DivInstrumentSTD::OpMacro& m=ins->std.opMacros[i]; - IntOp& o=op[i]; - doMacro(o.finishedAm,o.hadAm,o.hasAm,o.am,o.amPos,m.amMacro,m.amMacroLen,m.amMacroLoop,m.amMacroRel); - doMacro(o.finishedAr,o.hadAr,o.hasAr,o.ar,o.arPos,m.arMacro,m.arMacroLen,m.arMacroLoop,m.arMacroRel); - doMacro(o.finishedDr,o.hadDr,o.hasDr,o.dr,o.drPos,m.drMacro,m.drMacroLen,m.drMacroLoop,m.drMacroRel); - doMacro(o.finishedMult,o.hadMult,o.hasMult,o.mult,o.multPos,m.multMacro,m.multMacroLen,m.multMacroLoop,m.multMacroRel); - - doMacro(o.finishedRr,o.hadRr,o.hasRr,o.rr,o.rrPos,m.rrMacro,m.rrMacroLen,m.rrMacroLoop,m.rrMacroRel); - doMacro(o.finishedSl,o.hadSl,o.hasSl,o.sl,o.slPos,m.slMacro,m.slMacroLen,m.slMacroLoop,m.slMacroRel); - doMacro(o.finishedTl,o.hadTl,o.hasTl,o.tl,o.tlPos,m.tlMacro,m.tlMacroLen,m.tlMacroLoop,m.tlMacroRel); - doMacro(o.finishedDt2,o.hadDt2,o.hasDt2,o.dt2,o.dt2Pos,m.dt2Macro,m.dt2MacroLen,m.dt2MacroLoop,m.dt2MacroRel); - - doMacro(o.finishedRs,o.hadRs,o.hasRs,o.rs,o.rsPos,m.rsMacro,m.rsMacroLen,m.rsMacroLoop,m.rsMacroRel); - doMacro(o.finishedDt,o.hadDt,o.hasDt,o.dt,o.dtPos,m.dtMacro,m.dtMacroLen,m.dtMacroLoop,m.dtMacroRel); - doMacro(o.finishedD2r,o.hadD2r,o.hasD2r,o.d2r,o.d2rPos,m.d2rMacro,m.d2rMacroLen,m.d2rMacroLoop,m.d2rMacroRel); - doMacro(o.finishedSsg,o.hadSsg,o.hasSsg,o.ssg,o.ssgPos,m.ssgMacro,m.ssgMacroLen,m.ssgMacroLoop,m.ssgMacroRel); - - doMacro(o.finishedDam,o.hadDam,o.hasDam,o.dam,o.damPos,m.damMacro,m.damMacroLen,m.damMacroLoop,m.damMacroRel); - doMacro(o.finishedDvb,o.hadDvb,o.hasDvb,o.dvb,o.dvbPos,m.dvbMacro,m.dvbMacroLen,m.dvbMacroLoop,m.dvbMacroRel); - doMacro(o.finishedEgt,o.hadEgt,o.hasEgt,o.egt,o.egtPos,m.egtMacro,m.egtMacroLen,m.egtMacroLoop,m.egtMacroRel); - doMacro(o.finishedKsl,o.hadKsl,o.hasKsl,o.ksl,o.kslPos,m.kslMacro,m.kslMacroLen,m.kslMacroLoop,m.kslMacroRel); - - doMacro(o.finishedSus,o.hadSus,o.hasSus,o.sus,o.susPos,m.susMacro,m.susMacroLen,m.susMacroLoop,m.susMacroRel); - doMacro(o.finishedVib,o.hadVib,o.hasVib,o.vib,o.vibPos,m.vibMacro,m.vibMacroLen,m.vibMacroLoop,m.vibMacroRel); - doMacro(o.finishedWs,o.hadWs,o.hasWs,o.ws,o.wsPos,m.wsMacro,m.wsMacroLen,m.wsMacroLoop,m.wsMacroRel); - doMacro(o.finishedKsr,o.hadKsr,o.hasKsr,o.ksr,o.ksrPos,m.ksrMacro,m.ksrMacroLen,m.ksrMacroLoop,m.ksrMacroRel); + // Run macros + if (!macroList.empty()) { + for (std::list::iterator iter = macroList.begin(); iter!= macroList.end(); iter++) { + iter->doMacro(released); + } } } @@ -108,312 +62,275 @@ void DivMacroInt::release() { void DivMacroInt::init(DivInstrument* which) { ins=which; - volPos=0; - arpPos=0; - dutyPos=0; - wavePos=0; - pitchPos=0; - ex1Pos=0; - ex2Pos=0; - ex3Pos=0; - algPos=0; - fbPos=0; - fmsPos=0; - amsPos=0; - panLPos=0; - panRPos=0; - phaseResetPos=0; - ex4Pos=0; - ex5Pos=0; - ex6Pos=0; - ex7Pos=0; - ex8Pos=0; + macroList.clear(); + // initialize common macros + vol.init(); + arp.init(); + duty.init(); + wave.init(); + pitch.init(); + ex1.init(); + ex2.init(); + ex3.init(); + alg.init(); + fb.init(); + fms.init(); + ams.init(); + fms2.init(); + ams2.init(); + panL.init(); + panR.init(); + phaseReset.init(); + ex4.init(); + ex5.init(); + ex6.init(); + ex7.init(); + ex8.init(); released=false; - hasVol=false; - hasArp=false; - hasDuty=false; - hasWave=false; - hasPitch=false; - hasEx1=false; - hasEx2=false; - hasEx3=false; - hasAlg=false; - hasFb=false; - hasFms=false; - hasAms=false; - hasPanL=false; - hasPanR=false; - hasPhaseReset=false; - hasEx4=false; - hasEx5=false; - hasEx6=false; - hasEx7=false; - hasEx8=false; - - hadVol=false; - hadArp=false; - hadDuty=false; - hadWave=false; - hadPitch=false; - hadEx1=false; - hadEx2=false; - hadEx3=false; - hadAlg=false; - hadFb=false; - hadFms=false; - hadAms=false; - hadPanL=false; - hadPanR=false; - hadPhaseReset=false; - hadEx4=false; - hadEx5=false; - hadEx6=false; - hadEx7=false; - hadEx8=false; - - willVol=false; - willArp=false; - willDuty=false; - willWave=false; - willPitch=false; - willEx1=false; - willEx2=false; - willEx3=false; - willAlg=false; - willFb=false; - willFms=false; - willAms=false; - willPanL=false; - willPanR=false; - willPhaseReset=false; - willEx4=false; - willEx5=false; - willEx6=false; - willEx7=false; - willEx8=false; - + // initialize FM operator macro op[0]=IntOp(); op[1]=IntOp(); op[2]=IntOp(); op[3]=IntOp(); - arpMode=false; + // initialize wavesynth macro + ws=IntWS(); if (ins==NULL) return; - if (ins->std.volMacroLen>0) { - hadVol=true; - hasVol=true; - willVol=true; + // prepare common macro + if (ins->std.volMacro.len>0) { + macroList.push_back(DivMacroExecList(vol,ins->std.volMacro)); + vol.prepare(&ins->std.volMacro); } - if (ins->std.arpMacroLen>0) { - hadArp=true; - hasArp=true; - willArp=true; + if (ins->std.arpMacro.len>0) { + macroList.push_back(DivMacroExecList(arp,ins->std.arpMacro)); + arp.prepare(&ins->std.arpMacro); } - if (ins->std.dutyMacroLen>0) { - hadDuty=true; - hasDuty=true; - willDuty=true; + if (ins->std.dutyMacro.len>0) { + macroList.push_back(DivMacroExecList(duty,ins->std.dutyMacro)); + duty.prepare(&ins->std.dutyMacro); } - if (ins->std.waveMacroLen>0) { - hadWave=true; - hasWave=true; - willWave=true; + if (ins->std.waveMacro.len>0) { + macroList.push_back(DivMacroExecList(wave,ins->std.waveMacro)); + wave.prepare(&ins->std.waveMacro); } - if (ins->std.pitchMacroLen>0) { - hadPitch=true; - hasPitch=true; - willPitch=true; + if (ins->std.pitchMacro.len>0) { + macroList.push_back(DivMacroExecList(pitch,ins->std.pitchMacro)); + pitch.prepare(&ins->std.pitchMacro); } - if (ins->std.ex1MacroLen>0) { - hadEx1=true; - hasEx1=true; - willEx1=true; + if (ins->std.ex1Macro.len>0) { + macroList.push_back(DivMacroExecList(ex1,ins->std.ex1Macro)); + ex1.prepare(&ins->std.ex1Macro); } - if (ins->std.ex2MacroLen>0) { - hadEx2=true; - hasEx2=true; - willEx2=true; + if (ins->std.ex2Macro.len>0) { + macroList.push_back(DivMacroExecList(ex2,ins->std.ex2Macro)); + ex2.prepare(&ins->std.ex2Macro); } - if (ins->std.ex3MacroLen>0) { - hadEx3=true; - hasEx3=true; - willEx3=true; + if (ins->std.ex3Macro.len>0) { + macroList.push_back(DivMacroExecList(ex3,ins->std.ex3Macro)); + ex3.prepare(&ins->std.ex3Macro); } - if (ins->std.algMacroLen>0) { - hadAlg=true; - hasAlg=true; - willAlg=true; + if (ins->std.algMacro.len>0) { + macroList.push_back(DivMacroExecList(alg,ins->std.algMacro)); + alg.prepare(&ins->std.algMacro); } - if (ins->std.fbMacroLen>0) { - hadFb=true; - hasFb=true; - willFb=true; + if (ins->std.fbMacro.len>0) { + macroList.push_back(DivMacroExecList(fb,ins->std.fbMacro)); + fb.prepare(&ins->std.fbMacro); } - if (ins->std.fmsMacroLen>0) { - hadFms=true; - hasFms=true; - willFms=true; + if (ins->std.fmsMacro.len>0) { + macroList.push_back(DivMacroExecList(fms,ins->std.fmsMacro)); + fms.prepare(&ins->std.fmsMacro); } - if (ins->std.amsMacroLen>0) { - hadAms=true; - hasAms=true; - willAms=true; + if (ins->std.fms2Macro.len>0) { + macroList.push_back(DivMacroExecList(fms2,ins->std.fms2Macro)); + fms2.prepare(&ins->std.fms2Macro); + } + if (ins->std.amsMacro.len>0) { + macroList.push_back(DivMacroExecList(ams,ins->std.amsMacro)); + ams.prepare(&ins->std.amsMacro); + } + if (ins->std.ams2Macro.len>0) { + macroList.push_back(DivMacroExecList(ams2,ins->std.ams2Macro)); + ams2.prepare(&ins->std.ams2Macro); } // TODO: other macros - if (ins->std.panLMacroLen>0) { - hadPanL=true; - hasPanL=true; - willPanL=true; + if (ins->std.panLMacro.len>0) { + macroList.push_back(DivMacroExecList(panL,ins->std.panLMacro)); + panL.prepare(&ins->std.panLMacro); } - if (ins->std.panRMacroLen>0) { - hadPanR=true; - hasPanR=true; - willPanR=true; + if (ins->std.panRMacro.len>0) { + macroList.push_back(DivMacroExecList(panR,ins->std.panRMacro)); + panR.prepare(&ins->std.panRMacro); } - if (ins->std.phaseResetMacroLen>0) { - hadPhaseReset=true; - hasPhaseReset=true; - willPhaseReset=true; + if (ins->std.phaseResetMacro.len>0) { + macroList.push_back(DivMacroExecList(phaseReset,ins->std.phaseResetMacro)); + phaseReset.prepare(&ins->std.phaseResetMacro); } - if (ins->std.ex4MacroLen>0) { - hadEx4=true; - hasEx4=true; - willEx4=true; + if (ins->std.ex4Macro.len>0) { + macroList.push_back(DivMacroExecList(ex4,ins->std.ex4Macro)); + ex4.prepare(&ins->std.ex4Macro); } - if (ins->std.ex5MacroLen>0) { - hadEx5=true; - hasEx5=true; - willEx5=true; + if (ins->std.ex5Macro.len>0) { + macroList.push_back(DivMacroExecList(ex5,ins->std.ex5Macro)); + ex5.prepare(&ins->std.ex5Macro); } - if (ins->std.ex6MacroLen>0) { - hadEx6=true; - hasEx6=true; - willEx6=true; + if (ins->std.ex6Macro.len>0) { + macroList.push_back(DivMacroExecList(ex6,ins->std.ex6Macro)); + ex6.prepare(&ins->std.ex6Macro); } - if (ins->std.ex7MacroLen>0) { - hadEx7=true; - hasEx7=true; - willEx7=true; + if (ins->std.ex7Macro.len>0) { + macroList.push_back(DivMacroExecList(ex7,ins->std.ex7Macro)); + ex7.prepare(&ins->std.ex7Macro); } - if (ins->std.ex8MacroLen>0) { - hadEx8=true; - hasEx8=true; - willEx8=true; - } - - if (ins->std.arpMacroMode) { - arpMode=true; + if (ins->std.ex8Macro.len>0) { + macroList.push_back(DivMacroExecList(ex8,ins->std.ex8Macro)); + ex8.prepare(&ins->std.ex8Macro); } + // prepare FM operator macros for (int i=0; i<4; i++) { DivInstrumentSTD::OpMacro& m=ins->std.opMacros[i]; IntOp& o=op[i]; - - if (m.amMacroLen>0) { - o.hadAm=true; - o.hasAm=true; - o.willAm=true; + if (m.amMacro.len>0) { + macroList.push_back(DivMacroExecList(o.am,m.amMacro)); + o.am.prepare(&m.amMacro); } - if (m.arMacroLen>0) { - o.hadAr=true; - o.hasAr=true; - o.willAr=true; + if (m.arMacro.len>0) { + macroList.push_back(DivMacroExecList(o.ar,m.arMacro)); + o.ar.prepare(&m.arMacro); } - if (m.drMacroLen>0) { - o.hadDr=true; - o.hasDr=true; - o.willDr=true; + if (m.drMacro.len>0) { + macroList.push_back(DivMacroExecList(o.dr,m.drMacro)); + o.dr.prepare(&m.drMacro); } - if (m.multMacroLen>0) { - o.hadMult=true; - o.hasMult=true; - o.willMult=true; + if (m.multMacro.len>0) { + macroList.push_back(DivMacroExecList(o.mult,m.multMacro)); + o.mult.prepare(&m.multMacro); } - if (m.rrMacroLen>0) { - o.hadRr=true; - o.hasRr=true; - o.willRr=true; + if (m.rrMacro.len>0) { + macroList.push_back(DivMacroExecList(o.rr,m.rrMacro)); + o.rr.prepare(&m.rrMacro); } - if (m.slMacroLen>0) { - o.hadSl=true; - o.hasSl=true; - o.willSl=true; + if (m.slMacro.len>0) { + macroList.push_back(DivMacroExecList(o.sl,m.slMacro)); + o.sl.prepare(&m.slMacro); } - if (m.tlMacroLen>0) { - o.hadTl=true; - o.hasTl=true; - o.willTl=true; + if (m.tlMacro.len>0) { + macroList.push_back(DivMacroExecList(o.tl,m.tlMacro)); + o.tl.prepare(&m.tlMacro); } - if (m.dt2MacroLen>0) { - o.hadDt2=true; - o.hasDt2=true; - o.willDt2=true; + if (m.dt2Macro.len>0) { + macroList.push_back(DivMacroExecList(o.dt2,m.dt2Macro)); + o.dt2.prepare(&m.dt2Macro); } - if (m.rsMacroLen>0) { - o.hadRs=true; - o.hasRs=true; - o.willRs=true; + if (m.rsMacro.len>0) { + macroList.push_back(DivMacroExecList(o.rs,m.rsMacro)); + o.rs.prepare(&m.rsMacro); } - if (m.dtMacroLen>0) { - o.hadDt=true; - o.hasDt=true; - o.willDt=true; + if (m.dtMacro.len>0) { + macroList.push_back(DivMacroExecList(o.dt,m.dtMacro)); + o.dt.prepare(&m.dtMacro); } - if (m.d2rMacroLen>0) { - o.hadD2r=true; - o.hasD2r=true; - o.willD2r=true; + if (m.d2rMacro.len>0) { + macroList.push_back(DivMacroExecList(o.d2r,m.d2rMacro)); + o.d2r.prepare(&m.d2rMacro); } - if (m.ssgMacroLen>0) { - o.hadSsg=true; - o.hasSsg=true; - o.willSsg=true; + if (m.ssgMacro.len>0) { + macroList.push_back(DivMacroExecList(o.ssg,m.ssgMacro)); + o.ssg.prepare(&m.ssgMacro); } - if (m.damMacroLen>0) { - o.hadDam=true; - o.hasDam=true; - o.willDam=true; + if (m.damMacro.len>0) { + macroList.push_back(DivMacroExecList(o.dam,m.damMacro)); + o.dam.prepare(&m.damMacro); } - if (m.dvbMacroLen>0) { - o.hadDvb=true; - o.hasDvb=true; - o.willDvb=true; + if (m.dvbMacro.len>0) { + macroList.push_back(DivMacroExecList(o.dvb,m.dvbMacro)); + o.dvb.prepare(&m.dvbMacro); } - if (m.egtMacroLen>0) { - o.hadEgt=true; - o.hasEgt=true; - o.willEgt=true; + if (m.egtMacro.len>0) { + macroList.push_back(DivMacroExecList(o.egt,m.egtMacro)); + o.egt.prepare(&m.egtMacro); } - if (m.kslMacroLen>0) { - o.hadKsl=true; - o.hasKsl=true; - o.willKsl=true; + if (m.kslMacro.len>0) { + macroList.push_back(DivMacroExecList(o.ksl,m.kslMacro)); + o.ksl.prepare(&m.kslMacro); } - if (m.susMacroLen>0) { - o.hadSus=true; - o.hasSus=true; - o.willSus=true; + if (m.susMacro.len>0) { + macroList.push_back(DivMacroExecList(o.sus,m.susMacro)); + o.sus.prepare(&m.susMacro); } - if (m.vibMacroLen>0) { - o.hadVib=true; - o.hasVib=true; - o.willVib=true; + if (m.vibMacro.len>0) { + macroList.push_back(DivMacroExecList(o.vib,m.vibMacro)); + o.vib.prepare(&m.vibMacro); } - if (m.wsMacroLen>0) { - o.hadWs=true; - o.hasWs=true; - o.willWs=true; + if (m.wsMacro.len>0) { + macroList.push_back(DivMacroExecList(o.ws,m.wsMacro)); + o.ws.prepare(&m.wsMacro); } - if (m.ksrMacroLen>0) { - o.hadKsr=true; - o.hasKsr=true; - o.willKsr=true; + if (m.ksrMacro.len>0) { + macroList.push_back(DivMacroExecList(o.ksr,m.ksrMacro)); + o.ksr.prepare(&m.ksrMacro); + } + } + + // prepare wavesynth macros + if (ins->std.ws.wave1Macro.len>0) { + macroList.push_back(DivMacroExecList(ws.wave1,ins->std.ws.wave1Macro)); + ws.wave1.prepare(&ins->std.ws.wave1Macro); + } + if (ins->std.ws.wave2Macro.len>0) { + macroList.push_back(DivMacroExecList(ws.wave2,ins->std.ws.wave2Macro)); + ws.wave2.prepare(&ins->std.ws.wave2Macro); + } + if (ins->std.ws.rateDividerMacro.len>0) { + macroList.push_back(DivMacroExecList(ws.rateDivider,ins->std.ws.rateDividerMacro)); + ws.rateDivider.prepare(&ins->std.ws.rateDividerMacro); + } + if (ins->std.ws.effectMacro.len>0) { + macroList.push_back(DivMacroExecList(ws.effect,ins->std.ws.effectMacro)); + ws.effect.prepare(&ins->std.ws.effectMacro); + } + if (ins->std.ws.oneShotMacro.len>0) { + macroList.push_back(DivMacroExecList(ws.oneShot,ins->std.ws.oneShotMacro)); + ws.oneShot.prepare(&ins->std.ws.oneShotMacro); + } + if (ins->std.ws.enabledMacro.len>0) { + macroList.push_back(DivMacroExecList(ws.enabled,ins->std.ws.enabledMacro)); + ws.enabled.prepare(&ins->std.ws.enabledMacro); + } + if (ins->std.ws.globalMacro.len>0) { + macroList.push_back(DivMacroExecList(ws.global,ins->std.ws.globalMacro)); + ws.global.prepare(&ins->std.ws.globalMacro); + } + if (ins->std.ws.speedMacro.len>0) { + macroList.push_back(DivMacroExecList(ws.speed,ins->std.ws.speedMacro)); + ws.speed.prepare(&ins->std.ws.speedMacro); + } + if (ins->std.ws.param1Macro.len>0) { + macroList.push_back(DivMacroExecList(ws.param1,ins->std.ws.param1Macro)); + ws.param1.prepare(&ins->std.ws.param1Macro); + } + if (ins->std.ws.param2Macro.len>0) { + macroList.push_back(DivMacroExecList(ws.param2,ins->std.ws.param2Macro)); + ws.param2.prepare(&ins->std.ws.param2Macro); + } + if (ins->std.ws.param3Macro.len>0) { + macroList.push_back(DivMacroExecList(ws.param3,ins->std.ws.param3Macro)); + ws.param3.prepare(&ins->std.ws.param3Macro); + } + if (ins->std.ws.param4Macro.len>0) { + macroList.push_back(DivMacroExecList(ws.param4,ins->std.ws.param4Macro)); + ws.param4.prepare(&ins->std.ws.param4Macro); + } + if (!macroList.empty()) { + for (std::list::iterator iter = macroList.begin(); iter!= macroList.end(); iter++) { + iter->prepare(); } } } diff --git a/src/engine/macroInt.h b/src/engine/macroInt.h index d5e6fd140..d7236805e 100644 --- a/src/engine/macroInt.h +++ b/src/engine/macroInt.h @@ -21,127 +21,115 @@ #define _MACROINT_H #include "instrument.h" +#include + +struct DivMacroStruct { + DivInstrumentMacro* source; + int pos; + int val; + bool has, had, finished, will; + unsigned int mode; + void doMacro(DivInstrumentMacro& source, bool released); + void init() { + source=NULL; + pos=mode=0; + has=had=will=false; + } + void prepare(DivInstrumentMacro* s) { + if (s!=NULL) { + source=s; + has=had=will=true; + mode=source->mode; + } + } + DivMacroStruct(): + source(NULL), + pos(0), + val(0), + has(false), + had(false), + finished(false), + will(false), + mode(0) {} +}; + +struct DivMacroExecList { + DivMacroStruct& macro; + DivInstrumentMacro& source; + void prepare() { + macro.prepare(&source); + } + void doMacro(bool released) { + macro.doMacro(source, released); + } + DivMacroExecList(DivMacroStruct &m, DivInstrumentMacro& s): + macro(m), + source(s) {} +}; class DivMacroInt { DivInstrument* ins; - int volPos, arpPos, dutyPos, wavePos, pitchPos, ex1Pos, ex2Pos, ex3Pos; - int algPos, fbPos, fmsPos, amsPos; - int panLPos, panRPos, phaseResetPos, ex4Pos, ex5Pos, ex6Pos, ex7Pos, ex8Pos; + std::list macroList; bool released; public: - int vol; - int arp; - int duty, wave, pitch, ex1, ex2, ex3; - int alg, fb, fms, ams; - int panL, panR, phaseReset, ex4, ex5, ex6, ex7, ex8; - bool hasVol, hasArp, hasDuty, hasWave, hasPitch, hasEx1, hasEx2, hasEx3, hasAlg, hasFb, hasFms, hasAms; - bool hasPanL, hasPanR, hasPhaseReset, hasEx4, hasEx5, hasEx6, hasEx7, hasEx8; - bool hadVol, hadArp, hadDuty, hadWave, hadPitch, hadEx1, hadEx2, hadEx3, hadAlg, hadFb, hadFms, hadAms; - bool hadPanL, hadPanR, hadPhaseReset, hadEx4, hadEx5, hadEx6, hadEx7, hadEx8; - bool finishedVol, finishedArp, finishedDuty, finishedWave, finishedPitch, finishedEx1, finishedEx2, finishedEx3; - bool finishedAlg, finishedFb, finishedFms, finishedAms; - bool finishedPanL, finishedPanR, finishedPhaseReset, finishedEx4, finishedEx5, finishedEx6, finishedEx7, finishedEx8; - bool willVol, willArp, willDuty, willWave, willPitch, willEx1, willEx2, willEx3, willAlg, willFb, willFms, willAms; - bool willPanL, willPanR, willPhaseReset, willEx4, willEx5, willEx6, willEx7, willEx8; - bool arpMode; + // common macro + DivMacroStruct vol; + DivMacroStruct arp; + DivMacroStruct duty, wave, pitch, ex1, ex2, ex3; + DivMacroStruct alg, fb, fms, fms2, ams, ams2; + DivMacroStruct panL, panR, phaseReset, ex4, ex5, ex6, ex7, ex8; + + // FM operator macro struct IntOp { - int amPos, arPos, drPos, multPos; - int rrPos, slPos, tlPos, dt2Pos; - int rsPos, dtPos, d2rPos, ssgPos; - int damPos, dvbPos, egtPos, kslPos; - int susPos, vibPos, wsPos, ksrPos; - - int am, ar, dr, mult; - int rr, sl, tl, dt2; - int rs, dt, d2r, ssg; - int dam, dvb, egt, ksl; - int sus, vib, ws, ksr; - - bool hasAm, hasAr, hasDr, hasMult; - bool hasRr, hasSl, hasTl, hasDt2; - bool hasRs, hasDt, hasD2r, hasSsg; - bool hasDam, hasDvb, hasEgt, hasKsl; - bool hasSus, hasVib, hasWs, hasKsr; - - bool hadAm, hadAr, hadDr, hadMult; - bool hadRr, hadSl, hadTl, hadDt2; - bool hadRs, hadDt, hadD2r, hadSsg; - bool hadDam, hadDvb, hadEgt, hadKsl; - bool hadSus, hadVib, hadWs, hadKsr; - - bool finishedAm, finishedAr, finishedDr, finishedMult; - bool finishedRr, finishedSl, finishedTl, finishedDt2; - bool finishedRs, finishedDt, finishedD2r, finishedSsg; - bool finishedDam, finishedDvb, finishedEgt, finishedKsl; - bool finishedSus, finishedVib, finishedWs, finishedKsr; - - bool willAm, willAr, willDr, willMult; - bool willRr, willSl, willTl, willDt2; - bool willRs, willDt, willD2r, willSsg; - bool willDam, willDvb, willEgt, willKsl; - bool willSus, willVib, willWs, willKsr; + DivMacroStruct am, ar, dr, mult; + DivMacroStruct rr, sl, tl, dt2; + DivMacroStruct rs, dt, d2r, ssg; + DivMacroStruct dam, dvb, egt, ksl; + DivMacroStruct sus, vib, ws, ksr; IntOp(): - amPos(0), - arPos(0), - drPos(0), - multPos(0), - rrPos(0), - slPos(0), - tlPos(0), - dt2Pos(0), - rsPos(0), - dtPos(0), - d2rPos(0), - ssgPos(0), - damPos(0), - dvbPos(0), - egtPos(0), - kslPos(0), - susPos(0), - vibPos(0), - wsPos(0), - ksrPos(0), - am(0), - ar(0), - dr(0), - mult(0), - rr(0), - sl(0), - tl(0), - dt2(0), - rs(0), - dt(0), - d2r(0), - ssg(0), - dam(0), - dvb(0), - egt(0), - ksl(0), - sus(0), - vib(0), - ws(0), - ksr(0), - hasAm(false), hasAr(false), hasDr(false), hasMult(false), - hasRr(false), hasSl(false), hasTl(false), hasDt2(false), - hasRs(false), hasDt(false), hasD2r(false), hasSsg(false), - hasDam(false), hasDvb(false), hasEgt(false), hasKsl(false), - hasSus(false), hasVib(false), hasWs(false), hasKsr(false), - hadAm(false), hadAr(false), hadDr(false), hadMult(false), - hadRr(false), hadSl(false), hadTl(false), hadDt2(false), - hadRs(false), hadDt(false), hadD2r(false), hadSsg(false), - hadDam(false), hadDvb(false), hadEgt(false), hadKsl(false), - hadSus(false), hadVib(false), hadWs(false), hadKsr(false), - finishedAm(false), finishedAr(false), finishedDr(false), finishedMult(false), - finishedRr(false), finishedSl(false), finishedTl(false), finishedDt2(false), - finishedRs(false), finishedDt(false), finishedD2r(false), finishedSsg(false), - finishedDam(false), finishedDvb(false), finishedEgt(false), finishedKsl(false), - finishedSus(false), finishedVib(false), finishedWs(false), finishedKsr(false), - willAm(false), willAr(false), willDr(false), willMult(false), - willRr(false), willSl(false), willTl(false), willDt2(false), - willRs(false), willDt(false), willD2r(false), willSsg(false), - willDam(false), willDvb(false), willEgt(false), willKsl(false), - willSus(false), willVib(false), willWs(false), willKsr(false) {} + am(), + ar(), + dr(), + mult(), + rr(), + sl(), + tl(), + dt2(), + rs(), + dt(), + d2r(), + ssg(), + dam(), + dvb(), + egt(), + ksl(), + sus(), + vib(), + ws(), + ksr() {} } op[4]; + + // wavesynth macro + struct IntWS { + DivMacroStruct wave1, wave2; + DivMacroStruct rateDivider; + DivMacroStruct effect; + DivMacroStruct oneShot, enabled, global; + DivMacroStruct speed, param1, param2, param3, param4; + IntWS(): + wave1(), + wave2(), + rateDivider(), + effect(), + oneShot(), + enabled(), + global(), + speed(), + param1(), + param2(), + param3(), + param4() {} + } ws; /** * trigger macro release. @@ -167,128 +155,29 @@ class DivMacroInt { DivMacroInt(): ins(NULL), - volPos(0), - arpPos(0), - dutyPos(0), - wavePos(0), - pitchPos(0), - ex1Pos(0), - ex2Pos(0), - ex3Pos(0), - algPos(0), - fbPos(0), - fmsPos(0), - amsPos(0), - panLPos(0), - panRPos(0), - phaseResetPos(0), - ex4Pos(0), - ex5Pos(0), - ex6Pos(0), - ex7Pos(0), - ex8Pos(0), released(false), - vol(0), - arp(0), - duty(0), - wave(0), - pitch(0), - ex1(0), - ex2(0), - ex3(0), - alg(0), - fb(0), - fms(0), - ams(0), - panL(0), - panR(0), - phaseReset(0), - ex4(0), - ex5(0), - ex6(0), - ex7(0), - ex8(0), - hasVol(false), - hasArp(false), - hasDuty(false), - hasWave(false), - hasPitch(false), - hasEx1(false), - hasEx2(false), - hasEx3(false), - hasAlg(false), - hasFb(false), - hasFms(false), - hasAms(false), - hasPanL(false), - hasPanR(false), - hasPhaseReset(false), - hasEx4(false), - hasEx5(false), - hasEx6(false), - hasEx7(false), - hasEx8(false), - hadVol(false), - hadArp(false), - hadDuty(false), - hadWave(false), - hadPitch(false), - hadEx1(false), - hadEx2(false), - hadEx3(false), - hadAlg(false), - hadFb(false), - hadFms(false), - hadAms(false), - hadPanL(false), - hadPanR(false), - hadPhaseReset(false), - hadEx4(false), - hadEx5(false), - hadEx6(false), - hadEx7(false), - hadEx8(false), - finishedVol(false), - finishedArp(false), - finishedDuty(false), - finishedWave(false), - finishedPitch(false), - finishedEx1(false), - finishedEx2(false), - finishedEx3(false), - finishedAlg(false), - finishedFb(false), - finishedFms(false), - finishedAms(false), - finishedPanL(false), - finishedPanR(false), - finishedPhaseReset(false), - finishedEx4(false), - finishedEx5(false), - finishedEx6(false), - finishedEx7(false), - finishedEx8(false), - willVol(false), - willArp(false), - willDuty(false), - willWave(false), - willPitch(false), - willEx1(false), - willEx2(false), - willEx3(false), - willAlg(false), - willFb(false), - willFms(false), - willAms(false), - willPanL(false), - willPanR(false), - willPhaseReset(false), - willEx4(false), - willEx5(false), - willEx6(false), - willEx7(false), - willEx8(false), - arpMode(false) {} + vol(), + arp(), + duty(), + wave(), + pitch(), + ex1(), + ex2(), + ex3(), + alg(), + fb(), + fms(), + fms2(), + ams(), + ams2(), + panL(), + panR(), + phaseReset(), + ex4(), + ex5(), + ex6(), + ex7(), + ex8() {} }; #endif diff --git a/src/engine/platform/amiga.cpp b/src/engine/platform/amiga.cpp index e1bc83947..458c9329d 100644 --- a/src/engine/platform/amiga.cpp +++ b/src/engine/platform/amiga.cpp @@ -147,8 +147,8 @@ void DivPlatformAmiga::acquire(short* bufL, short* bufR, size_t start, size_t le void DivPlatformAmiga::tick() { for (int i=0; i<4; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=((chan[i].vol%65)*MIN(64,chan[i].std.vol))>>6; + if (chan[i].std.vol.had) { + chan[i].outVol=((chan[i].vol%65)*MIN(64,chan[i].std.vol.val))>>6; } double off=1.0; if (chan[i].sample>=0 && chan[i].samplesong.sampleLen) { @@ -159,24 +159,24 @@ void DivPlatformAmiga::tick() { off=8363.0/(double)s->centerRate; } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=round(off*NOTE_PERIODIC_NOROUND(chan[i].std.arp)); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=round(off*NOTE_PERIODIC_NOROUND(chan[i].std.arp.val)); } else { - chan[i].baseFreq=round(off*NOTE_PERIODIC_NOROUND(chan[i].note+chan[i].std.arp)); + chan[i].baseFreq=round(off*NOTE_PERIODIC_NOROUND(chan[i].note+chan[i].std.arp.val)); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=round(off*NOTE_PERIODIC_NOROUND(chan[i].note)); chan[i].freqChanged=true; } } - if (chan[i].std.hadWave) { - if (chan[i].wave!=chan[i].std.wave) { - chan[i].wave=chan[i].std.wave; + if (chan[i].std.wave.had) { + if (chan[i].wave!=chan[i].std.wave.val) { + chan[i].wave=chan[i].std.wave.val; if (!chan[i].keyOff) chan[i].keyOn=true; } } @@ -252,13 +252,13 @@ int DivPlatformAmiga::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } } break; case DIV_CMD_GET_VOLUME: - if (chan[c.chan].std.hasVol) { + if (chan[c.chan].std.vol.has) { return chan[c.chan].vol; } return chan[c.chan].outVol; @@ -315,7 +315,7 @@ int DivPlatformAmiga::dispatch(DivCommand c) { off=8363.0/(double)s->centerRate; } } - chan[c.chan].baseFreq=round(off*NOTE_PERIODIC_NOROUND(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp-12):(0)))); + chan[c.chan].baseFreq=round(off*NOTE_PERIODIC_NOROUND(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val-12):(0)))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/arcade.cpp b/src/engine/platform/arcade.cpp index 7c465a511..41530a0c7 100644 --- a/src/engine/platform/arcade.cpp +++ b/src/engine/platform/arcade.cpp @@ -220,8 +220,8 @@ void DivPlatformArcade::tick() { for (int i=0; i<8; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol))/127; + if (chan[i].std.vol.had) { + chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol.val))/127; for (int j=0; j<4; j++) { unsigned short baseAddr=chanOffs[i]|opOffs[j]; DivInstrumentFM::Operator& op=chan[i].state.op[j]; @@ -233,50 +233,50 @@ void DivPlatformArcade::tick() { } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_LINEAR(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_LINEAR(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_LINEAR(chan[i].note+(signed char)chan[i].std.arp); + chan[i].baseFreq=NOTE_LINEAR(chan[i].note+(signed char)chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_LINEAR(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadDuty) { - if (chan[i].std.duty>0) { - rWrite(0x0f,0x80|(0x20-chan[i].std.duty)); + if (chan[i].std.duty.had) { + if (chan[i].std.duty.val>0) { + rWrite(0x0f,0x80|(0x20-chan[i].std.duty.val)); } else { rWrite(0x0f,0); } } - if (chan[i].std.hadWave) { - rWrite(0x1b,chan[i].std.wave&3); + if (chan[i].std.wave.had) { + rWrite(0x1b,chan[i].std.wave.val&3); } - if (chan[i].std.hadEx1) { - amDepth=chan[i].std.ex1; + if (chan[i].std.ex1.had) { + amDepth=chan[i].std.ex1.val; immWrite(0x19,amDepth); } - if (chan[i].std.hadEx2) { - pmDepth=chan[i].std.ex2; + if (chan[i].std.ex2.had) { + pmDepth=chan[i].std.ex2.val; immWrite(0x19,0x80|pmDepth); } - if (chan[i].std.hadEx3) { - immWrite(0x18,chan[i].std.ex3); + if (chan[i].std.ex3.had) { + immWrite(0x18,chan[i].std.ex3.val); } - if (chan[i].std.hadAlg) { - chan[i].state.alg=chan[i].std.alg; + if (chan[i].std.alg.had) { + chan[i].state.alg=chan[i].std.alg.val; if (isMuted[i]) { rWrite(chanOffs[i]+ADDR_LR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3)); } else { @@ -296,72 +296,72 @@ void DivPlatformArcade::tick() { } } } - if (chan[i].std.hadFb) { - chan[i].state.fb=chan[i].std.fb; + if (chan[i].std.fb.had) { + chan[i].state.fb=chan[i].std.fb.val; if (isMuted[i]) { rWrite(chanOffs[i]+ADDR_LR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3)); } else { rWrite(chanOffs[i]+ADDR_LR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3)|((chan[i].chVolL&1)<<6)|((chan[i].chVolR&1)<<7)); } } - if (chan[i].std.hadFms) { - chan[i].state.fms=chan[i].std.fms; + if (chan[i].std.fms.had) { + chan[i].state.fms=chan[i].std.fms.val; rWrite(chanOffs[i]+ADDR_FMS_AMS,((chan[i].state.fms&7)<<4)|(chan[i].state.ams&3)); } - if (chan[i].std.hadAms) { - chan[i].state.ams=chan[i].std.ams; + if (chan[i].std.ams.had) { + chan[i].state.ams=chan[i].std.ams.val; rWrite(chanOffs[i]+ADDR_FMS_AMS,((chan[i].state.fms&7)<<4)|(chan[i].state.ams&3)); } for (int j=0; j<4; j++) { unsigned short baseAddr=chanOffs[i]|opOffs[j]; DivInstrumentFM::Operator& op=chan[i].state.op[j]; DivMacroInt::IntOp& m=chan[i].std.op[j]; - if (m.hadAm) { - op.am=m.am; + if (m.am.had) { + op.am=m.am.val; rWrite(baseAddr+ADDR_AM_DR,(op.dr&31)|(op.am<<7)); } - if (m.hadAr) { - op.ar=m.ar; + if (m.ar.had) { + op.ar=m.ar.val; rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.rs<<6)); } - if (m.hadDr) { - op.dr=m.dr; + if (m.dr.had) { + op.dr=m.dr.val; rWrite(baseAddr+ADDR_AM_DR,(op.dr&31)|(op.am<<7)); } - if (m.hadMult) { - op.mult=m.mult; + if (m.mult.had) { + op.mult=m.mult.val; rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4)); } - if (m.hadRr) { - op.rr=m.rr; + if (m.rr.had) { + op.rr=m.rr.val; rWrite(baseAddr+ADDR_SL_RR,(op.rr&15)|(op.sl<<4)); } - if (m.hadSl) { - op.sl=m.sl; + if (m.sl.had) { + op.sl=m.sl.val; rWrite(baseAddr+ADDR_SL_RR,(op.rr&15)|(op.sl<<4)); } - if (m.hadTl) { - op.tl=127-m.tl; + if (m.tl.had) { + op.tl=127-m.tl.val; if (isOutput[chan[i].state.alg][j]) { rWrite(baseAddr+ADDR_TL,127-(((127-op.tl)*(chan[i].outVol&0x7f))/127)); } else { rWrite(baseAddr+ADDR_TL,op.tl); } } - if (m.hadRs) { - op.rs=m.rs; + if (m.rs.had) { + op.rs=m.rs.val; rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.rs<<6)); } - if (m.hadDt) { - op.dt=m.dt; + if (m.dt.had) { + op.dt=m.dt.val; rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4)); } - if (m.hadD2r) { - op.d2r=m.d2r; + if (m.d2r.had) { + op.d2r=m.d2r.val; rWrite(baseAddr+ADDR_DT2_D2R,(op.d2r&31)|(op.dt2<<6)); } - if (m.hadDt2) { - op.dt2=m.dt2; + if (m.dt2.had) { + op.dt2=m.dt2.val; rWrite(baseAddr+ADDR_DT2_D2R,(op.d2r&31)|(op.dt2<<6)); } } @@ -413,7 +413,7 @@ int DivPlatformArcade::dispatch(DivCommand c) { } chan[c.chan].std.init(ins); - if (!chan[c.chan].std.willVol) { + if (!chan[c.chan].std.vol.will) { chan[c.chan].outVol=chan[c.chan].vol; } @@ -472,7 +472,7 @@ int DivPlatformArcade::dispatch(DivCommand c) { break; case DIV_CMD_VOLUME: { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } for (int i=0; i<4; i++) { diff --git a/src/engine/platform/ay.cpp b/src/engine/platform/ay.cpp index b798cba4e..6cdd6b030 100644 --- a/src/engine/platform/ay.cpp +++ b/src/engine/platform/ay.cpp @@ -176,8 +176,8 @@ void DivPlatformAY8910::tick() { // PSG for (int i=0; i<3; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=MIN(15,chan[i].std.vol)-(15-(chan[i].vol&15)); + if (chan[i].std.vol.had) { + chan[i].outVol=MIN(15,chan[i].std.vol.val)-(15-(chan[i].vol&15)); if (chan[i].outVol<0) chan[i].outVol=0; if (isMuted[i]) { rWrite(0x08+i,0); @@ -187,26 +187,26 @@ void DivPlatformAY8910::tick() { rWrite(0x08+i,(chan[i].outVol&15)|((chan[i].psgMode&4)<<2)); } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp); + chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_PERIODIC(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadDuty) { - rWrite(0x06,31-chan[i].std.duty); + if (chan[i].std.duty.had) { + rWrite(0x06,31-chan[i].std.duty.val); } - if (chan[i].std.hadWave) { - chan[i].psgMode=(chan[i].std.wave+1)&7; + if (chan[i].std.wave.had) { + chan[i].psgMode=(chan[i].std.wave.val+1)&7; if (isMuted[i]) { rWrite(0x08+i,0); } else if (intellivision && (chan[i].psgMode&4)) { @@ -215,19 +215,19 @@ void DivPlatformAY8910::tick() { rWrite(0x08+i,(chan[i].outVol&15)|((chan[i].psgMode&4)<<2)); } } - if (chan[i].std.hadEx2) { - ayEnvMode=chan[i].std.ex2; + if (chan[i].std.ex2.had) { + ayEnvMode=chan[i].std.ex2.val; rWrite(0x0d,ayEnvMode); } - if (chan[i].std.hadEx3) { - chan[i].autoEnvNum=chan[i].std.ex3; + if (chan[i].std.ex3.had) { + chan[i].autoEnvNum=chan[i].std.ex3.val; chan[i].freqChanged=true; - if (!chan[i].std.willAlg) chan[i].autoEnvDen=1; + if (!chan[i].std.alg.will) chan[i].autoEnvDen=1; } - if (chan[i].std.hadAlg) { - chan[i].autoEnvDen=chan[i].std.alg; + if (chan[i].std.alg.had) { + chan[i].autoEnvDen=chan[i].std.alg.val; chan[i].freqChanged=true; - if (!chan[i].std.willEx3) chan[i].autoEnvNum=1; + if (!chan[i].std.ex3.will) chan[i].autoEnvNum=1; } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); @@ -314,7 +314,7 @@ int DivPlatformAY8910::dispatch(DivCommand c) { break; case DIV_CMD_VOLUME: { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } if (isMuted[c.chan]) { diff --git a/src/engine/platform/ay8930.cpp b/src/engine/platform/ay8930.cpp index 1849d0cdc..de17fa67f 100644 --- a/src/engine/platform/ay8930.cpp +++ b/src/engine/platform/ay8930.cpp @@ -191,8 +191,8 @@ void DivPlatformAY8930::tick() { // PSG for (int i=0; i<3; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=MIN(31,chan[i].std.vol)-(31-(chan[i].vol&31)); + if (chan[i].std.vol.had) { + chan[i].outVol=MIN(31,chan[i].std.vol.val)-(31-(chan[i].vol&31)); if (chan[i].outVol<0) chan[i].outVol=0; if (isMuted[i]) { rWrite(0x08+i,0); @@ -200,55 +200,55 @@ void DivPlatformAY8930::tick() { rWrite(0x08+i,(chan[i].outVol&31)|((chan[i].psgMode&4)<<3)); } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp); + chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_PERIODIC(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadDuty) { - rWrite(0x06,chan[i].std.duty); + if (chan[i].std.duty.had) { + rWrite(0x06,chan[i].std.duty.val); } - if (chan[i].std.hadWave) { - chan[i].psgMode=(chan[i].std.wave+1)&7; + if (chan[i].std.wave.had) { + chan[i].psgMode=(chan[i].std.wave.val+1)&7; if (isMuted[i]) { rWrite(0x08+i,0); } else { rWrite(0x08+i,(chan[i].outVol&31)|((chan[i].psgMode&4)<<3)); } } - if (chan[i].std.hadEx1) { // duty - rWrite(0x16+i,chan[i].std.ex1); + if (chan[i].std.ex1.had) { // duty + rWrite(0x16+i,chan[i].std.ex1.val); } - if (chan[i].std.hadEx2) { - ayEnvMode[i]=chan[i].std.ex2; + if (chan[i].std.ex2.had) { + ayEnvMode[i]=chan[i].std.ex2.val; rWrite(regMode[i],ayEnvMode[i]); } - if (chan[i].std.hadEx3) { - chan[i].autoEnvNum=chan[i].std.ex3; + if (chan[i].std.ex3.had) { + chan[i].autoEnvNum=chan[i].std.ex3.val; chan[i].freqChanged=true; - if (!chan[i].std.willAlg) chan[i].autoEnvDen=1; + if (!chan[i].std.alg.will) chan[i].autoEnvDen=1; } - if (chan[i].std.hadAlg) { - chan[i].autoEnvDen=chan[i].std.alg; + if (chan[i].std.alg.had) { + chan[i].autoEnvDen=chan[i].std.alg.val; chan[i].freqChanged=true; - if (!chan[i].std.willEx3) chan[i].autoEnvNum=1; + if (!chan[i].std.ex3.will) chan[i].autoEnvNum=1; } - if (chan[i].std.hadFb) { - ayNoiseAnd=chan[i].std.fb; + if (chan[i].std.fb.had) { + ayNoiseAnd=chan[i].std.fb.val; immWrite(0x19,ayNoiseAnd); } - if (chan[i].std.hadFms) { - ayNoiseOr=chan[i].std.fms; + if (chan[i].std.fms.had) { + ayNoiseOr=chan[i].std.fms.val; immWrite(0x1a,ayNoiseOr); } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { @@ -256,7 +256,7 @@ void DivPlatformAY8930::tick() { if (chan[i].freq>65535) chan[i].freq=65535; if (chan[i].keyOn) { if (chan[i].insChanged) { - if (!chan[i].std.willEx1) immWrite(0x16+i,chan[i].duty); + if (!chan[i].std.ex1.will) immWrite(0x16+i,chan[i].duty); chan[i].insChanged=false; } } @@ -336,7 +336,7 @@ int DivPlatformAY8930::dispatch(DivCommand c) { break; case DIV_CMD_VOLUME: { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } if (isMuted[c.chan]) { diff --git a/src/engine/platform/bubsyswsg.cpp b/src/engine/platform/bubsyswsg.cpp index 989619722..712496c1c 100644 --- a/src/engine/platform/bubsyswsg.cpp +++ b/src/engine/platform/bubsyswsg.cpp @@ -84,28 +84,28 @@ void DivPlatformBubSysWSG::updateWave(int ch) { void DivPlatformBubSysWSG::tick() { for (int i=0; i<2; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=((chan[i].vol&15)*MIN(15,chan[i].std.vol))/15; + if (chan[i].std.vol.had) { + chan[i].outVol=((chan[i].vol&15)*MIN(15,chan[i].std.vol.val))/15; rWrite(2+i,(chan[i].wave<<5)|chan[i].outVol); } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp); + chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_PERIODIC(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadWave) { - if (chan[i].wave!=chan[i].std.wave || chan[i].ws.activeChanged()) { - chan[i].wave=chan[i].std.wave; + if (chan[i].std.wave.had) { + if (chan[i].wave!=chan[i].std.wave.val || chan[i].ws.activeChanged()) { + chan[i].wave=chan[i].std.wave.val; chan[i].ws.changeWave1(chan[i].wave); if (!chan[i].keyOff) chan[i].keyOn=true; } @@ -174,14 +174,14 @@ int DivPlatformBubSysWSG::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; if (chan[c.chan].active) rWrite(2+c.chan,(chan[c.chan].wave<<5)|chan[c.chan].outVol); } } break; case DIV_CMD_GET_VOLUME: - if (chan[c.chan].std.hasVol) { + if (chan[c.chan].std.vol.has) { return chan[c.chan].vol; } return chan[c.chan].outVol; @@ -219,7 +219,7 @@ int DivPlatformBubSysWSG::dispatch(DivCommand c) { break; } case DIV_CMD_LEGATO: - chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/c64.cpp b/src/engine/platform/c64.cpp index 49be60fb8..786da058c 100644 --- a/src/engine/platform/c64.cpp +++ b/src/engine/platform/c64.cpp @@ -125,43 +125,43 @@ void DivPlatformC64::updateFilter() { void DivPlatformC64::tick() { for (int i=0; i<3; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { + if (chan[i].std.vol.had) { DivInstrument* ins=parent->getIns(chan[i].ins); if (ins->c64.volIsCutoff) { if (ins->c64.filterIsAbs) { - filtCut=MIN(2047,chan[i].std.vol); + filtCut=MIN(2047,chan[i].std.vol.val); } else { - filtCut-=((signed char)chan[i].std.vol-18)*7; + filtCut-=((signed char)chan[i].std.vol.val-18)*7; if (filtCut>2047) filtCut=2047; if (filtCut<0) filtCut=0; } updateFilter(); } else { - vol=MIN(15,chan[i].std.vol); + vol=MIN(15,chan[i].std.vol.val); updateFilter(); } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+(signed char)chan[i].std.arp); + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+(signed char)chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadDuty) { + if (chan[i].std.duty.had) { DivInstrument* ins=parent->getIns(chan[i].ins); - if (ins->c64.dutyIsAbs) { - chan[i].duty=chan[i].std.duty; + if (ins->std.dutyMacro.mode) { + chan[i].duty=chan[i].std.duty.val; } else { - chan[i].duty-=((signed char)chan[i].std.duty-12)*4; + chan[i].duty-=((signed char)chan[i].std.duty.val-12)*4; } rWrite(i*7+2,chan[i].duty&0xff); rWrite(i*7+3,chan[i].duty>>8); @@ -175,21 +175,21 @@ void DivPlatformC64::tick() { } } } - if (chan[i].std.hadWave) { - chan[i].wave=chan[i].std.wave; + if (chan[i].std.wave.had) { + chan[i].wave=chan[i].std.wave.val; rWrite(i*7+4,(isMuted[i]?8:(chan[i].wave<<4))|(chan[i].ring<<2)|(chan[i].sync<<1)|chan[i].active); } - if (chan[i].std.hadEx1) { - filtControl=chan[i].std.ex1&15; + if (chan[i].std.ex1.had) { + filtControl=chan[i].std.ex1.val&15; updateFilter(); } - if (chan[i].std.hadEx2) { - filtRes=chan[i].std.ex2&15; + if (chan[i].std.ex2.had) { + filtRes=chan[i].std.ex2.val&15; updateFilter(); } - if (chan[i].std.hadEx3) { - chan[i].sync=chan[i].std.ex3&1; - chan[i].ring=chan[i].std.ex3&2; + if (chan[i].std.ex3.had) { + chan[i].sync=chan[i].std.ex3.val&1; + chan[i].ring=chan[i].std.ex3.val&2; chan[i].freqChanged=true; } @@ -226,7 +226,7 @@ int DivPlatformC64::dispatch(DivCommand c) { } chan[c.chan].active=true; chan[c.chan].keyOn=true; - if (chan[c.chan].insChanged || chan[c.chan].resetDuty || ins->std.waveMacroLen>0) { + if (chan[c.chan].insChanged || chan[c.chan].resetDuty || ins->std.waveMacro.len>0) { chan[c.chan].duty=ins->c64.duty; rWrite(c.chan*7+2,chan[c.chan].duty&0xff); rWrite(c.chan*7+3,chan[c.chan].duty>>8); @@ -279,7 +279,7 @@ int DivPlatformC64::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; vol=chan[c.chan].outVol; } else { @@ -333,7 +333,7 @@ int DivPlatformC64::dispatch(DivCommand c) { rWrite(c.chan*7+4,(isMuted[c.chan]?8:(chan[c.chan].wave<<4))|(chan[c.chan].ring<<2)|(chan[c.chan].sync<<1)|chan[c.chan].active); break; case DIV_CMD_LEGATO: - chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/fds.cpp b/src/engine/platform/fds.cpp index cd70dfacd..9960a0d74 100644 --- a/src/engine/platform/fds.cpp +++ b/src/engine/platform/fds.cpp @@ -100,40 +100,40 @@ void DivPlatformFDS::updateWave() { void DivPlatformFDS::tick() { for (int i=0; i<1; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { + if (chan[i].std.vol.had) { // ok, why are the volumes like that? - chan[i].outVol=MIN(32,chan[i].std.vol)-(32-MIN(32,chan[i].vol)); + chan[i].outVol=MIN(32,chan[i].std.vol.val)-(32-MIN(32,chan[i].vol)); if (chan[i].outVol<0) chan[i].outVol=0; rWrite(0x4080,0x80|chan[i].outVol); } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (i==3) { // noise - if (chan[i].std.arpMode) { - chan[i].baseFreq=chan[i].std.arp; + if (chan[i].std.arp.mode) { + chan[i].baseFreq=chan[i].std.arp.val; } else { - chan[i].baseFreq=chan[i].note+chan[i].std.arp; + chan[i].baseFreq=chan[i].note+chan[i].std.arp.val; } if (chan[i].baseFreq>255) chan[i].baseFreq=255; if (chan[i].baseFreq<0) chan[i].baseFreq=0; } else { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+chan[i].std.arp); + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+chan[i].std.arp.val); } } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note); chan[i].freqChanged=true; } } /* - if (chan[i].std.hadDuty) { - chan[i].duty=chan[i].std.duty; + if (chan[i].std.duty.had) { + chan[i].duty=chan[i].std.duty.val; if (i==3) { if (parent->song.properNoiseLayout) { chan[i].duty&=1; @@ -148,9 +148,9 @@ void DivPlatformFDS::tick() { chan[i].freqChanged=true; } }*/ - if (chan[i].std.hadWave) { - if (chan[i].wave!=chan[i].std.wave || ws.activeChanged()) { - chan[i].wave=chan[i].std.wave; + if (chan[i].std.wave.had) { + if (chan[i].wave!=chan[i].std.wave.val || ws.activeChanged()) { + chan[i].wave=chan[i].std.wave.val; ws.changeWave1(chan[i].wave); //if (!chan[i].keyOff) chan[i].keyOn=true; } @@ -161,18 +161,18 @@ void DivPlatformFDS::tick() { if (!chan[i].keyOff) chan[i].keyOn=true; } } - if (chan[i].std.hadEx1) { // mod depth - chan[i].modOn=chan[i].std.ex1; - chan[i].modDepth=chan[i].std.ex1; + if (chan[i].std.ex1.had) { // mod depth + chan[i].modOn=chan[i].std.ex1.val; + chan[i].modDepth=chan[i].std.ex1.val; rWrite(0x4084,(chan[i].modOn<<7)|0x40|chan[i].modDepth); } - if (chan[i].std.hadEx2) { // mod speed - chan[i].modFreq=chan[i].std.ex2; + if (chan[i].std.ex2.had) { // mod speed + chan[i].modFreq=chan[i].std.ex2.val; rWrite(0x4086,chan[i].modFreq&0xff); rWrite(0x4087,chan[i].modFreq>>8); } - if (chan[i].std.hadEx3) { // mod position - chan[i].modPos=chan[i].std.ex3; + if (chan[i].std.ex3.had) { // mod position + chan[i].modPos=chan[i].std.ex3.val; rWrite(0x4087,0x80|chan[i].modFreq>>8); rWrite(0x4085,chan[i].modPos); rWrite(0x4087,chan[i].modFreq>>8); @@ -276,7 +276,7 @@ int DivPlatformFDS::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } rWrite(0x4080,0x80|chan[c.chan].vol); @@ -359,7 +359,7 @@ int DivPlatformFDS::dispatch(DivCommand c) { } case DIV_CMD_LEGATO: if (c.chan==3) break; - chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/gb.cpp b/src/engine/platform/gb.cpp index 263e8e2ba..13eac1f32 100644 --- a/src/engine/platform/gb.cpp +++ b/src/engine/platform/gb.cpp @@ -149,45 +149,45 @@ static unsigned char noiseTable[256]={ void DivPlatformGB::tick() { for (int i=0; i<4; i++) { chan[i].std.next(); - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (i==3) { // noise - if (chan[i].std.arpMode) { - chan[i].baseFreq=chan[i].std.arp+24; + if (chan[i].std.arp.mode) { + chan[i].baseFreq=chan[i].std.arp.val+24; } else { - chan[i].baseFreq=chan[i].note+chan[i].std.arp; + chan[i].baseFreq=chan[i].note+chan[i].std.arp.val; } if (chan[i].baseFreq>255) chan[i].baseFreq=255; if (chan[i].baseFreq<0) chan[i].baseFreq=0; } else { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp+24); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val+24); } else { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp); + chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val); } } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_PERIODIC(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadDuty) { - chan[i].duty=chan[i].std.duty; + if (chan[i].std.duty.had) { + chan[i].duty=chan[i].std.duty.val; DivInstrument* ins=parent->getIns(chan[i].ins); if (i!=2) { rWrite(16+i*5+1,((chan[i].duty&3)<<6)|(63-(ins->gb.soundLen&63))); } else { if (parent->song.waveDutyIsVol) { - rWrite(16+i*5+2,gbVolMap[(chan[i].std.duty&3)<<2]); + rWrite(16+i*5+2,gbVolMap[(chan[i].std.duty.val&3)<<2]); } } } - if (i==2 && chan[i].std.hadWave) { - if (chan[i].wave!=chan[i].std.wave || ws.activeChanged()) { - chan[i].wave=chan[i].std.wave; + if (i==2 && chan[i].std.wave.had) { + if (chan[i].wave!=chan[i].std.wave.val || ws.activeChanged()) { + chan[i].wave=chan[i].std.wave.val; ws.changeWave1(chan[i].wave); if (!chan[i].keyOff) chan[i].keyOn=true; } @@ -359,7 +359,7 @@ int DivPlatformGB::dispatch(DivCommand c) { } case DIV_CMD_LEGATO: if (c.chan==3) break; - chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/genesis.cpp b/src/engine/platform/genesis.cpp index 0aff2b43a..c1c1648e1 100644 --- a/src/engine/platform/genesis.cpp +++ b/src/engine/platform/genesis.cpp @@ -225,8 +225,8 @@ void DivPlatformGenesis::tick() { if (i==2 && extMode) continue; chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol))/127; + if (chan[i].std.vol.had) { + chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol.val))/127; for (int j=0; j<4; j++) { unsigned short baseAddr=chanOffs[i]|opOffs[j]; DivInstrumentFM::Operator& op=chan[i].state.op[j]; @@ -242,24 +242,24 @@ void DivPlatformGenesis::tick() { } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+(signed char)chan[i].std.arp); + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+(signed char)chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadAlg) { - chan[i].state.alg=chan[i].std.alg; + if (chan[i].std.alg.had) { + chan[i].state.alg=chan[i].std.alg.val; rWrite(chanOffs[i]+ADDR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3)); if (!parent->song.algMacroBehavior) for (int j=0; j<4; j++) { unsigned short baseAddr=chanOffs[i]|opOffs[j]; @@ -275,48 +275,48 @@ void DivPlatformGenesis::tick() { } } } - if (chan[i].std.hadFb) { - chan[i].state.fb=chan[i].std.fb; + if (chan[i].std.fb.had) { + chan[i].state.fb=chan[i].std.fb.val; rWrite(chanOffs[i]+ADDR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3)); } - if (chan[i].std.hadFms) { - chan[i].state.fms=chan[i].std.fms; + if (chan[i].std.fms.had) { + chan[i].state.fms=chan[i].std.fms.val; rWrite(chanOffs[i]+ADDR_LRAF,(isMuted[i]?0:(chan[i].pan<<6))|(chan[i].state.fms&7)|((chan[i].state.ams&3)<<4)); } - if (chan[i].std.hadAms) { - chan[i].state.ams=chan[i].std.ams; + if (chan[i].std.ams.had) { + chan[i].state.ams=chan[i].std.ams.val; rWrite(chanOffs[i]+ADDR_LRAF,(isMuted[i]?0:(chan[i].pan<<6))|(chan[i].state.fms&7)|((chan[i].state.ams&3)<<4)); } for (int j=0; j<4; j++) { unsigned short baseAddr=chanOffs[i]|opOffs[j]; DivInstrumentFM::Operator& op=chan[i].state.op[j]; DivMacroInt::IntOp& m=chan[i].std.op[j]; - if (m.hadAm) { - op.am=m.am; + if (m.am.had) { + op.am=m.am.val; rWrite(baseAddr+ADDR_AM_DR,(op.dr&31)|(op.am<<7)); } - if (m.hadAr) { - op.ar=m.ar; + if (m.ar.had) { + op.ar=m.ar.val; rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.rs<<6)); } - if (m.hadDr) { - op.dr=m.dr; + if (m.dr.had) { + op.dr=m.dr.val; rWrite(baseAddr+ADDR_AM_DR,(op.dr&31)|(op.am<<7)); } - if (m.hadMult) { - op.mult=m.mult; + if (m.mult.had) { + op.mult=m.mult.val; rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4)); } - if (m.hadRr) { - op.rr=m.rr; + if (m.rr.had) { + op.rr=m.rr.val; rWrite(baseAddr+ADDR_SL_RR,(op.rr&15)|(op.sl<<4)); } - if (m.hadSl) { - op.sl=m.sl; + if (m.sl.had) { + op.sl=m.sl.val; rWrite(baseAddr+ADDR_SL_RR,(op.rr&15)|(op.sl<<4)); } - if (m.hadTl) { - op.tl=127-m.tl; + if (m.tl.had) { + op.tl=127-m.tl.val; if (isMuted[i]) { rWrite(baseAddr+ADDR_TL,127); } else { @@ -327,20 +327,20 @@ void DivPlatformGenesis::tick() { } } } - if (m.hadRs) { - op.rs=m.rs; + if (m.rs.had) { + op.rs=m.rs.val; rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.rs<<6)); } - if (m.hadDt) { - op.dt=m.dt; + if (m.dt.had) { + op.dt=m.dt.val; rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4)); } - if (m.hadD2r) { - op.d2r=m.d2r; + if (m.d2r.had) { + op.d2r=m.d2r.val; rWrite(baseAddr+ADDR_DT2_D2R,op.d2r&31); } - if (m.hadSsg) { - op.ssgEnv=m.ssg; + if (m.ssg.had) { + op.ssgEnv=m.ssg.val; rWrite(baseAddr+ADDR_SSG,op.ssgEnv&15); } } @@ -505,7 +505,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) { } chan[c.chan].std.init(ins); - if (!chan[c.chan].std.willVol) { + if (!chan[c.chan].std.vol.will) { chan[c.chan].outVol=chan[c.chan].vol; } @@ -578,7 +578,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) { break; case DIV_CMD_VOLUME: { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } for (int i=0; i<4; i++) { diff --git a/src/engine/platform/lynx.cpp b/src/engine/platform/lynx.cpp index dc0df8a65..70e7bc413 100644 --- a/src/engine/platform/lynx.cpp +++ b/src/engine/platform/lynx.cpp @@ -148,23 +148,23 @@ void DivPlatformLynx::acquire(short* bufL, short* bufR, size_t start, size_t len void DivPlatformLynx::tick() { for (int i=0; i<4; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=((chan[i].vol&127)*MIN(127,chan[i].std.vol))>>7; + if (chan[i].std.vol.had) { + chan[i].outVol=((chan[i].vol&127)*MIN(127,chan[i].std.vol.val))>>7; WRITE_VOLUME(i,(isMuted[i]?0:(chan[i].outVol&127))); } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp); - chan[i].actualNote=chan[i].std.arp; + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val); + chan[i].actualNote=chan[i].std.arp.val; } else { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp); - chan[i].actualNote=chan[i].note+chan[i].std.arp; + chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val); + chan[i].actualNote=chan[i].note+chan[i].std.arp.val; } chan[i].freqChanged=true; } } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_PERIODIC(chan[i].note); chan[i].actualNote=chan[i].note; chan[i].freqChanged=true; @@ -178,15 +178,15 @@ void DivPlatformLynx::tick() { chan[i].lfsr=-1; } chan[i].fd=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,true); - if (chan[i].std.hadDuty) { - chan[i].duty=chan[i].std.duty; + if (chan[i].std.duty.had) { + chan[i].duty=chan[i].std.duty.val; WRITE_FEEDBACK(i, chan[i].duty.feedback); } WRITE_CONTROL(i, (chan[i].fd.clockDivider|0x18|chan[i].duty.int_feedback7)); WRITE_BACKUP( i, chan[i].fd.backup ); } - else if (chan[i].std.hadDuty) { - chan[i].duty = chan[i].std.duty; + else if (chan[i].std.duty.had) { + chan[i].duty = chan[i].std.duty.val; WRITE_FEEDBACK(i, chan[i].duty.feedback); WRITE_CONTROL(i, (chan[i].fd.clockDivider|0x18|chan[i].duty.int_feedback7)); } @@ -228,7 +228,7 @@ int DivPlatformLynx::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } if (chan[c.chan].active) WRITE_VOLUME(c.chan,(isMuted[c.chan]?0:(chan[c.chan].vol&127))); @@ -239,7 +239,7 @@ int DivPlatformLynx::dispatch(DivCommand c) { WRITE_ATTEN(c.chan,chan[c.chan].pan); break; case DIV_CMD_GET_VOLUME: - if (chan[c.chan].std.hasVol) { + if (chan[c.chan].std.vol.has) { return chan[c.chan].vol; } return chan[c.chan].outVol; @@ -272,7 +272,7 @@ int DivPlatformLynx::dispatch(DivCommand c) { break; } case DIV_CMD_LEGATO: - chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; chan[c.chan].actualNote=c.value; diff --git a/src/engine/platform/mmc5.cpp b/src/engine/platform/mmc5.cpp index 3ccf95499..0f803ee20 100644 --- a/src/engine/platform/mmc5.cpp +++ b/src/engine/platform/mmc5.cpp @@ -99,29 +99,29 @@ void DivPlatformMMC5::acquire(short* bufL, short* bufR, size_t start, size_t len void DivPlatformMMC5::tick() { for (int i=0; i<2; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { + if (chan[i].std.vol.had) { // ok, why are the volumes like that? - chan[i].outVol=MIN(15,chan[i].std.vol)-(15-(chan[i].vol&15)); + chan[i].outVol=MIN(15,chan[i].std.vol.val)-(15-(chan[i].vol&15)); if (chan[i].outVol<0) chan[i].outVol=0; rWrite(0x5000+i*4,0x30|chan[i].outVol|((chan[i].duty&3)<<6)); } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp); + chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_PERIODIC(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadDuty) { - chan[i].duty=chan[i].std.duty; + if (chan[i].std.duty.had) { + chan[i].duty=chan[i].std.duty.val; rWrite(0x5000+i*4,0x30|chan[i].outVol|((chan[i].duty&3)<<6)); } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { @@ -243,7 +243,7 @@ int DivPlatformMMC5::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } if (chan[c.chan].active) { @@ -291,7 +291,7 @@ int DivPlatformMMC5::dispatch(DivCommand c) { } break; case DIV_CMD_LEGATO: - chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/n163.cpp b/src/engine/platform/n163.cpp index 2800fad11..6248cb562 100644 --- a/src/engine/platform/n163.cpp +++ b/src/engine/platform/n163.cpp @@ -203,8 +203,8 @@ void DivPlatformN163::updateWaveCh(int ch) { void DivPlatformN163::tick() { for (int i=0; i<=chanMax; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=(MIN(15,chan[i].std.vol)*(chan[i].vol&15))/15; + if (chan[i].std.vol.had) { + chan[i].outVol=(MIN(15,chan[i].std.vol.val)*(chan[i].vol&15))/15; if (chan[i].outVol<0) chan[i].outVol=0; if (chan[i].outVol>15) chan[i].outVol=15; if (chan[i].resVol!=chan[i].outVol) { @@ -214,87 +214,87 @@ void DivPlatformN163::tick() { } } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+(signed char)chan[i].std.arp); + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+(signed char)chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadDuty) { - if (chan[i].wavePos!=chan[i].std.duty) { - chan[i].wavePos=chan[i].std.duty; + if (chan[i].std.duty.had) { + if (chan[i].wavePos!=chan[i].std.duty.val) { + chan[i].wavePos=chan[i].std.duty.val; if (chan[i].waveMode&0x2) { chan[i].waveUpdated=true; } chan[i].waveChanged=true; } } - if (chan[i].std.hadWave) { - if (chan[i].wave!=chan[i].std.wave) { - chan[i].wave=chan[i].std.wave; + if (chan[i].std.wave.had) { + if (chan[i].wave!=chan[i].std.wave.val) { + chan[i].wave=chan[i].std.wave.val; if (chan[i].waveMode&0x2) { chan[i].waveUpdated=true; } } } - if (chan[i].std.hadEx1) { - if (chan[i].waveLen!=(chan[i].std.ex1&0xfc)) { - chan[i].waveLen=chan[i].std.ex1&0xfc; + if (chan[i].std.ex1.had) { + if (chan[i].waveLen!=(chan[i].std.ex1.val&0xfc)) { + chan[i].waveLen=chan[i].std.ex1.val&0xfc; if (chan[i].waveMode&0x2) { chan[i].waveUpdated=true; } chan[i].freqChanged=true; } } - if (chan[i].std.hadEx2) { - if ((chan[i].waveMode&0x2)!=(chan[i].std.ex2&0x2)) { // update when every waveform changed - chan[i].waveMode=(chan[i].waveMode&~0x2)|(chan[i].std.ex2&0x2); + if (chan[i].std.ex2.had) { + if ((chan[i].waveMode&0x2)!=(chan[i].std.ex2.val&0x2)) { // update when every waveform changed + chan[i].waveMode=(chan[i].waveMode&~0x2)|(chan[i].std.ex2.val&0x2); if (chan[i].waveMode&0x2) { chan[i].waveUpdated=true; chan[i].waveChanged=true; } } - if ((chan[i].waveMode&0x1)!=(chan[i].std.ex2&0x1)) { // update waveform now - chan[i].waveMode=(chan[i].waveMode&~0x1)|(chan[i].std.ex2&0x1); + if ((chan[i].waveMode&0x1)!=(chan[i].std.ex2.val&0x1)) { // update waveform now + chan[i].waveMode=(chan[i].waveMode&~0x1)|(chan[i].std.ex2.val&0x1); if (chan[i].waveMode&0x1) { // rising edge chan[i].waveUpdated=true; chan[i].waveChanged=true; } } } - if (chan[i].std.hadEx3) { - if (chan[i].loadWave!=chan[i].std.ex3) { - chan[i].loadWave=chan[i].std.ex3; + if (chan[i].std.ex3.had) { + if (chan[i].loadWave!=chan[i].std.ex3.val) { + chan[i].loadWave=chan[i].std.ex3.val; if (chan[i].loadMode&0x2) { updateWave(chan[i].loadWave,chan[i].loadPos,chan[i].loadLen&0xfc); } } } - if (chan[i].std.hadAlg) { - if (chan[i].loadPos!=chan[i].std.alg) { - chan[i].loadPos=chan[i].std.alg; + if (chan[i].std.alg.had) { + if (chan[i].loadPos!=chan[i].std.alg.val) { + chan[i].loadPos=chan[i].std.alg.val; } } - if (chan[i].std.hadFb) { - if (chan[i].loadLen!=(chan[i].std.fb&0xfc)) { - chan[i].loadLen=chan[i].std.fb&0xfc; + if (chan[i].std.fb.had) { + if (chan[i].loadLen!=(chan[i].std.fb.val&0xfc)) { + chan[i].loadLen=chan[i].std.fb.val&0xfc; } } - if (chan[i].std.hadFms) { - if ((chan[i].loadMode&0x2)!=(chan[i].std.fms&0x2)) { // load when every waveform changes - chan[i].loadMode=(chan[i].loadMode&~0x2)|(chan[i].std.fms&0x2); + if (chan[i].std.fms.had) { + if ((chan[i].loadMode&0x2)!=(chan[i].std.fms.val&0x2)) { // load when every waveform changes + chan[i].loadMode=(chan[i].loadMode&~0x2)|(chan[i].std.fms.val&0x2); } - if ((chan[i].loadMode&0x1)!=(chan[i].std.fms&0x1)) { // load now - chan[i].loadMode=(chan[i].loadMode&~0x1)|(chan[i].std.fms&0x1); + if ((chan[i].loadMode&0x1)!=(chan[i].std.fms.val&0x1)) { // load now + chan[i].loadMode=(chan[i].loadMode&~0x1)|(chan[i].std.fms.val&0x1); if (chan[i].loadMode&0x1) { // rising edge updateWave(chan[i].loadWave,chan[i].loadPos,chan[i].loadLen&0xfc); } @@ -400,7 +400,7 @@ int DivPlatformN163::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; chan[c.chan].resVol=chan[c.chan].outVol; } else { @@ -513,7 +513,7 @@ int DivPlatformN163::dispatch(DivCommand c) { } break; case DIV_CMD_LEGATO: - chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/nes.cpp b/src/engine/platform/nes.cpp index f61ed4fb6..5380b0b42 100644 --- a/src/engine/platform/nes.cpp +++ b/src/engine/platform/nes.cpp @@ -136,9 +136,9 @@ static unsigned char noiseTable[253]={ void DivPlatformNES::tick() { for (int i=0; i<4; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { + if (chan[i].std.vol.had) { // ok, why are the volumes like that? - chan[i].outVol=MIN(15,chan[i].std.vol)-(15-(chan[i].vol&15)); + chan[i].outVol=MIN(15,chan[i].std.vol.val)-(15-(chan[i].vol&15)); if (chan[i].outVol<0) chan[i].outVol=0; if (i==2) { // triangle rWrite(0x4000+i*4,(chan[i].outVol==0)?0:255); @@ -147,33 +147,33 @@ void DivPlatformNES::tick() { rWrite(0x4000+i*4,0x30|chan[i].outVol|((chan[i].duty&3)<<6)); } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (i==3) { // noise - if (chan[i].std.arpMode) { - chan[i].baseFreq=chan[i].std.arp; + if (chan[i].std.arp.mode) { + chan[i].baseFreq=chan[i].std.arp.val; } else { - chan[i].baseFreq=chan[i].note+chan[i].std.arp; + chan[i].baseFreq=chan[i].note+chan[i].std.arp.val; } if (chan[i].baseFreq>255) chan[i].baseFreq=255; if (chan[i].baseFreq<0) chan[i].baseFreq=0; } else { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp); + chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val); } } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_PERIODIC(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadDuty) { - chan[i].duty=chan[i].std.duty; + if (chan[i].std.duty.had) { + chan[i].duty=chan[i].std.duty.val; if (i==3) { if (parent->song.properNoiseLayout) { chan[i].duty&=1; @@ -337,7 +337,7 @@ int DivPlatformNES::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } if (chan[c.chan].active) { @@ -406,7 +406,7 @@ int DivPlatformNES::dispatch(DivCommand c) { break; case DIV_CMD_LEGATO: if (c.chan==3) break; - chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/opl.cpp b/src/engine/platform/opl.cpp index fcba9f80c..6b4db8c66 100644 --- a/src/engine/platform/opl.cpp +++ b/src/engine/platform/opl.cpp @@ -233,8 +233,8 @@ void DivPlatformOPL::tick() { int ops=(slots[3][i]!=255 && chan[i].state.ops==4 && oplType==3)?4:2; chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=(chan[i].vol*MIN(63,chan[i].std.vol))/63; + if (chan[i].std.vol.had) { + chan[i].outVol=(chan[i].vol*MIN(63,chan[i].std.vol.val))/63; for (int j=0; j1) { - if (m.hadWs) { - op.ws=m.ws; + if (m.ws.had) { + op.ws=m.ws.val; rWrite(baseAddr+ADDR_WS,op.ws&((oplType==3)?7:3)); } } - if (m.hadTl) { - op.tl=63-m.tl; + if (m.tl.had) { + op.tl=63-m.tl.val; } - if (m.hadKsl) { - op.ksl=m.ksl; + if (m.ksl.had) { + op.ksl=m.ksl.val; } - if (m.hadTl || m.hadKsl) { + if (m.tl.had || m.ksl.had) { if (isMuted[i]) { rWrite(baseAddr+ADDR_KSL_TL,63|(op.ksl<<6)); } else { @@ -528,7 +528,7 @@ int DivPlatformOPL::dispatch(DivCommand c) { } chan[c.chan].std.init(ins); - if (!chan[c.chan].std.willVol) { + if (!chan[c.chan].std.vol.will) { chan[c.chan].outVol=chan[c.chan].vol; } if (chan[c.chan].insChanged) { @@ -620,7 +620,7 @@ int DivPlatformOPL::dispatch(DivCommand c) { if (c.value>63) c.value=63; } chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } int ops=(slots[3][c.chan]!=255 && chan[c.chan].state.ops==4 && oplType==3)?4:2; diff --git a/src/engine/platform/opll.cpp b/src/engine/platform/opll.cpp index 55a1fa80c..2c23639b2 100644 --- a/src/engine/platform/opll.cpp +++ b/src/engine/platform/opll.cpp @@ -115,51 +115,51 @@ void DivPlatformOPLL::tick() { for (int i=0; i<11; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=(chan[i].vol*MIN(15,chan[i].std.vol))/15; + if (chan[i].std.vol.had) { + chan[i].outVol=(chan[i].vol*MIN(15,chan[i].std.vol.val))/15; if (i<9) { rWrite(0x30+i,((15-(chan[i].outVol*(15-chan[i].state.op[1].tl))/15)&15)|(chan[i].state.opllPreset<<4)); } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+(signed char)chan[i].std.arp); + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+(signed char)chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadWave && chan[i].state.opllPreset!=16) { - chan[i].state.opllPreset=chan[i].std.wave; + if (chan[i].std.wave.had && chan[i].state.opllPreset!=16) { + chan[i].state.opllPreset=chan[i].std.wave.val; if (i<9) { rWrite(0x30+i,((15-(chan[i].outVol*(15-chan[i].state.op[1].tl))/15)&15)|(chan[i].state.opllPreset<<4)); } } if (chan[i].state.opllPreset==0) { - if (chan[i].std.hadAlg) { // SUS - chan[i].state.alg=chan[i].std.alg; + if (chan[i].std.alg.had) { // SUS + chan[i].state.alg=chan[i].std.alg.val; chan[i].freqChanged=true; } - if (chan[i].std.hadFb) { - chan[i].state.fb=chan[i].std.fb; + if (chan[i].std.fb.had) { + chan[i].state.fb=chan[i].std.fb.val; rWrite(0x03,(chan[i].state.op[1].ksl<<6)|((chan[i].state.fms&1)<<4)|((chan[i].state.ams&1)<<3)|chan[i].state.fb); } - if (chan[i].std.hadFms) { - chan[i].state.fms=chan[i].std.fms; + if (chan[i].std.fms.had) { + chan[i].state.fms=chan[i].std.fms.val; rWrite(0x03,(chan[i].state.op[1].ksl<<6)|((chan[i].state.fms&1)<<4)|((chan[i].state.ams&1)<<3)|chan[i].state.fb); } - if (chan[i].std.hadAms) { - chan[i].state.ams=chan[i].std.ams; + if (chan[i].std.ams.had) { + chan[i].state.ams=chan[i].std.ams.val; rWrite(0x03,(chan[i].state.op[1].ksl<<6)|((chan[i].state.fms&1)<<4)|((chan[i].state.ams&1)<<3)|chan[i].state.fb); } @@ -167,32 +167,32 @@ void DivPlatformOPLL::tick() { DivInstrumentFM::Operator& op=chan[i].state.op[j]; DivMacroInt::IntOp& m=chan[i].std.op[j]; - if (m.hadAm) { - op.am=m.am; + if (m.am.had) { + op.am=m.am.val; rWrite(0x00+j,(op.am<<7)|(op.vib<<6)|((op.ssgEnv&8)<<2)|(op.ksr<<4)|(op.mult)); } - if (m.hadAr) { - op.ar=m.ar; + if (m.ar.had) { + op.ar=m.ar.val; rWrite(0x04+j,(op.ar<<4)|(op.dr)); } - if (m.hadDr) { - op.dr=m.dr; + if (m.dr.had) { + op.dr=m.dr.val; rWrite(0x04+j,(op.ar<<4)|(op.dr)); } - if (m.hadMult) { - op.mult=m.mult; + if (m.mult.had) { + op.mult=m.mult.val; rWrite(0x00+j,(op.am<<7)|(op.vib<<6)|((op.ssgEnv&8)<<2)|(op.ksr<<4)|(op.mult)); } - if (m.hadRr) { - op.rr=m.rr; + if (m.rr.had) { + op.rr=m.rr.val; rWrite(0x06+j,(op.sl<<4)|(op.rr)); } - if (m.hadSl) { - op.sl=m.sl; + if (m.sl.had) { + op.sl=m.sl.val; rWrite(0x06+j,(op.sl<<4)|(op.rr)); } - if (m.hadTl) { - op.tl=((j==1)?15:63)-m.tl; + if (m.tl.had) { + op.tl=((j==1)?15:63)-m.tl.val; if (j==1) { if (i<9) { rWrite(0x30+i,((15-(chan[i].outVol*(15-chan[i].state.op[1].tl))/15)&15)|(chan[i].state.opllPreset<<4)); @@ -202,24 +202,24 @@ void DivPlatformOPLL::tick() { } } - if (m.hadEgt) { - op.ssgEnv=(m.egt&1)?8:0; + if (m.egt.had) { + op.ssgEnv=(m.egt.val&1)?8:0; rWrite(0x00+j,(op.am<<7)|(op.vib<<6)|((op.ssgEnv&8)<<2)|(op.ksr<<4)|(op.mult)); } - if (m.hadKsl) { - op.ksl=m.ksl; + if (m.ksl.had) { + op.ksl=m.ksl.val; if (j==1) { rWrite(0x02,(chan[i].state.op[0].ksl<<6)|(chan[i].state.op[0].tl&63)); } else { rWrite(0x03,(chan[i].state.op[1].ksl<<6)|((chan[i].state.fms&1)<<4)|((chan[i].state.ams&1)<<3)|chan[i].state.fb); } } - if (m.hadKsr) { - op.ksr=m.ksr; + if (m.ksr.had) { + op.ksr=m.ksr.val; rWrite(0x00+j,(op.am<<7)|(op.vib<<6)|((op.ssgEnv&8)<<2)|(op.ksr<<4)|(op.mult)); } - if (m.hadVib) { - op.vib=m.vib; + if (m.vib.had) { + op.vib=m.vib.val; rWrite(0x00+j,(op.am<<7)|(op.vib<<6)|((op.ssgEnv&8)<<2)|(op.ksr<<4)|(op.mult)); } } @@ -361,7 +361,7 @@ int DivPlatformOPLL::dispatch(DivCommand c) { } chan[c.chan].std.init(ins); - if (!chan[c.chan].std.willVol) { + if (!chan[c.chan].std.vol.will) { chan[c.chan].outVol=chan[c.chan].vol; } @@ -490,7 +490,7 @@ int DivPlatformOPLL::dispatch(DivCommand c) { case DIV_CMD_VOLUME: { if (c.chan>=9 && !properDrums) return 0; chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } if (c.chan>=6 && properDrums) { diff --git a/src/engine/platform/pce.cpp b/src/engine/platform/pce.cpp index aa78aa625..0789c804d 100644 --- a/src/engine/platform/pce.cpp +++ b/src/engine/platform/pce.cpp @@ -149,39 +149,39 @@ static unsigned char noiseFreq[12]={ void DivPlatformPCE::tick() { for (int i=0; i<6; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=((chan[i].vol&31)*MIN(31,chan[i].std.vol))>>5; + if (chan[i].std.vol.had) { + chan[i].outVol=((chan[i].vol&31)*MIN(31,chan[i].std.vol.val))>>5; if (chan[i].furnaceDac) { // ignore for now } else { chWrite(i,0x04,0x80|chan[i].outVol); } } - if (chan[i].std.hadDuty && i>=4) { - chan[i].noise=chan[i].std.duty; + if (chan[i].std.duty.had && i>=4) { + chan[i].noise=chan[i].std.duty.val; chan[i].freqChanged=true; int noiseSeek=chan[i].note; if (noiseSeek<0) noiseSeek=0; chWrite(i,0x07,chan[i].noise?(0x80|(parent->song.properNoiseLayout?(noiseSeek&31):noiseFreq[noiseSeek%12])):0); } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val); // noise - int noiseSeek=chan[i].std.arp; + int noiseSeek=chan[i].std.arp.val; if (noiseSeek<0) noiseSeek=0; chWrite(i,0x07,chan[i].noise?(0x80|(parent->song.properNoiseLayout?(noiseSeek&31):noiseFreq[noiseSeek%12])):0); } else { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp); - int noiseSeek=chan[i].note+chan[i].std.arp; + chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val); + int noiseSeek=chan[i].note+chan[i].std.arp.val; if (noiseSeek<0) noiseSeek=0; chWrite(i,0x07,chan[i].noise?(0x80|(parent->song.properNoiseLayout?(noiseSeek&31):noiseFreq[noiseSeek%12])):0); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_PERIODIC(chan[i].note); int noiseSeek=chan[i].note; if (noiseSeek<0) noiseSeek=0; @@ -189,9 +189,9 @@ void DivPlatformPCE::tick() { chan[i].freqChanged=true; } } - if (chan[i].std.hadWave && !chan[i].pcm) { - if (chan[i].wave!=chan[i].std.wave || chan[i].ws.activeChanged()) { - chan[i].wave=chan[i].std.wave; + if (chan[i].std.wave.had && !chan[i].pcm) { + if (chan[i].wave!=chan[i].std.wave.val || chan[i].ws.activeChanged()) { + chan[i].wave=chan[i].std.wave.val; chan[i].ws.changeWave1(chan[i].wave); if (!chan[i].keyOff) chan[i].keyOn=true; } @@ -332,14 +332,14 @@ int DivPlatformPCE::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; if (chan[c.chan].active) chWrite(c.chan,0x04,0x80|chan[c.chan].outVol); } } break; case DIV_CMD_GET_VOLUME: - if (chan[c.chan].std.hasVol) { + if (chan[c.chan].std.vol.has) { return chan[c.chan].vol; } return chan[c.chan].outVol; @@ -409,7 +409,7 @@ int DivPlatformPCE::dispatch(DivCommand c) { break; } case DIV_CMD_LEGATO: - chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/pcspkr.cpp b/src/engine/platform/pcspkr.cpp index 5cfcdac3e..ee6ba7ef8 100644 --- a/src/engine/platform/pcspkr.cpp +++ b/src/engine/platform/pcspkr.cpp @@ -167,21 +167,21 @@ void DivPlatformPCSpeaker::acquire(short* bufL, short* bufR, size_t start, size_ void DivPlatformPCSpeaker::tick() { for (int i=0; i<1; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=(chan[i].vol && chan[i].std.vol); + if (chan[i].std.vol.had) { + chan[i].outVol=(chan[i].vol && chan[i].std.vol.val); on=chan[i].outVol; } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp); + chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_PERIODIC(chan[i].note); chan[i].freqChanged=true; } @@ -233,7 +233,7 @@ int DivPlatformPCSpeaker::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } if (chan[c.chan].active) { @@ -273,7 +273,7 @@ int DivPlatformPCSpeaker::dispatch(DivCommand c) { } case DIV_CMD_LEGATO: if (c.chan==3) break; - chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/pet.cpp b/src/engine/platform/pet.cpp index b89f95102..e46277e0a 100644 --- a/src/engine/platform/pet.cpp +++ b/src/engine/platform/pet.cpp @@ -87,28 +87,28 @@ void DivPlatformPET::writeOutVol() { void DivPlatformPET::tick() { chan.std.next(); - if (chan.std.hadVol) { - chan.outVol=chan.std.vol&chan.vol; + if (chan.std.vol.had) { + chan.outVol=chan.std.vol.val&chan.vol; writeOutVol(); } - if (chan.std.hadArp) { + if (chan.std.arp.had) { if (!chan.inPorta) { - if (chan.std.arpMode) { - chan.baseFreq=NOTE_PERIODIC(chan.std.arp); + if (chan.std.arp.mode) { + chan.baseFreq=NOTE_PERIODIC(chan.std.arp.val); } else { - chan.baseFreq=NOTE_PERIODIC(chan.note+chan.std.arp); + chan.baseFreq=NOTE_PERIODIC(chan.note+chan.std.arp.val); } } chan.freqChanged=true; } else { - if (chan.std.arpMode && chan.std.finishedArp) { + if (chan.std.arp.mode && chan.std.arp.finished) { chan.baseFreq=NOTE_PERIODIC(chan.note); chan.freqChanged=true; } } - if (chan.std.hadWave) { - if (chan.wave!=chan.std.wave) { - chan.wave=chan.std.wave; + if (chan.std.wave.had) { + if (chan.wave!=chan.std.wave.val) { + chan.wave=chan.std.wave.val; rWrite(10,chan.wave); } } @@ -118,7 +118,7 @@ void DivPlatformPET::tick() { if (chan.freq<2) chan.freq=2; rWrite(8,chan.freq-2); if (chan.keyOn) { - if (!chan.std.willVol) { + if (!chan.std.vol.will) { chan.outVol=chan.vol; writeOutVol(); } @@ -163,7 +163,7 @@ int DivPlatformPET::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan.vol!=c.value) { chan.vol=c.value; - if (!chan.std.hadVol) { + if (!chan.std.vol.had) { chan.outVol=chan.vol; writeOutVol(); } @@ -204,7 +204,7 @@ int DivPlatformPET::dispatch(DivCommand c) { break; } case DIV_CMD_LEGATO: - chan.baseFreq=NOTE_PERIODIC(c.value+((chan.std.willArp && !chan.std.arpMode)?(chan.std.arp):(0))); + chan.baseFreq=NOTE_PERIODIC(c.value+((chan.std.arp.will && !chan.std.arp.mode)?(chan.std.arp.val):(0))); chan.freqChanged=true; chan.note=c.value; break; diff --git a/src/engine/platform/qsound.cpp b/src/engine/platform/qsound.cpp index 12bf1c58b..a63ca9e50 100644 --- a/src/engine/platform/qsound.cpp +++ b/src/engine/platform/qsound.cpp @@ -277,8 +277,8 @@ void DivPlatformQSound::acquire(short* bufL, short* bufR, size_t start, size_t l void DivPlatformQSound::tick() { for (int i=0; i<16; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=((chan[i].vol&0xff)*chan[i].std.vol)>>6; + if (chan[i].std.vol.had) { + chan[i].outVol=((chan[i].vol&0xff)*chan[i].std.vol.val)>>6; // Check if enabled and write volume if (chan[i].active) { rWrite(q1_reg_map[Q1V_VOL][i], chan[i].outVol << 4); @@ -311,17 +311,17 @@ void DivPlatformQSound::tick() { qsound_loop = length - s->loopStart; } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=off*QS_NOTE_FREQUENCY(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=off*QS_NOTE_FREQUENCY(chan[i].std.arp.val); } else { - chan[i].baseFreq=off*QS_NOTE_FREQUENCY(chan[i].note+chan[i].std.arp); + chan[i].baseFreq=off*QS_NOTE_FREQUENCY(chan[i].note+chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=off*QS_NOTE_FREQUENCY(chan[i].note); chan[i].freqChanged=true; } @@ -338,7 +338,7 @@ void DivPlatformQSound::tick() { rWrite(q1_reg_map[Q1V_PHASE][i], 0x8000); //logW("ch %d bank=%04x, addr=%04x, end=%04x, loop=%04x!\n",i,qsound_bank,qsound_addr,qsound_end,qsound_loop); // Write sample address. Enable volume - if (!chan[i].std.hadVol) { + if (!chan[i].std.vol.had) { rWrite(q1_reg_map[Q1V_VOL][i], chan[i].vol << 4); } } @@ -404,7 +404,7 @@ int DivPlatformQSound::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { // Check if enabled and write volume chan[c.chan].outVol=c.value; if (chan[c.chan].active && c.chan < 16) { @@ -414,7 +414,7 @@ int DivPlatformQSound::dispatch(DivCommand c) { } break; case DIV_CMD_GET_VOLUME: - if (chan[c.chan].std.hasVol) { + if (chan[c.chan].std.vol.has) { return chan[c.chan].vol; } return chan[c.chan].outVol; @@ -477,7 +477,7 @@ int DivPlatformQSound::dispatch(DivCommand c) { off=(double)s->centerRate/24038.0/16.0; } } - chan[c.chan].baseFreq=off*QS_NOTE_FREQUENCY(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp-12):(0))); + chan[c.chan].baseFreq=off*QS_NOTE_FREQUENCY(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val-12):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/saa.cpp b/src/engine/platform/saa.cpp index 0bafaf157..db614ee71 100644 --- a/src/engine/platform/saa.cpp +++ b/src/engine/platform/saa.cpp @@ -135,8 +135,8 @@ inline unsigned char applyPan(unsigned char vol, unsigned char pan) { void DivPlatformSAA1099::tick() { for (int i=0; i<6; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=MIN(15,chan[i].std.vol)-(15-(chan[i].vol&15)); + if (chan[i].std.vol.had) { + chan[i].outVol=MIN(15,chan[i].std.vol.val)-(15-(chan[i].vol&15)); if (chan[i].outVol<0) chan[i].outVol=0; if (isMuted[i]) { rWrite(i,0); @@ -144,30 +144,30 @@ void DivPlatformSAA1099::tick() { rWrite(i,applyPan(chan[i].outVol&15,chan[i].pan)); } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp); + chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_PERIODIC(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadDuty) { - saaNoise[i/3]=chan[i].std.duty&3; + if (chan[i].std.duty.had) { + saaNoise[i/3]=chan[i].std.duty.val&3; rWrite(0x16,saaNoise[0]|(saaNoise[1]<<4)); } - if (chan[i].std.hadWave) { - chan[i].psgMode=chan[i].std.wave&3; + if (chan[i].std.wave.had) { + chan[i].psgMode=chan[i].std.wave.val&3; } - if (chan[i].std.hadEx1) { - saaEnv[i/3]=chan[i].std.ex1; + if (chan[i].std.ex1.had) { + saaEnv[i/3]=chan[i].std.ex1.val; rWrite(0x18+(i/3),saaEnv[i/3]); } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { @@ -253,7 +253,7 @@ int DivPlatformSAA1099::dispatch(DivCommand c) { break; case DIV_CMD_VOLUME: { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } if (isMuted[c.chan]) { diff --git a/src/engine/platform/segapcm.cpp b/src/engine/platform/segapcm.cpp index 69d8bd6e7..b87ee9a86 100644 --- a/src/engine/platform/segapcm.cpp +++ b/src/engine/platform/segapcm.cpp @@ -80,21 +80,21 @@ void DivPlatformSegaPCM::tick() { for (int i=0; i<16; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol))/127; + if (chan[i].std.vol.had) { + chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol.val))/127; } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=(chan[i].std.arp<<6); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=(chan[i].std.arp.val<<6); } else { - chan[i].baseFreq=((chan[i].note+(signed char)chan[i].std.arp)<<6); + chan[i].baseFreq=((chan[i].note+(signed char)chan[i].std.arp.val)<<6); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=(chan[i].note<<6); chan[i].freqChanged=true; } @@ -214,7 +214,7 @@ int DivPlatformSegaPCM::dispatch(DivCommand c) { break; case DIV_CMD_VOLUME: { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } chan[c.chan].chVolL=c.value; diff --git a/src/engine/platform/sms.cpp b/src/engine/platform/sms.cpp index 08cf568d8..f4bbc46e1 100644 --- a/src/engine/platform/sms.cpp +++ b/src/engine/platform/sms.cpp @@ -56,21 +56,21 @@ int DivPlatformSMS::acquireOne() { void DivPlatformSMS::tick() { for (int i=0; i<4; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=MIN(15,chan[i].std.vol)-(15-(chan[i].vol&15)); + if (chan[i].std.vol.had) { + chan[i].outVol=MIN(15,chan[i].std.vol.val)-(15-(chan[i].vol&15)); if (chan[i].outVol<0) chan[i].outVol=0; // old formula - // ((chan[i].vol&15)*MIN(15,chan[i].std.vol))>>4; + // ((chan[i].vol&15)*MIN(15,chan[i].std.vol.val))>>4; rWrite(0x90|(i<<5)|(isMuted[i]?15:(15-(chan[i].outVol&15)))); } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp); - chan[i].actualNote=chan[i].std.arp; + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val); + chan[i].actualNote=chan[i].std.arp.val; } else { // TODO: check whether this weird octave boundary thing applies to other systems as well - int areYouSerious=chan[i].note+chan[i].std.arp; + int areYouSerious=chan[i].note+chan[i].std.arp.val; while (areYouSerious>0x60) areYouSerious-=12; chan[i].baseFreq=NOTE_PERIODIC(areYouSerious); chan[i].actualNote=areYouSerious; @@ -78,15 +78,15 @@ void DivPlatformSMS::tick() { chan[i].freqChanged=true; } } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_PERIODIC(chan[i].note); chan[i].actualNote=chan[i].note; chan[i].freqChanged=true; } } - if (i==3) if (chan[i].std.hadDuty) { - snNoiseMode=chan[i].std.duty; - if (chan[i].std.duty<2) { + if (i==3) if (chan[i].std.duty.had) { + snNoiseMode=chan[i].std.duty.val; + if (chan[i].std.duty.val<2) { chan[3].freqChanged=false; } updateSNMode=true; @@ -130,11 +130,11 @@ void DivPlatformSMS::tick() { } } else { // 3 fixed values unsigned char value; - if (chan[3].std.hadArp) { - if (chan[3].std.arpMode) { - value=chan[3].std.arp%12; + if (chan[3].std.arp.had) { + if (chan[3].std.arp.mode) { + value=chan[3].std.arp.val%12; } else { - value=(chan[3].note+chan[3].std.arp)%12; + value=(chan[3].note+chan[3].std.arp.val)%12; } } else { value=chan[3].note%12; @@ -181,14 +181,14 @@ int DivPlatformSMS::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } if (chan[c.chan].active) rWrite(0x90|c.chan<<5|(isMuted[c.chan]?15:(15-(chan[c.chan].vol&15)))); } break; case DIV_CMD_GET_VOLUME: - if (chan[c.chan].std.hasVol) { + if (chan[c.chan].std.vol.has) { return chan[c.chan].vol; } return chan[c.chan].outVol; @@ -225,7 +225,7 @@ int DivPlatformSMS::dispatch(DivCommand c) { updateSNMode=true; break; case DIV_CMD_LEGATO: - chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; chan[c.chan].actualNote=c.value; diff --git a/src/engine/platform/swan.cpp b/src/engine/platform/swan.cpp index 6966a2d1c..802f27b86 100644 --- a/src/engine/platform/swan.cpp +++ b/src/engine/platform/swan.cpp @@ -145,31 +145,31 @@ void DivPlatformSwan::tick() { unsigned char sndCtrl=(pcm?0x20:0)|(sweep?0x40:0)|((noise>0)?0x80:0); for (int i=0; i<4; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - int env=chan[i].std.vol; + if (chan[i].std.vol.had) { + int env=chan[i].std.vol.val; if(parent->getIns(chan[i].ins)->type==DIV_INS_AMIGA) { env=MIN(env/4,15); } calcAndWriteOutVol(i,env); } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp); + chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_PERIODIC(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadWave && !(i==1 && pcm)) { - if (chan[i].wave!=chan[i].std.wave || chan[i].ws.activeChanged()) { - chan[i].wave=chan[i].std.wave; + if (chan[i].std.wave.had && !(i==1 && pcm)) { + if (chan[i].wave!=chan[i].std.wave.val || chan[i].ws.activeChanged()) { + chan[i].wave=chan[i].std.wave.val; chan[i].ws.changeWave1(chan[i].wave); } } @@ -200,7 +200,7 @@ void DivPlatformSwan::tick() { rWrite(i*2,rVal&0xff); rWrite(i*2+1,rVal>>8); if (chan[i].keyOn) { - if (!chan[i].std.willVol) { + if (!chan[i].std.vol.will) { calcAndWriteOutVol(i,15); } chan[i].keyOn=false; @@ -211,8 +211,8 @@ void DivPlatformSwan::tick() { chan[i].freqChanged=false; } } - if (chan[3].std.hadDuty) { - noise=chan[3].std.duty; + if (chan[3].std.duty.had) { + noise=chan[3].std.duty.val; if (noise>0) { rWrite(0x0e,((noise-1)&0x07)|0x18); sndCtrl|=0x80; @@ -319,7 +319,7 @@ int DivPlatformSwan::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hadVol) { + if (!chan[c.chan].std.vol.had) { calcAndWriteOutVol(c.chan,15); } } @@ -391,11 +391,11 @@ int DivPlatformSwan::dispatch(DivCommand c) { break; case DIV_CMD_PANNING: { chan[c.chan].pan=c.value; - calcAndWriteOutVol(c.chan,chan[c.chan].std.willVol?chan[c.chan].std.vol:15); + calcAndWriteOutVol(c.chan,chan[c.chan].std.vol.will?chan[c.chan].std.vol.val:15); break; } case DIV_CMD_LEGATO: - chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/tia.cpp b/src/engine/platform/tia.cpp index 2b99731fe..e06c5c74f 100644 --- a/src/engine/platform/tia.cpp +++ b/src/engine/platform/tia.cpp @@ -87,8 +87,8 @@ unsigned char DivPlatformTIA::dealWithFreq(unsigned char shape, int base, int pi void DivPlatformTIA::tick() { for (int i=0; i<2; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=MIN(15,chan[i].std.vol)-(15-(chan[i].vol&15)); + if (chan[i].std.vol.had) { + chan[i].outVol=MIN(15,chan[i].std.vol.val)-(15-(chan[i].vol&15)); if (chan[i].outVol<0) chan[i].outVol=0; if (isMuted[i]) { rWrite(0x19+i,0); @@ -96,29 +96,29 @@ void DivPlatformTIA::tick() { rWrite(0x19+i,chan[i].outVol&15); } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=0x80000000|chan[i].std.arp; + if (chan[i].std.arp.mode) { + chan[i].baseFreq=0x80000000|chan[i].std.arp.val; } else { - chan[i].baseFreq=(chan[i].note+chan[i].std.arp)<<8; + chan[i].baseFreq=(chan[i].note+chan[i].std.arp.val)<<8; } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=chan[i].note<<8; chan[i].freqChanged=true; } } - if (chan[i].std.hadWave) { - chan[i].shape=chan[i].std.wave&15; + if (chan[i].std.wave.had) { + chan[i].shape=chan[i].std.wave.val&15; rWrite(0x15+i,chan[i].shape); chan[i].freqChanged=true; } if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { if (chan[i].insChanged) { - if (!chan[i].std.willWave) { + if (!chan[i].std.wave.will) { chan[i].shape=4; rWrite(0x15+i,chan[i].shape); } @@ -179,7 +179,7 @@ int DivPlatformTIA::dispatch(DivCommand c) { break; case DIV_CMD_VOLUME: { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } if (isMuted[c.chan]) { diff --git a/src/engine/platform/tx81z.cpp b/src/engine/platform/tx81z.cpp index e9e817cd7..8ae4c6882 100644 --- a/src/engine/platform/tx81z.cpp +++ b/src/engine/platform/tx81z.cpp @@ -184,8 +184,8 @@ void DivPlatformTX81Z::tick() { for (int i=0; i<8; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol))/127; + if (chan[i].std.vol.had) { + chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol.val))/127; for (int j=0; j<4; j++) { unsigned short baseAddr=chanOffs[i]|opOffs[j]; DivInstrumentFM::Operator& op=chan[i].state.op[j]; @@ -197,50 +197,50 @@ void DivPlatformTX81Z::tick() { } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_LINEAR(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_LINEAR(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_LINEAR(chan[i].note+(signed char)chan[i].std.arp); + chan[i].baseFreq=NOTE_LINEAR(chan[i].note+(signed char)chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_LINEAR(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadDuty) { - if (chan[i].std.duty>0) { - rWrite(0x0f,0x80|(0x20-chan[i].std.duty)); + if (chan[i].std.duty.had) { + if (chan[i].std.duty.val>0) { + rWrite(0x0f,0x80|(0x20-chan[i].std.duty.val)); } else { rWrite(0x0f,0); } } - if (chan[i].std.hadWave) { - rWrite(0x1b,chan[i].std.wave&3); + if (chan[i].std.wave.had) { + rWrite(0x1b,chan[i].std.wave.val&3); } - if (chan[i].std.hadEx1) { - amDepth=chan[i].std.ex1; + if (chan[i].std.ex1.had) { + amDepth=chan[i].std.ex1.val; immWrite(0x19,amDepth); } - if (chan[i].std.hadEx2) { - pmDepth=chan[i].std.ex2; + if (chan[i].std.ex2.had) { + pmDepth=chan[i].std.ex2.val; immWrite(0x19,0x80|pmDepth); } - if (chan[i].std.hadEx3) { - immWrite(0x18,chan[i].std.ex3); + if (chan[i].std.ex3.had) { + immWrite(0x18,chan[i].std.ex3.val); } - if (chan[i].std.hadAlg) { - chan[i].state.alg=chan[i].std.alg; + if (chan[i].std.alg.had) { + chan[i].state.alg=chan[i].std.alg.val; if (isMuted[i]) { immWrite(chanOffs[i]+ADDR_LR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3)|0x40); } else { @@ -260,72 +260,72 @@ void DivPlatformTX81Z::tick() { } } } - if (chan[i].std.hadFb) { - chan[i].state.fb=chan[i].std.fb; + if (chan[i].std.fb.had) { + chan[i].state.fb=chan[i].std.fb.val; if (isMuted[i]) { immWrite(chanOffs[i]+ADDR_LR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3)|0x40); } else { immWrite(chanOffs[i]+ADDR_LR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3)|(chan[i].active?0:0x40)|(chan[i].chVolR<<7)); } } - if (chan[i].std.hadFms) { - chan[i].state.fms=chan[i].std.fms; + if (chan[i].std.fms.had) { + chan[i].state.fms=chan[i].std.fms.val; rWrite(chanOffs[i]+ADDR_FMS_AMS,((chan[i].state.fms&7)<<4)|(chan[i].state.ams&3)); } - if (chan[i].std.hadAms) { - chan[i].state.ams=chan[i].std.ams; + if (chan[i].std.ams.had) { + chan[i].state.ams=chan[i].std.ams.val; rWrite(chanOffs[i]+ADDR_FMS_AMS,((chan[i].state.fms&7)<<4)|(chan[i].state.ams&3)); } for (int j=0; j<4; j++) { unsigned short baseAddr=chanOffs[i]|opOffs[j]; DivInstrumentFM::Operator& op=chan[i].state.op[j]; DivMacroInt::IntOp& m=chan[i].std.op[j]; - if (m.hadAm) { - op.am=m.am; + if (m.am.had) { + op.am=m.am.val; rWrite(baseAddr+ADDR_AM_DR,(op.dr&31)|(op.am<<7)); } - if (m.hadAr) { - op.ar=m.ar; + if (m.ar.had) { + op.ar=m.ar.val; rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.egt<<5)|(op.rs<<6)); } - if (m.hadDr) { - op.dr=m.dr; + if (m.dr.had) { + op.dr=m.dr.val; rWrite(baseAddr+ADDR_AM_DR,(op.dr&31)|(op.am<<7)); } - if (m.hadMult) { - op.mult=m.mult; + if (m.mult.had) { + op.mult=m.mult.val; rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4)); } - if (m.hadRr) { - op.rr=m.rr; + if (m.rr.had) { + op.rr=m.rr.val; rWrite(baseAddr+ADDR_SL_RR,(op.rr&15)|(op.sl<<4)); } - if (m.hadSl) { - op.sl=m.sl; + if (m.sl.had) { + op.sl=m.sl.val; rWrite(baseAddr+ADDR_SL_RR,(op.rr&15)|(op.sl<<4)); } - if (m.hadTl) { - op.tl=127-m.tl; + if (m.tl.had) { + op.tl=127-m.tl.val; if (isOutput[chan[i].state.alg][j]) { rWrite(baseAddr+ADDR_TL,127-(((127-op.tl)*(chan[i].outVol&0x7f))/127)); } else { rWrite(baseAddr+ADDR_TL,op.tl); } } - if (m.hadRs) { - op.rs=m.rs; + if (m.rs.had) { + op.rs=m.rs.val; rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.egt<<5)|(op.rs<<6)); } - if (m.hadDt) { - op.dt=m.dt; + if (m.dt.had) { + op.dt=m.dt.val; rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4)); } - if (m.hadD2r) { - op.d2r=m.d2r; + if (m.d2r.had) { + op.d2r=m.d2r.val; rWrite(baseAddr+ADDR_DT2_D2R,(op.d2r&31)|(op.dt2<<6)); } - if (m.hadDt2) { - op.dt2=m.dt2; + if (m.dt2.had) { + op.dt2=m.dt2.val; rWrite(baseAddr+ADDR_DT2_D2R,(op.d2r&31)|(op.dt2<<6)); } } @@ -401,7 +401,7 @@ int DivPlatformTX81Z::dispatch(DivCommand c) { } chan[c.chan].std.init(ins); - if (!chan[c.chan].std.willVol) { + if (!chan[c.chan].std.vol.will) { chan[c.chan].outVol=chan[c.chan].vol; } @@ -463,7 +463,7 @@ int DivPlatformTX81Z::dispatch(DivCommand c) { break; case DIV_CMD_VOLUME: { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } for (int i=0; i<4; i++) { diff --git a/src/engine/platform/vera.cpp b/src/engine/platform/vera.cpp index 8965719f5..77f5c8050 100644 --- a/src/engine/platform/vera.cpp +++ b/src/engine/platform/vera.cpp @@ -158,30 +158,30 @@ int DivPlatformVERA::calcNoteFreq(int ch, int note) { void DivPlatformVERA::tick() { for (int i=0; i<16; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=MAX(chan[i].vol+chan[i].std.vol-63,0); + if (chan[i].std.vol.had) { + chan[i].outVol=MAX(chan[i].vol+chan[i].std.vol.val-63,0); rWriteLo(i,2,chan[i].outVol); } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=calcNoteFreq(0,chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=calcNoteFreq(0,chan[i].std.arp.val); } else { - chan[i].baseFreq=calcNoteFreq(0,chan[i].note+chan[i].std.arp); + chan[i].baseFreq=calcNoteFreq(0,chan[i].note+chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=calcNoteFreq(0,chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadDuty) { - rWriteLo(i,3,chan[i].std.duty); + if (chan[i].std.duty.had) { + rWriteLo(i,3,chan[i].std.duty.val); } - if (chan[i].std.hadWave) { - rWriteHi(i,3,chan[i].std.wave); + if (chan[i].std.wave.had) { + rWriteHi(i,3,chan[i].std.wave.val); } if (chan[i].freqChanged) { chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,8); @@ -193,21 +193,21 @@ void DivPlatformVERA::tick() { } // PCM chan[16].std.next(); - if (chan[16].std.hadVol) { - chan[16].outVol=MAX(chan[16].vol+MIN(chan[16].std.vol/4,15)-15,0); + if (chan[16].std.vol.had) { + chan[16].outVol=MAX(chan[16].vol+MIN(chan[16].std.vol.val/4,15)-15,0); rWritePCMVol(chan[16].outVol&15); } - if (chan[16].std.hadArp) { + if (chan[16].std.arp.had) { if (!chan[16].inPorta) { - if (chan[16].std.arpMode) { - chan[16].baseFreq=calcNoteFreq(16,chan[16].std.arp); + if (chan[16].std.arp.mode) { + chan[16].baseFreq=calcNoteFreq(16,chan[16].std.arp.val); } else { - chan[16].baseFreq=calcNoteFreq(16,chan[16].note+chan[16].std.arp); + chan[16].baseFreq=calcNoteFreq(16,chan[16].note+chan[16].std.arp.val); } } chan[16].freqChanged=true; } else { - if (chan[16].std.arpMode && chan[16].std.finishedArp) { + if (chan[16].std.arp.mode && chan[16].std.arp.finished) { chan[16].baseFreq=calcNoteFreq(16,chan[16].note); chan[16].freqChanged=true; } @@ -311,7 +311,7 @@ int DivPlatformVERA::dispatch(DivCommand c) { break; } case DIV_CMD_LEGATO: - chan[c.chan].baseFreq=calcNoteFreq(c.chan,c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=calcNoteFreq(c.chan,c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/vic20.cpp b/src/engine/platform/vic20.cpp index 7fe13e96f..b45fecfc3 100644 --- a/src/engine/platform/vic20.cpp +++ b/src/engine/platform/vic20.cpp @@ -94,28 +94,28 @@ void DivPlatformVIC20::writeOutVol(int ch) { void DivPlatformVIC20::tick() { for (int i=0; i<4; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - int env=chan[i].std.vol; + if (chan[i].std.vol.had) { + int env=chan[i].std.vol.val; calcAndWriteOutVol(i,env); } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp); + chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_PERIODIC(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadWave) { - if (chan[i].wave!=chan[i].std.wave) { - chan[i].wave=chan[i].std.wave&0x0f; + if (chan[i].std.wave.had) { + if (chan[i].wave!=chan[i].std.wave.val) { + chan[i].wave=chan[i].std.wave.val&0x0f; chan[i].keyOn=true; } } @@ -183,7 +183,7 @@ int DivPlatformVIC20::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hadVol) { + if (!chan[c.chan].std.vol.had) { calcAndWriteOutVol(c.chan,15); } } @@ -223,7 +223,7 @@ int DivPlatformVIC20::dispatch(DivCommand c) { break; } case DIV_CMD_LEGATO: - chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/vrc6.cpp b/src/engine/platform/vrc6.cpp index c89df338e..31694a62c 100644 --- a/src/engine/platform/vrc6.cpp +++ b/src/engine/platform/vrc6.cpp @@ -140,16 +140,16 @@ void DivPlatformVRC6::tick() { // 16 for pulse; 14 for saw int CHIP_DIVIDER=(i==2)?14:16; chan[i].std.next(); - if (chan[i].std.hadVol) { + if (chan[i].std.vol.had) { if (i==2) { // sawtooth - chan[i].outVol=((chan[i].vol&63)*MIN(63,chan[i].std.vol))/63; + chan[i].outVol=((chan[i].vol&63)*MIN(63,chan[i].std.vol.val))/63; if (chan[i].outVol<0) chan[i].outVol=0; if (chan[i].outVol>63) chan[i].outVol=63; if (!isMuted[i]) { chWrite(i,0,chan[i].outVol); } } else { // pulse - chan[i].outVol=((chan[i].vol&15)*MIN(15,chan[i].std.vol))/15; + chan[i].outVol=((chan[i].vol&15)*MIN(15,chan[i].std.vol.val))/15; if (chan[i].outVol<0) chan[i].outVol=0; if (chan[i].outVol>15) chan[i].outVol=15; if ((!isMuted[i]) && (!chan[i].pcm)) { @@ -157,23 +157,23 @@ void DivPlatformVRC6::tick() { } } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_PERIODIC(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp); + chan[i].baseFreq=NOTE_PERIODIC(chan[i].note+chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_PERIODIC(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadDuty) { - chan[i].duty=chan[i].std.duty; + if (chan[i].std.duty.had) { + chan[i].duty=chan[i].std.duty.val; if ((!isMuted[i]) && (i!=2) && (!chan[i].pcm)) { // pulse chWrite(i,0,(chan[i].outVol&0xf)|((chan[i].duty&7)<<4)); } @@ -310,7 +310,7 @@ int DivPlatformVRC6::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } if (!isMuted[c.chan]) { @@ -371,7 +371,7 @@ int DivPlatformVRC6::dispatch(DivCommand c) { } break; case DIV_CMD_LEGATO: - chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.willArp && !chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((chan[c.chan].std.arp.will && !chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; chan[c.chan].note=c.value; break; diff --git a/src/engine/platform/x1_010.cpp b/src/engine/platform/x1_010.cpp index 68f6db297..124e0ace6 100644 --- a/src/engine/platform/x1_010.cpp +++ b/src/engine/platform/x1_010.cpp @@ -339,41 +339,41 @@ void DivPlatformX1_010::updateEnvelope(int ch) { void DivPlatformX1_010::tick() { for (int i=0; i<16; i++) { chan[i].std.next(); - if (chan[i].std.hadVol) { - signed char macroVol=((chan[i].vol&15)*MIN(chan[i].furnacePCM?64:15,chan[i].std.vol))/(chan[i].furnacePCM?64:15); + if (chan[i].std.vol.had) { + signed char macroVol=((chan[i].vol&15)*MIN(chan[i].furnacePCM?64:15,chan[i].std.vol.val))/(chan[i].furnacePCM?64:15); if ((!isMuted[i]) && (macroVol!=chan[i].outVol)) { chan[i].outVol=macroVol; chan[i].envChanged=true; } } if ((!chan[i].pcm) || chan[i].furnacePCM) { - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NoteX1_010(i,chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NoteX1_010(i,chan[i].std.arp.val); } else { - chan[i].baseFreq=NoteX1_010(i,chan[i].note+chan[i].std.arp); + chan[i].baseFreq=NoteX1_010(i,chan[i].note+chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NoteX1_010(i,chan[i].note); chan[i].freqChanged=true; } } } - if (chan[i].std.hadWave && !chan[i].pcm) { - if (chan[i].wave!=chan[i].std.wave || chan[i].ws.activeChanged()) { - chan[i].wave=chan[i].std.wave; + if (chan[i].std.wave.had && !chan[i].pcm) { + if (chan[i].wave!=chan[i].std.wave.val || chan[i].ws.activeChanged()) { + chan[i].wave=chan[i].std.wave.val; if (!chan[i].pcm) { chan[i].ws.changeWave1(chan[i].wave); if (!chan[i].keyOff) chan[i].keyOn=true; } } } - if (chan[i].std.hadEx1) { - bool nextEnable=(chan[i].std.ex1&1); + if (chan[i].std.ex1.had) { + bool nextEnable=(chan[i].std.ex1.val&1); if (nextEnable!=(chan[i].env.flag.envEnable)) { chan[i].env.flag.envEnable=nextEnable; if (!chan[i].pcm) { @@ -383,42 +383,42 @@ void DivPlatformX1_010::tick() { refreshControl(i); } } - bool nextOneshot=(chan[i].std.ex1&2); + bool nextOneshot=(chan[i].std.ex1.val&2); if (nextOneshot!=(chan[i].env.flag.envOneshot)) { chan[i].env.flag.envOneshot=nextOneshot; if (!chan[i].pcm) { refreshControl(i); } } - bool nextSplit=(chan[i].std.ex1&4); + bool nextSplit=(chan[i].std.ex1.val&4); if (nextSplit!=(chan[i].env.flag.envSplit)) { chan[i].env.flag.envSplit=nextSplit; if (!isMuted[i] && !chan[i].pcm) { chan[i].envChanged=true; } } - bool nextHinvR=(chan[i].std.ex1&8); + bool nextHinvR=(chan[i].std.ex1.val&8); if (nextHinvR!=(chan[i].env.flag.envHinvR)) { chan[i].env.flag.envHinvR=nextHinvR; if (!isMuted[i] && !chan[i].pcm) { chan[i].envChanged=true; } } - bool nextVinvR=(chan[i].std.ex1&16); + bool nextVinvR=(chan[i].std.ex1.val&16); if (nextVinvR!=(chan[i].env.flag.envVinvR)) { chan[i].env.flag.envVinvR=nextVinvR; if (!isMuted[i] && !chan[i].pcm) { chan[i].envChanged=true; } } - bool nextHinvL=(chan[i].std.ex1&32); + bool nextHinvL=(chan[i].std.ex1.val&32); if (nextHinvL!=(chan[i].env.flag.envHinvL)) { chan[i].env.flag.envHinvL=nextHinvL; if (!isMuted[i] && !chan[i].pcm) { chan[i].envChanged=true; } } - bool nextVinvL=(chan[i].std.ex1&64); + bool nextVinvL=(chan[i].std.ex1.val&64); if (nextVinvL!=(chan[i].env.flag.envVinvL)) { chan[i].env.flag.envVinvL=nextVinvL; if (!isMuted[i] && !chan[i].pcm) { @@ -426,9 +426,9 @@ void DivPlatformX1_010::tick() { } } } - if (chan[i].std.hadEx2) { - if (chan[i].env.shape!=chan[i].std.ex2) { - chan[i].env.shape=chan[i].std.ex2; + if (chan[i].std.ex2.had) { + if (chan[i].env.shape!=chan[i].std.ex2.val) { + chan[i].env.shape=chan[i].std.ex2.val; if (!chan[i].pcm) { if (chan[i].env.flag.envEnable && (!isMuted[i])) { chan[i].envChanged=true; @@ -437,18 +437,18 @@ void DivPlatformX1_010::tick() { } } } - if (chan[i].std.hadEx3) { - chan[i].autoEnvNum=chan[i].std.ex3; + if (chan[i].std.ex3.had) { + chan[i].autoEnvNum=chan[i].std.ex3.val; if (!chan[i].pcm) { chan[i].freqChanged=true; - if (!chan[i].std.willAlg) chan[i].autoEnvDen=1; + if (!chan[i].std.alg.will) chan[i].autoEnvDen=1; } } - if (chan[i].std.hadAlg) { - chan[i].autoEnvDen=chan[i].std.alg; + if (chan[i].std.alg.had) { + chan[i].autoEnvDen=chan[i].std.alg.val; if (!chan[i].pcm) { chan[i].freqChanged=true; - if (!chan[i].std.willEx3) chan[i].autoEnvNum=1; + if (!chan[i].std.ex3.will) chan[i].autoEnvNum=1; } } if (chan[i].active) { @@ -601,7 +601,7 @@ int DivPlatformX1_010::dispatch(DivCommand c) { case DIV_CMD_VOLUME: if (chan[c.chan].vol!=c.value) { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { if (chan[c.chan].outVol!=c.value) { chan[c.chan].outVol=c.value; if (!isMuted[c.chan]) { @@ -612,7 +612,7 @@ int DivPlatformX1_010::dispatch(DivCommand c) { } break; case DIV_CMD_GET_VOLUME: - if (chan[c.chan].std.hasVol) { + if (chan[c.chan].std.vol.has) { return chan[c.chan].vol; } return chan[c.chan].outVol; @@ -685,7 +685,7 @@ int DivPlatformX1_010::dispatch(DivCommand c) { } case DIV_CMD_LEGATO: chan[c.chan].note=c.value; - chan[c.chan].baseFreq=NoteX1_010(c.chan,chan[c.chan].note+((chan[c.chan].std.willArp&&!chan[c.chan].std.arpMode)?(chan[c.chan].std.arp):(0))); + chan[c.chan].baseFreq=NoteX1_010(c.chan,chan[c.chan].note+((chan[c.chan].std.arp.will&&!chan[c.chan].std.arp.mode)?(chan[c.chan].std.arp.val):(0))); chan[c.chan].freqChanged=true; break; case DIV_CMD_PRE_PORTA: diff --git a/src/engine/platform/ym2610.cpp b/src/engine/platform/ym2610.cpp index 77c1243bd..398d5be4b 100644 --- a/src/engine/platform/ym2610.cpp +++ b/src/engine/platform/ym2610.cpp @@ -376,8 +376,8 @@ void DivPlatformYM2610::tick() { if (i==1 && extMode) continue; chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol))/127; + if (chan[i].std.vol.had) { + chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol.val))/127; for (int j=0; j<4; j++) { unsigned short baseAddr=chanOffs[i]|opOffs[j]; DivInstrumentFM::Operator& op=chan[i].state.op[j]; @@ -389,24 +389,24 @@ void DivPlatformYM2610::tick() { } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+(signed char)chan[i].std.arp); + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+(signed char)chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadAlg) { - chan[i].state.alg=chan[i].std.alg; + if (chan[i].std.alg.had) { + chan[i].state.alg=chan[i].std.alg.val; rWrite(chanOffs[i]+ADDR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3)); if (!parent->song.algMacroBehavior) for (int j=0; j<4; j++) { unsigned short baseAddr=chanOffs[i]|opOffs[j]; @@ -422,68 +422,68 @@ void DivPlatformYM2610::tick() { } } } - if (chan[i].std.hadFb) { - chan[i].state.fb=chan[i].std.fb; + if (chan[i].std.fb.had) { + chan[i].state.fb=chan[i].std.fb.val; rWrite(chanOffs[i]+ADDR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3)); } - if (chan[i].std.hadFms) { - chan[i].state.fms=chan[i].std.fms; + if (chan[i].std.fms.had) { + chan[i].state.fms=chan[i].std.fms.val; rWrite(chanOffs[i]+ADDR_LRAF,(isMuted[i]?0:(chan[i].pan<<6))|(chan[i].state.fms&7)|((chan[i].state.ams&3)<<4)); } - if (chan[i].std.hadAms) { - chan[i].state.ams=chan[i].std.ams; + if (chan[i].std.ams.had) { + chan[i].state.ams=chan[i].std.ams.val; rWrite(chanOffs[i]+ADDR_LRAF,(isMuted[i]?0:(chan[i].pan<<6))|(chan[i].state.fms&7)|((chan[i].state.ams&3)<<4)); } for (int j=0; j<4; j++) { unsigned short baseAddr=chanOffs[i]|opOffs[j]; DivInstrumentFM::Operator& op=chan[i].state.op[j]; DivMacroInt::IntOp& m=chan[i].std.op[j]; - if (m.hadAm) { - op.am=m.am; + if (m.am.had) { + op.am=m.am.val; rWrite(baseAddr+ADDR_AM_DR,(op.dr&31)|(op.am<<7)); } - if (m.hadAr) { - op.ar=m.ar; + if (m.ar.had) { + op.ar=m.ar.val; rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.rs<<6)); } - if (m.hadDr) { - op.dr=m.dr; + if (m.dr.had) { + op.dr=m.dr.val; rWrite(baseAddr+ADDR_AM_DR,(op.dr&31)|(op.am<<7)); } - if (m.hadMult) { - op.mult=m.mult; + if (m.mult.had) { + op.mult=m.mult.val; rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4)); } - if (m.hadRr) { - op.rr=m.rr; + if (m.rr.had) { + op.rr=m.rr.val; rWrite(baseAddr+ADDR_SL_RR,(op.rr&15)|(op.sl<<4)); } - if (m.hadSl) { - op.sl=m.sl; + if (m.sl.had) { + op.sl=m.sl.val; rWrite(baseAddr+ADDR_SL_RR,(op.rr&15)|(op.sl<<4)); } - if (m.hadTl) { - op.tl=127-m.tl; + if (m.tl.had) { + op.tl=127-m.tl.val; if (isOutput[chan[i].state.alg][j]) { rWrite(baseAddr+ADDR_TL,127-(((127-op.tl)*(chan[i].outVol&0x7f))/127)); } else { rWrite(baseAddr+ADDR_TL,op.tl); } } - if (m.hadRs) { - op.rs=m.rs; + if (m.rs.had) { + op.rs=m.rs.val; rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.rs<<6)); } - if (m.hadDt) { - op.dt=m.dt; + if (m.dt.had) { + op.dt=m.dt.val; rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4)); } - if (m.hadD2r) { - op.d2r=m.d2r; + if (m.d2r.had) { + op.d2r=m.d2r.val; rWrite(baseAddr+ADDR_DT2_D2R,op.d2r&31); } - if (m.hadSsg) { - op.ssgEnv=m.ssg; + if (m.ssg.had) { + op.ssgEnv=m.ssg.val; rWrite(baseAddr+ADDR_SSG,op.ssgEnv&15); } } @@ -498,22 +498,22 @@ void DivPlatformYM2610::tick() { if (chan[13].furnacePCM) { chan[13].std.next(); - if (chan[13].std.hadVol) { - chan[13].outVol=(chan[13].vol*MIN(64,chan[13].std.vol))/64; + if (chan[13].std.vol.had) { + chan[13].outVol=(chan[13].vol*MIN(64,chan[13].std.vol.val))/64; immWrite(0x1b,chan[13].outVol); } - if (chan[13].std.hadArp) { + if (chan[13].std.arp.had) { if (!chan[13].inPorta) { - if (chan[13].std.arpMode) { - chan[13].baseFreq=NOTE_ADPCMB(chan[13].std.arp); + if (chan[13].std.arp.mode) { + chan[13].baseFreq=NOTE_ADPCMB(chan[13].std.arp.val); } else { - chan[13].baseFreq=NOTE_ADPCMB(chan[13].note+(signed char)chan[13].std.arp); + chan[13].baseFreq=NOTE_ADPCMB(chan[13].note+(signed char)chan[13].std.arp.val); } } chan[13].freqChanged=true; } else { - if (chan[13].std.arpMode && chan[13].std.finishedArp) { + if (chan[13].std.arp.mode && chan[13].std.arp.finished) { chan[13].baseFreq=NOTE_ADPCMB(chan[13].note); chan[13].freqChanged=true; } @@ -608,7 +608,7 @@ int DivPlatformYM2610::dispatch(DivCommand c) { if (skipRegisterWrites) break; if (chan[c.chan].furnacePCM) { chan[c.chan].std.init(ins); - if (!chan[c.chan].std.willVol) { + if (!chan[c.chan].std.vol.will) { chan[c.chan].outVol=chan[c.chan].vol; immWrite(0x1b,chan[c.chan].outVol); } @@ -685,7 +685,7 @@ int DivPlatformYM2610::dispatch(DivCommand c) { DivInstrument* ins=parent->getIns(chan[c.chan].ins); chan[c.chan].std.init(ins); if (c.chan<4) { - if (!chan[c.chan].std.willVol) { + if (!chan[c.chan].std.vol.will) { chan[c.chan].outVol=chan[c.chan].vol; } } @@ -764,7 +764,7 @@ int DivPlatformYM2610::dispatch(DivCommand c) { break; case DIV_CMD_VOLUME: { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } if (c.chan>12) { // ADPCM-B diff --git a/src/engine/platform/ym2610b.cpp b/src/engine/platform/ym2610b.cpp index dfd847235..147a75469 100644 --- a/src/engine/platform/ym2610b.cpp +++ b/src/engine/platform/ym2610b.cpp @@ -440,8 +440,8 @@ void DivPlatformYM2610B::tick() { if (i==2 && extMode) continue; chan[i].std.next(); - if (chan[i].std.hadVol) { - chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol))/127; + if (chan[i].std.vol.had) { + chan[i].outVol=(chan[i].vol*MIN(127,chan[i].std.vol.val))/127; for (int j=0; j<4; j++) { unsigned short baseAddr=chanOffs[i]|opOffs[j]; DivInstrumentFM::Operator& op=chan[i].state.op[j]; @@ -453,24 +453,24 @@ void DivPlatformYM2610B::tick() { } } - if (chan[i].std.hadArp) { + if (chan[i].std.arp.had) { if (!chan[i].inPorta) { - if (chan[i].std.arpMode) { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp); + if (chan[i].std.arp.mode) { + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp.val); } else { - chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+(signed char)chan[i].std.arp); + chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+(signed char)chan[i].std.arp.val); } } chan[i].freqChanged=true; } else { - if (chan[i].std.arpMode && chan[i].std.finishedArp) { + if (chan[i].std.arp.mode && chan[i].std.arp.finished) { chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note); chan[i].freqChanged=true; } } - if (chan[i].std.hadAlg) { - chan[i].state.alg=chan[i].std.alg; + if (chan[i].std.alg.had) { + chan[i].state.alg=chan[i].std.alg.val; rWrite(chanOffs[i]+ADDR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3)); if (!parent->song.algMacroBehavior) for (int j=0; j<4; j++) { unsigned short baseAddr=chanOffs[i]|opOffs[j]; @@ -486,68 +486,68 @@ void DivPlatformYM2610B::tick() { } } } - if (chan[i].std.hadFb) { - chan[i].state.fb=chan[i].std.fb; + if (chan[i].std.fb.had) { + chan[i].state.fb=chan[i].std.fb.val; rWrite(chanOffs[i]+ADDR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3)); } - if (chan[i].std.hadFms) { - chan[i].state.fms=chan[i].std.fms; + if (chan[i].std.fms.had) { + chan[i].state.fms=chan[i].std.fms.val; rWrite(chanOffs[i]+ADDR_LRAF,(isMuted[i]?0:(chan[i].pan<<6))|(chan[i].state.fms&7)|((chan[i].state.ams&3)<<4)); } - if (chan[i].std.hadAms) { - chan[i].state.ams=chan[i].std.ams; + if (chan[i].std.ams.had) { + chan[i].state.ams=chan[i].std.ams.val; rWrite(chanOffs[i]+ADDR_LRAF,(isMuted[i]?0:(chan[i].pan<<6))|(chan[i].state.fms&7)|((chan[i].state.ams&3)<<4)); } for (int j=0; j<4; j++) { unsigned short baseAddr=chanOffs[i]|opOffs[j]; DivInstrumentFM::Operator& op=chan[i].state.op[j]; DivMacroInt::IntOp& m=chan[i].std.op[j]; - if (m.hadAm) { - op.am=m.am; + if (m.am.had) { + op.am=m.am.val; rWrite(baseAddr+ADDR_AM_DR,(op.dr&31)|(op.am<<7)); } - if (m.hadAr) { - op.ar=m.ar; + if (m.ar.had) { + op.ar=m.ar.val; rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.rs<<6)); } - if (m.hadDr) { - op.dr=m.dr; + if (m.dr.had) { + op.dr=m.dr.val; rWrite(baseAddr+ADDR_AM_DR,(op.dr&31)|(op.am<<7)); } - if (m.hadMult) { - op.mult=m.mult; + if (m.mult.had) { + op.mult=m.mult.val; rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4)); } - if (m.hadRr) { - op.rr=m.rr; + if (m.rr.had) { + op.rr=m.rr.val; rWrite(baseAddr+ADDR_SL_RR,(op.rr&15)|(op.sl<<4)); } - if (m.hadSl) { - op.sl=m.sl; + if (m.sl.had) { + op.sl=m.sl.val; rWrite(baseAddr+ADDR_SL_RR,(op.rr&15)|(op.sl<<4)); } - if (m.hadTl) { - op.tl=127-m.tl; + if (m.tl.had) { + op.tl=127-m.tl.val; if (isOutput[chan[i].state.alg][j]) { rWrite(baseAddr+ADDR_TL,127-(((127-op.tl)*(chan[i].outVol&0x7f))/127)); } else { rWrite(baseAddr+ADDR_TL,op.tl); } } - if (m.hadRs) { - op.rs=m.rs; + if (m.rs.had) { + op.rs=m.rs.val; rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.rs<<6)); } - if (m.hadDt) { - op.dt=m.dt; + if (m.dt.had) { + op.dt=m.dt.val; rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4)); } - if (m.hadD2r) { - op.d2r=m.d2r; + if (m.d2r.had) { + op.d2r=m.d2r.val; rWrite(baseAddr+ADDR_DT2_D2R,op.d2r&31); } - if (m.hadSsg) { - op.ssgEnv=m.ssg; + if (m.ssg.had) { + op.ssgEnv=m.ssg.val; rWrite(baseAddr+ADDR_SSG,op.ssgEnv&15); } } @@ -561,22 +561,22 @@ void DivPlatformYM2610B::tick() { if (chan[15].furnacePCM) { chan[15].std.next(); - if (chan[15].std.hadVol) { - chan[15].outVol=(chan[15].vol*MIN(64,chan[15].std.vol))/64; + if (chan[15].std.vol.had) { + chan[15].outVol=(chan[15].vol*MIN(64,chan[15].std.vol.val))/64; immWrite(0x1b,chan[15].outVol); } - if (chan[15].std.hadArp) { + if (chan[15].std.arp.had) { if (!chan[15].inPorta) { - if (chan[15].std.arpMode) { - chan[15].baseFreq=NOTE_ADPCMB(chan[15].std.arp); + if (chan[15].std.arp.mode) { + chan[15].baseFreq=NOTE_ADPCMB(chan[15].std.arp.val); } else { - chan[15].baseFreq=NOTE_ADPCMB(chan[15].note+(signed char)chan[15].std.arp); + chan[15].baseFreq=NOTE_ADPCMB(chan[15].note+(signed char)chan[15].std.arp.val); } } chan[15].freqChanged=true; } else { - if (chan[15].std.arpMode && chan[15].std.finishedArp) { + if (chan[15].std.arp.mode && chan[15].std.arp.finished) { chan[15].baseFreq=NOTE_ADPCMB(chan[15].note); chan[15].freqChanged=true; } @@ -671,7 +671,7 @@ int DivPlatformYM2610B::dispatch(DivCommand c) { if (skipRegisterWrites) break; if (chan[c.chan].furnacePCM) { chan[c.chan].std.init(ins); - if (!chan[c.chan].std.willVol) { + if (!chan[c.chan].std.vol.will) { chan[c.chan].outVol=chan[c.chan].vol; immWrite(0x1b,chan[c.chan].outVol); } @@ -748,7 +748,7 @@ int DivPlatformYM2610B::dispatch(DivCommand c) { DivInstrument* ins=parent->getIns(chan[c.chan].ins); chan[c.chan].std.init(ins); if (c.chan<6) { - if (!chan[c.chan].std.willVol) { + if (!chan[c.chan].std.vol.will) { chan[c.chan].outVol=chan[c.chan].vol; } } @@ -827,7 +827,7 @@ int DivPlatformYM2610B::dispatch(DivCommand c) { break; case DIV_CMD_VOLUME: { chan[c.chan].vol=c.value; - if (!chan[c.chan].std.hasVol) { + if (!chan[c.chan].std.vol.has) { chan[c.chan].outVol=c.value; } if (c.chan>14) { // ADPCM-B diff --git a/src/engine/safeReader.cpp b/src/engine/safeReader.cpp index 9add1b5aa..f27e90446 100644 --- a/src/engine/safeReader.cpp +++ b/src/engine/safeReader.cpp @@ -66,6 +66,42 @@ int SafeReader::read(void* where, size_t count) { return count; } +template +int SafeReader::readByte(T* where, size_t count, unsigned char byte, Endianness endianness) { + if (byte==sizeof(T)) { + return read(where,count*byte); + } else { +#ifdef READ_DEBUG + logD("SR: reading %d x %d bit words at %x\n",count,byte<<3,curSeek); +#endif + if (count==0) return 0; + if (curSeek+(count*byte)>len) throw EndOfFileException(this,len); + int start,end,inc; + switch (endianness) { + case BigEndian: + start=byte-1; + end=-1; + inc=-1; + break; + case LittleEndian: + default: + start=0; + end=byte; + inc=1; + break; + } + for (int c=0; c #include "../ta-utils.h" +enum Endianness { + LittleEndian=0, + BigEndian +}; + class SafeReader; struct EndOfFileException { @@ -46,6 +51,7 @@ class SafeReader { size_t size(); int read(void* where, size_t count); + template int readByte(T* where, size_t count, unsigned char byte=sizeof(T), Endianness endianness=LittleEndian); // these functions may throw EndOfFileException. signed char readC(); diff --git a/src/engine/safeWriter.cpp b/src/engine/safeWriter.cpp index f29800a4a..2e8fb7dd4 100644 --- a/src/engine/safeWriter.cpp +++ b/src/engine/safeWriter.cpp @@ -73,6 +73,39 @@ int SafeWriter::write(const void* what, size_t count) { return count; } +template +int SafeWriter::writeByte(T* what, size_t count, unsigned char byte, Endianness endianness) { + if (byte==sizeof(T)) { + return write(what,count*byte); + } else { + if (!operative) return 0; + checkSize(count*byte); + int start,end,inc; + switch (endianness) { + case BigEndian: + start=byte-1; + end=-1; + inc=-1; + break; + case LittleEndian: + default: + start=0; + end=byte; + inc=1; + break; + } + for (int c=0; c>(byte<<3))&0xff; + } + } + count*=byte; + if (curSeek>len) len=curSeek; + } + return count; +} + int SafeWriter::writeC(signed char val) { return write(&val,1); } diff --git a/src/engine/safeWriter.h b/src/engine/safeWriter.h index 9072c61d7..c4920378a 100644 --- a/src/engine/safeWriter.h +++ b/src/engine/safeWriter.h @@ -43,6 +43,7 @@ class SafeWriter { size_t size(); int write(const void* what, size_t count); + template int writeByte(T* what, size_t count, unsigned char byte=sizeof(T), Endianness endianness=LittleEndian); int writeC(signed char val); int writeS(short val); diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 14ca65b40..1f5d9e914 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -176,6 +176,15 @@ const char* dualWSEffects[7]={ "Phase (dual)", }; +const char* macroAbsoluteMode[2]={ + "Relative", + "Absolute", +}; + +const char* macroDummyMode[2]={ + "empty", +}; + String macroHoverNote(int id, float val) { if (val<-60 || val>=120) return "???"; return fmt::sprintf("%d: %s",id,noteNames[(int)val+60]); @@ -924,8 +933,8 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, ImVec2 posREnd=ImLerp(rect.Min,rect.Max,ImVec2(rrPos,1.0));//release end ImVec2 posSLineHEnd=ImLerp(rect.Min,rect.Max,ImVec2(1.0,(float)((tl/maxTl)+(sl/15.0)-((tl/maxTl)*(sl/15.0))))); //sustain horizontal line end ImVec2 posSLineVEnd=ImLerp(rect.Min,rect.Max,ImVec2(drPos,1.0)); //sustain vertical line end - ImVec2 posDecayRate0Pt=ImLerp(rect.Min,rect.Max,ImVec2(1.0,(tl/maxTl))); //Heght of the peak of AR, forever - ImVec2 posDecay2Rate0Pt=ImLerp(rect.Min,rect.Max,ImVec2(1.0,(float)((tl/maxTl)+(sl/15.0)-((tl/maxTl)*(sl/15.0))))); //Heght of the peak of SR, forever + ImVec2 posDecayRate0Pt=ImLerp(rect.Min,rect.Max,ImVec2(1.0,(tl/maxTl))); //Height of the peak of AR, forever + ImVec2 posDecay2Rate0Pt=ImLerp(rect.Min,rect.Max,ImVec2(1.0,(float)((tl/maxTl)+(sl/15.0)-((tl/maxTl)*(sl/15.0))))); //Height of the peak of SR, forever //dl->Flags=ImDrawListFlags_AntiAliasedLines|ImDrawListFlags_AntiAliasedLinesUseTex; if (ar==0.0) { //if AR = 0, the envelope never starts @@ -963,7 +972,7 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, #define PARAMETER MARK_MODIFIED; e->notifyInsChange(curIns); -#define NORMAL_MACRO(macro,macroLen,macroLoop,macroRel,macroMin,macroHeight,macroName,displayName,displayHeight,displayLoop,bitfield,bfVal,drawSlider,sliderVal,sliderLow,macroDispMin,bitOff,macroMode,macroColor,mmlStr,macroAMin,macroAMax,hoverFunc,blockMode) \ +#define NORMAL_MACRO(macro,macroMin,macroHeight,macroName,displayName,displayHeight,displayLoop,bitfield,bfVal,drawSlider,sliderVal,sliderLow,macroDispMin,bitOff,macroMode,macroModeMax,displayModeName,macroColor,mmlStr,macroAMin,macroAMax,hoverFunc,blockMode) \ ImGui::TableNextRow(); \ ImGui::TableNextColumn(); \ ImGui::Text("%s",displayName); \ @@ -973,26 +982,41 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, } \ if (displayLoop) { \ ImGui::SetNextItemWidth(lenAvail); \ - if (ImGui::InputScalar("##IMacroLen_" macroName,ImGuiDataType_U8,¯oLen,&_ONE,&_THREE)) { MARK_MODIFIED \ - if (macroLen>127) macroLen=127; \ + if (ImGui::InputScalar("##IMacroLen_" macroName,ImGuiDataType_U8,¯o.len,&_ONE,&_THREE)) { MARK_MODIFIED \ + if (macro.len>127) macro.len=127; \ } \ - if (macroMode!=NULL) { \ - ImGui::Checkbox("Fixed##IMacroMode_" macroName,macroMode); \ + if (macroMode) { \ + String modeName; \ + if (macro.mode>macroModeMax) { \ + modeName="none selected"; \ + } else { \ + modeName=displayModeName[macro.mode]; \ + } \ + if (ImGui::BeginCombo("Macro Mode",modeName.c_str())) { \ + String id; \ + for (unsigned int i=0; i<=macroModeMax; i++) { \ + id=fmt::sprintf("%d: %s",i,displayModeName[i]); \ + if (ImGui::Selectable(id.c_str(),macro.mode==i)) { PARAMETER \ + macro.mode=i; \ + } \ + } \ + ImGui::EndCombo(); \ + } \ } \ } \ ImGui::TableNextColumn(); \ for (int j=0; j<256; j++) { \ - if (j+macroDragScroll>=macroLen) { \ + if (j+macroDragScroll>=macro.len) { \ asFloat[j]=0; \ asInt[j]=0; \ } else { \ - asFloat[j]=macro[j+macroDragScroll]+macroDispMin; \ - asInt[j]=macro[j+macroDragScroll]+macroDispMin+bitOff; \ + asFloat[j]=macro.val[j+macroDragScroll]+macroDispMin; \ + asInt[j]=macro.val[j+macroDragScroll]+macroDispMin+bitOff; \ } \ - if (j+macroDragScroll>=macroLen || (j+macroDragScroll>macroRel && macroLoop=macro.len || (j+macroDragScroll>macro.rel && macro.loop=macroLoop))|((macroRel!=-1 && (j+macroDragScroll)==macroRel)<<1); \ + loopIndicator[j]=((macro.loop!=-1 && (j+macroDragScroll)>=macro.loop))|((macro.rel!=-1 && (j+macroDragScroll)==macro.rel)<<1); \ } \ } \ ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,ImVec2(0.0f,0.0f)); \ @@ -1000,7 +1024,7 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, if (bitfield) { \ PlotBitfield("##IMacro_" macroName,asInt,totalFit,0,bfVal,macroHeight,ImVec2(availableWidth,(displayLoop)?(displayHeight*dpiScale):(32.0f*dpiScale))); \ } else { \ - PlotCustom("##IMacro_" macroName,asFloat,totalFit,macroDragScroll,NULL,macroDispMin+macroMin,macroHeight+macroDispMin,ImVec2(availableWidth,(displayLoop)?(displayHeight*dpiScale):(32.0f*dpiScale)),sizeof(float),macroColor,macroLen-macroDragScroll,hoverFunc,blockMode); \ + PlotCustom("##IMacro_" macroName,asFloat,totalFit,macroDragScroll,NULL,macroDispMin+macroMin,macroHeight+macroDispMin,ImVec2(availableWidth,(displayLoop)?(displayHeight*dpiScale):(32.0f*dpiScale)),sizeof(float),macroColor,macro.len-macroDragScroll,hoverFunc,blockMode); \ } \ if (displayLoop && ImGui::IsItemClicked(ImGuiMouseButton_Left)) { \ macroDragStart=ImGui::GetItemRectMin(); \ @@ -1013,7 +1037,7 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, macroDragInitialValue=false; \ macroDragLen=totalFit; \ macroDragActive=true; \ - macroDragTarget=macro; \ + macroDragTarget=macro.val; \ macroDragChar=false; \ processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); \ } \ @@ -1022,63 +1046,81 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, ImGui::SameLine(); \ CWVSliderInt("##IArpMacroPos",ImVec2(20.0f*dpiScale,displayHeight*dpiScale),sliderVal,sliderLow,70); \ } \ - PlotCustom("##IMacroLoop_" macroName,loopIndicator,totalFit,macroDragScroll,NULL,0,2,ImVec2(availableWidth,12.0f*dpiScale),sizeof(float),macroColor,macroLen-macroDragScroll,¯oHoverLoop); \ + PlotCustom("##IMacroLoop_" macroName,loopIndicator,totalFit,macroDragScroll,NULL,0,2,ImVec2(availableWidth,12.0f*dpiScale),sizeof(float),macroColor,macro.len-macroDragScroll,¯oHoverLoop); \ if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) { \ macroLoopDragStart=ImGui::GetItemRectMin(); \ macroLoopDragAreaSize=ImVec2(availableWidth,12.0f*dpiScale); \ macroLoopDragLen=totalFit; \ if (ImGui::IsKeyDown(ImGuiKey_LeftShift) || ImGui::IsKeyDown(ImGuiKey_RightShift)) { \ - macroLoopDragTarget=¯oRel; \ + macroLoopDragTarget=¯o.rel; \ } else { \ - macroLoopDragTarget=¯oLoop; \ + macroLoopDragTarget=¯o.loop; \ } \ macroLoopDragActive=true; \ processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); \ } \ if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { \ if (ImGui::IsKeyDown(ImGuiKey_LeftShift) || ImGui::IsKeyDown(ImGuiKey_RightShift)) { \ - macroRel=-1; \ + macro.rel=-1; \ } else { \ - macroLoop=-1; \ + macro.loop=-1; \ } \ } \ ImGui::SetNextItemWidth(availableWidth); \ if (ImGui::InputText("##IMacroMML_" macroName,&mmlStr)) { \ - decodeMMLStr(mmlStr,macro,macroLen,macroLoop,macroAMin,(bitfield)?((1<127) macroLen=127; \ + if (ImGui::InputScalar("##IOPMacro.len_" #op macroName,ImGuiDataType_U8,¯o.len,&_ONE,&_THREE)) { MARK_MODIFIED \ + if (macro.len>127) macro.len=127; \ + } \ + if (macroMode) { \ + String modeName; \ + if (macro.mode>macroModeMax) { \ + modeName="none selected"; \ + } else { \ + modeName=displayModeName[macro.mode]; \ + } \ + if (ImGui::BeginCombo("Macro Mode",modeName.c_str())) { \ + String id; \ + for (unsigned int i=0; i<=macroModeMax; i++) { \ + id=fmt::sprintf("%d: %s",i,displayModeName[i]); \ + if (ImGui::Selectable(id.c_str(),macro.mode==i)) { PARAMETER \ + macro.mode=i; \ + } \ + } \ + ImGui::EndCombo(); \ + } \ } \ } \ ImGui::TableNextColumn(); \ for (int j=0; j<256; j++) { \ - if (j+macroDragScroll>=macroLen) { \ + if (j+macroDragScroll>=macro.len) { \ asFloat[j]=0; \ asInt[j]=0; \ } else { \ - asFloat[j]=macro[j+macroDragScroll]; \ - asInt[j]=macro[j+macroDragScroll]; \ + asFloat[j]=macro.val[j+macroDragScroll]; \ + asInt[j]=macro.val[j+macroDragScroll]; \ } \ - if (j+macroDragScroll>=macroLen || (j+macroDragScroll>macroRel && macroLoop=macro.len || (j+macroDragScroll>macro.rel && macro.loop=macroLoop))|((macroRel!=-1 && (j+macroDragScroll)==macroRel)<<1); \ + loopIndicator[j]=((macro.loop!=-1 && (j+macroDragScroll)>=macro.loop))|((macro.rel!=-1 && (j+macroDragScroll)==macro.rel)<<1); \ } \ } \ ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,ImVec2(0.0f,0.0f)); \ @@ -1086,7 +1128,7 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, if (bitfield) { \ PlotBitfield("##IOPMacro_" #op macroName,asInt,totalFit,0,bfVal,macroHeight,ImVec2(availableWidth,displayLoop?(displayHeight*dpiScale):(24*dpiScale))); \ } else { \ - PlotCustom("##IOPMacro_" #op macroName,asFloat,totalFit,macroDragScroll,NULL,0,macroHeight,ImVec2(availableWidth,displayLoop?(displayHeight*dpiScale):(24*dpiScale)),sizeof(float),uiColors[GUI_COLOR_MACRO_OTHER],macroLen-macroDragScroll); \ + PlotCustom("##IOPMacro_" #op macroName,asFloat,totalFit,macroDragScroll,NULL,0,macroHeight,ImVec2(availableWidth,displayLoop?(displayHeight*dpiScale):(24*dpiScale)),sizeof(float),uiColors[GUI_COLOR_MACRO_OTHER],macro.len-macroDragScroll); \ } \ if (displayLoop && ImGui::IsItemClicked(ImGuiMouseButton_Left)) { \ macroDragStart=ImGui::GetItemRectMin(); \ @@ -1099,37 +1141,37 @@ void FurnaceGUI::drawFMEnv(unsigned char tl, unsigned char ar, unsigned char dr, macroDragInitialValue=false; \ macroDragLen=totalFit; \ macroDragActive=true; \ - macroDragCTarget=macro; \ - macroDragChar=true; \ + macroDragTarget=macro.val; \ + macroDragChar=false; \ processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); \ } \ if (displayLoop) { \ - PlotCustom("##IOPMacroLoop_" #op macroName,loopIndicator,totalFit,macroDragScroll,NULL,0,2,ImVec2(availableWidth,12.0f*dpiScale),sizeof(float),uiColors[GUI_COLOR_MACRO_OTHER],macroLen-macroDragScroll,¯oHoverLoop); \ + PlotCustom("##IOPMacro.loop_" #op macroName,loopIndicator,totalFit,macroDragScroll,NULL,0,2,ImVec2(availableWidth,12.0f*dpiScale),sizeof(float),uiColors[GUI_COLOR_MACRO_OTHER],macro.len-macroDragScroll,¯oHoverLoop); \ if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) { \ macroLoopDragStart=ImGui::GetItemRectMin(); \ macroLoopDragAreaSize=ImVec2(availableWidth,8.0f*dpiScale); \ macroLoopDragLen=totalFit; \ if (ImGui::IsKeyDown(ImGuiKey_LeftShift) || ImGui::IsKeyDown(ImGuiKey_RightShift)) { \ - macroLoopDragTarget=¯oRel; \ + macroLoopDragTarget=¯o.rel; \ } else { \ - macroLoopDragTarget=¯oLoop; \ + macroLoopDragTarget=¯o.loop; \ } \ macroLoopDragActive=true; \ processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); \ } \ if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { \ if (ImGui::IsKeyDown(ImGuiKey_LeftShift) || ImGui::IsKeyDown(ImGuiKey_RightShift)) { \ - macroRel=-1; \ + macro.rel=-1; \ } else { \ - macroLoop=-1; \ + macro.loop=-1; \ } \ } \ ImGui::SetNextItemWidth(availableWidth); \ if (ImGui::InputText("##IOPMacroMML_" macroName,&mmlStr)) { \ - decodeMMLStr(mmlStr,macro,macroLen,macroLoop,0,bitfield?((1<type==DIV_INS_OPLL) { - NORMAL_MACRO(ins->std.algMacro,ins->std.algMacroLen,ins->std.algMacroLoop,ins->std.algMacroRel,0,1,"alg",FM_NAME(FM_SUS),32,ins->std.algMacroOpen,true,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[0],0,1,NULL,false); - NORMAL_MACRO(ins->std.fbMacro,ins->std.fbMacroLen,ins->std.fbMacroLoop,ins->std.fbMacroRel,0,7,"fb",FM_NAME(FM_FB),96,ins->std.fbMacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[1],0,7,NULL,false); - NORMAL_MACRO(ins->std.fmsMacro,ins->std.fmsMacroLen,ins->std.fmsMacroLoop,ins->std.fmsMacroRel,0,1,"fms",FM_NAME(FM_DC),32,ins->std.fmsMacroOpen,true,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[2],0,1,NULL,false); - NORMAL_MACRO(ins->std.amsMacro,ins->std.amsMacroLen,ins->std.amsMacroLoop,ins->std.amsMacroRel,0,1,"ams",FM_NAME(FM_DM),32,ins->std.amsMacroOpen,true,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[3],0,1,NULL,false); + NORMAL_MACRO(ins->std.algMacro,0,1,"alg",FM_NAME(FM_SUS),32,ins->std.algMacro.open,true,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[0],0,1,NULL,false); + NORMAL_MACRO(ins->std.fbMacro,0,7,"fb",FM_NAME(FM_FB),96,ins->std.fbMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[1],0,7,NULL,false); + NORMAL_MACRO(ins->std.fmsMacro,0,1,"fms",FM_NAME(FM_DC),32,ins->std.fmsMacro.open,true,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[2],0,1,NULL,false); + NORMAL_MACRO(ins->std.amsMacro,0,1,"ams",FM_NAME(FM_DM),32,ins->std.amsMacro.open,true,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[3],0,1,NULL,false); } else { - NORMAL_MACRO(ins->std.algMacro,ins->std.algMacroLen,ins->std.algMacroLoop,ins->std.algMacroRel,0,7,"alg",FM_NAME(FM_ALG),96,ins->std.algMacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[0],0,7,NULL,false); - NORMAL_MACRO(ins->std.fbMacro,ins->std.fbMacroLen,ins->std.fbMacroLoop,ins->std.fbMacroRel,0,7,"fb",FM_NAME(FM_FB),96,ins->std.fbMacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[1],0,7,NULL,false); + NORMAL_MACRO(ins->std.algMacro,0,7,"alg",FM_NAME(FM_ALG),96,ins->std.algMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[0],0,7,NULL,false); + NORMAL_MACRO(ins->std.fbMacro,0,7,"fb",FM_NAME(FM_FB),96,ins->std.fbMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[1],0,7,NULL,false); if (ins->type!=DIV_INS_OPL) { - NORMAL_MACRO(ins->std.fmsMacro,ins->std.fmsMacroLen,ins->std.fmsMacroLoop,ins->std.fmsMacroRel,0,7,"fms",FM_NAME(FM_FMS),96,ins->std.fmsMacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[2],0,7,NULL,false); - NORMAL_MACRO(ins->std.amsMacro,ins->std.amsMacroLen,ins->std.amsMacroLoop,ins->std.amsMacroRel,0,3,"ams",FM_NAME(FM_AMS),48,ins->std.amsMacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[3],0,3,NULL,false); + if (ins->type==DIV_INS_OPZ) { + NORMAL_MACRO(ins->std.fmsMacro,0,7,"fms",FM_NAME(FM_FMS),96,ins->std.fmsMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[2],0,7,NULL,false); + NORMAL_MACRO(ins->std.fms2Macro,0,7,"fms2",FM_NAME(FM_FMS2),96,ins->std.fms2Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[3],0,7,NULL,false); + NORMAL_MACRO(ins->std.amsMacro,0,3,"ams",FM_NAME(FM_AMS),48,ins->std.amsMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,3,NULL,false); + NORMAL_MACRO(ins->std.ams2Macro,0,3,"ams2",FM_NAME(FM_AMS2),48,ins->std.ams2Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[5],0,3,NULL,false); + } else { + NORMAL_MACRO(ins->std.fmsMacro,0,7,"fms",FM_NAME(FM_FMS),96,ins->std.fmsMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[2],0,7,NULL,false); + NORMAL_MACRO(ins->std.amsMacro,0,3,"ams",FM_NAME(FM_AMS),48,ins->std.amsMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[3],0,3,NULL,false); + } } } if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPZ) { - NORMAL_MACRO(ins->std.ex1Macro,ins->std.ex1MacroLen,ins->std.ex1MacroLoop,ins->std.ex1MacroRel,0,127,"ex1","AM Depth",128,ins->std.ex1MacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,127,NULL,false); - NORMAL_MACRO(ins->std.ex2Macro,ins->std.ex2MacroLen,ins->std.ex2MacroLoop,ins->std.ex2MacroRel,0,127,"ex2","PM Depth",128,ins->std.ex2MacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[5],0,127,NULL,false); - NORMAL_MACRO(ins->std.ex3Macro,ins->std.ex3MacroLen,ins->std.ex3MacroLoop,ins->std.ex3MacroRel,0,255,"ex3","LFO Speed",128,ins->std.ex3MacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[6],0,255,NULL,false); - NORMAL_MACRO(ins->std.waveMacro,ins->std.waveMacroLen,ins->std.waveMacroLoop,ins->std.waveMacroRel,0,3,"wave","LFO Shape",48,ins->std.waveMacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_WAVE],mmlString[7],0,3,¯oLFOWaves,false); + NORMAL_MACRO(ins->std.ex1Macro,0,127,"ex1","AM Depth",128,ins->std.ex1Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[6],0,127,NULL,false); + NORMAL_MACRO(ins->std.ex2Macro,0,127,"ex2","PM Depth",128,ins->std.ex2Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[7],0,127,NULL,false); + NORMAL_MACRO(ins->std.ex3Macro,0,255,"ex3","LFO Speed",128,ins->std.ex3Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[8],0,255,NULL,false); + NORMAL_MACRO(ins->std.waveMacro,0,3,"wave","LFO Shape",48,ins->std.waveMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_WAVE],mmlString[9],0,3,¯oLFOWaves,false); } MACRO_END; ImGui::EndTabItem(); @@ -2041,45 +2090,45 @@ void FurnaceGUI::drawInsEdit() { int maxArDr=(ins->type==DIV_INS_FM || ins->type==DIV_INS_OPZ)?31:15; if (ins->type==DIV_INS_OPL) { - OP_MACRO(ins->std.opMacros[ordi].tlMacro,ins->std.opMacros[ordi].tlMacroLen,ins->std.opMacros[ordi].tlMacroLoop,ins->std.opMacros[ordi].tlMacroRel,maxTl,ordi,"tl",FM_NAME(FM_TL),128,ins->std.opMacros[ordi].tlMacroOpen,false,NULL,mmlString[0]); - OP_MACRO(ins->std.opMacros[ordi].arMacro,ins->std.opMacros[ordi].arMacroLen,ins->std.opMacros[ordi].arMacroLoop,ins->std.opMacros[ordi].arMacroRel,maxArDr,ordi,"ar",FM_NAME(FM_AR),64,ins->std.opMacros[ordi].arMacroOpen,false,NULL,mmlString[1]); - OP_MACRO(ins->std.opMacros[ordi].drMacro,ins->std.opMacros[ordi].drMacroLen,ins->std.opMacros[ordi].drMacroLoop,ins->std.opMacros[ordi].drMacroRel,maxArDr,ordi,"dr",FM_NAME(FM_DR),64,ins->std.opMacros[ordi].drMacroOpen,false,NULL,mmlString[2]); - OP_MACRO(ins->std.opMacros[ordi].slMacro,ins->std.opMacros[ordi].slMacroLen,ins->std.opMacros[ordi].slMacroLoop,ins->std.opMacros[ordi].slMacroRel,15,ordi,"sl",FM_NAME(FM_SL),64,ins->std.opMacros[ordi].slMacroOpen,false,NULL,mmlString[5]); - OP_MACRO(ins->std.opMacros[ordi].rrMacro,ins->std.opMacros[ordi].rrMacroLen,ins->std.opMacros[ordi].rrMacroLoop,ins->std.opMacros[ordi].rrMacroRel,15,ordi,"rr",FM_NAME(FM_RR),64,ins->std.opMacros[ordi].rrMacroOpen,false,NULL,mmlString[4]); - OP_MACRO(ins->std.opMacros[ordi].kslMacro,ins->std.opMacros[ordi].kslMacroLen,ins->std.opMacros[ordi].kslMacroLoop,ins->std.opMacros[ordi].kslMacroRel,3,ordi,"ksl",FM_NAME(FM_KSL),32,ins->std.opMacros[ordi].kslMacroOpen,false,NULL,mmlString[6]); - OP_MACRO(ins->std.opMacros[ordi].multMacro,ins->std.opMacros[ordi].multMacroLen,ins->std.opMacros[ordi].multMacroLoop,ins->std.opMacros[ordi].multMacroRel,15,ordi,"mult",FM_NAME(FM_MULT),64,ins->std.opMacros[ordi].multMacroOpen,false,NULL,mmlString[7]); - OP_MACRO(ins->std.opMacros[ordi].wsMacro,ins->std.opMacros[ordi].wsMacroLen,ins->std.opMacros[ordi].wsMacroLoop,ins->std.opMacros[ordi].wsMacroRel,7,ordi,"ws",FM_NAME(FM_WS),64,ins->std.opMacros[ordi].wsMacroOpen,false,NULL,mmlString[8]); + OP_MACRO(ins->std.opMacros[ordi].tlMacro,maxTl,ordi,"tl",FM_NAME(FM_TL),128,ins->std.opMacros[ordi].tlMacro.open,false,NULL,false,0,macroDummyMode,mmlString[0]); + OP_MACRO(ins->std.opMacros[ordi].arMacro,maxArDr,ordi,"ar",FM_NAME(FM_AR),64,ins->std.opMacros[ordi].arMacro.open,false,NULL,false,0,macroDummyMode,mmlString[1]); + OP_MACRO(ins->std.opMacros[ordi].drMacro,maxArDr,ordi,"dr",FM_NAME(FM_DR),64,ins->std.opMacros[ordi].drMacro.open,false,NULL,false,0,macroDummyMode,mmlString[2]); + OP_MACRO(ins->std.opMacros[ordi].slMacro,15,ordi,"sl",FM_NAME(FM_SL),64,ins->std.opMacros[ordi].slMacro.open,false,NULL,false,0,macroDummyMode,mmlString[5]); + OP_MACRO(ins->std.opMacros[ordi].rrMacro,15,ordi,"rr",FM_NAME(FM_RR),64,ins->std.opMacros[ordi].rrMacro.open,false,NULL,false,0,macroDummyMode,mmlString[4]); + OP_MACRO(ins->std.opMacros[ordi].kslMacro,3,ordi,"ksl",FM_NAME(FM_KSL),32,ins->std.opMacros[ordi].kslMacro.open,false,NULL,false,0,macroDummyMode,mmlString[6]); + OP_MACRO(ins->std.opMacros[ordi].multMacro,15,ordi,"mult",FM_NAME(FM_MULT),64,ins->std.opMacros[ordi].multMacro.open,false,NULL,false,0,macroDummyMode,mmlString[7]); + OP_MACRO(ins->std.opMacros[ordi].wsMacro,7,ordi,"ws",FM_NAME(FM_WS),64,ins->std.opMacros[ordi].wsMacro.open,false,NULL,false,0,macroDummyMode,mmlString[8]); - OP_MACRO(ins->std.opMacros[ordi].amMacro,ins->std.opMacros[ordi].amMacroLen,ins->std.opMacros[ordi].amMacroLoop,ins->std.opMacros[ordi].amMacroRel,1,ordi,"am",FM_NAME(FM_AM),32,ins->std.opMacros[ordi].amMacroOpen,true,NULL,mmlString[9]); - OP_MACRO(ins->std.opMacros[ordi].vibMacro,ins->std.opMacros[ordi].vibMacroLen,ins->std.opMacros[ordi].vibMacroLoop,ins->std.opMacros[ordi].vibMacroRel,1,ordi,"vib",FM_NAME(FM_VIB),32,ins->std.opMacros[ordi].vibMacroOpen,true,NULL,mmlString[10]); - OP_MACRO(ins->std.opMacros[ordi].ksrMacro,ins->std.opMacros[ordi].ksrMacroLen,ins->std.opMacros[ordi].ksrMacroLoop,ins->std.opMacros[ordi].ksrMacroRel,1,ordi,"ksr",FM_NAME(FM_KSR),32,ins->std.opMacros[ordi].ksrMacroOpen,true,NULL,mmlString[11]); - OP_MACRO(ins->std.opMacros[ordi].susMacro,ins->std.opMacros[ordi].susMacroLen,ins->std.opMacros[ordi].susMacroLoop,ins->std.opMacros[ordi].susMacroRel,1,ordi,"sus",FM_NAME(FM_SUS),32,ins->std.opMacros[ordi].susMacroOpen,true,NULL,mmlString[12]); + OP_MACRO(ins->std.opMacros[ordi].amMacro,1,ordi,"am",FM_NAME(FM_AM),32,ins->std.opMacros[ordi].amMacro.open,true,NULL,false,0,macroDummyMode,mmlString[9]); + OP_MACRO(ins->std.opMacros[ordi].vibMacro,1,ordi,"vib",FM_NAME(FM_VIB),32,ins->std.opMacros[ordi].vibMacro.open,true,NULL,false,0,macroDummyMode,mmlString[10]); + OP_MACRO(ins->std.opMacros[ordi].ksrMacro,1,ordi,"ksr",FM_NAME(FM_KSR),32,ins->std.opMacros[ordi].ksrMacro.open,true,NULL,false,0,macroDummyMode,mmlString[11]); + OP_MACRO(ins->std.opMacros[ordi].susMacro,1,ordi,"sus",FM_NAME(FM_SUS),32,ins->std.opMacros[ordi].susMacro.open,true,NULL,false,0,macroDummyMode,mmlString[12]); } else if (ins->type==DIV_INS_OPLL) { - OP_MACRO(ins->std.opMacros[ordi].tlMacro,ins->std.opMacros[ordi].tlMacroLen,ins->std.opMacros[ordi].tlMacroLoop,ins->std.opMacros[ordi].tlMacroRel,maxTl,ordi,"tl",FM_NAME(FM_TL),128,ins->std.opMacros[ordi].tlMacroOpen,false,NULL,mmlString[0]); - OP_MACRO(ins->std.opMacros[ordi].arMacro,ins->std.opMacros[ordi].arMacroLen,ins->std.opMacros[ordi].arMacroLoop,ins->std.opMacros[ordi].arMacroRel,maxArDr,ordi,"ar",FM_NAME(FM_AR),64,ins->std.opMacros[ordi].arMacroOpen,false,NULL,mmlString[1]); - OP_MACRO(ins->std.opMacros[ordi].drMacro,ins->std.opMacros[ordi].drMacroLen,ins->std.opMacros[ordi].drMacroLoop,ins->std.opMacros[ordi].drMacroRel,maxArDr,ordi,"dr",FM_NAME(FM_DR),64,ins->std.opMacros[ordi].drMacroOpen,false,NULL,mmlString[2]); - OP_MACRO(ins->std.opMacros[ordi].slMacro,ins->std.opMacros[ordi].slMacroLen,ins->std.opMacros[ordi].slMacroLoop,ins->std.opMacros[ordi].slMacroRel,15,ordi,"sl",FM_NAME(FM_SL),64,ins->std.opMacros[ordi].slMacroOpen,false,NULL,mmlString[5]); - OP_MACRO(ins->std.opMacros[ordi].rrMacro,ins->std.opMacros[ordi].rrMacroLen,ins->std.opMacros[ordi].rrMacroLoop,ins->std.opMacros[ordi].rrMacroRel,15,ordi,"rr",FM_NAME(FM_RR),64,ins->std.opMacros[ordi].rrMacroOpen,false,NULL,mmlString[4]); - OP_MACRO(ins->std.opMacros[ordi].kslMacro,ins->std.opMacros[ordi].kslMacroLen,ins->std.opMacros[ordi].kslMacroLoop,ins->std.opMacros[ordi].kslMacroRel,3,ordi,"ksl",FM_NAME(FM_KSL),32,ins->std.opMacros[ordi].kslMacroOpen,false,NULL,mmlString[6]); - OP_MACRO(ins->std.opMacros[ordi].multMacro,ins->std.opMacros[ordi].multMacroLen,ins->std.opMacros[ordi].multMacroLoop,ins->std.opMacros[ordi].multMacroRel,15,ordi,"mult",FM_NAME(FM_MULT),64,ins->std.opMacros[ordi].multMacroOpen,false,NULL,mmlString[7]); + OP_MACRO(ins->std.opMacros[ordi].tlMacro,maxTl,ordi,"tl",FM_NAME(FM_TL),128,ins->std.opMacros[ordi].tlMacro.open,false,NULL,false,0,macroDummyMode,mmlString[0]); + OP_MACRO(ins->std.opMacros[ordi].arMacro,maxArDr,ordi,"ar",FM_NAME(FM_AR),64,ins->std.opMacros[ordi].arMacro.open,false,NULL,false,0,macroDummyMode,mmlString[1]); + OP_MACRO(ins->std.opMacros[ordi].drMacro,maxArDr,ordi,"dr",FM_NAME(FM_DR),64,ins->std.opMacros[ordi].drMacro.open,false,NULL,false,0,macroDummyMode,mmlString[2]); + OP_MACRO(ins->std.opMacros[ordi].slMacro,15,ordi,"sl",FM_NAME(FM_SL),64,ins->std.opMacros[ordi].slMacro.open,false,NULL,false,0,macroDummyMode,mmlString[5]); + OP_MACRO(ins->std.opMacros[ordi].rrMacro,15,ordi,"rr",FM_NAME(FM_RR),64,ins->std.opMacros[ordi].rrMacro.open,false,NULL,false,0,macroDummyMode,mmlString[4]); + OP_MACRO(ins->std.opMacros[ordi].kslMacro,3,ordi,"ksl",FM_NAME(FM_KSL),32,ins->std.opMacros[ordi].kslMacro.open,false,NULL,false,0,macroDummyMode,mmlString[6]); + OP_MACRO(ins->std.opMacros[ordi].multMacro,15,ordi,"mult",FM_NAME(FM_MULT),64,ins->std.opMacros[ordi].multMacro.open,false,NULL,false,0,macroDummyMode,mmlString[7]); - OP_MACRO(ins->std.opMacros[ordi].amMacro,ins->std.opMacros[ordi].amMacroLen,ins->std.opMacros[ordi].amMacroLoop,ins->std.opMacros[ordi].amMacroRel,1,ordi,"am",FM_NAME(FM_AM),32,ins->std.opMacros[ordi].amMacroOpen,true,NULL,mmlString[8]); - OP_MACRO(ins->std.opMacros[ordi].vibMacro,ins->std.opMacros[ordi].vibMacroLen,ins->std.opMacros[ordi].vibMacroLoop,ins->std.opMacros[ordi].vibMacroRel,1,ordi,"vib",FM_NAME(FM_VIB),32,ins->std.opMacros[ordi].vibMacroOpen,true,NULL,mmlString[9]); - OP_MACRO(ins->std.opMacros[ordi].ksrMacro,ins->std.opMacros[ordi].ksrMacroLen,ins->std.opMacros[ordi].ksrMacroLoop,ins->std.opMacros[ordi].ksrMacroRel,1,ordi,"ksr",FM_NAME(FM_KSR),32,ins->std.opMacros[ordi].ksrMacroOpen,true,NULL,mmlString[10]); - OP_MACRO(ins->std.opMacros[ordi].egtMacro,ins->std.opMacros[ordi].egtMacroLen,ins->std.opMacros[ordi].egtMacroLoop,ins->std.opMacros[ordi].egtMacroRel,1,ordi,"egt",FM_NAME(FM_EGS),32,ins->std.opMacros[ordi].egtMacroOpen,true,NULL,mmlString[11]); + OP_MACRO(ins->std.opMacros[ordi].amMacro,1,ordi,"am",FM_NAME(FM_AM),32,ins->std.opMacros[ordi].amMacro.open,true,NULL,false,0,macroDummyMode,mmlString[8]); + OP_MACRO(ins->std.opMacros[ordi].vibMacro,1,ordi,"vib",FM_NAME(FM_VIB),32,ins->std.opMacros[ordi].vibMacro.open,true,NULL,false,0,macroDummyMode,mmlString[9]); + OP_MACRO(ins->std.opMacros[ordi].ksrMacro,1,ordi,"ksr",FM_NAME(FM_KSR),32,ins->std.opMacros[ordi].ksrMacro.open,true,NULL,false,0,macroDummyMode,mmlString[10]); + OP_MACRO(ins->std.opMacros[ordi].egtMacro,1,ordi,"egt",FM_NAME(FM_EGS),32,ins->std.opMacros[ordi].egtMacro.open,true,NULL,false,0,macroDummyMode,mmlString[11]); } else { - OP_MACRO(ins->std.opMacros[ordi].tlMacro,ins->std.opMacros[ordi].tlMacroLen,ins->std.opMacros[ordi].tlMacroLoop,ins->std.opMacros[ordi].tlMacroRel,maxTl,ordi,"tl",FM_NAME(FM_TL),128,ins->std.opMacros[ordi].tlMacroOpen,false,NULL,mmlString[0]); - OP_MACRO(ins->std.opMacros[ordi].arMacro,ins->std.opMacros[ordi].arMacroLen,ins->std.opMacros[ordi].arMacroLoop,ins->std.opMacros[ordi].arMacroRel,maxArDr,ordi,"ar",FM_NAME(FM_AR),64,ins->std.opMacros[ordi].arMacroOpen,false,NULL,mmlString[1]); - OP_MACRO(ins->std.opMacros[ordi].drMacro,ins->std.opMacros[ordi].drMacroLen,ins->std.opMacros[ordi].drMacroLoop,ins->std.opMacros[ordi].drMacroRel,maxArDr,ordi,"dr",FM_NAME(FM_DR),64,ins->std.opMacros[ordi].drMacroOpen,false,NULL,mmlString[2]); - OP_MACRO(ins->std.opMacros[ordi].d2rMacro,ins->std.opMacros[ordi].d2rMacroLen,ins->std.opMacros[ordi].d2rMacroLoop,ins->std.opMacros[ordi].d2rMacroRel,31,ordi,"d2r",FM_NAME(FM_D2R),64,ins->std.opMacros[ordi].d2rMacroOpen,false,NULL,mmlString[3]); - OP_MACRO(ins->std.opMacros[ordi].rrMacro,ins->std.opMacros[ordi].rrMacroLen,ins->std.opMacros[ordi].rrMacroLoop,ins->std.opMacros[ordi].rrMacroRel,15,ordi,"rr",FM_NAME(FM_RR),64,ins->std.opMacros[ordi].rrMacroOpen,false,NULL,mmlString[4]); - OP_MACRO(ins->std.opMacros[ordi].slMacro,ins->std.opMacros[ordi].slMacroLen,ins->std.opMacros[ordi].slMacroLoop,ins->std.opMacros[ordi].slMacroRel,15,ordi,"sl",FM_NAME(FM_SL),64,ins->std.opMacros[ordi].slMacroOpen,false,NULL,mmlString[5]); - OP_MACRO(ins->std.opMacros[ordi].rsMacro,ins->std.opMacros[ordi].rsMacroLen,ins->std.opMacros[ordi].rsMacroLoop,ins->std.opMacros[ordi].rsMacroRel,3,ordi,"rs",FM_NAME(FM_RS),32,ins->std.opMacros[ordi].rsMacroOpen,false,NULL,mmlString[6]); - OP_MACRO(ins->std.opMacros[ordi].multMacro,ins->std.opMacros[ordi].multMacroLen,ins->std.opMacros[ordi].multMacroLoop,ins->std.opMacros[ordi].multMacroRel,15,ordi,"mult",FM_NAME(FM_MULT),64,ins->std.opMacros[ordi].multMacroOpen,false,NULL,mmlString[7]); - OP_MACRO(ins->std.opMacros[ordi].dtMacro,ins->std.opMacros[ordi].dtMacroLen,ins->std.opMacros[ordi].dtMacroLoop,ins->std.opMacros[ordi].dtMacroRel,7,ordi,"dt",FM_NAME(FM_DT),64,ins->std.opMacros[ordi].dtMacroOpen,false,NULL,mmlString[8]); - OP_MACRO(ins->std.opMacros[ordi].dt2Macro,ins->std.opMacros[ordi].dt2MacroLen,ins->std.opMacros[ordi].dt2MacroLoop,ins->std.opMacros[ordi].dt2MacroRel,3,ordi,"dt2",FM_NAME(FM_DT2),32,ins->std.opMacros[ordi].dt2MacroOpen,false,NULL,mmlString[9]); - OP_MACRO(ins->std.opMacros[ordi].amMacro,ins->std.opMacros[ordi].amMacroLen,ins->std.opMacros[ordi].amMacroLoop,ins->std.opMacros[ordi].amMacroRel,1,ordi,"am",FM_NAME(FM_AM),32,ins->std.opMacros[ordi].amMacroOpen,true,NULL,mmlString[10]); - OP_MACRO(ins->std.opMacros[ordi].ssgMacro,ins->std.opMacros[ordi].ssgMacroLen,ins->std.opMacros[ordi].ssgMacroLoop,ins->std.opMacros[ordi].ssgMacroRel,4,ordi,"ssg",FM_NAME(FM_SSG),64,ins->std.opMacros[ordi].ssgMacroOpen,true,ssgEnvBits,mmlString[11]); + OP_MACRO(ins->std.opMacros[ordi].tlMacro,maxTl,ordi,"tl",FM_NAME(FM_TL),128,ins->std.opMacros[ordi].tlMacro.open,false,NULL,false,0,macroDummyMode,mmlString[0]); + OP_MACRO(ins->std.opMacros[ordi].arMacro,maxArDr,ordi,"ar",FM_NAME(FM_AR),64,ins->std.opMacros[ordi].arMacro.open,false,NULL,false,0,macroDummyMode,mmlString[1]); + OP_MACRO(ins->std.opMacros[ordi].drMacro,maxArDr,ordi,"dr",FM_NAME(FM_DR),64,ins->std.opMacros[ordi].drMacro.open,false,NULL,false,0,macroDummyMode,mmlString[2]); + OP_MACRO(ins->std.opMacros[ordi].d2rMacro,31,ordi,"d2r",FM_NAME(FM_D2R),64,ins->std.opMacros[ordi].d2rMacro.open,false,NULL,false,0,macroDummyMode,mmlString[3]); + OP_MACRO(ins->std.opMacros[ordi].rrMacro,15,ordi,"rr",FM_NAME(FM_RR),64,ins->std.opMacros[ordi].rrMacro.open,false,NULL,false,0,macroDummyMode,mmlString[4]); + OP_MACRO(ins->std.opMacros[ordi].slMacro,15,ordi,"sl",FM_NAME(FM_SL),64,ins->std.opMacros[ordi].slMacro.open,false,NULL,false,0,macroDummyMode,mmlString[5]); + OP_MACRO(ins->std.opMacros[ordi].rsMacro,3,ordi,"rs",FM_NAME(FM_RS),32,ins->std.opMacros[ordi].rsMacro.open,false,NULL,false,0,macroDummyMode,mmlString[6]); + OP_MACRO(ins->std.opMacros[ordi].multMacro,15,ordi,"mult",FM_NAME(FM_MULT),64,ins->std.opMacros[ordi].multMacro.open,false,NULL,false,0,macroDummyMode,mmlString[7]); + OP_MACRO(ins->std.opMacros[ordi].dtMacro,7,ordi,"dt",FM_NAME(FM_DT),64,ins->std.opMacros[ordi].dtMacro.open,false,NULL,false,0,macroDummyMode,mmlString[8]); + OP_MACRO(ins->std.opMacros[ordi].dt2Macro,3,ordi,"dt2",FM_NAME(FM_DT2),32,ins->std.opMacros[ordi].dt2Macro.open,false,NULL,false,0,macroDummyMode,mmlString[9]); + OP_MACRO(ins->std.opMacros[ordi].amMacro,1,ordi,"am",FM_NAME(FM_AM),32,ins->std.opMacros[ordi].amMacro.open,true,NULL,false,0,macroDummyMode,mmlString[10]); + OP_MACRO(ins->std.opMacros[ordi].ssgMacro,4,ordi,"ssg",FM_NAME(FM_SSG),64,ins->std.opMacros[ordi].ssgMacro.open,true,ssgEnvBits,false,0,macroDummyMode,mmlString[11]); } MACRO_END; ImGui::PopID(); @@ -2182,7 +2231,10 @@ void FurnaceGUI::drawInsEdit() { P(ImGui::Checkbox("Volume Macro is Cutoff Macro",&ins->c64.volIsCutoff)); P(ImGui::Checkbox("Absolute Cutoff Macro",&ins->c64.filterIsAbs)); - P(ImGui::Checkbox("Absolute Duty Macro",&ins->c64.dutyIsAbs)); + bool dutyAbs=ins->std.dutyMacro.mode&1; + if (ImGui::Checkbox("Absolute Duty Macro",&dutyAbs)) { PARAMETER + ins->std.dutyMacro.mode^=1; + } ImGui::EndTabItem(); } if (ins->type==DIV_INS_AMIGA) if (ImGui::BeginTabItem("Amiga/Sample")) { @@ -2328,6 +2380,9 @@ void FurnaceGUI::drawInsEdit() { ins->type==DIV_INS_SWAN || ins->type==DIV_INS_PCE || ins->type==DIV_INS_SCC) { + float asFloat[256]; + int asInt[256]; + float loopIndicator[256]; if (ImGui::BeginTabItem("Wavetable")) { ImGui::Checkbox("Enable synthesizer",&ins->ws.enabled); ImGui::SameLine(); @@ -2422,6 +2477,20 @@ void FurnaceGUI::drawInsEdit() { ImGui::EndTabItem(); } + if (ImGui::BeginTabItem("Wavetable Macros")) { + MACRO_BEGIN(0); + NORMAL_MACRO(ins->std.ws.enabledMacro,0,1,"enabled","Enable",160,ins->std.ws.enabledMacro.open,true,oneBit,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[5],0,1,NULL,false); + NORMAL_MACRO(ins->std.ws.oneShotMacro,0,1,"oneShot","One Shot",160,ins->std.ws.oneShotMacro.open,true,oneBit,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,1,NULL,false); + NORMAL_MACRO(ins->std.ws.globalMacro,0,1,"global","Global",160,ins->std.ws.globalMacro.open,true,oneBit,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[6],0,1,NULL,false); + NORMAL_MACRO(ins->std.ws.effectMacro,0,255,"effect","Effect",160,ins->std.ws.effectMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[3],0,255,NULL,false); + NORMAL_MACRO(ins->std.ws.wave1Macro,0,255,"wave1","Wave 1",160,ins->std.ws.wave1Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[0],0,255,NULL,false); + NORMAL_MACRO(ins->std.ws.wave2Macro,0,255,"wave2","Wave 2",160,ins->std.ws.wave2Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[1],0,255,NULL,false); + NORMAL_MACRO(ins->std.ws.rateDividerMacro,1,7,"rateDivider","Rate",160,ins->std.ws.rateDividerMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[2],1,7,NULL,false); + NORMAL_MACRO(ins->std.ws.speedMacro,0,255,"speed","Speed",160,ins->std.ws.speedMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[6],0,255,NULL,false); + NORMAL_MACRO(ins->std.ws.param1Macro,1,7,"amount","Amount",160,ins->std.ws.param1Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[6],1,7,NULL,false); + MACRO_END; + ImGui::EndTabItem(); + } } if (ImGui::BeginTabItem("Macros")) { float asFloat[256]; @@ -2464,13 +2533,13 @@ void FurnaceGUI::drawInsEdit() { volMax=32; } - bool arpMode=ins->std.arpMacroMode; + bool arpMode=ins->std.arpMacro.mode; const char* dutyLabel="Duty/Noise"; int dutyMax=3; if (ins->type==DIV_INS_C64) { dutyLabel="Duty"; - if (ins->c64.dutyIsAbs) { + if (ins->std.dutyMacro.mode) { dutyMax=4095; } else { dutyMax=24; @@ -2517,7 +2586,7 @@ void FurnaceGUI::drawInsEdit() { dutyLabel="Duty"; dutyMax=7; } - bool dutyIsRel=(ins->type==DIV_INS_C64 && !ins->c64.dutyIsAbs); + bool dutyIsRel=(ins->type==DIV_INS_C64 && !ins->std.dutyMacro.mode); const char* waveLabel="Waveform"; int waveMax=(ins->type==DIV_INS_AY || ins->type==DIV_INS_AY8930 || ins->type==DIV_INS_VERA)?3:63; @@ -2571,66 +2640,67 @@ void FurnaceGUI::drawInsEdit() { if (settings.macroView==0) { // modern view MACRO_BEGIN(28*dpiScale); if (volMax>0) { - NORMAL_MACRO(ins->std.volMacro,ins->std.volMacroLen,ins->std.volMacroLoop,ins->std.volMacroRel,volMin,volMax,"vol",volumeLabel,160,ins->std.volMacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_VOLUME],mmlString[0],volMin,volMax,NULL,false); + NORMAL_MACRO(ins->std.volMacro,volMin,volMax,"vol",volumeLabel,160,ins->std.volMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_VOLUME],mmlString[0],volMin,volMax,NULL,false); } - NORMAL_MACRO(ins->std.arpMacro,ins->std.arpMacroLen,ins->std.arpMacroLoop,ins->std.arpMacroRel,arpMacroScroll,arpMacroScroll+24,"arp","Arpeggio",160,ins->std.arpMacroOpen,false,NULL,true,&arpMacroScroll,(arpMode?-60:-80),0,0,&ins->std.arpMacroMode,uiColors[GUI_COLOR_MACRO_PITCH],mmlString[1],-92,94,(ins->std.arpMacroMode?(¯oHoverNote):NULL),true); + NORMAL_MACRO(ins->std.arpMacro,arpMacroScroll,arpMacroScroll+24,"arp","Arpeggio",160,ins->std.arpMacro.open,false,NULL,true,&arpMacroScroll,(arpMode?-60:-80),0,0,true,1,macroAbsoluteMode,uiColors[GUI_COLOR_MACRO_PITCH],mmlString[1],-92,94,(ins->std.arpMacro.mode?(¯oHoverNote):NULL),true); if (dutyMax>0) { if (ins->type==DIV_INS_MIKEY) { - NORMAL_MACRO(ins->std.dutyMacro,ins->std.dutyMacroLen,ins->std.dutyMacroLoop,ins->std.dutyMacroRel,0,dutyMax,"duty",dutyLabel,160,ins->std.dutyMacroOpen,true,mikeyFeedbackBits,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[2],0,dutyMax,NULL,false); + NORMAL_MACRO(ins->std.dutyMacro,0,dutyMax,"duty",dutyLabel,160,ins->std.dutyMacro.open,true,mikeyFeedbackBits,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[2],0,dutyMax,NULL,false); + } else if (ins->type==DIV_INS_C64) { + NORMAL_MACRO(ins->std.dutyMacro,0,dutyMax,"duty",dutyLabel,160,ins->std.dutyMacro.open,false,NULL,false,NULL,0,0,0,true,1,macroAbsoluteMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[2],0,dutyMax,NULL,false); + } else { + NORMAL_MACRO(ins->std.dutyMacro,0,dutyMax,"duty",dutyLabel,160,ins->std.dutyMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[2],0,dutyMax,NULL,false); } - else { - NORMAL_MACRO(ins->std.dutyMacro,ins->std.dutyMacroLen,ins->std.dutyMacroLoop,ins->std.dutyMacroRel,0,dutyMax,"duty",dutyLabel,160,ins->std.dutyMacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[2],0,dutyMax,NULL,false); - } } if (waveMax>0) { - NORMAL_MACRO(ins->std.waveMacro,ins->std.waveMacroLen,ins->std.waveMacroLoop,ins->std.waveMacroRel,0,waveMax,"wave",waveLabel,(bitMode && ins->type!=DIV_INS_PET)?64:160,ins->std.waveMacroOpen,bitMode,waveNames,false,NULL,0,0,((ins->type==DIV_INS_AY || ins->type==DIV_INS_AY8930)?1:0),NULL,uiColors[GUI_COLOR_MACRO_WAVE],mmlString[3],0,waveMax,NULL,false); + NORMAL_MACRO(ins->std.waveMacro,0,waveMax,"wave",waveLabel,(bitMode && ins->type!=DIV_INS_PET)?64:160,ins->std.waveMacro.open,bitMode,waveNames,false,NULL,0,0,((ins->type==DIV_INS_AY || ins->type==DIV_INS_AY8930)?1:0),false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_WAVE],mmlString[3],0,waveMax,NULL,false); } if (ex1Max>0) { if (ins->type==DIV_INS_C64) { - NORMAL_MACRO(ins->std.ex1Macro,ins->std.ex1MacroLen,ins->std.ex1MacroLoop,ins->std.ex1MacroRel,0,ex1Max,"ex1","Filter Mode",64,ins->std.ex1MacroOpen,true,filtModeBits,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,ex1Max,NULL,false); + NORMAL_MACRO(ins->std.ex1Macro,0,ex1Max,"ex1","Filter Mode",64,ins->std.ex1Macro.open,true,filtModeBits,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,ex1Max,NULL,false); } else if (ins->type==DIV_INS_SAA1099) { - NORMAL_MACRO(ins->std.ex1Macro,ins->std.ex1MacroLen,ins->std.ex1MacroLoop,ins->std.ex1MacroRel,0,ex1Max,"ex1","Envelope",160,ins->std.ex1MacroOpen,true,saaEnvBits,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,ex1Max,NULL,false); + NORMAL_MACRO(ins->std.ex1Macro,0,ex1Max,"ex1","Envelope",160,ins->std.ex1Macro.open,true,saaEnvBits,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,ex1Max,NULL,false); } else if (ins->type==DIV_INS_X1_010) { - NORMAL_MACRO(ins->std.ex1Macro,ins->std.ex1MacroLen,ins->std.ex1MacroLoop,ins->std.ex1MacroRel,0,ex1Max,"ex1","Envelope Mode",160,ins->std.ex1MacroOpen,true,x1_010EnvBits,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,ex1Max,NULL,false); + NORMAL_MACRO(ins->std.ex1Macro,0,ex1Max,"ex1","Envelope Mode",160,ins->std.ex1Macro.open,true,x1_010EnvBits,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,ex1Max,NULL,false); } else if (ins->type==DIV_INS_N163) { - NORMAL_MACRO(ins->std.ex1Macro,ins->std.ex1MacroLen,ins->std.ex1MacroLoop,ins->std.ex1MacroRel,0,ex1Max,"ex1","Waveform len.",160,ins->std.ex1MacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,ex1Max,NULL,false); + NORMAL_MACRO(ins->std.ex1Macro,0,ex1Max,"ex1","Waveform len.",160,ins->std.ex1Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,ex1Max,NULL,false); } else if (ins->type==DIV_INS_FDS) { - NORMAL_MACRO(ins->std.ex1Macro,ins->std.ex1MacroLen,ins->std.ex1MacroLoop,ins->std.ex1MacroRel,0,ex1Max,"ex1","Mod Depth",160,ins->std.ex1MacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,ex1Max,NULL,false); + NORMAL_MACRO(ins->std.ex1Macro,0,ex1Max,"ex1","Mod Depth",160,ins->std.ex1Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,ex1Max,NULL,false); } else { - NORMAL_MACRO(ins->std.ex1Macro,ins->std.ex1MacroLen,ins->std.ex1MacroLoop,ins->std.ex1MacroRel,0,ex1Max,"ex1","Duty",160,ins->std.ex1MacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,ex1Max,NULL,false); + NORMAL_MACRO(ins->std.ex1Macro,0,ex1Max,"ex1","Duty",160,ins->std.ex1Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[4],0,ex1Max,NULL,false); } } if (ex2Max>0) { if (ins->type==DIV_INS_C64) { - NORMAL_MACRO(ins->std.ex2Macro,ins->std.ex2MacroLen,ins->std.ex2MacroLoop,ins->std.ex2MacroRel,0,ex2Max,"ex2","Resonance",64,ins->std.ex2MacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[5],0,ex2Max,NULL,false); + NORMAL_MACRO(ins->std.ex2Macro,0,ex2Max,"ex2","Resonance",64,ins->std.ex2Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[5],0,ex2Max,NULL,false); } else if (ins->type==DIV_INS_N163) { - NORMAL_MACRO(ins->std.ex2Macro,ins->std.ex2MacroLen,ins->std.ex2MacroLoop,ins->std.ex2MacroRel,0,ex2Max,"ex2","Waveform update",64,ins->std.ex2MacroOpen,true,n163UpdateBits,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[5],0,ex2Max,NULL,false); + NORMAL_MACRO(ins->std.ex2Macro,0,ex2Max,"ex2","Waveform update",64,ins->std.ex2Macro.open,true,n163UpdateBits,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[5],0,ex2Max,NULL,false); } else if (ins->type==DIV_INS_FDS) { - NORMAL_MACRO(ins->std.ex2Macro,ins->std.ex2MacroLen,ins->std.ex2MacroLoop,ins->std.ex2MacroRel,0,ex2Max,"ex2","Mod Speed",160,ins->std.ex2MacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[5],0,ex2Max,NULL,false); + NORMAL_MACRO(ins->std.ex2Macro,0,ex2Max,"ex2","Mod Speed",160,ins->std.ex2Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[5],0,ex2Max,NULL,false); } else { - NORMAL_MACRO(ins->std.ex2Macro,ins->std.ex2MacroLen,ins->std.ex2MacroLoop,ins->std.ex2MacroRel,0,ex2Max,"ex2","Envelope",ex2Bit?64:160,ins->std.ex2MacroOpen,ex2Bit,ayEnvBits,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[5],0,ex2Max,NULL,false); + NORMAL_MACRO(ins->std.ex2Macro,0,ex2Max,"ex2","Envelope",ex2Bit?64:160,ins->std.ex2Macro.open,ex2Bit,ayEnvBits,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[5],0,ex2Max,NULL,false); } } if (ins->type==DIV_INS_C64) { - NORMAL_MACRO(ins->std.ex3Macro,ins->std.ex3MacroLen,ins->std.ex3MacroLoop,ins->std.ex3MacroRel,0,2,"ex3","Special",32,ins->std.ex3MacroOpen,true,c64SpecialBits,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[6],0,2,NULL,false); + NORMAL_MACRO(ins->std.ex3Macro,0,2,"ex3","Special",32,ins->std.ex3Macro.open,true,c64SpecialBits,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[6],0,2,NULL,false); } if (ins->type==DIV_INS_AY || ins->type==DIV_INS_AY8930 || ins->type==DIV_INS_X1_010) { - NORMAL_MACRO(ins->std.ex3Macro,ins->std.ex3MacroLen,ins->std.ex3MacroLoop,ins->std.ex3MacroRel,0,15,"ex3","AutoEnv Num",96,ins->std.ex3MacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[6],0,15,NULL,false); - NORMAL_MACRO(ins->std.algMacro,ins->std.algMacroLen,ins->std.algMacroLoop,ins->std.algMacroRel,0,15,"alg","AutoEnv Den",96,ins->std.algMacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[7],0,15,NULL,false); + NORMAL_MACRO(ins->std.ex3Macro,0,15,"ex3","AutoEnv Num",96,ins->std.ex3Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[6],0,15,NULL,false); + NORMAL_MACRO(ins->std.algMacro,0,15,"alg","AutoEnv Den",96,ins->std.algMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[7],0,15,NULL,false); } if (ins->type==DIV_INS_AY8930) { // oh my i am running out of macros - NORMAL_MACRO(ins->std.fbMacro,ins->std.fbMacroLen,ins->std.fbMacroLoop,ins->std.fbMacroRel,0,8,"fb","Noise AND Mask",96,ins->std.fbMacroOpen,true,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[8],0,8,NULL,false); - NORMAL_MACRO(ins->std.fmsMacro,ins->std.fmsMacroLen,ins->std.fmsMacroLoop,ins->std.fmsMacroRel,0,8,"fms","Noise OR Mask",96,ins->std.fmsMacroOpen,true,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[9],0,8,NULL,false); + NORMAL_MACRO(ins->std.fbMacro,0,8,"fb","Noise AND Mask",96,ins->std.fbMacro.open,true,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[8],0,8,NULL,false); + NORMAL_MACRO(ins->std.fmsMacro,0,8,"fms","Noise OR Mask",96,ins->std.fmsMacro.open,true,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[9],0,8,NULL,false); } if (ins->type==DIV_INS_N163) { - NORMAL_MACRO(ins->std.ex3Macro,ins->std.ex3MacroLen,ins->std.ex3MacroLoop,ins->std.ex3MacroRel,0,255,"ex3","Waveform to Load",160,ins->std.ex3MacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[6],0,255,NULL,false); - NORMAL_MACRO(ins->std.algMacro,ins->std.algMacroLen,ins->std.algMacroLoop,ins->std.algMacroRel,0,255,"alg","Wave pos. to Load",160,ins->std.algMacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[7],0,255,NULL,false); - NORMAL_MACRO(ins->std.fbMacro,ins->std.fbMacroLen,ins->std.fbMacroLoop,ins->std.fbMacroRel,0,252,"fb","Wave len. to Load",160,ins->std.fbMacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[8],0,252,NULL,false); - NORMAL_MACRO(ins->std.fmsMacro,ins->std.fmsMacroLen,ins->std.fmsMacroLoop,ins->std.fmsMacroRel,0,2,"fms","Waveform load",64,ins->std.fmsMacroOpen,true,n163UpdateBits,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[9],0,2,NULL,false); + NORMAL_MACRO(ins->std.ex3Macro,0,255,"ex3","Waveform to Load",160,ins->std.ex3Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[6],0,255,NULL,false); + NORMAL_MACRO(ins->std.algMacro,0,255,"alg","Wave pos. to Load",160,ins->std.algMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[7],0,255,NULL,false); + NORMAL_MACRO(ins->std.fbMacro,0,252,"fb","Wave len. to Load",160,ins->std.fbMacro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[8],0,252,NULL,false); + NORMAL_MACRO(ins->std.fmsMacro,0,2,"fms","Waveform load",64,ins->std.fmsMacro.open,true,n163UpdateBits,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[9],0,2,NULL,false); } if (ins->type==DIV_INS_FDS) { - NORMAL_MACRO(ins->std.ex3Macro,ins->std.ex3MacroLen,ins->std.ex3MacroLoop,ins->std.ex3MacroRel,0,127,"ex3","Mod Position",160,ins->std.ex3MacroOpen,false,NULL,false,NULL,0,0,0,NULL,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[6],0,2,NULL,false); + NORMAL_MACRO(ins->std.ex3Macro,0,127,"ex3","Mod Position",160,ins->std.ex3Macro.open,false,NULL,false,NULL,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[6],0,2,NULL,false); } MACRO_END; @@ -2646,87 +2716,87 @@ void FurnaceGUI::drawInsEdit() { } else { ImGui::Text("Volume Macro"); } - for (int i=0; istd.volMacroLen; i++) { + for (int i=0; istd.volMacro.len; i++) { if (ins->type==DIV_INS_C64 && ins->c64.volIsCutoff && !ins->c64.filterIsAbs) { - asFloat[i]=ins->std.volMacro[i]-18; + asFloat[i]=ins->std.volMacro.val[i]-18; } else { - asFloat[i]=ins->std.volMacro[i]; + asFloat[i]=ins->std.volMacro.val[i]; } - loopIndicator[i]=(ins->std.volMacroLoop!=-1 && i>=ins->std.volMacroLoop); + loopIndicator[i]=(ins->std.volMacro.loop!=-1 && i>=ins->std.volMacro.loop); } macroDragScroll=0; if (volMax>0) { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,ImVec2(0.0f,0.0f)); - ImGui::PlotHistogram("##IVolMacro",asFloat,ins->std.volMacroLen,0,NULL,volMin,volMax,ImVec2(400.0f*dpiScale,200.0f*dpiScale)); + ImGui::PlotHistogram("##IVolMacro",asFloat,ins->std.volMacro.len,0,NULL,volMin,volMax,ImVec2(400.0f*dpiScale,200.0f*dpiScale)); if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) { macroDragStart=ImGui::GetItemRectMin(); macroDragAreaSize=ImVec2(400.0f*dpiScale,200.0f*dpiScale); macroDragMin=volMin; macroDragMax=volMax; - macroDragLen=ins->std.volMacroLen; + macroDragLen=ins->std.volMacro.len; macroDragActive=true; - macroDragTarget=ins->std.volMacro; + macroDragTarget=ins->std.volMacro.val; macroDragChar=false; processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); } - ImGui::PlotHistogram("##IVolMacroLoop",loopIndicator,ins->std.volMacroLen,0,NULL,0,1,ImVec2(400.0f*dpiScale,16.0f*dpiScale)); + ImGui::PlotHistogram("##IVolMacro.loop",loopIndicator,ins->std.volMacro.len,0,NULL,0,1,ImVec2(400.0f*dpiScale,16.0f*dpiScale)); if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) { macroLoopDragStart=ImGui::GetItemRectMin(); macroLoopDragAreaSize=ImVec2(400.0f*dpiScale,16.0f*dpiScale); - macroLoopDragLen=ins->std.volMacroLen; - macroLoopDragTarget=&ins->std.volMacroLoop; + macroLoopDragLen=ins->std.volMacro.len; + macroLoopDragTarget=&ins->std.volMacro.loop; macroLoopDragActive=true; processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); } if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { - ins->std.volMacroLoop=-1; + ins->std.volMacro.loop=-1; } ImGui::PopStyleVar(); - if (ImGui::InputScalar("Length##IVolMacroL",ImGuiDataType_U8,&ins->std.volMacroLen,&_ONE,&_THREE)) { - if (ins->std.volMacroLen>127) ins->std.volMacroLen=127; + if (ImGui::InputScalar("Length##IVolMacroL",ImGuiDataType_U8,&ins->std.volMacro.len,&_ONE,&_THREE)) { + if (ins->std.volMacro.len>127) ins->std.volMacro.len=127; } } // arp macro ImGui::Separator(); ImGui::Text("Arpeggio Macro"); - for (int i=0; istd.arpMacroLen; i++) { - asFloat[i]=ins->std.arpMacro[i]; - loopIndicator[i]=(ins->std.arpMacroLoop!=-1 && i>=ins->std.arpMacroLoop); + for (int i=0; istd.arpMacro.len; i++) { + asFloat[i]=ins->std.arpMacro.val[i]; + loopIndicator[i]=(ins->std.arpMacro.loop!=-1 && i>=ins->std.arpMacro.loop); } ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,ImVec2(0.0f,0.0f)); - ImGui::PlotHistogram("##IArpMacro",asFloat,ins->std.arpMacroLen,0,NULL,arpMode?arpMacroScroll:(arpMacroScroll-12),arpMacroScroll+(arpMode?24:12),ImVec2(400.0f*dpiScale,200.0f*dpiScale)); + ImGui::PlotHistogram("##IArpMacro",asFloat,ins->std.arpMacro.len,0,NULL,arpMode?arpMacroScroll:(arpMacroScroll-12),arpMacroScroll+(arpMode?24:12),ImVec2(400.0f*dpiScale,200.0f*dpiScale)); if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) { macroDragStart=ImGui::GetItemRectMin(); macroDragAreaSize=ImVec2(400.0f*dpiScale,200.0f*dpiScale); macroDragMin=arpMacroScroll; macroDragMax=arpMacroScroll+24; - macroDragLen=ins->std.arpMacroLen; + macroDragLen=ins->std.arpMacro.len; macroDragActive=true; - macroDragTarget=ins->std.arpMacro; + macroDragTarget=ins->std.arpMacro.val; macroDragChar=false; processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); } ImGui::SameLine(); CWVSliderInt("##IArpMacroPos",ImVec2(20.0f*dpiScale,200.0f*dpiScale),&arpMacroScroll,arpMode?0:-80,70); - ImGui::PlotHistogram("##IArpMacroLoop",loopIndicator,ins->std.arpMacroLen,0,NULL,0,1,ImVec2(400.0f*dpiScale,16.0f*dpiScale)); + ImGui::PlotHistogram("##IArpMacro.loop",loopIndicator,ins->std.arpMacro.len,0,NULL,0,1,ImVec2(400.0f*dpiScale,16.0f*dpiScale)); if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) { macroLoopDragStart=ImGui::GetItemRectMin(); macroLoopDragAreaSize=ImVec2(400.0f*dpiScale,16.0f*dpiScale); - macroLoopDragLen=ins->std.arpMacroLen; - macroLoopDragTarget=&ins->std.arpMacroLoop; + macroLoopDragLen=ins->std.arpMacro.len; + macroLoopDragTarget=&ins->std.arpMacro.loop; macroLoopDragActive=true; processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); } if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { - ins->std.arpMacroLoop=-1; + ins->std.arpMacro.loop=-1; } ImGui::PopStyleVar(); - if (ImGui::InputScalar("Length##IArpMacroL",ImGuiDataType_U8,&ins->std.arpMacroLen,&_ONE,&_THREE)) { - if (ins->std.arpMacroLen>127) ins->std.arpMacroLen=127; + if (ImGui::InputScalar("Length##IArpMacroL",ImGuiDataType_U8,&ins->std.arpMacro.len,&_ONE,&_THREE)) { + if (ins->std.arpMacro.len>127) ins->std.arpMacro.len=127; } if (ImGui::Checkbox("Fixed",&arpMode)) { - ins->std.arpMacroMode=arpMode; + ins->std.arpMacro.mode=arpMode; if (arpMode) { if (arpMacroScroll<0) arpMacroScroll=0; } @@ -2736,7 +2806,7 @@ void FurnaceGUI::drawInsEdit() { if (dutyMax>0) { ImGui::Separator(); if (ins->type==DIV_INS_C64) { - if (ins->c64.dutyIsAbs) { + if (ins->std.dutyMacro.mode) { ImGui::Text("Duty Macro"); } else { ImGui::Text("Relative Duty Macro"); @@ -2748,39 +2818,39 @@ void FurnaceGUI::drawInsEdit() { ImGui::Text("Duty/Noise Mode Macro"); } } - for (int i=0; istd.dutyMacroLen; i++) { - asFloat[i]=ins->std.dutyMacro[i]-(dutyIsRel?12:0); - loopIndicator[i]=(ins->std.dutyMacroLoop!=-1 && i>=ins->std.dutyMacroLoop); + for (int i=0; istd.dutyMacro.len; i++) { + asFloat[i]=ins->std.dutyMacro.val[i]-(dutyIsRel?12:0); + loopIndicator[i]=(ins->std.dutyMacro.loop!=-1 && i>=ins->std.dutyMacro.loop); } ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,ImVec2(0.0f,0.0f)); - ImGui::PlotHistogram("##IDutyMacro",asFloat,ins->std.dutyMacroLen,0,NULL,dutyIsRel?-12:0,dutyMax-(dutyIsRel?12:0),ImVec2(400.0f*dpiScale,200.0f*dpiScale)); + ImGui::PlotHistogram("##IDutyMacro",asFloat,ins->std.dutyMacro.len,0,NULL,dutyIsRel?-12:0,dutyMax-(dutyIsRel?12:0),ImVec2(400.0f*dpiScale,200.0f*dpiScale)); if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) { macroDragStart=ImGui::GetItemRectMin(); macroDragAreaSize=ImVec2(400.0f*dpiScale,200.0f*dpiScale); macroDragMin=0; macroDragMax=dutyMax; - macroDragLen=ins->std.dutyMacroLen; + macroDragLen=ins->std.dutyMacro.len; macroDragActive=true; - macroDragTarget=ins->std.dutyMacro; + macroDragTarget=ins->std.dutyMacro.val; macroDragChar=false; processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); } - ImGui::PlotHistogram("##IDutyMacroLoop",loopIndicator,ins->std.dutyMacroLen,0,NULL,0,1,ImVec2(400.0f*dpiScale,16.0f*dpiScale)); + ImGui::PlotHistogram("##IDutyMacro.loop",loopIndicator,ins->std.dutyMacro.len,0,NULL,0,1,ImVec2(400.0f*dpiScale,16.0f*dpiScale)); if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) { macroLoopDragStart=ImGui::GetItemRectMin(); macroLoopDragAreaSize=ImVec2(400.0f*dpiScale,16.0f*dpiScale); - macroLoopDragLen=ins->std.dutyMacroLen; - macroLoopDragTarget=&ins->std.dutyMacroLoop; + macroLoopDragLen=ins->std.dutyMacro.len; + macroLoopDragTarget=&ins->std.dutyMacro.loop; macroLoopDragActive=true; processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); } if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { - ins->std.dutyMacroLoop=-1; + ins->std.dutyMacro.loop=-1; } ImGui::PopStyleVar(); - if (ImGui::InputScalar("Length##IDutyMacroL",ImGuiDataType_U8,&ins->std.dutyMacroLen,&_ONE,&_THREE)) { - if (ins->std.dutyMacroLen>127) ins->std.dutyMacroLen=127; + if (ImGui::InputScalar("Length##IDutyMacroL",ImGuiDataType_U8,&ins->std.dutyMacro.len,&_ONE,&_THREE)) { + if (ins->std.dutyMacro.len>127) ins->std.dutyMacro.len=127; } } @@ -2788,24 +2858,24 @@ void FurnaceGUI::drawInsEdit() { if (waveMax>0) { ImGui::Separator(); ImGui::Text("Waveform Macro"); - for (int i=0; istd.waveMacroLen; i++) { - asFloat[i]=ins->std.waveMacro[i]; + for (int i=0; istd.waveMacro.len; i++) { + asFloat[i]=ins->std.waveMacro.val[i]; if (ins->type==DIV_INS_AY || ins->type==DIV_INS_AY8930) { - asInt[i]=ins->std.waveMacro[i]+1; + asInt[i]=ins->std.waveMacro.val[i]+1; } else { - asInt[i]=ins->std.waveMacro[i]; + asInt[i]=ins->std.waveMacro.val[i]; } - loopIndicator[i]=(ins->std.waveMacroLoop!=-1 && i>=ins->std.waveMacroLoop); + loopIndicator[i]=(ins->std.waveMacro.loop!=-1 && i>=ins->std.waveMacro.loop); } ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,ImVec2(0.0f,0.0f)); ImVec2 areaSize=ImVec2(400.0f*dpiScale,200.0f*dpiScale); if (ins->type==DIV_INS_C64 || ins->type==DIV_INS_AY || ins->type==DIV_INS_AY8930 || ins->type==DIV_INS_SAA1099) { areaSize=ImVec2(400.0f*dpiScale,waveMax*32.0f*dpiScale); - PlotBitfield("##IWaveMacro",asInt,ins->std.waveMacroLen,0,(ins->type==DIV_INS_C64)?c64ShapeBits:ayShapeBits,waveMax,areaSize); + PlotBitfield("##IWaveMacro",asInt,ins->std.waveMacro.len,0,(ins->type==DIV_INS_C64)?c64ShapeBits:ayShapeBits,waveMax,areaSize); bitMode=true; } else { - ImGui::PlotHistogram("##IWaveMacro",asFloat,ins->std.waveMacroLen,0,NULL,0,waveMax,areaSize); + ImGui::PlotHistogram("##IWaveMacro",asFloat,ins->std.waveMacro.len,0,NULL,0,waveMax,areaSize); } if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) { macroDragStart=ImGui::GetItemRectMin(); @@ -2816,27 +2886,27 @@ void FurnaceGUI::drawInsEdit() { macroDragBitMode=bitMode; macroDragInitialValueSet=false; macroDragInitialValue=false; - macroDragLen=ins->std.waveMacroLen; + macroDragLen=ins->std.waveMacro.len; macroDragActive=true; - macroDragTarget=ins->std.waveMacro; + macroDragTarget=ins->std.waveMacro.val; macroDragChar=false; processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); } - ImGui::PlotHistogram("##IWaveMacroLoop",loopIndicator,ins->std.waveMacroLen,0,NULL,0,1,ImVec2(400.0f*dpiScale,16.0f*dpiScale)); + ImGui::PlotHistogram("##IWaveMacro.loop",loopIndicator,ins->std.waveMacro.len,0,NULL,0,1,ImVec2(400.0f*dpiScale,16.0f*dpiScale)); if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) { macroLoopDragStart=ImGui::GetItemRectMin(); macroLoopDragAreaSize=ImVec2(400.0f*dpiScale,16.0f*dpiScale); - macroLoopDragLen=ins->std.waveMacroLen; - macroLoopDragTarget=&ins->std.waveMacroLoop; + macroLoopDragLen=ins->std.waveMacro.len; + macroLoopDragTarget=&ins->std.waveMacro.loop; macroLoopDragActive=true; processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); } if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { - ins->std.waveMacroLoop=-1; + ins->std.waveMacro.loop=-1; } ImGui::PopStyleVar(); - if (ImGui::InputScalar("Length##IWaveMacroL",ImGuiDataType_U8,&ins->std.waveMacroLen,&_ONE,&_THREE)) { - if (ins->std.waveMacroLen>127) ins->std.waveMacroLen=127; + if (ImGui::InputScalar("Length##IWaveMacroL",ImGuiDataType_U8,&ins->std.waveMacro.len,&_ONE,&_THREE)) { + if (ins->std.waveMacro.len>127) ins->std.waveMacro.len=127; } } @@ -2848,39 +2918,39 @@ void FurnaceGUI::drawInsEdit() { } else { ImGui::Text("Extra 1 Macro"); } - for (int i=0; istd.ex1MacroLen; i++) { - asFloat[i]=ins->std.ex1Macro[i]; - loopIndicator[i]=(ins->std.ex1MacroLoop!=-1 && i>=ins->std.ex1MacroLoop); + for (int i=0; istd.ex1Macro.len; i++) { + asFloat[i]=ins->std.ex1Macro.val[i]; + loopIndicator[i]=(ins->std.ex1Macro.loop!=-1 && i>=ins->std.ex1Macro.loop); } ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,ImVec2(0.0f,0.0f)); - ImGui::PlotHistogram("##IEx1Macro",asFloat,ins->std.ex1MacroLen,0,NULL,0,ex1Max,ImVec2(400.0f*dpiScale,200.0f*dpiScale)); + ImGui::PlotHistogram("##IEx1Macro",asFloat,ins->std.ex1Macro.len,0,NULL,0,ex1Max,ImVec2(400.0f*dpiScale,200.0f*dpiScale)); if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) { macroDragStart=ImGui::GetItemRectMin(); macroDragAreaSize=ImVec2(400.0f*dpiScale,200.0f*dpiScale); macroDragMin=0; macroDragMax=ex1Max; - macroDragLen=ins->std.ex1MacroLen; + macroDragLen=ins->std.ex1Macro.len; macroDragActive=true; - macroDragTarget=ins->std.ex1Macro; + macroDragTarget=ins->std.ex1Macro.val; macroDragChar=false; processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); } - ImGui::PlotHistogram("##IEx1MacroLoop",loopIndicator,ins->std.ex1MacroLen,0,NULL,0,1,ImVec2(400.0f*dpiScale,16.0f*dpiScale)); + ImGui::PlotHistogram("##IEx1Macro.loop",loopIndicator,ins->std.ex1Macro.len,0,NULL,0,1,ImVec2(400.0f*dpiScale,16.0f*dpiScale)); if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) { macroLoopDragStart=ImGui::GetItemRectMin(); macroLoopDragAreaSize=ImVec2(400.0f*dpiScale,16.0f*dpiScale); - macroLoopDragLen=ins->std.ex1MacroLen; - macroLoopDragTarget=&ins->std.ex1MacroLoop; + macroLoopDragLen=ins->std.ex1Macro.len; + macroLoopDragTarget=&ins->std.ex1Macro.loop; macroLoopDragActive=true; processDrags(ImGui::GetMousePos().x,ImGui::GetMousePos().y); } if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { - ins->std.ex1MacroLoop=-1; + ins->std.ex1Macro.loop=-1; } ImGui::PopStyleVar(); - if (ImGui::InputScalar("Length##IEx1MacroL",ImGuiDataType_U8,&ins->std.ex1MacroLen,&_ONE,&_THREE)) { - if (ins->std.ex1MacroLen>127) ins->std.ex1MacroLen=127; + if (ImGui::InputScalar("Length##IEx1MacroL",ImGuiDataType_U8,&ins->std.ex1Macro.len,&_ONE,&_THREE)) { + if (ins->std.ex1Macro.len>127) ins->std.ex1Macro.len=127; } } }