pico, fix psg sound and fast forward

This commit is contained in:
kub 2022-10-14 18:47:20 +00:00
parent c9d5f41b0a
commit e44c606f39
2 changed files with 22 additions and 20 deletions

View file

@ -77,6 +77,7 @@ PICO_INTERNAL void PicoPicoPCMUpdate(short *buffer, int length, int stereo)
srcval = *src >> 4; srcval = *src >> 4;
do_sample(); do_sample();
if (buffer)
for (needsamples += stepsamples; needsamples > (1<<10) && length > 0; needsamples -= (1<<10), length--) { for (needsamples += stepsamples; needsamples > (1<<10) && length > 0; needsamples -= (1<<10), length--) {
*buffer++ += sample; *buffer++ += sample;
if (stereo) { buffer[0] = buffer[-1]; buffer++; } if (stereo) { buffer[0] = buffer[-1]; buffer++; }
@ -85,6 +86,7 @@ PICO_INTERNAL void PicoPicoPCMUpdate(short *buffer, int length, int stereo)
srcval = *src & 0xf; srcval = *src & 0xf;
do_sample(); do_sample();
if (buffer)
for (needsamples += stepsamples; needsamples > (1<<10) && length > 0; needsamples -= (1<<10), length--) { for (needsamples += stepsamples; needsamples > (1<<10) && length > 0; needsamples -= (1<<10), length--) {
*buffer++ += sample; *buffer++ += sample;
if (stereo) { buffer[0] = buffer[-1]; buffer++; } if (stereo) { buffer[0] = buffer[-1]; buffer++; }
@ -109,7 +111,7 @@ PICO_INTERNAL void PicoPicoPCMUpdate(short *buffer, int length, int stereo)
PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer; PicoPicohw.xpcm_ptr = PicoPicohw.xpcm_buffer;
end: end:
if (stereo) if (buffer && stereo)
// still must expand SN76496 to stereo // still must expand SN76496 to stereo
for (; length > 0; buffer+=2, length--) for (; length > 0; buffer+=2, length--)
buffer[1] = buffer[0]; buffer[1] = buffer[0];

View file

@ -430,10 +430,18 @@ static int PsndRender(int offset, int length)
pprof_start(sound); 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) { if (PicoIn.AHW & PAHW_PICO) {
// XXX ugly hack, need to render sound for interrupts // always need to render sound for interrupts
s16 *buf16 = PicoIn.sndOut ? PicoIn.sndOut : (s16 *)PsndBuffer; s16 *buf16 = PicoIn.sndOut ? PicoIn.sndOut + (offset<<stereo) : NULL;
PicoPicoPCMUpdate(buf16+(offset<<stereo), length-offset, stereo); PicoPicoPCMUpdate(buf16, length-offset, stereo);
return length; return length;
} }
@ -450,14 +458,6 @@ static int PsndRender(int offset, int length)
Pico.snd.dac_val2 = Pico.snd.dac_val; Pico.snd.dac_val2 = Pico.snd.dac_val;
} }
// 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);
}
// Add in parts of the FM buffer not yet done // Add in parts of the FM buffer not yet done
if (length-fmlen > 0 && PicoIn.sndOut) { if (length-fmlen > 0 && PicoIn.sndOut) {
s32 *fmbuf = buf32 + ((fmlen-offset) << stereo); s32 *fmbuf = buf32 + ((fmlen-offset) << stereo);