--- np2/sound/psggeng.c 2003/10/19 16:54:51 1.2 +++ np2/sound/psggeng.c 2003/11/14 05:26:53 1.6 @@ -1,4 +1,5 @@ #include "compiler.h" +#include "parts.h" #include "sound.h" #include "psggen.h" @@ -19,7 +20,14 @@ void SOUNDCALL psggen_getpcm(PSGGEN psg, UINT i; UINT noise; - while(count--) { + if ((psg->mixer & 0x3f) == 0) { + count = min(count, psg->puchicount); + psg->puchicount -= count; + } + if (count == 0) { + return; + } + do { noisevol = 0; if (psg->envcnt) { psg->envcnt--; @@ -51,7 +59,8 @@ void SOUNDCALL psggen_getpcm(PSGGEN psg, countbak = psg->noise.count; psg->noise.count -= psg->noise.freq; if (psg->noise.count > countbak) { - psg->noise.base = rand() & (1 << (1 << PSGADDEDBIT)); +// psg->noise.base = GETRAND() & (1 << (1 << PSGADDEDBIT)); + psg->noise.base = rand_get() & (1 << (1 << PSGADDEDBIT)); } noisetbl += psg->noise.base; noisetbl >>= 1; @@ -59,10 +68,10 @@ void SOUNDCALL psggen_getpcm(PSGGEN psg, } tone = psg->tone; toneterm = tone + 3; - samp = 0; do { psgvol = (*(tone->pvol)) & 15; if (psgvol) { + samp = 0; vol = psggencfg.volume[psgvol]; switch(mixer & 9) { case 0: // no mix @@ -101,12 +110,16 @@ void SOUNDCALL psggen_getpcm(PSGGEN psg, } break; } + if (!(tone->pan & 1)) { + pcm[0] += samp; + } + if (!(tone->pan & 2)) { + pcm[1] += samp; + } } mixer >>= 1; } while(++tone < toneterm); - pcm[0] += samp; - pcm[1] += samp; pcm += 2; - } + } while(--count); }