Fix sound in d_pce. The DDA mode makes things difficult and this is the cleanest way I can think of to make it work. iq - if you're not happy with this implementation feel free to revert.

This commit is contained in:
Barry Harris 2012-01-20 14:36:16 +00:00
parent 5b8a3c0ee7
commit d37e0b4245
1 changed files with 27 additions and 6 deletions

View File

@ -673,17 +673,38 @@ static INT32 PCEFrame()
PCECompileInputs();
INT32 nCyclesTotal = (INT32)((INT64)7159090 * nBurnCPUSpeedAdjust / (0x0100 * 60));
INT32 nSoundBufferPos = 0;
INT32 nInterleave = nBurnSoundLen;
INT32 IRQSlice[262];
for (INT32 i = 0; i < 262; i++) {
IRQSlice[i] = (INT32)((double)((nInterleave * (i + 1)) / 263));
}
h6280Open(0);
for (INT32 i = 0; i < 262; i++)
for (INT32 i = 0; i < nInterleave; i++)
{
h6280Run(nCyclesTotal / 262);
interrupt();
h6280Run(nCyclesTotal / nInterleave);
for (INT32 j = 0; j < 262; j++) {
if (i == IRQSlice[j]) interrupt();
}
if (pBurnSoundOut) {
INT32 nSegmentLength = nBurnSoundLen / nInterleave;
INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
c6280_update(pSoundBuf, nSegmentLength);
nSoundBufferPos += nSegmentLength;
}
}
if (pBurnSoundOut) {
c6280_update(pBurnSoundOut, nBurnSoundLen);
INT32 nSegmentLength = nBurnSoundLen - nSoundBufferPos;
INT16* pSoundBuf = pBurnSoundOut + (nSoundBufferPos << 1);
if (nSegmentLength) {
c6280_update(pSoundBuf, nSegmentLength);
}
}
h6280Close();