sound, remove hysteresis (lessens distortion, increases frequency limit)

This commit is contained in:
kub 2021-10-23 01:09:04 +02:00
parent f0e6d1e371
commit 027940e108
2 changed files with 3 additions and 19 deletions

View file

@ -225,7 +225,7 @@ static void z80_sms_out(unsigned short a, unsigned char d)
case 0x40: case 0x40:
case 0x41: case 0x41:
PsndDoPSG(z80_cyclesDone()); PsndDoPSG(Pico.m.scanline*228 + 228-z80_cyclesLeft);
SN76496Write(d); SN76496Write(d);
break; break;

View file

@ -130,10 +130,6 @@ PICO_INTERNAL void PsndDoDAC(int cyc_to)
// number of samples to fill in buffer (Q20) // number of samples to fill in buffer (Q20)
len = (cyc_to * Pico.snd.clkl_mult) - Pico.snd.dac_pos; len = (cyc_to * Pico.snd.clkl_mult) - Pico.snd.dac_pos;
// don't do this too often (about once every 2 scanlines)
if (len <= PicoIn.sndRate << 3) // Q16, (PicoIn.sndRate << 16) >> 13
return;
// update position and calculate buffer offset and length // update position and calculate buffer offset and length
pos = (Pico.snd.dac_pos+0x80000) >> 20; pos = (Pico.snd.dac_pos+0x80000) >> 20;
Pico.snd.dac_pos += len; Pico.snd.dac_pos += len;
@ -173,10 +169,6 @@ PICO_INTERNAL void PsndDoPSG(int cyc_to)
// number of samples to fill in buffer (Q20) // number of samples to fill in buffer (Q20)
len = (cyc_to * Pico.snd.clkl_mult) - Pico.snd.psg_pos; len = (cyc_to * Pico.snd.clkl_mult) - Pico.snd.psg_pos;
// don't do this too often (about once every 2 scanlines)
if (len <= PicoIn.sndRate << 3) // Q16, (PicoIn.sndRate << 16) >> 13
return;
// update position and calculate buffer offset and length // update position and calculate buffer offset and length
pos = (Pico.snd.psg_pos+0x80000) >> 20; pos = (Pico.snd.psg_pos+0x80000) >> 20;
Pico.snd.psg_pos += len; Pico.snd.psg_pos += len;
@ -204,10 +196,6 @@ PICO_INTERNAL void PsndDoYM2413(int cyc_to)
// number of samples to fill in buffer (Q20) // number of samples to fill in buffer (Q20)
len = (cyc_to * Pico.snd.clkl_mult) - Pico.snd.ym2413_pos; len = (cyc_to * Pico.snd.clkl_mult) - Pico.snd.ym2413_pos;
// don't do this too often (about once every 2 scanlines)
if (len <= PicoIn.sndRate << 3) // Q16, (PicoIn.sndRate << 16) >> 13
return;
// update position and calculate buffer offset and length // update position and calculate buffer offset and length
pos = (Pico.snd.ym2413_pos+0x80000) >> 20; pos = (Pico.snd.ym2413_pos+0x80000) >> 20;
Pico.snd.ym2413_pos += len; Pico.snd.ym2413_pos += len;
@ -245,13 +233,9 @@ PICO_INTERNAL void PsndDoFM(int cyc_to)
int pos, len; int pos, len;
int stereo = 0; int stereo = 0;
// Q16, number of samples since last call // Q20, number of samples since last call
len = (cyc_to * Pico.snd.clkl_mult) - Pico.snd.fm_pos; len = (cyc_to * Pico.snd.clkl_mult) - Pico.snd.fm_pos;
// don't do this too often (about once every 2 scanlines)
if (len <= PicoIn.sndRate << 3) // Q16, (PicoIn.sndRate << 16) >> 13
return;
// update position and calculate buffer offset and length // update position and calculate buffer offset and length
pos = (Pico.snd.fm_pos+0x80000) >> 20; pos = (Pico.snd.fm_pos+0x80000) >> 20;
Pico.snd.fm_pos += len; Pico.snd.fm_pos += len;
@ -351,7 +335,7 @@ static int PsndRender(int offset, int length)
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 (Q 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; Pico.snd.dac_pos += (length-daclen) << 20;