X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2Fsound%2Fsound.c;h=aa2acb2e4c75e761d3a32a1bbc26a408ed0edb6d;hb=88b3d7c16ae976d332b8462de839b86f856a7180;hp=8bec0ba593f88bd3179c8a6020536d38bf5b59ff;hpb=9a8ffeeeea54301c5289fd510aece552175ce13d;p=picodrive.git diff --git a/Pico/sound/sound.c b/Pico/sound/sound.c index 8bec0ba..aa2acb2 100644 --- a/Pico/sound/sound.c +++ b/Pico/sound/sound.c @@ -15,6 +15,8 @@ #include "../../cpu/mz80/mz80.h" #elif defined(_USE_DRZ80) #include "../../cpu/DrZ80/drz80.h" +#elif defined(_USE_CZ80) +#include "../../cpu/cz80/cz80.h" #endif #include "../PicoInt.h" @@ -99,7 +101,7 @@ static void dac_recalculate(void) } -PICO_INTERNAL void sound_reset(void) +PICO_INTERNAL void PsndReset(void) { void *ym2612_regs; @@ -108,12 +110,12 @@ PICO_INTERNAL void sound_reset(void) memset(ym2612_regs, 0, 0x200+4); z80startCycle = z80stopCycle = 0; - sound_rerate(0); + PsndRerate(0); } // to be called after changing sound rate or chips -void sound_rerate(int preserve_state) +void PsndRerate(int preserve_state) { void *state = NULL; int target_fps = Pico.m.pal ? 50 : 60; @@ -161,12 +163,12 @@ void sound_rerate(int preserve_state) // clear all buffers memset32(PsndBuffer, 0, sizeof(PsndBuffer)/4); if (PsndOut) - sound_clear(); + PsndClear(); } // This is called once per raster (aka line), but not necessarily for every line -PICO_INTERNAL void sound_timers_and_dac(int raster) +PICO_INTERNAL void Psnd_timers_and_dac(int raster) { int pos, len; int do_dac = PsndOut && (PicoOpt&1) && *ym2612_dacen; @@ -214,16 +216,22 @@ PICO_INTERNAL void sound_timers_and_dac(int raster) } -PICO_INTERNAL void sound_clear(void) +PICO_INTERNAL void PsndClear(void) { int len = PsndLen; if (PsndLen_exc_add) len++; - if (PicoOpt & 8) memset32((int *) PsndOut, 0, len); // clear both channels at once - else memset(PsndOut, 0, len<<1); + if (PicoOpt & 8) + memset32((int *) PsndOut, 0, len); // assume PsndOut to be aligned + else { + short *out = PsndOut; + if ((int)out & 2) { *out++ = 0; len--; } + memset32((int *) out, 0, len/2); + if (len & 1) out[len-1] = 0; + } } -PICO_INTERNAL int sound_render(int offset, int length) +PICO_INTERNAL int PsndRender(int offset, int length) { int buf32_updated = 0; int *buf32 = PsndBuffer+offset; @@ -246,9 +254,9 @@ PICO_INTERNAL int sound_render(int offset, int length) SN76496Update(PsndOut+offset, length, stereo); // Add in the stereo FM buffer - if (PicoOpt & 1) { + if (PicoOpt & 1) buf32_updated = YM2612UpdateOne(buf32, length, stereo, 1); - } else + else memset32(buf32, 0, length<