// Q16, number of samples since last call\r
len = ((line_to-1) * Pico.snd.fm_mult) - Pico.snd.fm_pos;\r
\r
- // don't do this too often (no more than 256 per sec)\r
- if (len >> 16 <= PicoIn.sndRate >> 9)\r
+ // don't do this too often (about every 4th scanline)\r
+ if (len >> 16 <= PicoIn.sndRate >> 12)\r
return;\r
\r
// update position and calculate buffer offset and length\r
{\r
int *buf32;\r
int stereo = (PicoIn.opt & 8) >> 3;\r
- int fmlen = ((Pico.snd.fm_pos+0x8000) >> 16) - offset;\r
- int daclen = ((Pico.snd.dac_pos+0x80000) >> 20) - offset;\r
+ int fmlen = ((Pico.snd.fm_pos+0x8000) >> 16);\r
+ int daclen = ((Pico.snd.dac_pos+0x80000) >> 20);\r
\r
- offset <<= stereo;\r
- buf32 = PsndBuffer+offset;\r
+ buf32 = PsndBuffer+(offset<<stereo);\r
\r
pprof_start(sound);\r
\r
if (PicoIn.AHW & PAHW_PICO) {\r
- PicoPicoPCMUpdate(PicoIn.sndOut+offset, length, stereo);\r
+ PicoPicoPCMUpdate(PicoIn.sndOut+(offset<<stereo), length-offset, stereo);\r
return length;\r
}\r
\r
// Fill up DAC output in case of missing samples (Q16 rounding errors)\r
if (length-daclen > 0) {\r
short *dacbuf = PicoIn.sndOut + (daclen << stereo);\r
+ Pico.snd.dac_pos += (length-daclen) << 20;\r
for (; length-daclen > 0; daclen++) {\r
*dacbuf++ += Pico.snd.dac_val;\r
if (stereo) dacbuf++;\r
\r
// Add in parts of the FM buffer not yet done\r
if (length-fmlen > 0) {\r
- int *fmbuf = buf32 + (fmlen << stereo);\r
+ int *fmbuf = buf32 + ((fmlen-offset) << stereo);\r
+ Pico.snd.fm_pos += (length-fmlen) << 16;\r
if (PicoIn.opt & POPT_EN_FM)\r
YM2612UpdateOne(fmbuf, length-fmlen, stereo, 1);\r
}\r
\r
// CD: PCM sound\r
if (PicoIn.AHW & PAHW_MCD) {\r
- pcd_pcm_update(buf32, length, stereo);\r
+ pcd_pcm_update(buf32, length-offset, stereo);\r
}\r
\r
// CD: CDDA audio\r
{\r
// note: only 44, 22 and 11 kHz supported, with forced stereo\r
if (Pico_mcd->cdda_type == CT_MP3)\r
- mp3_update(buf32, length, stereo);\r
+ mp3_update(buf32, length-offset, stereo);\r
else\r
- cdda_raw_update(buf32, length);\r
+ cdda_raw_update(buf32, length-offset);\r
}\r
\r
if ((PicoIn.AHW & PAHW_32X) && (PicoIn.opt & POPT_EN_PWM))\r
- p32x_pwm_update(buf32, length, stereo);\r
+ p32x_pwm_update(buf32, length-offset, stereo);\r
\r
// convert + limit to normal 16bit output\r
- PsndMix_32_to_16l(PicoIn.sndOut+offset, buf32, length);\r
+ PsndMix_32_to_16l(PicoIn.sndOut+(offset<<stereo), buf32, length-offset);\r
\r
pprof_end(sound);\r
\r
UINT16 *writebuff = shared_ctl->writebuffsel ? shared_ctl->writebuff0 : shared_ctl->writebuff1;\r
\r
/* detect rapid ym updates */\r
- if (upd && !(writebuff_ptr & 0x80000000) && scanline < 224)\r
+ if (upd && !(writebuff_ptr & 0x80000000))\r
{\r
- int mid = Pico.m.pal ? 68 : 93;\r
- if (scanline > mid) {\r
+ int mid = (Pico.m.pal ? 313 : 262) / 2;\r
+ if (scanline >= mid) {\r
//printf("%05i:%03i: rapid ym\n", Pico.m.frame_count, scanline);\r
writebuff[writebuff_ptr++ & 0xffff] = 0xfffe;\r
writebuff_ptr |= 0x80000000;\r