dev199 - SID2: fix cut/res range

This commit is contained in:
tildearrow 2024-04-22 06:21:13 -05:00
parent d96244080d
commit d5633e7484
4 changed files with 34 additions and 9 deletions

View file

@ -333,7 +333,8 @@ size | description
2 | duty
2 | cutoff/resonance
| - bit 12-15: resonance
| - bit 0-10: cutoff
| - bit 0-10: cutoff (0-11 on SID2)
1 | upper nibble of resonance (for SID2) (>=199)
```
## C64 compatibility note (>=187)

View file

@ -54,8 +54,8 @@ class DivWorkPool;
#define DIV_UNSTABLE
#define DIV_VERSION "dev198"
#define DIV_ENGINE_VERSION 198
#define DIV_VERSION "dev199"
#define DIV_ENGINE_VERSION 199
// for imports
#define DIV_VERSION_MOD 0xff01
#define DIV_VERSION_FC 0xff02

View file

@ -481,7 +481,9 @@ void DivInstrument::writeFeature64(SafeWriter* w) {
w->writeC(((c64.a&15)<<4)|(c64.d&15));
w->writeC(((c64.s&15)<<4)|(c64.r&15));
w->writeS(c64.duty);
w->writeS((unsigned short)((c64.cut&2047)|(c64.res<<12)));
w->writeS((unsigned short)((c64.cut&4095)|((c64.res&15)<<12)));
w->writeC((c64.res>>4)&15);
FEATURE_END;
}
@ -1647,9 +1649,13 @@ void DivInstrument::readFeature64(SafeReader& reader, bool& volIsCutoff, short v
c64.duty=reader.readS()&4095;
unsigned short cr=reader.readS();
c64.cut=cr&2047;
c64.cut=cr&4095;
c64.res=cr>>12;
if (version>=199) {
c64.res|=((unsigned char)reader.readC())<<4;
}
READ_FEAT_END;
}

View file

@ -5754,8 +5754,13 @@ void FurnaceGUI::drawInsEdit() {
P(ImGui::Checkbox("Enable filter",&ins->c64.toFilter));
P(ImGui::Checkbox("Initialize filter",&ins->c64.initFilter));
if (ins->type==DIV_INS_SID2) {
P(CWSliderScalar("Cutoff",ImGuiDataType_U16,&ins->c64.cut,&_ZERO,&_FOUR_THOUSAND_NINETY_FIVE)); rightClickable
P(CWSliderScalar("Resonance",ImGuiDataType_U8,&ins->c64.res,&_ZERO,&_TWO_HUNDRED_FIFTY_FIVE)); rightClickable
} else {
P(CWSliderScalar("Cutoff",ImGuiDataType_U16,&ins->c64.cut,&_ZERO,&_TWO_THOUSAND_FORTY_SEVEN)); rightClickable
P(CWSliderScalar("Resonance",ImGuiDataType_U8,&ins->c64.res,&_ZERO,&_FIFTEEN)); rightClickable
}
ImGui::AlignTextToFramePadding();
ImGui::Text("Filter Mode");
@ -7048,7 +7053,7 @@ void FurnaceGUI::drawInsEdit() {
}
if (ins->type==DIV_INS_SID2) {
ex1Max=3;
ex2Max=15;
ex2Max=255;
}
if (ins->type==DIV_INS_X1_010) {
dutyMax=0;
@ -7292,6 +7297,17 @@ void FurnaceGUI::drawInsEdit() {
cutoffMin=0;
cutoffMax=2047;
}
if (ins->type==DIV_INS_SID2) {
if (ins->c64.filterIsAbs) {
cutoffMin=0;
cutoffMax=4095;
} else {
cutoffMin=-4095;
cutoffMax=4095;
}
}
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) {
@ -7327,8 +7343,10 @@ void FurnaceGUI::drawInsEdit() {
}
}
if (ex2Max>0) {
if (ins->type==DIV_INS_C64 || ins->type==DIV_INS_SID2) {
if (ins->type==DIV_INS_C64) {
macroList.push_back(FurnaceGUIMacroDesc("Resonance",&ins->std.ex2Macro,0,ex2Max,64,uiColors[GUI_COLOR_MACRO_OTHER]));
} else if (ins->type==DIV_INS_SID2) {
macroList.push_back(FurnaceGUIMacroDesc("Resonance",&ins->std.ex2Macro,0,ex2Max,160,uiColors[GUI_COLOR_MACRO_OTHER]));
} else if (ins->type==DIV_INS_FDS) {
macroList.push_back(FurnaceGUIMacroDesc("Mod Speed",&ins->std.ex2Macro,0,ex2Max,160,uiColors[GUI_COLOR_MACRO_OTHER]));
} else if (ins->type==DIV_INS_SU) {