diff --git a/src/engine/engine.h b/src/engine/engine.h index 5c81f3e1c..87ff7116e 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -56,8 +56,8 @@ #define DIV_UNSTABLE -#define DIV_VERSION "dev164" -#define DIV_ENGINE_VERSION 164 +#define DIV_VERSION "dev165" +#define DIV_ENGINE_VERSION 165 // for imports #define DIV_VERSION_MOD 0xff01 #define DIV_VERSION_FC 0xff02 diff --git a/src/engine/fileOps.cpp b/src/engine/fileOps.cpp index 77f3f3dc5..6e87a4431 100644 --- a/src/engine/fileOps.cpp +++ b/src/engine/fileOps.cpp @@ -2941,6 +2941,15 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) { } } + // Namco 163 pitch compensation compat + if (ds.version<165) { + for (int i=0; icalcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,false,2,chan[i].pitch2,chipClock,CHIP_FREQBASE); - chan[i].freq=(((chan[i].freq*chan[i].curWaveLen)*(chanMax+1))/16); + if (lenCompensate) { + chan[i].freq=(((chan[i].freq*chan[i].curWaveLen)*(chanMax+1))/256); + } else { + chan[i].freq*=(chanMax+1); + chan[i].freq>>=3; + } if (chan[i].freq<0) chan[i].freq=0; if (chan[i].freq>0x3ffff) chan[i].freq=0x3ffff; if (chan[i].keyOn) { @@ -359,13 +364,13 @@ int DivPlatformN163::dispatch(DivCommand c) { int destFreq=NOTE_FREQUENCY(c.value2); bool return2=false; if (destFreq>chan[c.chan].baseFreq) { - chan[c.chan].baseFreq+=c.value; + chan[c.chan].baseFreq+=c.value*((parent->song.linearPitch==2)?1:16); if (chan[c.chan].baseFreq>=destFreq) { chan[c.chan].baseFreq=destFreq; return2=true; } } else { - chan[c.chan].baseFreq-=c.value; + chan[c.chan].baseFreq-=c.value*((parent->song.linearPitch==2)?1:16); if (chan[c.chan].baseFreq<=destFreq) { chan[c.chan].baseFreq=destFreq; return2=true; @@ -570,6 +575,8 @@ void DivPlatformN163::setFlags(const DivConfig& flags) { oscBuf[i]->rate=rate/(initChanMax+1); } + lenCompensate=flags.getBool("lenCompensate",false); + // needed to make sure changing channel count won't trigger glitches reset(); } diff --git a/src/engine/platform/n163.h b/src/engine/platform/n163.h index 3ebcbc441..c5ec64b7e 100644 --- a/src/engine/platform/n163.h +++ b/src/engine/platform/n163.h @@ -61,7 +61,7 @@ class DivPlatformN163: public DivDispatch { unsigned char initChanMax; unsigned char chanMax; short loadWave, loadPos; - bool multiplex; + bool multiplex, lenCompensate; n163_core n163; unsigned char regPool[128]; diff --git a/src/gui/sysConf.cpp b/src/gui/sysConf.cpp index a87f2fa34..0a746e61f 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -962,6 +962,7 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo int clockSel=flags.getInt("clockSel",0); int channels=flags.getInt("channels",0)+1; bool multiplex=flags.getBool("multiplex",false); + bool lenCompensate=flags.getBool("lenCompensate",false); ImGui::Text("Clock rate:"); if (ImGui::RadioButton("NTSC (1.79MHz)",clockSel==0)) { @@ -985,12 +986,16 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo if (ImGui::Checkbox("Disable hissing",&multiplex)) { altered=true; } + if (ImGui::Checkbox("Scale frequency to wave length",&lenCompensate)) { + altered=true; + } if (altered) { e->lockSave([&]() { flags.set("clockSel",clockSel); flags.set("channels",channels-1); flags.set("multiplex",multiplex); + flags.set("lenCompensate",lenCompensate); }); } break;