AY: fix per-chan osc in Sunsoft 5B mode

This commit is contained in:
tildearrow 2022-08-29 04:15:53 -05:00
parent 4b4a254064
commit 3af287cf9d
3 changed files with 33 additions and 15 deletions

View file

@ -69,6 +69,14 @@ const char* regCheatSheetAY8914[]={
NULL NULL
}; };
// taken from ay8910.cpp
const int sunsoftVolTable[32]={
103350, 73770, 52657, 37586, 32125, 27458, 24269, 21451,
18447, 15864, 14009, 12371, 10506, 8922, 7787, 6796,
5689, 4763, 4095, 3521, 2909, 2403, 2043, 1737,
1397, 1123, 925, 762, 578, 438, 332, 251
};
const char** DivPlatformAY8910::getRegisterSheet() { const char** DivPlatformAY8910::getRegisterSheet() {
return intellivision?regCheatSheetAY8914:regCheatSheetAY; return intellivision?regCheatSheetAY8914:regCheatSheetAY;
} }
@ -93,27 +101,33 @@ void DivPlatformAY8910::acquire(short* bufL, short* bufR, size_t start, size_t l
regPool[w.addr&0x0f]=w.val; regPool[w.addr&0x0f]=w.val;
writes.pop(); writes.pop();
} }
ay->sound_stream_update(ayBuf,len);
if (sunsoft) { if (sunsoft) {
for (size_t i=0; i<len; i++) { for (size_t i=0; i<len; i++) {
bufL[i+start]=ayBuf[0][i]; ay->sound_stream_update(ayBuf,1);
bufL[i+start]=ayBuf[0][0];
bufR[i+start]=bufL[i+start]; bufR[i+start]=bufL[i+start];
}
} else if (stereo) { oscBuf[0]->data[oscBuf[0]->needle++]=sunsoftVolTable[31-(ay->lastIndx&31)]>>3;
for (size_t i=0; i<len; i++) { oscBuf[1]->data[oscBuf[1]->needle++]=sunsoftVolTable[31-((ay->lastIndx>>5)&31)]>>3;
bufL[i+start]=ayBuf[0][i]+ayBuf[1][i]; oscBuf[2]->data[oscBuf[2]->needle++]=sunsoftVolTable[31-((ay->lastIndx>>10)&31)]>>3;
bufR[i+start]=ayBuf[1][i]+ayBuf[2][i];
} }
} else { } else {
for (size_t i=0; i<len; i++) { ay->sound_stream_update(ayBuf,len);
bufL[i+start]=ayBuf[0][i]+ayBuf[1][i]+ayBuf[2][i]; if (stereo) {
bufR[i+start]=bufL[i+start]; for (size_t i=0; i<len; i++) {
bufL[i+start]=ayBuf[0][i]+ayBuf[1][i];
bufR[i+start]=ayBuf[1][i]+ayBuf[2][i];
}
} else {
for (size_t i=0; i<len; i++) {
bufL[i+start]=ayBuf[0][i]+ayBuf[1][i]+ayBuf[2][i];
bufR[i+start]=bufL[i+start];
}
} }
} for (int ch=0; ch<3; ch++) {
for (size_t i=0; i<len; i++) {
for (int ch=0; ch<3; ch++) { oscBuf[ch]->data[oscBuf[ch]->needle++]=ayBuf[ch][i];
for (size_t i=0; i<len; i++) { }
oscBuf[ch]->data[oscBuf[ch]->needle++]=ayBuf[ch][i];
} }
} }
} }

View file

@ -924,6 +924,7 @@ float ay8910_device::mix_3D()
indx |= tone_mask | (m_vol_enabled[chan] ? tone_volume(tone) << (chan*5) : 0); indx |= tone_mask | (m_vol_enabled[chan] ? tone_volume(tone) << (chan*5) : 0);
} }
} }
lastIndx=indx;
return m_vol3d_table[indx]; return m_vol3d_table[indx];
} }
@ -1359,6 +1360,7 @@ unsigned char ay8910_device::ay8910_read_ym()
void ay8910_device::device_reset() void ay8910_device::device_reset()
{ {
lastIndx=0;
ay8910_reset_ym(); ay8910_reset_ym();
} }

View file

@ -146,6 +146,8 @@ public:
double m_Kn[32]; double m_Kn[32];
}; };
int lastIndx;
// internal interface for PSG component of YM device // internal interface for PSG component of YM device
// FIXME: these should be private, but vector06 accesses them directly // FIXME: these should be private, but vector06 accesses them directly