dev223 - Y8950: fix ADPCM pitch

issue #2028
This commit is contained in:
tildearrow 2024-09-26 14:41:14 -05:00
parent 0cf6c7cd64
commit 0f2fd76a90
5 changed files with 23 additions and 5 deletions

View file

@ -54,8 +54,8 @@ class DivWorkPool;
#define DIV_UNSTABLE #define DIV_UNSTABLE
#define DIV_VERSION "dev222" #define DIV_VERSION "dev223"
#define DIV_ENGINE_VERSION 222 #define DIV_ENGINE_VERSION 223
// for imports // for imports
#define DIV_VERSION_MOD 0xff01 #define DIV_VERSION_MOD 0xff01
#define DIV_VERSION_FC 0xff02 #define DIV_VERSION_FC 0xff02

View file

@ -2111,6 +2111,15 @@ bool DivEngine::loadFur(unsigned char* file, size_t len, int variantID) {
} }
} }
// Y8950 broken ADPCM pitch
if (ds.version<223) {
for (int i=0; i<ds.systemLen; i++) {
if (ds.system[i]==DIV_SYSTEM_Y8950 || ds.system[i]==DIV_SYSTEM_Y8950_DRUMS) {
ds.systemFlags[i].set("compatYPitch",true);
}
}
}
if (active) quitDispatch(); if (active) quitDispatch();
BUSY_BEGIN_SOFT; BUSY_BEGIN_SOFT;

View file

@ -985,7 +985,7 @@ double DivPlatformOPL::NOTE_ADPCMB(int note) {
if (adpcmChan<0) return 0; if (adpcmChan<0) return 0;
if (chan[adpcmChan].sample>=0 && chan[adpcmChan].sample<parent->song.sampleLen) { if (chan[adpcmChan].sample>=0 && chan[adpcmChan].sample<parent->song.sampleLen) {
double off=65535.0*(double)(parent->getSample(chan[adpcmChan].sample)->centerRate)/8363.0; double off=65535.0*(double)(parent->getSample(chan[adpcmChan].sample)->centerRate)/8363.0;
return parent->calcBaseFreq((double)chipClock/144,off,note,false); return parent->calcBaseFreq((double)chipClock/(compatYPitch?144:72),off,note,false);
} }
return 0; return 0;
} }
@ -1315,7 +1315,7 @@ void DivPlatformOPL::tick(bool sysTick) {
if (chan[adpcmChan].freqChanged || chan[adpcmChan].keyOn || chan[adpcmChan].keyOff) { if (chan[adpcmChan].freqChanged || chan[adpcmChan].keyOn || chan[adpcmChan].keyOff) {
if (chan[adpcmChan].sample>=0 && chan[adpcmChan].sample<parent->song.sampleLen) { if (chan[adpcmChan].sample>=0 && chan[adpcmChan].sample<parent->song.sampleLen) {
double off=65535.0*(double)(parent->getSample(chan[adpcmChan].sample)->centerRate)/8363.0; double off=65535.0*(double)(parent->getSample(chan[adpcmChan].sample)->centerRate)/8363.0;
chan[adpcmChan].freq=parent->calcFreq(chan[adpcmChan].baseFreq,chan[adpcmChan].pitch,chan[adpcmChan].fixedArp?chan[adpcmChan].baseNoteOverride:chan[adpcmChan].arpOff,chan[adpcmChan].fixedArp,false,4,chan[adpcmChan].pitch2,(double)chipClock/144,off); chan[adpcmChan].freq=parent->calcFreq(chan[adpcmChan].baseFreq,chan[adpcmChan].pitch,chan[adpcmChan].fixedArp?chan[adpcmChan].baseNoteOverride:chan[adpcmChan].arpOff,chan[adpcmChan].fixedArp,false,4,chan[adpcmChan].pitch2,(double)chipClock/(compatYPitch?144:72),off);
} else { } else {
chan[adpcmChan].freq=0; chan[adpcmChan].freq=0;
} }
@ -3152,6 +3152,7 @@ void DivPlatformOPL::setFlags(const DivConfig& flags) {
break; break;
} }
compatPan=flags.getBool("compatPan",false); compatPan=flags.getBool("compatPan",false);
compatYPitch=flags.getBool("compatYPitch",false);
for (int i=0; i<44; i++) { for (int i=0; i<44; i++) {
oscBuf[i]->rate=rate; oscBuf[i]->rate=rate;

View file

@ -151,7 +151,7 @@ class DivPlatformOPL: public DivDispatch {
// 2: YM3812-LLE/YMF262-LLE // 2: YM3812-LLE/YMF262-LLE
unsigned char emuCore; unsigned char emuCore;
bool update4OpMask, pretendYMU, downsample, compatPan; bool update4OpMask, pretendYMU, downsample, compatPan, compatYPitch;
short oldWrites[768]; short oldWrites[768];
short pendingWrites[768]; short pendingWrites[768];

View file

@ -1757,6 +1757,7 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
case DIV_SYSTEM_Y8950: case DIV_SYSTEM_Y8950:
case DIV_SYSTEM_Y8950_DRUMS: { case DIV_SYSTEM_Y8950_DRUMS: {
int clockSel=flags.getInt("clockSel",0); int clockSel=flags.getInt("clockSel",0);
bool compatYPitch=flags.getBool("compatYPitch",false);
ImGui::Text(_("Clock rate:")); ImGui::Text(_("Clock rate:"));
ImGui::Indent(); ImGui::Indent();
@ -1786,9 +1787,16 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
} }
ImGui::Unindent(); ImGui::Unindent();
if ((type==DIV_SYSTEM_Y8950 || type==DIV_SYSTEM_Y8950_DRUMS) && compatYPitch) {
if (ImGui::Checkbox(_("ADPCM channel one octave up (compatibility)"),&compatYPitch)) {
altered=true;
}
}
if (altered) { if (altered) {
e->lockSave([&]() { e->lockSave([&]() {
flags.set("clockSel",clockSel); flags.set("clockSel",clockSel);
flags.set("compatYPitch",compatYPitch);
}); });
} }
break; break;