ES5506: I am blowing up now

This commit is contained in:
tildearrow 2023-02-12 02:02:22 -05:00
parent c9eb4482b0
commit 11154923b0
2 changed files with 17 additions and 16 deletions

View File

@ -190,7 +190,8 @@ void DivPlatformES5506::tick(bool sysTick) {
signed int k1=chan[i].k1Prev,k2=chan[i].k2Prev; signed int k1=chan[i].k1Prev,k2=chan[i].k2Prev;
// volume/panning macros // volume/panning macros
if (chan[i].std.vol.had) { if (chan[i].std.vol.had) {
const unsigned int nextVol=VOL_SCALE_LOG((0xfff*chan[i].vol)/0xff,(0xfff*(unsigned int)chan[i].std.vol.val)/chan[i].volMacroMax,0xfff); const int nextVol=VOL_SCALE_LOG((0xfff*chan[i].vol)/0xff,(0xfff*chan[i].std.vol.val)/chan[i].volMacroMax,0xfff);
logV("nextVol[%d]: %d (%d,%d,%d)",i,nextVol,chan[i].vol,chan[i].std.vol.val,chan[i].volMacroMax);
if (chan[i].outVol!=nextVol) { if (chan[i].outVol!=nextVol) {
chan[i].outVol=nextVol; chan[i].outVol=nextVol;
chan[i].volChanged.lVol=1; chan[i].volChanged.lVol=1;
@ -198,14 +199,14 @@ void DivPlatformES5506::tick(bool sysTick) {
} }
} }
if (chan[i].std.panL.had) { if (chan[i].std.panL.had) {
const unsigned int nextLVol=VOL_SCALE_LOG((0xfff*chan[i].lVol)/0xff,(0xfff*(unsigned int)chan[i].std.panL.val)/chan[i].panMacroMax,0xfff); const int nextLVol=VOL_SCALE_LOG((0xfff*chan[i].lVol)/0xff,(0xfff*chan[i].std.panL.val)/chan[i].panMacroMax,0xfff);
if (chan[i].outLVol!=nextLVol) { if (chan[i].outLVol!=nextLVol) {
chan[i].outLVol=nextLVol; chan[i].outLVol=nextLVol;
chan[i].volChanged.lVol=1; chan[i].volChanged.lVol=1;
} }
} }
if (chan[i].std.panR.had) { if (chan[i].std.panR.had) {
const unsigned int nextRVol=VOL_SCALE_LOG((0xfff*chan[i].rVol)/0xff,(0xfff*(unsigned int)chan[i].std.panR.val)/chan[i].panMacroMax,0xfff); const int nextRVol=VOL_SCALE_LOG((0xfff*chan[i].rVol)/0xff,(0xfff*chan[i].std.panR.val)/chan[i].panMacroMax,0xfff);
if (chan[i].outRVol!=nextRVol) { if (chan[i].outRVol!=nextRVol) {
chan[i].outRVol=nextRVol; chan[i].outRVol=nextRVol;
chan[i].volChanged.rVol=1; chan[i].volChanged.rVol=1;
@ -790,7 +791,7 @@ int DivPlatformES5506::dispatch(DivCommand c) {
} }
break; break;
case DIV_CMD_VOLUME: case DIV_CMD_VOLUME:
if (chan[c.chan].vol!=(unsigned int)(c.value)) { if (chan[c.chan].vol!=c.value) {
chan[c.chan].vol=c.value; chan[c.chan].vol=c.value;
if (!chan[c.chan].std.vol.has) { if (!chan[c.chan].std.vol.has) {
chan[c.chan].outVol=(0xfff*c.value)/0xff; chan[c.chan].outVol=(0xfff*c.value)/0xff;
@ -807,7 +808,7 @@ int DivPlatformES5506::dispatch(DivCommand c) {
chan[c.chan].volChanged.ca=1; chan[c.chan].volChanged.ca=1;
} }
// Left volume // Left volume
if (chan[c.chan].lVol!=(unsigned int)(c.value)) { if (chan[c.chan].lVol!=c.value) {
chan[c.chan].lVol=c.value; chan[c.chan].lVol=c.value;
if (!chan[c.chan].std.panL.has) { if (!chan[c.chan].std.panL.has) {
chan[c.chan].outLVol=(0xfff*c.value)/0xff; chan[c.chan].outLVol=(0xfff*c.value)/0xff;
@ -815,7 +816,7 @@ int DivPlatformES5506::dispatch(DivCommand c) {
} }
} }
// Right volume // Right volume
if (chan[c.chan].rVol!=(unsigned int)(c.value2)) { if (chan[c.chan].rVol!=c.value2) {
chan[c.chan].rVol=c.value2; chan[c.chan].rVol=c.value2;
if (!chan[c.chan].std.panR.has) { if (!chan[c.chan].std.panR.has) {
chan[c.chan].outRVol=(0xfff*c.value2)/0xff; chan[c.chan].outRVol=(0xfff*c.value2)/0xff;
@ -832,20 +833,20 @@ int DivPlatformES5506::dispatch(DivCommand c) {
} }
if ((c.value&1)==0) { if ((c.value&1)==0) {
// Left volume // Left volume
if (chan[c.chan].lVol!=(unsigned int)(c.value2)) { if (chan[c.chan].lVol!=c.value2) {
chan[c.chan].lVol=c.value2; chan[c.chan].lVol=c.value2;
if (!chan[c.chan].std.panL.has) { if (!chan[c.chan].std.panL.has) {
chan[c.chan].outLVol=(0xffff*c.value2)/0xff; chan[c.chan].outLVol=(0xfff*c.value2)/0xff;
chan[c.chan].volChanged.lVol=1; chan[c.chan].volChanged.lVol=1;
} }
} }
} }
else if ((c.value&1)==1) { else if ((c.value&1)==1) {
// Right volume // Right volume
if (chan[c.chan].rVol!=(unsigned int)(c.value2)) { if (chan[c.chan].rVol!=c.value2) {
chan[c.chan].rVol=c.value2; chan[c.chan].rVol=c.value2;
if (!chan[c.chan].std.panR.has) { 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; chan[c.chan].volChanged.rVol=1;
} }
} }

View File

@ -28,7 +28,7 @@
#include "vgsound_emu/src/es550x/es5506.hpp" #include "vgsound_emu/src/es550x/es5506.hpp"
class DivPlatformES5506: public DivDispatch, public es550x_intf { class DivPlatformES5506: public DivDispatch, public es550x_intf {
struct Channel : public SharedChannel<unsigned int> { struct Channel : public SharedChannel<int> {
struct PCM { struct PCM {
bool isNoteMap; bool isNoteMap;
int index, next; int index, next;
@ -63,7 +63,7 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf {
loopMode(DIV_SAMPLE_LOOP_MAX) {} loopMode(DIV_SAMPLE_LOOP_MAX) {}
} pcm; } pcm;
int nextFreq, nextNote, currNote, wave; int nextFreq, nextNote, currNote, wave;
unsigned int volMacroMax, panMacroMax; int volMacroMax, panMacroMax;
bool useWave, isReverseLoop; bool useWave, isReverseLoop;
unsigned int cr; unsigned int cr;
@ -177,14 +177,14 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf {
signed int k1Offs, k2Offs; signed int k1Offs, k2Offs;
signed int k1Slide, k2Slide; signed int k1Slide, k2Slide;
signed int k1Prev, k2Prev; signed int k1Prev, k2Prev;
unsigned int lVol, rVol; int lVol, rVol;
unsigned int outLVol, outRVol; int outLVol, outRVol;
unsigned int resLVol, resRVol; int resLVol, resRVol;
signed int oscOut; signed int oscOut;
DivInstrumentES5506::Filter filter; DivInstrumentES5506::Filter filter;
DivInstrumentES5506::Envelope envelope; DivInstrumentES5506::Envelope envelope;
Channel(): Channel():
SharedChannel<unsigned int>(0xff), SharedChannel<int>(0xff),
pcm(PCM()), pcm(PCM()),
nextFreq(0), nextFreq(0),
nextNote(0), nextNote(0),