From c4c66b22ae607aa8dc5e6983f7ab030ead01faae Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 21 Dec 2014 00:36:00 +0200 Subject: spu: avoid NULL pSpuIrq CTR sets 0 irq address, and savestates mess up --- plugins/dfsound/freeze.c | 7 +++++-- plugins/dfsound/spu.c | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'plugins/dfsound') diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index b865b84..d38faa6 100644 --- a/plugins/dfsound/freeze.c +++ b/plugins/dfsound/freeze.c @@ -307,6 +307,9 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode, SPUFreeze_t * pF, ClearWorkingState(); spu.cycles_played = cycles; + if (spu.spuCtrl & CTRL_IRQ) + schedule_next_irq(); + return 1; } @@ -318,7 +321,7 @@ void LoadStateV5(SPUFreeze_t * pF) pFO=(SPUOSSFreeze_t *)(pF+1); - if(pFO->pSpuIrq) spu.pSpuIrq = spu.spuMemC+((long)pFO->pSpuIrq&0x7fff0); else spu.pSpuIrq=NULL; + spu.pSpuIrq = spu.spuMemC + ((spu.regArea[(H_SPUirqAddr - 0x0c00) / 2] << 3) & ~0xf); if(pFO->spuAddr) { @@ -353,7 +356,7 @@ void LoadStateUnknown(SPUFreeze_t * pF, uint32_t cycles) spu.dwNewChannel=0; spu.dwChannelOn=0; spu.dwChannelDead=0; - spu.pSpuIrq=0; + spu.pSpuIrq=spu.spuMemC; for(i=0;i<0xc0;i++) { diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index ca362b7..2c13ca1 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -738,7 +738,7 @@ void do_samples(unsigned int cycles_to) // an IRQ. if (unlikely((spu.spuCtrl & CTRL_IRQ) - && spu.pSpuIrq && spu.pSpuIrq < spu.spuMemC+0x1000)) + && spu.pSpuIrq < spu.spuMemC+0x1000)) { int irq_pos = (spu.pSpuIrq - spu.spuMemC) / 2 & 0x1ff; int left = (irq_pos - spu.decode_pos) & 0x1ff; @@ -1027,7 +1027,7 @@ long CALLBACK SPUinit(void) spu.spuAddr = 0xffffffff; spu.decode_pos = 0; memset((void *)s_chan, 0, sizeof(s_chan)); - spu.pSpuIrq = 0; + spu.pSpuIrq = spu.spuMemC; SetupStreams(); // prepare streaming -- cgit v1.2.3 From bdd050c3ed792381df2e744fee5b7ee80b93fd68 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 21 Dec 2014 02:20:41 +0200 Subject: spu: fix first sample, don't play ahead --- plugins/dfsound/spu.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'plugins/dfsound') diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index 2c13ca1..835555d 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -5,7 +5,7 @@ copyright : (C) 2002 by Pete Bernert email : BlackDove@addcom.de - Portions (C) Gražvydas "notaz" Ignotas, 2010-2012 + Portions (C) Gražvydas "notaz" Ignotas, 2010-2012,2014 ***************************************************************************/ /*************************************************************************** @@ -253,14 +253,13 @@ INLINE void StartSound(int ch) s_chan[ch].SB[26]=0; // init mixing vars s_chan[ch].SB[27]=0; - s_chan[ch].iSBPos=28; + s_chan[ch].iSBPos=27; + s_chan[ch].SB[28]=0; s_chan[ch].SB[29]=0; // init our interpolation helpers s_chan[ch].SB[30]=0; - - if(spu_config.iUseInterpolation>=2) // gauss interpolation? - {s_chan[ch].spos=0x30000L;s_chan[ch].SB[28]=0;} // -> start with more decoding - else {s_chan[ch].spos=0x10000L;s_chan[ch].SB[31]=0;} // -> no/simple interpolation starts with one 44100 decoding + s_chan[ch].SB[31]=0; + s_chan[ch].spos=0; spu.dwNewChannel&=~(1<