// number of samples to fill in buffer (Q20)\r
len = (cyc_to * Pico.snd.clkl_mult) - Pico.snd.dac_pos;\r
\r
+ // don't do this too often (about once every 2 scanlines)\r
+ if (len <= PicoIn.sndRate << 3) // Q16, (PicoIn.sndRate << 16) >> 13\r
+ return;\r
+\r
// update position and calculate buffer offset and length\r
pos = (Pico.snd.dac_pos+0x80000) >> 20;\r
Pico.snd.dac_pos += len;\r
// number of samples to fill in buffer (Q20)\r
len = (cyc_to * Pico.snd.clkl_mult) - Pico.snd.psg_pos;\r
\r
+ // don't do this too often (about once every 2 scanlines)\r
+ if (len <= PicoIn.sndRate << 3) // Q16, (PicoIn.sndRate << 16) >> 13\r
+ return;\r
+\r
// update position and calculate buffer offset and length\r
pos = (Pico.snd.psg_pos+0x80000) >> 20;\r
Pico.snd.psg_pos += len;\r
len = ((Pico.snd.psg_pos+0x80000) >> 20) - pos;\r
\r
- // avoid loss of the 1st sample of a new block (Q rounding issues)\r
- if (pos+len == 0)\r
- len = 1, Pico.snd.psg_pos += 0x80000;\r
if (len <= 0)\r
return;\r
-\r
if (!PicoIn.sndOut || !(PicoIn.opt & POPT_EN_PSG))\r
return;\r
\r
// number of samples to fill in buffer (Q20)\r
len = (cyc_to * Pico.snd.clkl_mult) - Pico.snd.ym2413_pos;\r
\r
+ // don't do this too often (about once every 2 scanlines)\r
+ if (len <= PicoIn.sndRate << 3) // Q16, (PicoIn.sndRate << 16) >> 13\r
+ return;\r
+\r
// update position and calculate buffer offset and length\r
pos = (Pico.snd.ym2413_pos+0x80000) >> 20;\r
Pico.snd.ym2413_pos += len;\r
len = ((Pico.snd.ym2413_pos+0x80000) >> 20) - pos;\r
\r
- // avoid loss of the 1st sample of a new block (Q rounding issues)\r
- if (pos+len == 0)\r
- len = 1, Pico.snd.ym2413_pos += 0x80000;\r
if (len <= 0)\r
return;\r
-\r
if (!PicoIn.sndOut || !(PicoIn.opt & POPT_EN_YM2413))\r
return;\r
\r
// Q16, number of samples since last call\r
len = (cyc_to * Pico.snd.clkl_mult) - Pico.snd.fm_pos;\r
\r
- // don't do this too often (about once every 4 scanlines)\r
- if (len <= PicoIn.sndRate << 4) // Q16, (PicoIn.sndRate << 16) >> 12\r
+ // don't do this too often (about once every 2 scanlines)\r
+ if (len <= PicoIn.sndRate << 3) // Q16, (PicoIn.sndRate << 16) >> 13\r
return;\r
\r
// update position and calculate buffer offset and length\r
pos = (Pico.snd.fm_pos+0x80000) >> 20;\r
Pico.snd.fm_pos += len;\r
len = ((Pico.snd.fm_pos+0x80000) >> 20) - pos;\r
+ if (len <= 0)\r
+ return;\r
\r
// fill buffer\r
if (PicoIn.opt & POPT_EN_STEREO) {\r
int stereo = (PicoIn.opt & 8) >> 3;\r
int fmlen = ((Pico.snd.fm_pos+0x80000) >> 20);\r
int daclen = ((Pico.snd.dac_pos+0x80000) >> 20);\r
- int psglen = ((Pico.snd.psg_pos+0x8000) >> 16);\r
+ int psglen = ((Pico.snd.psg_pos+0x80000) >> 20);\r
\r
buf32 = PsndBuffer+(offset<<stereo);\r
\r
// Add in parts of the PSG output not yet done\r
if (length-psglen > 0) {\r
short *psgbuf = PicoIn.sndOut + (psglen << stereo);\r
- Pico.snd.psg_pos += (length-psglen) << 16;\r
+ Pico.snd.psg_pos += (length-psglen) << 20;\r
if (PicoIn.opt & POPT_EN_PSG)\r
SN76496Update(psgbuf, length-psglen, stereo);\r
}\r
static int PsndRenderMS(int offset, int length)\r
{\r
int stereo = (PicoIn.opt & 8) >> 3;\r
- int psglen = ((Pico.snd.psg_pos+0x8000) >> 16);\r
- int ym2413len = ((Pico.snd.ym2413_pos+0x8000) >> 16);\r
+ int psglen = ((Pico.snd.psg_pos+0x80000) >> 20);\r
+ int ym2413len = ((Pico.snd.ym2413_pos+0x80000) >> 20);\r
\r
pprof_start(sound);\r
\r
// Add in parts of the PSG output not yet done\r
if (length-psglen > 0) {\r
short *psgbuf = PicoIn.sndOut + (psglen << stereo);\r
- Pico.snd.psg_pos += (length-psglen) << 16;\r
+ Pico.snd.psg_pos += (length-psglen) << 20;\r
if (PicoIn.opt & POPT_EN_PSG)\r
SN76496Update(psgbuf, length-psglen, stereo);\r
}\r
\r
if (length-ym2413len > 0) {\r
short *ym2413buf = PicoIn.sndOut + (ym2413len << stereo);\r
- Pico.snd.ym2413_pos += (length-ym2413len) << 16;\r
+ Pico.snd.ym2413_pos += (length-ym2413len) << 20;\r
int len = (length-ym2413len);\r
if (PicoIn.opt & POPT_EN_YM2413){\r
while (len-- > 0) {\r