X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fsound%2Fsound.c;h=1f23e1aaebee33b1bd5fc69f053bed78f7bdd5fe;hb=9b5713af95da3f72cb659d4d8017559aca593a31;hp=a7510db457f3e8811f8e819a47ed294443d809be;hpb=19954be1966a04304b16d9180b003ec8ca3bc532;p=picodrive.git diff --git a/pico/sound/sound.c b/pico/sound/sound.c index a7510db..1f23e1a 100644 --- a/pico/sound/sound.c +++ b/pico/sound/sound.c @@ -1,11 +1,11 @@ -// This is part of Pico Library - -// (c) Copyright 2004 Dave, All rights reserved. -// (c) Copyright 2006,2007 notaz, All rights reserved. -// Free for non-commercial use. - -// For commercial use, separate licencing terms must be obtained. - +/* + * PicoDrive + * (c) Copyright Dave, 2004 + * (C) notaz, 2006-2009 + * + * This work is licensed under the terms of MAME license. + * See COPYING file in the top-level directory. + */ #include #include "ym2612.h" @@ -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(); } @@ -186,6 +181,9 @@ PICO_INTERNAL void PsndDoDAC(int line_to) int dout = ym2612.dacout; int line_from = PsndDacLine; + if (line_to >= 312) + line_to = 311; + PsndDacLine = line_to + 1; pos =dac_info[line_from]>>4; @@ -252,7 +250,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 +294,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 +311,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 @@ -340,6 +340,7 @@ static int PsndRender(int offset, int length) memset32(buf32, 0, length< 0; i--, p++) *p |= *p << 16; } if (PicoWriteSound != NULL) - PicoWriteSound(length); + PicoWriteSound(length * ((PicoOpt & POPT_EN_STEREO) ? 4 : 2)); PsndClear(); }