From c9eb4482b0ac8d7c6d8d7b458cb65c7eb626d51f Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 12 Feb 2023 01:48:02 -0500 Subject: [PATCH] ES5506: new vol/pan range is 4095 --- src/engine/platform/es5506.cpp | 26 +++++++++++++------------- src/engine/platform/es5506.h | 14 +++++++------- src/gui/insEdit.cpp | 4 ++-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/engine/platform/es5506.cpp b/src/engine/platform/es5506.cpp index e7b7ee5ce..8af013e54 100644 --- a/src/engine/platform/es5506.cpp +++ b/src/engine/platform/es5506.cpp @@ -190,7 +190,7 @@ void DivPlatformES5506::tick(bool sysTick) { signed int k1=chan[i].k1Prev,k2=chan[i].k2Prev; // volume/panning macros if (chan[i].std.vol.had) { - const unsigned int nextVol=VOL_SCALE_LOG((0xffff*chan[i].vol)/0xff,(0xffff*(unsigned int)chan[i].std.vol.val)/chan[i].volMacroMax,0xffff); + const unsigned int nextVol=VOL_SCALE_LOG((0xfff*chan[i].vol)/0xff,(0xfff*(unsigned int)chan[i].std.vol.val)/chan[i].volMacroMax,0xfff); if (chan[i].outVol!=nextVol) { chan[i].outVol=nextVol; chan[i].volChanged.lVol=1; @@ -198,14 +198,14 @@ void DivPlatformES5506::tick(bool sysTick) { } } if (chan[i].std.panL.had) { - const unsigned int nextLVol=VOL_SCALE_LOG((0xffff*chan[i].lVol)/0xff,(0xffff*(unsigned int)chan[i].std.panL.val)/chan[i].panMacroMax,0xffff); + const unsigned int nextLVol=VOL_SCALE_LOG((0xfff*chan[i].lVol)/0xff,(0xfff*(unsigned int)chan[i].std.panL.val)/chan[i].panMacroMax,0xfff); if (chan[i].outLVol!=nextLVol) { chan[i].outLVol=nextLVol; chan[i].volChanged.lVol=1; } } if (chan[i].std.panR.had) { - const unsigned int nextRVol=VOL_SCALE_LOG((0xffff*chan[i].rVol)/0xff,(0xffff*(unsigned int)chan[i].std.panR.val)/chan[i].panMacroMax,0xffff); + const unsigned int nextRVol=VOL_SCALE_LOG((0xfff*chan[i].rVol)/0xff,(0xfff*(unsigned int)chan[i].std.panR.val)/chan[i].panMacroMax,0xfff); if (chan[i].outRVol!=nextRVol) { chan[i].outRVol=nextRVol; chan[i].volChanged.rVol=1; @@ -385,13 +385,13 @@ void DivPlatformES5506::tick(bool sysTick) { if (chan[i].volChanged.changed) { // calculate volume (16 bit) if (chan[i].volChanged.lVol) { - chan[i].resLVol=VOL_SCALE_LOG(chan[i].outVol,chan[i].outLVol,0xffff); + chan[i].resLVol=VOL_SCALE_LOG(chan[i].outVol,chan[i].outLVol,0xfff)<<4; if (!chan[i].keyOn && chan[i].active) { pageWrite(0x00|i,0x02,chan[i].resLVol); } } if (chan[i].volChanged.rVol) { - chan[i].resRVol=VOL_SCALE_LOG(chan[i].outVol,chan[i].outRVol,0xffff); + chan[i].resRVol=VOL_SCALE_LOG(chan[i].outVol,chan[i].outRVol,0xfff)<<4; if (!chan[i].keyOn && chan[i].active) { pageWrite(0x00|i,0x04,chan[i].resRVol); } @@ -738,8 +738,8 @@ int DivPlatformES5506::dispatch(DivCommand c) { } if (sample>=0 && samplesong.sampleLen) { sampleVaild=true; - chan[c.chan].volMacroMax=ins->type==DIV_INS_AMIGA?64:0xffff; - chan[c.chan].panMacroMax=ins->type==DIV_INS_AMIGA?127:0xffff; + chan[c.chan].volMacroMax=ins->type==DIV_INS_AMIGA?64:0xfff; + chan[c.chan].panMacroMax=ins->type==DIV_INS_AMIGA?127:0xfff; chan[c.chan].pcm.next=sample; chan[c.chan].filter=ins->es5506.filter; chan[c.chan].envelope=ins->es5506.envelope; @@ -760,13 +760,13 @@ int DivPlatformES5506::dispatch(DivCommand c) { chan[c.chan].volChanged.changed=0xff; } if (!chan[c.chan].std.vol.will) { - chan[c.chan].outVol=(0xffff*chan[c.chan].vol)/0xff; + chan[c.chan].outVol=(0xfff*chan[c.chan].vol)/0xff; } if (!chan[c.chan].std.panL.will) { - chan[c.chan].outLVol=(0xffff*chan[c.chan].lVol)/0xff; + chan[c.chan].outLVol=(0xfff*chan[c.chan].lVol)/0xff; } if (!chan[c.chan].std.panR.will) { - chan[c.chan].outRVol=(0xffff*chan[c.chan].rVol)/0xff; + chan[c.chan].outRVol=(0xfff*chan[c.chan].rVol)/0xff; } chan[c.chan].active=true; chan[c.chan].keyOn=true; @@ -793,7 +793,7 @@ int DivPlatformES5506::dispatch(DivCommand c) { if (chan[c.chan].vol!=(unsigned int)(c.value)) { chan[c.chan].vol=c.value; if (!chan[c.chan].std.vol.has) { - chan[c.chan].outVol=(0xffff*c.value)/0xff; + chan[c.chan].outVol=(0xfff*c.value)/0xff; chan[c.chan].volChanged.changed=0xff; } } @@ -810,7 +810,7 @@ int DivPlatformES5506::dispatch(DivCommand c) { if (chan[c.chan].lVol!=(unsigned int)(c.value)) { chan[c.chan].lVol=c.value; if (!chan[c.chan].std.panL.has) { - chan[c.chan].outLVol=(0xffff*c.value)/0xff; + chan[c.chan].outLVol=(0xfff*c.value)/0xff; chan[c.chan].volChanged.lVol=1; } } @@ -818,7 +818,7 @@ int DivPlatformES5506::dispatch(DivCommand c) { if (chan[c.chan].rVol!=(unsigned int)(c.value2)) { chan[c.chan].rVol=c.value2; if (!chan[c.chan].std.panR.has) { - chan[c.chan].outRVol=(0xffff*c.value2)/0xff; + chan[c.chan].outRVol=(0xfff*c.value2)/0xff; chan[c.chan].volChanged.rVol=1; } } diff --git a/src/engine/platform/es5506.h b/src/engine/platform/es5506.h index cb358a20e..43cd7bc04 100644 --- a/src/engine/platform/es5506.h +++ b/src/engine/platform/es5506.h @@ -190,8 +190,8 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf { nextNote(0), currNote(0), wave(-1), - volMacroMax(0xffff), - panMacroMax(0xffff), + volMacroMax(0xfff), + panMacroMax(0xfff), useWave(false), isReverseLoop(false), cr(0), @@ -210,14 +210,14 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf { k2Prev(0xffff), lVol(0xff), rVol(0xff), - outLVol(0xffff), - outRVol(0xffff), - resLVol(0xffff), - resRVol(0xffff), + outLVol(0xfff), + outRVol(0xfff), + resLVol(0xfff), + resRVol(0xfff), oscOut(0), filter(DivInstrumentES5506::Filter()), envelope(DivInstrumentES5506::Envelope()) { - outVol=0xffff; + outVol=0xfff; } }; Channel chan[32]; diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 6832f19d2..514fd616d 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -4998,7 +4998,7 @@ void FurnaceGUI::drawInsEdit() { volMax=32; } if (ins->type==DIV_INS_ES5506) { - volMax=65535; + volMax=4095; } if (ins->type==DIV_INS_MSM6258) { volMax=0; @@ -5288,7 +5288,7 @@ void FurnaceGUI::drawInsEdit() { panMax=127; } if (ins->type==DIV_INS_ES5506) { - panMax=65535; + panMax=4095; } if (volMax>0) {