diff --git a/src/engine/fileOps.cpp b/src/engine/fileOps.cpp index 0175c02e2..213e7cc7a 100644 --- a/src/engine/fileOps.cpp +++ b/src/engine/fileOps.cpp @@ -3008,11 +3008,12 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) { } } - // C64 1Exy compat + // C64 1Exy and old version test bit macro compat if (ds.version<186) { for (int i=0; igetIns(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; + } + if (NEW_ARP_STRAT) { chan[i].handleArp(); } else if (chan[i].std.arp.had) { @@ -220,9 +233,40 @@ void DivPlatformC64::tick(bool sysTick) { } 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)); } + 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)); + } + + 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)); + } + + 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)); + } + + 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)); + } + if (sysTick) { if (chan[i].testWhen>0) { if (--chan[i].testWhen<1) { @@ -396,7 +440,7 @@ int DivPlatformC64::dispatch(DivCommand c) { break; case DIV_CMD_PRE_PORTA: if (chan[c.chan].active && c.value2) { - if (parent->song.resetMacroOnPorta || !chan[c.chan].inPorta) { + if (parent->song.resetMacroOnPorta) {// || !chan[c.chan].inPorta) { chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_C64)); chan[c.chan].keyOn=true; } @@ -686,6 +730,7 @@ 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 67ead6aa7..51777f6d0 100644 --- a/src/engine/platform/c64.h +++ b/src/engine/platform/c64.h @@ -72,7 +72,7 @@ class DivPlatformC64: public DivDispatch { unsigned char sidCore; int filtCut, resetTime; - bool keyPriority, sidIs6581, needInitTables, no1EUpdate; + bool keyPriority, sidIs6581, needInitTables, no1EUpdate, newTestBitMacro; unsigned char chanOrder[3]; unsigned char testAD, testSR; diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 0833093dc..24d869743 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -257,6 +257,10 @@ const char* c64SpecialBits[3]={ "sync", "ring", NULL }; +const char* c64TestGateBits[3]={ + "test", "gate", NULL +}; + const char* pokeyCtlBits[9]={ "15KHz", "filter 2+4", "filter 1+3", "16-bit 3+4", "16-bit 1+2", "high3", "high1", "poly9", NULL }; @@ -6434,6 +6438,15 @@ void FurnaceGUI::drawInsEdit() { } if (ex1Max>0) { if (ins->type==DIV_INS_C64) { + 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])); 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)); @@ -6480,7 +6493,12 @@ 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,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])); } 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 d53582f6c..1f03375a8 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -587,6 +587,7 @@ 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); @@ -649,11 +650,16 @@ 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);