From 90032899c79f55c113957e63edac6c863af9bffe Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 29 Oct 2023 01:39:37 -0500 Subject: [PATCH] C64: bunch of changes - merging test/gate and special macros - drop new test/gate compat flag - not necessary - code style and tabs to spaces TODO: compatibility! --- src/engine/fileOps.cpp | 9 ---- src/engine/platform/c64.cpp | 94 ++++++++++++++----------------------- src/engine/platform/c64.h | 9 +++- src/gui/insEdit.cpp | 52 ++++++-------------- src/gui/sysConf.cpp | 6 --- 5 files changed, 57 insertions(+), 113 deletions(-) diff --git a/src/engine/fileOps.cpp b/src/engine/fileOps.cpp index 9e8b6acaf..0175c02e2 100644 --- a/src/engine/fileOps.cpp +++ b/src/engine/fileOps.cpp @@ -3017,15 +3017,6 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) { } } - // C64 old version test bit macro - if (ds.version<187) { - for (int i=0; igetIns(chan[i].ins,DIV_INS_C64); - if (ins->c64.volIsCutoff) { - if (ins->c64.filterIsAbs) { - filtCut=MIN(2047,chan[i].std.vol.val); - } else { - filtCut-=((signed char)chan[i].std.vol.val)*7; - if (filtCut>2047) filtCut=2047; - if (filtCut<0) filtCut=0; - } - willUpdateFilter=true; - } else { - vol=MIN(15,chan[i].std.vol.val); - willUpdateFilter=true; - } - } - if (chan[i].std.alg.had) { //new cutoff macro! - DivInstrument* ins = parent->getIns(chan[i].ins, DIV_INS_C64); - if (ins->c64.filterIsAbs) { - filtCut = MIN(2047, chan[i].std.alg.val); - } - else { - filtCut += ((signed char)chan[i].std.alg.val) * 7; //new macro should not be executed in inverted way when in relative mode jesus - if (filtCut > 2047) filtCut = 2047; - if (filtCut < 0) filtCut = 0; - } - willUpdateFilter = true; + vol=MIN(15,chan[i].std.vol.val); + willUpdateFilter=true; } if (NEW_ARP_STRAT) { @@ -206,7 +182,7 @@ void DivPlatformC64::tick(bool sysTick) { } if (chan[i].std.wave.had) { chan[i].wave=chan[i].std.wave.val; - rWrite(i*7+4,(chan[i].wave<<4)|(chan[i].test<<3)|(chan[i].ring<<2)|(chan[i].sync<<1)|(int)(chan[i].active)); + rWrite(i*7+4,(chan[i].wave<<4)|(chan[i].test<<3)|(chan[i].ring<<2)|(chan[i].sync<<1)|(int)(chan[i].active && chan[i].gate)); } if (chan[i].std.pitch.had) { if (chan[i].std.pitch.mode) { @@ -217,6 +193,20 @@ void DivPlatformC64::tick(bool sysTick) { } chan[i].freqChanged=true; } + if (chan[i].std.alg.had) { // new cutoff macro + DivInstrument* ins=parent->getIns(chan[i].ins,DIV_INS_C64); + if (ins->c64.filterIsAbs) { + filtCut=MIN(2047,chan[i].std.alg.val); + } else { + // TODO: + // - why signed char? + // - add a mode in where it's not multiplied by 7 - dang it Delek + filtCut+=((signed char)chan[i].std.alg.val)*7; + if (filtCut>2047) filtCut=2047; + if (filtCut<0) filtCut=0; + } + willUpdateFilter=true; + } if (chan[i].std.ex1.had) { filtControl=chan[i].std.ex1.val&15; willUpdateFilter=true; @@ -225,46 +215,33 @@ void DivPlatformC64::tick(bool sysTick) { filtRes=chan[i].std.ex2.val&15; willUpdateFilter=true; } - 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; - rWrite(i*7+4,(chan[i].wave<<4)|(chan[i].test<<3)|(chan[i].ring<<2)|(chan[i].sync<<1)|(int)(chan[i].active)); - } if (chan[i].std.ex4.had) { - chan[i].test=chan[i].std.ex4.val&1; - - if (newTestBitMacro) - { - chan[i].active = chan[i].std.ex4.val & 2; - if (!chan[i].active) - { - chan[i].keyOff = true; - chan[i].keyOn = false; - } - } - - rWrite(i*7+4,(chan[i].wave<<4)|(chan[i].test<<3)|(chan[i].ring<<2)|(chan[i].sync<<1)|(int)(chan[i].active)); + chan[i].gate=chan[i].std.ex4.val&1; + chan[i].sync=chan[i].std.ex4.val&2; + chan[i].ring=chan[i].std.ex4.val&4; + chan[i].test=chan[i].std.ex4.val&8; + chan[i].freqChanged=true; + rWrite(i*7+4,(chan[i].wave<<4)|(chan[i].test<<3)|(chan[i].ring<<2)|(chan[i].sync<<1)|(int)(chan[i].active && chan[i].gate)); } if (chan[i].std.ex5.had) { - chan[i].attack = chan[i].std.ex5.val & 15; - rWrite(i * 7 + 5, (chan[i].attack << 4) | (chan[i].decay)); + chan[i].attack=chan[i].std.ex5.val&15; + rWrite(i*7+5,(chan[i].attack<<4)|(chan[i].decay)); } if (chan[i].std.ex6.had) { - chan[i].decay = chan[i].std.ex6.val & 15; - rWrite(i * 7 + 5, (chan[i].attack << 4) | (chan[i].decay)); + chan[i].decay=chan[i].std.ex6.val&15; + rWrite(i*7+5,(chan[i].attack<<4)|(chan[i].decay)); } if (chan[i].std.ex7.had) { - chan[i].sustain = chan[i].std.ex7.val & 15; - rWrite(i * 7 + 6, (chan[i].sustain << 4) | (chan[i].release)); + chan[i].sustain=chan[i].std.ex7.val&15; + rWrite(i*7+6,(chan[i].sustain<<4)|(chan[i].release)); } if (chan[i].std.ex8.had) { - chan[i].release = chan[i].std.ex8.val & 15; - rWrite(i * 7 + 6, (chan[i].sustain << 4) | (chan[i].release)); + chan[i].release=chan[i].std.ex8.val&15; + rWrite(i*7+6,(chan[i].sustain<<4)|(chan[i].release)); } if (sysTick) { @@ -287,7 +264,7 @@ void DivPlatformC64::tick(bool sysTick) { if (chan[i].keyOn) { rWrite(i*7+5,(chan[i].attack<<4)|(chan[i].decay)); rWrite(i*7+6,(chan[i].sustain<<4)|(chan[i].release)); - rWrite(i*7+4,(chan[i].wave<<4)|(chan[i].test<<3)|(chan[i].ring<<2)|(chan[i].sync<<1)|1); + rWrite(i*7+4,(chan[i].wave<<4)|(chan[i].test<<3)|(chan[i].ring<<2)|(chan[i].sync<<1)|chan[i].gate); } if (chan[i].keyOff) { rWrite(i*7+5,(chan[i].attack<<4)|(chan[i].decay)); @@ -431,7 +408,7 @@ int DivPlatformC64::dispatch(DivCommand c) { break; case DIV_CMD_WAVE: chan[c.chan].wave=c.value; - rWrite(c.chan*7+4,(chan[c.chan].wave<<4)|(chan[c.chan].test<<3)|(chan[c.chan].ring<<2)|(chan[c.chan].sync<<1)|(int)(chan[c.chan].active)); + rWrite(c.chan*7+4,(chan[c.chan].wave<<4)|(chan[c.chan].test<<3)|(chan[c.chan].ring<<2)|(chan[c.chan].sync<<1)|(int)(chan[c.chan].active && chan[c.chan].gate)); break; case DIV_CMD_LEGATO: chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value+((HACKY_LEGATO_MESS)?(chan[c.chan].std.arp.val):(0))); @@ -525,11 +502,11 @@ int DivPlatformC64::dispatch(DivCommand c) { break; case 4: chan[c.chan].ring=c.value; - rWrite(c.chan*7+4,(chan[c.chan].wave<<4)|(chan[c.chan].test<<3)|(chan[c.chan].ring<<2)|(chan[c.chan].sync<<1)|(int)(chan[c.chan].active)); + rWrite(c.chan*7+4,(chan[c.chan].wave<<4)|(chan[c.chan].test<<3)|(chan[c.chan].ring<<2)|(chan[c.chan].sync<<1)|(int)(chan[c.chan].active && chan[c.chan].gate)); break; case 5: chan[c.chan].sync=c.value; - rWrite(c.chan*7+4,(chan[c.chan].wave<<4)|(chan[c.chan].test<<3)|(chan[c.chan].ring<<2)|(chan[c.chan].sync<<1)|(int)(chan[c.chan].active)); + rWrite(c.chan*7+4,(chan[c.chan].wave<<4)|(chan[c.chan].test<<3)|(chan[c.chan].ring<<2)|(chan[c.chan].sync<<1)|(int)(chan[c.chan].active && chan[c.chan].gate)); break; case 6: filtControl&=7; @@ -730,7 +707,6 @@ void DivPlatformC64::setFlags(const DivConfig& flags) { } keyPriority=flags.getBool("keyPriority",true); no1EUpdate=flags.getBool("no1EUpdate",false); - newTestBitMacro = flags.getBool("newTestBitMacro", false); testAD=((flags.getInt("testAttack",0)&15)<<4)|(flags.getInt("testDecay",0)&15); testSR=((flags.getInt("testSustain",0)&15)<<4)|(flags.getInt("testRelease",0)&15); diff --git a/src/engine/platform/c64.h b/src/engine/platform/c64.h index 51777f6d0..334479144 100644 --- a/src/engine/platform/c64.h +++ b/src/engine/platform/c64.h @@ -26,13 +26,17 @@ #include "sound/c64_fp/SID.h" #include "sound/c64_d/dsid.h" +// TODO: +// - ex3 (special) unify with ex4 (gate/test) +// - ex4 (test) compatibility + class DivPlatformC64: public DivDispatch { struct Channel: public SharedChannel { int prevFreq, testWhen; unsigned char sweep, wave, attack, decay, sustain, release; short duty; bool sweepChanged, filter; - bool resetMask, resetFilter, resetDuty, ring, sync, test; + bool resetMask, resetFilter, resetDuty, gate, ring, sync, test; Channel(): SharedChannel(15), prevFreq(65535), @@ -49,6 +53,7 @@ class DivPlatformC64: public DivDispatch { resetMask(false), resetFilter(false), resetDuty(false), + gate(true), ring(false), sync(false), test(false) {} @@ -72,7 +77,7 @@ class DivPlatformC64: public DivDispatch { unsigned char sidCore; int filtCut, resetTime; - bool keyPriority, sidIs6581, needInitTables, no1EUpdate, newTestBitMacro; + bool keyPriority, sidIs6581, needInitTables, no1EUpdate; unsigned char chanOrder[3]; unsigned char testAD, testSR; diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 24d869743..fafc3c4b6 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -253,12 +253,8 @@ const char* filtModeBits[5]={ "low", "band", "high", "ch3off", NULL }; -const char* c64SpecialBits[3]={ - "sync", "ring", NULL -}; - -const char* c64TestGateBits[3]={ - "test", "gate", NULL +const char* c64TestGateBits[5]={ + "gate", "sync", "ring", "test", NULL }; const char* pokeyCtlBits[9]={ @@ -5009,12 +5005,8 @@ void FurnaceGUI::drawInsEdit() { } popToggleColors(); - if (ImGui::Checkbox("Volume Macro is Cutoff Macro",&ins->c64.volIsCutoff)) { - ins->std.volMacro.vZoom=-1; - PARAMETER; - } if (ImGui::Checkbox("Absolute Cutoff Macro",&ins->c64.filterIsAbs)) { - ins->std.volMacro.vZoom=-1; + ins->std.algMacro.vZoom=-1; PARAMETER; } if (ImGui::Checkbox("Absolute Duty Macro",&ins->c64.dutyIsAbs)) { @@ -5982,17 +5974,6 @@ void FurnaceGUI::drawInsEdit() { int volMax=15; int volMin=0; - if (ins->type==DIV_INS_C64) { - if (ins->c64.volIsCutoff) { - volumeLabel="Cutoff"; - if (ins->c64.filterIsAbs) { - volMax=2047; - } else { - volMin=-64; - volMax=64; - } - } - } if (ins->type==DIV_INS_PCE || ins->type==DIV_INS_AY8930 || ins->type==DIV_INS_SM8521) { volMax=31; } @@ -6438,15 +6419,14 @@ void FurnaceGUI::drawInsEdit() { } if (ex1Max>0) { if (ins->type==DIV_INS_C64) { - int cutoffmin = -64; - int cutoffmax = 64; + int cutoffMin=-64; + int cutoffMax=64; - if (ins->c64.filterIsAbs) { - ins->std.algMacro.vZoom = -1; - cutoffmin = 0; - cutoffmax = 2047; - } - macroList.push_back(FurnaceGUIMacroDesc("Filter Cutoff", &ins->std.algMacro, cutoffmin, cutoffmax, 160, uiColors[GUI_COLOR_MACRO_OTHER])); + if (ins->c64.filterIsAbs) { + cutoffMin=0; + cutoffMax=2047; + } + macroList.push_back(FurnaceGUIMacroDesc("Cutoff",&ins->std.algMacro,cutoffMin,cutoffMax,160,uiColors[GUI_COLOR_MACRO_OTHER])); macroList.push_back(FurnaceGUIMacroDesc("Filter Mode",&ins->std.ex1Macro,0,ex1Max,64,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true,filtModeBits)); } else if (ins->type==DIV_INS_SAA1099) { macroList.push_back(FurnaceGUIMacroDesc("Envelope",&ins->std.ex1Macro,0,ex1Max,160,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true,saaEnvBits)); @@ -6492,13 +6472,11 @@ void FurnaceGUI::drawInsEdit() { } } if (ins->type==DIV_INS_C64) { - macroList.push_back(FurnaceGUIMacroDesc("Special",&ins->std.ex3Macro,0,2,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true,c64SpecialBits)); - //macroList.push_back(FurnaceGUIMacroDesc("Test/Gate",&ins->std.ex4Macro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); - macroList.push_back(FurnaceGUIMacroDesc("Test/Gate",&ins->std.ex4Macro,0,2,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL, true, c64TestGateBits)); - macroList.push_back(FurnaceGUIMacroDesc("Attack", &ins->std.ex5Macro, 0, 15, 128, uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc("Decay", &ins->std.ex6Macro, 0, 15, 128, uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc("Sustain", &ins->std.ex7Macro, 0, 15, 128, uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc("Release", &ins->std.ex8Macro, 0, 15, 128, uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc("Special",&ins->std.ex4Macro,0,4,64,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true,c64TestGateBits)); + macroList.push_back(FurnaceGUIMacroDesc("Attack",&ins->std.ex5Macro,0,15,128,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc("Decay",&ins->std.ex6Macro,0,15,128,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc("Sustain",&ins->std.ex7Macro,0,15,128,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc("Release",&ins->std.ex8Macro,0,15,128,uiColors[GUI_COLOR_MACRO_OTHER])); } if (ins->type==DIV_INS_AY || ins->type==DIV_INS_AY8930 || (ins->type==DIV_INS_X1_010 && !ins->amiga.useSample)) { macroList.push_back(FurnaceGUIMacroDesc("AutoEnv Num",&ins->std.ex3Macro,0,15,160,uiColors[GUI_COLOR_MACRO_OTHER])); diff --git a/src/gui/sysConf.cpp b/src/gui/sysConf.cpp index 1f03375a8..d53582f6c 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -587,7 +587,6 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl int clockSel=flags.getInt("clockSel",0); bool keyPriority=flags.getBool("keyPriority",true); bool no1EUpdate=flags.getBool("no1EUpdate",false); - bool newTestBitMacro = flags.getBool("newTestBitMacro", false); int testAttack=flags.getInt("testAttack",0); int testDecay=flags.getInt("testDecay",0); int testSustain=flags.getInt("testSustain",0); @@ -650,16 +649,11 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl altered=true; } - if (ImGui::Checkbox("New test bit macro behaviour (with gate bit) (compatibility)", &newTestBitMacro)) { - altered = true; - } - if (altered) { e->lockSave([&]() { flags.set("clockSel",clockSel); flags.set("keyPriority",keyPriority); flags.set("no1EUpdate",no1EUpdate); - flags.set("newTestBitMacro", newTestBitMacro); flags.set("testAttack",testAttack); flags.set("testDecay",testDecay); flags.set("testSustain",testSustain);