Skip to content

Commit

Permalink
fix AY being one octave down on .dmf import
Browse files Browse the repository at this point in the history
  • Loading branch information
tildearrow committed Dec 7, 2024
1 parent 54620b0 commit 3289f66
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/engine/fileOps/dmf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,9 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
} else if (ds.system[0]==DIV_SYSTEM_GENESIS && ds.version<0x0e && pat->data[k][1]>0 && i>5) {
// ditto
pat->data[k][1]--;
} else if (ds.system[0]==DIV_SYSTEM_MSX2 && pat->data[k][1]>0 && i<3) {
// why the hell?
pat->data[k][1]++;
}
if (ds.version<0x12) {
if (ds.system[0]==DIV_SYSTEM_GB && i==3 && pat->data[k][1]>0) {
Expand Down Expand Up @@ -1066,6 +1069,24 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
}
}

// AY+SCC stuff
if (ds.system[0]==DIV_SYSTEM_MSX2) {
for (DivInstrument* i: ds.ins) {
if (i->type==DIV_INS_AY) {
// move wave macro
i->std.waveMacro.len=i->std.dutyMacro.len;
i->std.waveMacro.loop=i->std.dutyMacro.loop;
i->std.waveMacro.mode=i->std.dutyMacro.mode;
i->std.waveMacro.open=i->std.dutyMacro.open;
memcpy(i->std.waveMacro.val,i->std.dutyMacro.val,sizeof(i->std.waveMacro.val));
for (int j=0; j<i->std.waveMacro.len; j++) {
i->std.waveMacro.val[j]++;
}
i->std.dutyMacro.len=0;
}
}
}

// handle compound systems
if (ds.system[0]==DIV_SYSTEM_GENESIS) {
ds.systemLen=2;
Expand All @@ -1088,6 +1109,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
ds.systemLen=2;
ds.system[0]=DIV_SYSTEM_AY8910;
ds.system[1]=DIV_SYSTEM_SCC;
ds.systemFlags[0].set("chipType",1);
}
if (ds.system[0]==DIV_SYSTEM_SMS_OPLL) {
ds.systemLen=2;
Expand Down Expand Up @@ -1187,6 +1209,7 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) {
}
if (song.system[0]==DIV_SYSTEM_AY8910 && song.system[1]==DIV_SYSTEM_SCC) {
isFlat=true;
addWarning("your song will sound different. I am not going to bother adding further compatibility.");
}
}
// fail if more than one system
Expand Down

2 comments on commit 3289f66

@freq-mod
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deflemask got undead and added MSX2? I legit hope SCC is not 4-bit www

@tildearrow
Copy link
Owner Author

@tildearrow tildearrow commented on 3289f66 Dec 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DefleMask SCC is 8-bit as it should be.
Emulation isn't 100% accurate but good enough.
Channel 4 and 5 wave sharing differs from Furnace.
AY noise is different as well and macros/effects have changed. I am not going to implement compatibility for that.

Yeah, still no hardware envelopes.

Please sign in to comment.