From a85010ba7496a4a9a2f6442b0ae67efc1f4e3f92 Mon Sep 17 00:00:00 2001 From: kub Date: Tue, 25 Mar 2025 23:23:10 +0100 Subject: [PATCH] mcd, fix for md+ state loading and reset behaviour --- pico/cd/cdd.c | 2 ++ pico/cd/mcd.c | 7 ++++++- pico/cd/megasd.c | 12 +++++++++++- pico/cd/megasd.h | 1 + 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pico/cd/cdd.c b/pico/cd/cdd.c index dcb3be4a..a1ee9cd2 100644 --- a/pico/cd/cdd.c +++ b/pico/cd/cdd.c @@ -181,6 +181,8 @@ void cdd_reset(void) /* clear CD-DA output */ cdd.audio[0] = cdd.audio[1] = 0; + /* no audio track playing */ + Pico_mcd->s68k_regs[0x36+0] = 0x01; /* reset file read position */ read_pos = -1; } diff --git a/pico/cd/mcd.c b/pico/cd/mcd.c index 9c7a60ec..42a5a515 100644 --- a/pico/cd/mcd.c +++ b/pico/cd/mcd.c @@ -80,6 +80,9 @@ PICO_INTERNAL void PicoPowerMCD(void) if (Pico.romsize == 0) // no HINT vector from gate array for MSU memset(Pico_mcd->bios + 0x70, 0xff, 4); pcd_event_schedule_s68k(PCD_EVENT_CDC, 12500000/75); + + cdc_reset(); + cdd_reset(); } void pcd_soft_reset(void) @@ -118,7 +121,6 @@ PICO_INTERNAL int PicoResetMCD(void) Pico.sv.start = Pico.sv.end = 0; // unused } - msd_reset(); return 0; } @@ -456,6 +458,9 @@ void pcd_state_loaded(void) // reschedule event_time_next = 0; pcd_run_events(SekCycleCntS68k); + + // msd + msd_load(); } // vim:shiftwidth=2:ts=2:expandtab diff --git a/pico/cd/megasd.c b/pico/cd/megasd.c index 98e2dcbc..bc03d17c 100644 --- a/pico/cd/megasd.c +++ b/pico/cd/megasd.c @@ -181,13 +181,23 @@ static void msd_init(void) void msd_reset(void) { if (Pico_msd.state) { - Pico_msd.state = Pico_msd.command = Pico_msd.result = 0; cdd_stop(); + Pico_msd.state = Pico_msd.command = Pico_msd.result = 0; PicoResetHook = NULL; } } +void msd_load(void) +{ + if (Pico_msd.state & MSD_ST_PLAY) + cdd_play_audio(Pico_msd.index, Pico_msd.currentlba); + + // old saves have this initialized wrong + if (cdd.status == NO_DISC) + Pico_mcd->s68k_regs[0x36+0] = 0x01; +} + // memory r/w functions static u32 msd_read16(u32 a) { diff --git a/pico/cd/megasd.h b/pico/cd/megasd.h index 7c311584..b590d4af 100644 --- a/pico/cd/megasd.h +++ b/pico/cd/megasd.h @@ -34,6 +34,7 @@ extern struct megasd Pico_msd; extern void msd_update(void); // 75Hz update, like CDD irq extern void msd_reset(void); // reset state +extern void msd_load(void); // state loaded extern void msd_write8(u32 a, u32 d); // interface extern void msd_write16(u32 a, u32 d); -- 2.39.5