From fe90daf24050787f8b81154065bafde959cdb989 Mon Sep 17 00:00:00 2001 From: kub Date: Tue, 4 Feb 2025 21:52:57 +0100 Subject: [PATCH] libretro, fix cart sram handling for MSU/MD+ cartridges --- pico/media.c | 12 ++++++------ platform/libretro/libretro.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pico/media.c b/pico/media.c index ff7a338a..e0c25b24 100644 --- a/pico/media.c +++ b/pico/media.c @@ -412,12 +412,6 @@ enum media_type_e PicoLoadMedia(const char *filename, lprintf("detected SMS ROM\n"); } - if (PicoCartInsert(rom_data, rom_size, carthw_cfg_fname)) { - media_type = PM_ERROR; - goto out; - } - rom_data = NULL; // now belongs to PicoCart - // insert CD if it was detected Pico.m.ncart_in = 0; if (cd_img_type != CT_UNKNOWN) { @@ -431,6 +425,12 @@ enum media_type_e PicoLoadMedia(const char *filename, Pico.m.ncart_in = 1; } + if (PicoCartInsert(rom_data, rom_size, carthw_cfg_fname)) { + media_type = PM_ERROR; + goto out; + } + rom_data = NULL; // now belongs to PicoCart + if (PicoIn.quirks & PQUIRK_FORCE_6BTN) PicoSetInputDevice(0, PICO_INPUT_PAD_6BTN); diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 1fafa0bc..82fae8a9 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -1714,9 +1714,9 @@ size_t retro_get_memory_size(unsigned type) switch(type) { case RETRO_MEMORY_SAVE_RAM: - if (PicoIn.AHW & PAHW_MCD) + if ((PicoIn.AHW & PAHW_MCD) && Pico.romsize == 0) { - if (Pico.romsize == 0 && PicoIn.opt & POPT_EN_MCD_RAMCART) + if (PicoIn.opt & POPT_EN_MCD_RAMCART) return 0x12000; else /* bram */ return 0x2000; -- 2.39.5