From ed5b27c962dc0654d003a34685076244b34bd1e2 Mon Sep 17 00:00:00 2001 From: kub Date: Sat, 25 Jan 2025 19:58:47 +0100 Subject: [PATCH] mcd, fix MD+ playing binary track as audio --- pico/cd/cdd.c | 1 + pico/cd/megasd.c | 15 +++++++++------ pico/cd/memory.c | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pico/cd/cdd.c b/pico/cd/cdd.c index 806bb2d9..2e95a89a 100644 --- a/pico/cd/cdd.c +++ b/pico/cd/cdd.c @@ -188,6 +188,7 @@ void cdd_play_audio(int index, int lba) for (i = index; i >= 0; i--) if (cdd.toc.tracks[i].fd != NULL) break; + if (! is_audio(i)) return; Pico_mcd->cdda_stream = cdd.toc.tracks[i].fd; base = cdd.toc.tracks[index].offset; diff --git a/pico/cd/megasd.c b/pico/cd/megasd.c index f0228a40..98e2dcbc 100644 --- a/pico/cd/megasd.c +++ b/pico/cd/megasd.c @@ -192,20 +192,20 @@ void msd_reset(void) static u32 msd_read16(u32 a) { u16 d = 0; + u16 a16 = a; - a = (u16)a; - if (a >= 0x0f800) { + if (a16 >= 0x0f800) { d = Pico_msd.data[(a&0x7ff)>>1]; - } else if (a >= 0xf7f6) { - switch (a&0xe) { + } else if (a16 >= 0xf7f6) { + switch (a16&0xe) { case 0x6: d = 0x5241; break; // RA case 0x8: d = 0x5445; break; // TE case 0xa: d = 0xcd54; break; case 0xc: d = Pico_msd.result; break; case 0xe: d = Pico_msd.command; break; } - } else if (Pico.romsize > 0x30000) - d = *(u16 *)(Pico.rom + 0x30000 + a); + } else if (Pico.romsize > a) + d = *(u16 *)(Pico.rom + a); return d; } @@ -236,6 +236,9 @@ void msd_write16(u32 a, u32 d) } else if (Pico.romsize > base) { cpu68k_map_set(m68k_read8_map, base, 0x03ffff, Pico.rom+base, 0); cpu68k_map_set(m68k_read16_map, base, 0x03ffff, Pico.rom+base, 0); + base += 0x800000; // mirror + cpu68k_map_set(m68k_read8_map, base, 0x0bffff, Pico.rom+base, 0); + cpu68k_map_set(m68k_read16_map, base, 0x0bffff, Pico.rom+base, 0); } } else if (a == 0xf7fe) { // command port diff --git a/pico/cd/memory.c b/pico/cd/memory.c index 7b9452fd..b3838905 100644 --- a/pico/cd/memory.c +++ b/pico/cd/memory.c @@ -674,7 +674,7 @@ static u32 PicoReadM68k8_ramc(u32 a) { u32 d = 0; - if (PicoIn.opt & POPT_EN_MCD_RAMCART) { + if (Pico.romsize == 0 && (PicoIn.opt & POPT_EN_MCD_RAMCART)) { if ((a & 0xf00001) == 0x400001) { if (Pico.sv.data != NULL) d = 3; // 64k cart @@ -703,7 +703,7 @@ static u32 PicoReadM68k16_ramc(u32 a) static void PicoWriteM68k8_ramc(u32 a, u32 d) { - if (PicoIn.opt & POPT_EN_MCD_RAMCART) { + if (Pico.romsize == 0 && (PicoIn.opt & POPT_EN_MCD_RAMCART)) { if ((a & 0xf00001) == 0x600001) { if (Pico.sv.data != NULL && (Pico_mcd->m.bcram_reg & 1)) { Pico.sv.data[((a >> 1) & 0xffff) + 0x2000] = d; -- 2.39.5