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!
This commit is contained in:
tildearrow 2023-10-29 01:39:37 -05:00
parent 2ec1074b21
commit 90032899c7
5 changed files with 57 additions and 113 deletions

View file

@ -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; i<ds.systemLen; i++) {
if (ds.system[i]==DIV_SYSTEM_C64_8580 || ds.system[i]==DIV_SYSTEM_C64_6581) {
ds.systemFlags[i].set("newTestBitMacro",true);
}
}
}
if (active) quitDispatch(); if (active) quitDispatch();
BUSY_BEGIN_SOFT; BUSY_BEGIN_SOFT;
saveLock.lock(); saveLock.lock();

View file

@ -158,32 +158,8 @@ void DivPlatformC64::tick(bool sysTick) {
chan[i].std.next(); chan[i].std.next();
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {
DivInstrument* ins=parent->getIns(chan[i].ins,DIV_INS_C64); vol=MIN(15,chan[i].std.vol.val);
if (ins->c64.volIsCutoff) { willUpdateFilter=true;
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;
} }
if (NEW_ARP_STRAT) { if (NEW_ARP_STRAT) {
@ -206,7 +182,7 @@ void DivPlatformC64::tick(bool sysTick) {
} }
if (chan[i].std.wave.had) { if (chan[i].std.wave.had) {
chan[i].wave=chan[i].std.wave.val; 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.had) {
if (chan[i].std.pitch.mode) { if (chan[i].std.pitch.mode) {
@ -217,6 +193,20 @@ void DivPlatformC64::tick(bool sysTick) {
} }
chan[i].freqChanged=true; 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) { if (chan[i].std.ex1.had) {
filtControl=chan[i].std.ex1.val&15; filtControl=chan[i].std.ex1.val&15;
willUpdateFilter=true; willUpdateFilter=true;
@ -225,46 +215,33 @@ void DivPlatformC64::tick(bool sysTick) {
filtRes=chan[i].std.ex2.val&15; filtRes=chan[i].std.ex2.val&15;
willUpdateFilter=true; 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) { if (chan[i].std.ex4.had) {
chan[i].test=chan[i].std.ex4.val&1; chan[i].gate=chan[i].std.ex4.val&1;
chan[i].sync=chan[i].std.ex4.val&2;
if (newTestBitMacro) chan[i].ring=chan[i].std.ex4.val&4;
{ chan[i].test=chan[i].std.ex4.val&8;
chan[i].active = chan[i].std.ex4.val & 2; chan[i].freqChanged=true;
if (!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));
{
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) { if (chan[i].std.ex5.had) {
chan[i].attack = chan[i].std.ex5.val & 15; chan[i].attack=chan[i].std.ex5.val&15;
rWrite(i * 7 + 5, (chan[i].attack << 4) | (chan[i].decay)); rWrite(i*7+5,(chan[i].attack<<4)|(chan[i].decay));
} }
if (chan[i].std.ex6.had) { if (chan[i].std.ex6.had) {
chan[i].decay = chan[i].std.ex6.val & 15; chan[i].decay=chan[i].std.ex6.val&15;
rWrite(i * 7 + 5, (chan[i].attack << 4) | (chan[i].decay)); rWrite(i*7+5,(chan[i].attack<<4)|(chan[i].decay));
} }
if (chan[i].std.ex7.had) { if (chan[i].std.ex7.had) {
chan[i].sustain = chan[i].std.ex7.val & 15; chan[i].sustain=chan[i].std.ex7.val&15;
rWrite(i * 7 + 6, (chan[i].sustain << 4) | (chan[i].release)); rWrite(i*7+6,(chan[i].sustain<<4)|(chan[i].release));
} }
if (chan[i].std.ex8.had) { if (chan[i].std.ex8.had) {
chan[i].release = chan[i].std.ex8.val & 15; chan[i].release=chan[i].std.ex8.val&15;
rWrite(i * 7 + 6, (chan[i].sustain << 4) | (chan[i].release)); rWrite(i*7+6,(chan[i].sustain<<4)|(chan[i].release));
} }
if (sysTick) { if (sysTick) {
@ -287,7 +264,7 @@ void DivPlatformC64::tick(bool sysTick) {
if (chan[i].keyOn) { if (chan[i].keyOn) {
rWrite(i*7+5,(chan[i].attack<<4)|(chan[i].decay)); 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+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) { if (chan[i].keyOff) {
rWrite(i*7+5,(chan[i].attack<<4)|(chan[i].decay)); rWrite(i*7+5,(chan[i].attack<<4)|(chan[i].decay));
@ -431,7 +408,7 @@ int DivPlatformC64::dispatch(DivCommand c) {
break; break;
case DIV_CMD_WAVE: case DIV_CMD_WAVE:
chan[c.chan].wave=c.value; 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; break;
case DIV_CMD_LEGATO: case DIV_CMD_LEGATO:
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value+((HACKY_LEGATO_MESS)?(chan[c.chan].std.arp.val):(0))); 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; break;
case 4: case 4:
chan[c.chan].ring=c.value; 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; break;
case 5: case 5:
chan[c.chan].sync=c.value; 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; break;
case 6: case 6:
filtControl&=7; filtControl&=7;
@ -730,7 +707,6 @@ void DivPlatformC64::setFlags(const DivConfig& flags) {
} }
keyPriority=flags.getBool("keyPriority",true); keyPriority=flags.getBool("keyPriority",true);
no1EUpdate=flags.getBool("no1EUpdate",false); no1EUpdate=flags.getBool("no1EUpdate",false);
newTestBitMacro = flags.getBool("newTestBitMacro", false);
testAD=((flags.getInt("testAttack",0)&15)<<4)|(flags.getInt("testDecay",0)&15); testAD=((flags.getInt("testAttack",0)&15)<<4)|(flags.getInt("testDecay",0)&15);
testSR=((flags.getInt("testSustain",0)&15)<<4)|(flags.getInt("testRelease",0)&15); testSR=((flags.getInt("testSustain",0)&15)<<4)|(flags.getInt("testRelease",0)&15);

View file

@ -26,13 +26,17 @@
#include "sound/c64_fp/SID.h" #include "sound/c64_fp/SID.h"
#include "sound/c64_d/dsid.h" #include "sound/c64_d/dsid.h"
// TODO:
// - ex3 (special) unify with ex4 (gate/test)
// - ex4 (test) compatibility
class DivPlatformC64: public DivDispatch { class DivPlatformC64: public DivDispatch {
struct Channel: public SharedChannel<signed char> { struct Channel: public SharedChannel<signed char> {
int prevFreq, testWhen; int prevFreq, testWhen;
unsigned char sweep, wave, attack, decay, sustain, release; unsigned char sweep, wave, attack, decay, sustain, release;
short duty; short duty;
bool sweepChanged, filter; bool sweepChanged, filter;
bool resetMask, resetFilter, resetDuty, ring, sync, test; bool resetMask, resetFilter, resetDuty, gate, ring, sync, test;
Channel(): Channel():
SharedChannel<signed char>(15), SharedChannel<signed char>(15),
prevFreq(65535), prevFreq(65535),
@ -49,6 +53,7 @@ class DivPlatformC64: public DivDispatch {
resetMask(false), resetMask(false),
resetFilter(false), resetFilter(false),
resetDuty(false), resetDuty(false),
gate(true),
ring(false), ring(false),
sync(false), sync(false),
test(false) {} test(false) {}
@ -72,7 +77,7 @@ class DivPlatformC64: public DivDispatch {
unsigned char sidCore; unsigned char sidCore;
int filtCut, resetTime; int filtCut, resetTime;
bool keyPriority, sidIs6581, needInitTables, no1EUpdate, newTestBitMacro; bool keyPriority, sidIs6581, needInitTables, no1EUpdate;
unsigned char chanOrder[3]; unsigned char chanOrder[3];
unsigned char testAD, testSR; unsigned char testAD, testSR;

View file

@ -253,12 +253,8 @@ const char* filtModeBits[5]={
"low", "band", "high", "ch3off", NULL "low", "band", "high", "ch3off", NULL
}; };
const char* c64SpecialBits[3]={ const char* c64TestGateBits[5]={
"sync", "ring", NULL "gate", "sync", "ring", "test", NULL
};
const char* c64TestGateBits[3]={
"test", "gate", NULL
}; };
const char* pokeyCtlBits[9]={ const char* pokeyCtlBits[9]={
@ -5009,12 +5005,8 @@ void FurnaceGUI::drawInsEdit() {
} }
popToggleColors(); 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)) { if (ImGui::Checkbox("Absolute Cutoff Macro",&ins->c64.filterIsAbs)) {
ins->std.volMacro.vZoom=-1; ins->std.algMacro.vZoom=-1;
PARAMETER; PARAMETER;
} }
if (ImGui::Checkbox("Absolute Duty Macro",&ins->c64.dutyIsAbs)) { if (ImGui::Checkbox("Absolute Duty Macro",&ins->c64.dutyIsAbs)) {
@ -5982,17 +5974,6 @@ void FurnaceGUI::drawInsEdit() {
int volMax=15; int volMax=15;
int volMin=0; 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) { if (ins->type==DIV_INS_PCE || ins->type==DIV_INS_AY8930 || ins->type==DIV_INS_SM8521) {
volMax=31; volMax=31;
} }
@ -6438,15 +6419,14 @@ void FurnaceGUI::drawInsEdit() {
} }
if (ex1Max>0) { if (ex1Max>0) {
if (ins->type==DIV_INS_C64) { if (ins->type==DIV_INS_C64) {
int cutoffmin = -64; int cutoffMin=-64;
int cutoffmax = 64; int cutoffMax=64;
if (ins->c64.filterIsAbs) { if (ins->c64.filterIsAbs) {
ins->std.algMacro.vZoom = -1; cutoffMin=0;
cutoffmin = 0; cutoffMax=2047;
cutoffmax = 2047; }
} macroList.push_back(FurnaceGUIMacroDesc("Cutoff",&ins->std.algMacro,cutoffMin,cutoffMax,160,uiColors[GUI_COLOR_MACRO_OTHER]));
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)); 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) { } 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)); 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) { 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("Special",&ins->std.ex4Macro,0,4,64,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true,c64TestGateBits));
//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("Attack",&ins->std.ex5Macro,0,15,128,uiColors[GUI_COLOR_MACRO_OTHER]));
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("Decay",&ins->std.ex6Macro,0,15,128,uiColors[GUI_COLOR_MACRO_OTHER]));
macroList.push_back(FurnaceGUIMacroDesc("Attack", &ins->std.ex5Macro, 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("Decay", &ins->std.ex6Macro, 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("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)) { 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])); macroList.push_back(FurnaceGUIMacroDesc("AutoEnv Num",&ins->std.ex3Macro,0,15,160,uiColors[GUI_COLOR_MACRO_OTHER]));

View file

@ -587,7 +587,6 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
int clockSel=flags.getInt("clockSel",0); int clockSel=flags.getInt("clockSel",0);
bool keyPriority=flags.getBool("keyPriority",true); bool keyPriority=flags.getBool("keyPriority",true);
bool no1EUpdate=flags.getBool("no1EUpdate",false); bool no1EUpdate=flags.getBool("no1EUpdate",false);
bool newTestBitMacro = flags.getBool("newTestBitMacro", false);
int testAttack=flags.getInt("testAttack",0); int testAttack=flags.getInt("testAttack",0);
int testDecay=flags.getInt("testDecay",0); int testDecay=flags.getInt("testDecay",0);
int testSustain=flags.getInt("testSustain",0); int testSustain=flags.getInt("testSustain",0);
@ -650,16 +649,11 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
altered=true; altered=true;
} }
if (ImGui::Checkbox("New test bit macro behaviour (with gate bit) (compatibility)", &newTestBitMacro)) {
altered = true;
}
if (altered) { if (altered) {
e->lockSave([&]() { e->lockSave([&]() {
flags.set("clockSel",clockSel); flags.set("clockSel",clockSel);
flags.set("keyPriority",keyPriority); flags.set("keyPriority",keyPriority);
flags.set("no1EUpdate",no1EUpdate); flags.set("no1EUpdate",no1EUpdate);
flags.set("newTestBitMacro", newTestBitMacro);
flags.set("testAttack",testAttack); flags.set("testAttack",testAttack);
flags.set("testDecay",testDecay); flags.set("testDecay",testDecay);
flags.set("testSustain",testSustain); flags.set("testSustain",testSustain);