X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fsound%2Fsound.c;h=5bb8e9d89fc216358958c98572e5ce1dae3db880;hb=cf82669f5072028f623a4b92516c74947040e563;hp=7f3fd8dfb58e35c2d886ec838735a301a94f2eb9;hpb=2ec9bec58b89831cdead4cdec8f593c5b99d2715;p=picodrive.git diff --git a/pico/sound/sound.c b/pico/sound/sound.c index 7f3fd8d..5bb8e9d 100644 --- a/pico/sound/sound.c +++ b/pico/sound/sound.c @@ -107,14 +107,9 @@ static void dac_recalculate(void) PICO_INTERNAL void PsndReset(void) { - void *ym2612_regs; - - // also clear the internal registers+addr line - ym2612_regs = YM2612GetRegs(); - memset(ym2612_regs, 0, 0x200+4); - timers_reset(); - + // PsndRerate calls YM2612Init, which also resets PsndRerate(0); + timers_reset(); } @@ -252,7 +247,7 @@ PICO_INTERNAL void cdda_start_play(void) lba_offset += Pico_mcd->TOC.Tracks[index].Offset; // find the actual file for this track - for (i = index; i >= 0; i--) + for (i = index; i > 0; i--) if (Pico_mcd->TOC.Tracks[i].F != NULL) break; if (Pico_mcd->TOC.Tracks[i].F == NULL) { @@ -296,7 +291,7 @@ PICO_INTERNAL void PsndClear(void) memset32((int *) PsndOut, 0, len); // assume PsndOut to be aligned else { short *out = PsndOut; - if ((int)out & 2) { *out++ = 0; len--; } + if ((long)out & 2) { *out++ = 0; len--; } memset32((int *) out, 0, len/2); if (len & 1) out[len-1] = 0; } @@ -313,6 +308,8 @@ static int PsndRender(int offset, int length) (Pico_mcd->pcm.control & 0x80) && Pico_mcd->pcm.enabled; offset <<= stereo; + pprof_start(sound); + #if !SIMPLE_WRITE_SOUND if (offset == 0) { // should happen once per frame // compensate for float part of PsndLen @@ -361,9 +358,14 @@ static int PsndRender(int offset, int length) cdda_raw_update(buf32, length); } + if ((PicoAHW & PAHW_32X) && (PicoOpt & POPT_EN_PWM)) + p32x_pwm_update(buf32, length, stereo); + // convert + limit to normal 16bit output PsndMix_32_to_16l(PsndOut+offset, buf32, length); + pprof_end(sound); + return length; } @@ -398,7 +400,6 @@ PICO_INTERNAL void PsndGetSamples(int y) PICO_INTERNAL void PsndGetSamplesMS(void) { - int *buf32 = PsndBuffer; int stereo = (PicoOpt & 8) >> 3; int length = PsndLen; @@ -415,8 +416,12 @@ PICO_INTERNAL void PsndGetSamplesMS(void) if (PicoOpt & POPT_EN_PSG) SN76496Update(PsndOut, length, stereo); - // convert + limit to normal 16bit output - PsndMix_32_to_16l(PsndOut, buf32, length); + // upmix to "stereo" if needed + if (stereo) { + int i, *p; + for (i = length, p = (void *)PsndOut; i > 0; i--, p++) + *p |= *p << 16; + } if (PicoWriteSound != NULL) PicoWriteSound(length);