Skip to content

fix: RetroAchievements memory regions built too late, disabling achievements - #801

Open
apommel wants to merge 1 commit into
LoveRetro:mainfrom
apommel:ra-memory-init-order
Open

fix: RetroAchievements memory regions built too late, disabling achievements#801
apommel wants to merge 1 commit into
LoveRetro:mainfrom
apommel:ra-memory-init-order

Conversation

@apommel

@apommel apommel commented Aug 9, 2026

Copy link
Copy Markdown

Fixes a regression from #775 where some achievements, notably from GBC, stopped unlocking. Closes #800.

#775 aimed to use the console detection from rcheevos to improve RetroAchievements behavior on minarch to not rely exclusively on emulator tags, which allows custom emulator cores from Pak and emulator cores supporting several consoles, to work properly.

However I misunderstood the rcheevos process and I thought it was safe to initialize the memory regions in ra_game_loaded_callback(), once the console has been identified, but it appears that at this point rcheevos has probed every memory address and permanently disabled achievements with any read error. I did not notice the issue because there was a fallback in ra_read_memory(), which allowed the first memory region to work when it mapped to system RAM, and as I tested on SNES games, where this is the case, it seemed to work as expected. On Game Boy, the RAM was not the first memory region and achievements unlocks were therefore not evaluated

To fix this issue while maintaining the fix, I moved the regions build to the first memory read instead. RetroArch does a similar thing: libretro/RetroArch/cheevos/cheevos.c#L1457.

In addition, when I looked at RetroArch source code I saw that they mention some cores only expose memory after the first retro_run(). To handle that, ra_read_memory() now reports memory as readable while the game is still loading, so rcheevos doesn't outright disable achievements in this case, and RA_doFrame() retries the init every second while holding off rc_client_do_frame(). This should be an improvement over the previous behavior, which never retried. I did not test this part however, because RetroArch mentions Mupen64 that needs that, but it does not work in minarch (it needs to get the GL context).

I tested the fix on Dragon Warrior III on GBC, with the achievement identified in #800. I also re-tested SNES achievements, and an achievement in a custom Pak (Genesis Plus GX, GPGX) in QuackShot. I did test in both online and offline modes.

Sorry about the regression, I should have tested on more systems in my previous PR.

I used Claude Opus 5 to help with understanding the issue and creating the fix.

@frysee @clintonium-119

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.

Many RetroAchievements not triggering on latest master

1 participant