From: kub Date: Fri, 28 Mar 2025 22:02:40 +0000 (+0100) Subject: mcd, improve pcm save state X-Git-Tag: v2.04~8 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6bb77d1a1770882dbae14dce70fa9d4de19b0f7;p=picodrive.git mcd, improve pcm save state --- diff --git a/pico/cd/mcd.c b/pico/cd/mcd.c index 9476f501..4140f20a 100644 --- a/pico/cd/mcd.c +++ b/pico/cd/mcd.c @@ -442,7 +442,6 @@ PICO_INTERNAL void PicoFrameMCD(void) void pcd_state_loaded(void) { unsigned int cycles; - int diff; pcd_state_loaded_mem(); @@ -453,7 +452,7 @@ void pcd_state_loaded(void) // old savestates.. cycles = pcd_cycles_m68k_to_s68k(Pico.t.m68c_aim); - if (CYCLES_GE(cycles - SekCycleAimS68k, 1000)) { + if (CYCLES_GE(cycles - SekCycleAimS68k, 12500000/60)) { SekCycleCntS68k = SekCycleAimS68k = cycles; } if (pcd_event_times[PCD_EVENT_CDC] == 0) { @@ -464,8 +463,7 @@ void pcd_state_loaded(void) (Pico_mcd->s68k_regs[0x31]+1) * 384); } - diff = cycles - Pico_mcd->pcm.update_cycles; - if ((unsigned int)diff > 12500000/50) + if (CYCLES_GE(cycles - Pico_mcd->pcm.update_cycles, 12500000/50)) Pico_mcd->pcm.update_cycles = cycles; if (Pico_mcd->m.need_sync) { diff --git a/pico/cd/pcm.c b/pico/cd/pcm.c index b38ce2d6..abb65f6c 100644 --- a/pico/cd/pcm.c +++ b/pico/cd/pcm.c @@ -62,7 +62,7 @@ void pcd_pcm_sync(unsigned int to) if ((int)(to - cycles) < 384) return; - steps = (to - cycles) / 384; + steps = (to - cycles) * ((1LL << 32) / 384) >> 32; if (Pico_mcd->pcm_mixpos + steps > PCM_MIXBUF_LEN) // shouldn't happen, but occasionally does steps = PCM_MIXBUF_LEN - Pico_mcd->pcm_mixpos; @@ -147,7 +147,7 @@ void pcd_pcm_update(s32 *buf32, int length, int stereo) else { while (length-- > 0) { // mostly unused - *buf32++ += pcm[0]; + *buf32++ += (pcm[0] + pcm[1]) >> 1; p += step; pcm += (p >> 16) * 2;