X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=plugins%2Fdfsound%2Fspu.c;h=283d598867415ce46606e7cf91164816bd7beabc;hb=d358733b8461f6fa182b33d29f0676c2df505854;hp=038f946eee2ec286700e2aff1ccf62e0bcdfa7d0;hpb=73d2a9037e5ea290cac10a9f26860a6405b55a0c;p=pcsx_rearmed.git diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index 038f946e..283d5988 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -250,9 +250,10 @@ static void StartSoundMain(int ch) StartADSR(ch); StartREVERB(ch); - s_chan->prevflags=2; - s_chan->iSBPos=27; - s_chan->spos=0; + s_chan->prevflags = 2; + s_chan->iSBPos = 27; + s_chan->spos = 0; + s_chan->bStarting = 1; s_chan->pCurr = spu.spuMemC + ((regAreaGetCh(ch, 6) & ~1) << 3); @@ -421,8 +422,11 @@ static int decode_block(void *unused, int ch, int *SB) int ret = 0; start = s_chan->pCurr; // set up the current pos - if (start == spu.spuMemC) // ? + if (start - spu.spuMemC < 0x1000) { // ? + //log_unhandled("ch%02d plays decode bufs @%05lx\n", + // ch, (long)(start - spu.spuMemC)); ret = 1; + } if (s_chan->prevflags & 1) // 1: stop/loop { @@ -448,6 +452,7 @@ static int decode_block(void *unused, int ch, int *SB) s_chan->pCurr = start; // store values for next cycle s_chan->prevflags = flags; + s_chan->bStarting = 0; return ret; } @@ -477,6 +482,7 @@ static int skip_block(int ch) s_chan->pCurr = start; s_chan->prevflags = flags; + s_chan->bStarting = 0; return ret; } @@ -493,6 +499,8 @@ static void scan_for_irq(int ch, unsigned int *upd_samples) pos = s_chan->spos; sinc = s_chan->sinc; end = pos + *upd_samples * sinc; + if (s_chan->prevflags & 1) // 1: stop/loop + block = s_chan->pLoop; pos += (28 - s_chan->iSBPos) << 16; while (pos < end) @@ -792,12 +800,14 @@ static void do_channels(int ns_to) d = do_samples_default(decode_block, NULL, ch, ns_to, SB, sinc, &s_chan->spos, &s_chan->iSBPos); - d = MixADSR(&s_chan->ADSRX, d); - if (d < ns_to) { - spu.dwChannelsAudible &= ~(1 << ch); - s_chan->ADSRX.State = ADSR_RELEASE; - s_chan->ADSRX.EnvelopeVol = 0; - memset(&ChanBuf[d], 0, (ns_to - d) * sizeof(ChanBuf[0])); + if (!s_chan->bStarting) { + d = MixADSR(&s_chan->ADSRX, d); + if (d < ns_to) { + spu.dwChannelsAudible &= ~(1 << ch); + s_chan->ADSRX.State = ADSR_RELEASE; + s_chan->ADSRX.EnvelopeVol = 0; + memset(&ChanBuf[d], 0, (ns_to - d) * sizeof(ChanBuf[0])); + } } if (ch == 1 || ch == 3) @@ -963,12 +973,14 @@ static void queue_channel_work(int ns_to, unsigned int silentch) d = do_samples_skip(ch, ns_to); work->ch[ch].ns_to = d; - // note: d is not accurate on skip - d = SkipADSR(&s_chan->ADSRX, d); - if (d < ns_to) { - spu.dwChannelsAudible &= ~(1 << ch); - s_chan->ADSRX.State = ADSR_RELEASE; - s_chan->ADSRX.EnvelopeVol = 0; + if (!s_chan->bStarting) { + // note: d is not accurate on skip + d = SkipADSR(&s_chan->ADSRX, d); + if (d < ns_to) { + spu.dwChannelsAudible &= ~(1 << ch); + s_chan->ADSRX.State = ADSR_RELEASE; + s_chan->ADSRX.EnvelopeVol = 0; + } } s_chan->bNewPitch = 0; } @@ -1152,7 +1164,10 @@ void do_samples(unsigned int cycles_to, int do_direct) do_irq(); } } - check_irq_io(spu.spuAddr); + if (!spu.cycles_dma_end || (int)(spu.cycles_dma_end - cycles_to) < 0) { + spu.cycles_dma_end = 0; + check_irq_io(spu.spuAddr); + } if (unlikely(spu.rvb->dirty)) REVERBPrep(); @@ -1173,6 +1188,11 @@ void do_samples(unsigned int cycles_to, int do_direct) spu.cycles_played += ns_to * 768; spu.decode_pos = (spu.decode_pos + ns_to) & 0x1ff; +#if 0 + static int ccount; static time_t ctime; ccount++; + if (time(NULL) != ctime) + { printf("%d\n", ccount); ccount = 0; ctime = time(NULL); } +#endif } static void do_samples_finish(int *SSumLR, int ns_to, @@ -1482,6 +1502,7 @@ long CALLBACK SPUinit(void) { int i; + memset(&spu, 0, sizeof(spu)); spu.spuMemC = calloc(1, 512 * 1024); InitADSR(); @@ -1560,33 +1581,6 @@ long CALLBACK SPUshutdown(void) return 0; } -// SPUTEST: we don't test, we are always fine ;) -long CALLBACK SPUtest(void) -{ - return 0; -} - -// SPUCONFIGURE: call config dialog -long CALLBACK SPUconfigure(void) -{ -#ifdef _MACOSX - DoConfiguration(); -#else -// StartCfgTool("CFG"); -#endif - return 0; -} - -// SPUABOUT: show about window -void CALLBACK SPUabout(void) -{ -#ifdef _MACOSX - DoAbout(); -#else -// StartCfgTool("ABOUT"); -#endif -} - // SETUP CALLBACKS // this functions will be called once, // passes a callback that should be called on SPU-IRQ/cdda volume change