Changed PCM FIFO refill behavior to only stuff the FIFO with silence if it runs completely empty, which seems to fix the stuttering in Mother 3. From the technical behavior, Mother 3's sound code would periodically set DMA 1 and 2 to reason 0, then reset them back to reason 3. This presumably occurs every time the source buffers run empty and the source addresses are reset. Unfortunately, with the current execution and memory timing, this occurs just in time for the DMA buffers to run down to only 16 samples each, and then the attempted refill call will trigger while the DMA reason is 0, so they don't refill, and the timer routine thus stuffs the FIFO buffers with 16 samples worth of silence, causing a stutter. Now, the buffer is allowed to drop below 16, which gives Mother 3's sound code enough time to restart the DMA channels, and they continue to pump samples gracefully, as I never detected a full underrun in my testing.

This commit is contained in:
kode54 2013-10-21 21:46:49 +00:00
parent 552a8cf2ff
commit 12172db5ac
1 changed files with 2 additions and 2 deletions

View File

@ -187,11 +187,11 @@ void Gba_Pcm_Fifo::timer_overflowed( int which_timer )
{
// Need to fill FIFO
CPUCheckDMA( 3, which ? 4 : 2 );
if ( count <= 16 )
if ( count == 0 ) // Fixes Mother 3
{
// Not filled by DMA, so fill with 16 bytes of silence
int reg = which ? FIFOB_L : FIFOA_L;
for ( int n = 4; n--; )
for ( int n = 8; n--; )
{
soundEvent(reg , (u16)0);
soundEvent(reg+2, (u16)0);