From 4d4da36108e5ba54ef796a9e60990c7563fce3da Mon Sep 17 00:00:00 2001 From: Nikita Borodikhin Date: Sat, 9 May 2026 17:13:08 -0500 Subject: [PATCH] fix: skip M68K RAM patching in picodrive SMS mode retro_cheat_set and retro_cheat_reset called m68k_read16/m68k_write16 for patch addresses outside ROM range without checking for SMS mode. In SMS mode the M68K memory map is uninitialised, causing a SIGSEGV. Add PAHW_SMS guard so the M68K accessors are only used for Genesis/MD. RAM patching on SMS was never correctly implemented anyway since the SMS uses a Z80, not an M68K. --- .../001-skip-ram-patching-on-sms.patch | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 workspace/all/cores/patches/picodrive/001-skip-ram-patching-on-sms.patch diff --git a/workspace/all/cores/patches/picodrive/001-skip-ram-patching-on-sms.patch b/workspace/all/cores/patches/picodrive/001-skip-ram-patching-on-sms.patch new file mode 100644 index 000000000..55448b869 --- /dev/null +++ b/workspace/all/cores/patches/picodrive/001-skip-ram-patching-on-sms.patch @@ -0,0 +1,20 @@ +--- a/platform/libretro/libretro.c ++++ b/platform/libretro/libretro.c +@@ -856,7 +856,7 @@ + if (addr < Pico.romsize) { + if (PicoPatches[i].active) + *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data_old; +- } else { ++ } else if (!(PicoIn.AHW & PAHW_SMS)) { + if (PicoPatches[i].active) + m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old); + } +@@ -907,7 +907,7 @@ + PicoPatches[PicoPatchCount].comp = pt.comp; + if (PicoPatches[PicoPatchCount].addr < Pico.romsize) + PicoPatches[PicoPatchCount].data_old = *(uint16_t *)(Pico.rom + PicoPatches[PicoPatchCount].addr); +- else ++ else if (!(PicoIn.AHW & PAHW_SMS)) + PicoPatches[PicoPatchCount].data_old = (uint16_t) m68k_read16(PicoPatches[PicoPatchCount].addr); + PicoPatchCount++; +