dev87 - C64 changes

issue #335
This commit is contained in:
tildearrow 2022-04-25 17:55:48 -05:00
parent 8ba2787160
commit 2a952b1a66
7 changed files with 57 additions and 14 deletions

View File

@ -29,6 +29,7 @@ furthermore, an `or reserved` indicates this field is always present, but is res
the format versions are:
- 87: Furnace dev87
- 86: Furnace dev86
- 85: Furnace dev85
- 84: Furnace dev84
@ -423,9 +424,11 @@ size | description
1 | reserved (>=17) or duty macro height (>=15) or reserved
1 | reserved (>=17) or wave macro height (>=15) or reserved
4?? | volume macro
| - before version 87, if this is the C64 relative cutoff macro, its values were stored offset by 18.
4?? | arp macro
| - before version 31, this macro's values were stored offset by 12.
4?? | duty macro
| - before version 87, if this is the C64 relative duty macro, its values were stored offset by 12.
4?? | wave macro
4?? | pitch macro (>=17)
4?? | extra 1 macro (>=17)

View File

@ -43,8 +43,8 @@
#define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock();
#define BUSY_END isBusy.unlock(); softLocked=false;
#define DIV_VERSION "dev86"
#define DIV_ENGINE_VERSION 86
#define DIV_VERSION "dev87"
#define DIV_ENGINE_VERSION 87
// for imports
#define DIV_VERSION_MOD 0xff01

View File

@ -501,9 +501,9 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
} else {
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.val[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.dutyMacro.len>0) {
ins->std.dutyMacro.open=true;
@ -556,6 +556,16 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
ins->c64.bp=reader.readC();
ins->c64.lp=reader.readC();
ins->c64.ch3off=reader.readC();
// weird storage
if (ins->c64.volIsCutoff) {
for (int j=0; j<ins->std.volMacro.len; j++) {
ins->std.volMacro.val[j]-=18;
}
}
for (int j=0; j<ins->std.dutyMacro.len; j++) {
ins->std.dutyMacro.val[j]-=12;
}
}
if (ds.system[0]==DIV_SYSTEM_GB && ds.version>0x11) {
@ -2609,7 +2619,13 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) {
} else { // STD
if (sys!=DIV_SYSTEM_GB) {
w->writeC(i->std.volMacro.len);
w->write(i->std.volMacro.val,4*i->std.volMacro.len);
if ((sys==DIV_SYSTEM_C64_6581 || sys==DIV_SYSTEM_C64_8580) && i->c64.volIsCutoff) {
for (int j=0; j<i->std.volMacro.len; j++) {
w->writeI(i->std.volMacro.val[j]+18);
}
} else {
w->write(i->std.volMacro.val,4*i->std.volMacro.len);
}
if (i->std.volMacro.len>0) {
w->writeC(i->std.volMacro.loop);
}
@ -2629,7 +2645,13 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) {
w->writeC(i->std.arpMacro.mode);
w->writeC(i->std.dutyMacro.len);
w->write(i->std.dutyMacro.val,4*i->std.dutyMacro.len);
if (sys==DIV_SYSTEM_C64_6581 || sys==DIV_SYSTEM_C64_8580) {
for (int j=0; j<i->std.dutyMacro.len; j++) {
w->writeI(i->std.dutyMacro.val[j]+12);
}
} else {
w->write(i->std.dutyMacro.val,4*i->std.dutyMacro.len);
}
if (i->std.dutyMacro.len>0) {
w->writeC(i->std.dutyMacro.loop);
}

View File

@ -345,6 +345,16 @@ void DivEngine::loadDMP(SafeReader& reader, std::vector<DivInstrument*>& ret, St
ins->c64.bp=reader.readC();
ins->c64.lp=reader.readC();
ins->c64.ch3off=reader.readC();
// weird storage
if (ins->c64.volIsCutoff) {
for (int j=0; j<ins->std.volMacro.len; j++) {
ins->std.volMacro.val[j]-=18;
}
}
for (int j=0; j<ins->std.dutyMacro.len; j++) {
ins->std.dutyMacro.val[j]-=12;
}
}
if (ins->type==DIV_INS_GB) {
ins->gb.envVol=reader.readC();

View File

@ -639,6 +639,14 @@ DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) {
std.arpMacro.val[j]-=12;
}
}
if (type==DIV_INS_C64 && version<87) {
if (c64.volIsCutoff && !c64.filterIsAbs) for (int j=0; j<std.volMacro.len; j++) {
std.volMacro.val[j]-=18;
}
if (!c64.dutyIsAbs) for (int j=0; j<std.dutyMacro.len; j++) {
std.dutyMacro.val[j]-=12;
}
}
if (version>=17) {
reader.read(std.pitchMacro.val,4*std.pitchMacro.len);
reader.read(std.ex1Macro.val,4*std.ex1Macro.len);

View File

@ -131,7 +131,7 @@ void DivPlatformC64::tick(bool sysTick) {
if (ins->c64.filterIsAbs) {
filtCut=MIN(2047,chan[i].std.vol.val);
} else {
filtCut-=((signed char)chan[i].std.vol.val-18)*7;
filtCut-=((signed char)chan[i].std.vol.val)*7;
if (filtCut>2047) filtCut=2047;
if (filtCut<0) filtCut=0;
}
@ -161,7 +161,7 @@ void DivPlatformC64::tick(bool sysTick) {
if (ins->c64.dutyIsAbs) {
chan[i].duty=chan[i].std.duty.val;
} else {
chan[i].duty-=((signed char)chan[i].std.duty.val-12)*4;
chan[i].duty-=((signed char)chan[i].std.duty.val)*4;
}
rWrite(i*7+2,chan[i].duty&0xff);
rWrite(i*7+3,chan[i].duty>>8);

View File

@ -2687,8 +2687,8 @@ void FurnaceGUI::drawInsEdit() {
if (ins->c64.filterIsAbs) {
volMax=2047;
} else {
volMin=-18;
volMax=18;
volMin=-64;
volMax=64;
}
}
}
@ -2717,13 +2717,15 @@ void FurnaceGUI::drawInsEdit() {
bool arpMode=ins->std.arpMacro.mode;
const char* dutyLabel="Duty/Noise";
int dutyMin=0;
int dutyMax=3;
if (ins->type==DIV_INS_C64) {
dutyLabel="Duty";
if (ins->c64.dutyIsAbs) {
dutyMax=4095;
} else {
dutyMax=24;
dutyMin=-96;
dutyMax=96;
}
}
if (ins->type==DIV_INS_FM) {
@ -2840,10 +2842,8 @@ void FurnaceGUI::drawInsEdit() {
if (dutyMax>0) {
if (ins->type==DIV_INS_MIKEY) {
NORMAL_MACRO(ins->std.dutyMacro,0,dutyMax,"duty",dutyLabel,160,ins->std.dutyMacro.open,true,mikeyFeedbackBits,false,NULL,0,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,0,false,0,macroDummyMode,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,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[2],0,dutyMax,NULL,false);
NORMAL_MACRO(ins->std.dutyMacro,dutyMin,dutyMax,"duty",dutyLabel,160,ins->std.dutyMacro.open,false,NULL,false,NULL,0,0,0,0,false,0,macroDummyMode,uiColors[GUI_COLOR_MACRO_OTHER],mmlString[2],dutyMin,dutyMax,NULL,false);
}
}
if (waveMax>0) {