Skip to content

fix: picodrive crash when enabling cheats in SMS mode#719

Open
nborodikhin wants to merge 1 commit into
LoveRetro:mainfrom
nborodikhin:fix/picodrive-sms-cheat-crash
Open

fix: picodrive crash when enabling cheats in SMS mode#719
nborodikhin wants to merge 1 commit into
LoveRetro:mainfrom
nborodikhin:fix/picodrive-sms-cheat-crash

Conversation

@nborodikhin
Copy link
Copy Markdown

@nborodikhin nborodikhin commented May 9, 2026

Summary

Using Action Replay cheats for Sega Master System causes a SIGSEGV crash in picodrive core.

The issue is that Action Replay hardware patches RAM region, but picodrive only supports RAM patching (customary for Game Genie hardware).

Changes

  • add !(PicoIn.AHW & PAHW_SMS) guard so the M68K accessors are only reached when actually emulating a Genesis/Mega Drive
    • RAM patching for SMS is silently skipped, which is correct behavior — SMS uses a Z80, not an M68K, so those functions were never the right tool for SMS RAM patching.
    • The vast majority of SMS cheats in the libretro database are Action Replay format targeting RAM addresses, so all of them previously caused a crash.

The same fix is also posted to upstream: irixxxx/picodrive#218

Test plan

  • Load "Wonder Boy in Monster Land" game
  • Load Action Replay cheat from libretro database
  • Select a cheat from menu

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.
@nborodikhin nborodikhin marked this pull request as ready for review May 9, 2026 22:41
@frysee
Copy link
Copy Markdown
Member

frysee commented May 9, 2026

Im not going to start patching around in cores (more than necessary), please contribute fixes to the upstream core repos.

@frysee
Copy link
Copy Markdown
Member

frysee commented May 12, 2026

irixxxx/picodrive#218

Leaving this open as a reminder so we can pull the latest core when this lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants