From: kub Date: Fri, 14 Oct 2022 18:47:20 +0000 (+0000) Subject: pico, fix psg sound and fast forward X-Git-Tag: v2.00~277 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e44c606f39e8b97b9708bee6a55c70975ae9ef5f;p=picodrive.git pico, fix psg sound and fast forward --- diff --git a/pico/pico/xpcm.c b/pico/pico/xpcm.c index ee204464..5d13a4b7 100644 --- a/pico/pico/xpcm.c +++ b/pico/pico/xpcm.c @@ -77,18 +77,20 @@ PICO_INTERNAL void PicoPicoPCMUpdate(short *buffer, int length, int stereo) srcval = *src >> 4; do_sample(); - for (needsamples += stepsamples; needsamples > (1<<10) && length > 0; needsamples -= (1<<10), length--) { - *buffer++ += sample; - if (stereo) { buffer[0] = buffer[-1]; buffer++; } - } + if (buffer) + for (needsamples += stepsamples; needsamples > (1<<10) && length > 0; needsamples -= (1<<10), length--) { + *buffer++ += sample; + if (stereo) { buffer[0] = buffer[-1]; buffer++; } + } srcval = *src & 0xf; do_sample(); - for (needsamples += stepsamples; needsamples > (1<<10) && length > 0; needsamples -= (1<<10), length--) { - *buffer++ += sample; - if (stereo) { buffer[0] = buffer[-1]; buffer++; } - } + if (buffer) + for (needsamples += stepsamples; needsamples > (1<<10) && length > 0; needsamples -= (1<<10), length--) { + *buffer++ += sample; + if (stereo) { buffer[0] = buffer[-1]; buffer++; } + } // lame normalization stuff, needed due to wrong adpcm algo sgn += (sample < 0) ? -1 : 1; @@ -109,7 +111,7 @@ PICO_INTERNAL void PicoPicoPCMUpdate(short *buffer, int length, int stereo) PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer; end: - if (stereo) + if (buffer && stereo) // still must expand SN76496 to stereo for (; length > 0; buffer+=2, length--) buffer[1] = buffer[0]; diff --git a/pico/sound/sound.c b/pico/sound/sound.c index 74a40b58..5093829b 100644 --- a/pico/sound/sound.c +++ b/pico/sound/sound.c @@ -430,10 +430,18 @@ static int PsndRender(int offset, int length) pprof_start(sound); + // Add in parts of the PSG output not yet done + if (length-psglen > 0 && PicoIn.sndOut) { + s16 *psgbuf = PicoIn.sndOut + (psglen << stereo); + Pico.snd.psg_pos += (length-psglen) << 20; + if (PicoIn.opt & POPT_EN_PSG) + SN76496Update(psgbuf, length-psglen, stereo); + } + if (PicoIn.AHW & PAHW_PICO) { - // XXX ugly hack, need to render sound for interrupts - s16 *buf16 = PicoIn.sndOut ? PicoIn.sndOut : (s16 *)PsndBuffer; - PicoPicoPCMUpdate(buf16+(offset< 0 && PicoIn.sndOut) { - s16 *psgbuf = PicoIn.sndOut + (psglen << stereo); - Pico.snd.psg_pos += (length-psglen) << 20; - if (PicoIn.opt & POPT_EN_PSG) - SN76496Update(psgbuf, length-psglen, stereo); - } - // Add in parts of the FM buffer not yet done if (length-fmlen > 0 && PicoIn.sndOut) { s32 *fmbuf = buf32 + ((fmlen-offset) << stereo);