mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
fix for gp2x audio regression
This commit is contained in:
parent
02138162c4
commit
84e18560bb
3 changed files with 18 additions and 17 deletions
|
@ -1057,11 +1057,11 @@ static int ym2612_write_local(u32 a, u32 d, int is_from_z80)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PsndDoFM(get_scanline(is_from_z80));
|
|
||||||
#ifdef __GP2X__
|
#ifdef __GP2X__
|
||||||
if (PicoIn.opt & POPT_EXT_FM)
|
if (PicoIn.opt & POPT_EXT_FM)
|
||||||
return YM2612Write_940(a, d, get_scanline(is_from_z80));
|
return YM2612Write_940(a, d, get_scanline(is_from_z80));
|
||||||
#endif
|
#endif
|
||||||
|
PsndDoFM(get_scanline(is_from_z80));
|
||||||
return YM2612Write_(a, d);
|
return YM2612Write_(a, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,8 +193,8 @@ PICO_INTERNAL void PsndDoFM(int line_to)
|
||||||
// Q16, number of samples since last call
|
// Q16, number of samples since last call
|
||||||
len = ((line_to-1) * Pico.snd.fm_mult) - Pico.snd.fm_pos;
|
len = ((line_to-1) * Pico.snd.fm_mult) - Pico.snd.fm_pos;
|
||||||
|
|
||||||
// don't do this too often (no more than 256 per sec)
|
// don't do this too often (about every 4th scanline)
|
||||||
if (len >> 16 <= PicoIn.sndRate >> 9)
|
if (len >> 16 <= PicoIn.sndRate >> 12)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// update position and calculate buffer offset and length
|
// update position and calculate buffer offset and length
|
||||||
|
@ -281,22 +281,22 @@ static int PsndRender(int offset, int length)
|
||||||
{
|
{
|
||||||
int *buf32;
|
int *buf32;
|
||||||
int stereo = (PicoIn.opt & 8) >> 3;
|
int stereo = (PicoIn.opt & 8) >> 3;
|
||||||
int fmlen = ((Pico.snd.fm_pos+0x8000) >> 16) - offset;
|
int fmlen = ((Pico.snd.fm_pos+0x8000) >> 16);
|
||||||
int daclen = ((Pico.snd.dac_pos+0x80000) >> 20) - offset;
|
int daclen = ((Pico.snd.dac_pos+0x80000) >> 20);
|
||||||
|
|
||||||
offset <<= stereo;
|
buf32 = PsndBuffer+(offset<<stereo);
|
||||||
buf32 = PsndBuffer+offset;
|
|
||||||
|
|
||||||
pprof_start(sound);
|
pprof_start(sound);
|
||||||
|
|
||||||
if (PicoIn.AHW & PAHW_PICO) {
|
if (PicoIn.AHW & PAHW_PICO) {
|
||||||
PicoPicoPCMUpdate(PicoIn.sndOut+offset, length, stereo);
|
PicoPicoPCMUpdate(PicoIn.sndOut+(offset<<stereo), length-offset, stereo);
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill up DAC output in case of missing samples (Q16 rounding errors)
|
// Fill up DAC output in case of missing samples (Q16 rounding errors)
|
||||||
if (length-daclen > 0) {
|
if (length-daclen > 0) {
|
||||||
short *dacbuf = PicoIn.sndOut + (daclen << stereo);
|
short *dacbuf = PicoIn.sndOut + (daclen << stereo);
|
||||||
|
Pico.snd.dac_pos += (length-daclen) << 20;
|
||||||
for (; length-daclen > 0; daclen++) {
|
for (; length-daclen > 0; daclen++) {
|
||||||
*dacbuf++ += Pico.snd.dac_val;
|
*dacbuf++ += Pico.snd.dac_val;
|
||||||
if (stereo) dacbuf++;
|
if (stereo) dacbuf++;
|
||||||
|
@ -305,14 +305,15 @@ static int PsndRender(int offset, int length)
|
||||||
|
|
||||||
// Add in parts of the FM buffer not yet done
|
// Add in parts of the FM buffer not yet done
|
||||||
if (length-fmlen > 0) {
|
if (length-fmlen > 0) {
|
||||||
int *fmbuf = buf32 + (fmlen << stereo);
|
int *fmbuf = buf32 + ((fmlen-offset) << stereo);
|
||||||
|
Pico.snd.fm_pos += (length-fmlen) << 16;
|
||||||
if (PicoIn.opt & POPT_EN_FM)
|
if (PicoIn.opt & POPT_EN_FM)
|
||||||
YM2612UpdateOne(fmbuf, length-fmlen, stereo, 1);
|
YM2612UpdateOne(fmbuf, length-fmlen, stereo, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CD: PCM sound
|
// CD: PCM sound
|
||||||
if (PicoIn.AHW & PAHW_MCD) {
|
if (PicoIn.AHW & PAHW_MCD) {
|
||||||
pcd_pcm_update(buf32, length, stereo);
|
pcd_pcm_update(buf32, length-offset, stereo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CD: CDDA audio
|
// CD: CDDA audio
|
||||||
|
@ -323,16 +324,16 @@ static int PsndRender(int offset, int length)
|
||||||
{
|
{
|
||||||
// note: only 44, 22 and 11 kHz supported, with forced stereo
|
// note: only 44, 22 and 11 kHz supported, with forced stereo
|
||||||
if (Pico_mcd->cdda_type == CT_MP3)
|
if (Pico_mcd->cdda_type == CT_MP3)
|
||||||
mp3_update(buf32, length, stereo);
|
mp3_update(buf32, length-offset, stereo);
|
||||||
else
|
else
|
||||||
cdda_raw_update(buf32, length);
|
cdda_raw_update(buf32, length-offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((PicoIn.AHW & PAHW_32X) && (PicoIn.opt & POPT_EN_PWM))
|
if ((PicoIn.AHW & PAHW_32X) && (PicoIn.opt & POPT_EN_PWM))
|
||||||
p32x_pwm_update(buf32, length, stereo);
|
p32x_pwm_update(buf32, length-offset, stereo);
|
||||||
|
|
||||||
// convert + limit to normal 16bit output
|
// convert + limit to normal 16bit output
|
||||||
PsndMix_32_to_16l(PicoIn.sndOut+offset, buf32, length);
|
PsndMix_32_to_16l(PicoIn.sndOut+(offset<<stereo), buf32, length-offset);
|
||||||
|
|
||||||
pprof_end(sound);
|
pprof_end(sound);
|
||||||
|
|
||||||
|
|
|
@ -100,10 +100,10 @@ int YM2612Write_940(unsigned int a, unsigned int v, int scanline)
|
||||||
UINT16 *writebuff = shared_ctl->writebuffsel ? shared_ctl->writebuff0 : shared_ctl->writebuff1;
|
UINT16 *writebuff = shared_ctl->writebuffsel ? shared_ctl->writebuff0 : shared_ctl->writebuff1;
|
||||||
|
|
||||||
/* detect rapid ym updates */
|
/* detect rapid ym updates */
|
||||||
if (upd && !(writebuff_ptr & 0x80000000) && scanline < 224)
|
if (upd && !(writebuff_ptr & 0x80000000))
|
||||||
{
|
{
|
||||||
int mid = Pico.m.pal ? 68 : 93;
|
int mid = (Pico.m.pal ? 313 : 262) / 2;
|
||||||
if (scanline > mid) {
|
if (scanline >= mid) {
|
||||||
//printf("%05i:%03i: rapid ym\n", Pico.m.frame_count, scanline);
|
//printf("%05i:%03i: rapid ym\n", Pico.m.frame_count, scanline);
|
||||||
writebuff[writebuff_ptr++ & 0xffff] = 0xfffe;
|
writebuff[writebuff_ptr++ & 0xffff] = 0xfffe;
|
||||||
writebuff_ptr |= 0x80000000;
|
writebuff_ptr |= 0x80000000;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue