Skip to content

Advertise Jaguar memory map for RetroAchievements support#117

Merged
JoeMatt merged 11 commits intolibretro:masterfrom
Provenance-Emu:feature/retroachievements-memory-map
Apr 23, 2026
Merged

Advertise Jaguar memory map for RetroAchievements support#117
JoeMatt merged 11 commits intolibretro:masterfrom
Provenance-Emu:feature/retroachievements-memory-map

Conversation

@JoeMatt
Copy link
Copy Markdown
Collaborator

@JoeMatt JoeMatt commented Apr 23, 2026

Summary

  • Advertises the Jaguar's 2 MB system RAM via RETRO_ENVIRONMENT_SET_MEMORY_MAPS in retro_load_game, enabling RetroAchievements (rcheevos) memory lookups
  • Calls RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS in retro_set_environment to signal achievement support
  • Uses static storage for the memory descriptor and map structs to prevent dangling pointers after retro_load_game returns
  • All declarations are C89-compliant (no mid-block declarations)

Memory Map Descriptor

Field Value
flags RETRO_MEMDESC_SYSTEM_RAM | RETRO_MEMDESC_BIGENDIAN
ptr jaguarMainRAM (2 MB)
start 0x000000
len 0x200000
addrspace "RAM"

Test Plan

  • New test/tools/test_memory_map.c with 10 automated checks:
    1. SET_SUPPORT_ACHIEVEMENTS called during retro_set_environment
    2. SET_MEMORY_MAPS called during retro_load_game
    3. Exactly 1 descriptor
    4. Descriptor start == 0x000000
    5. Descriptor len == 0x200000
    6. RETRO_MEMDESC_SYSTEM_RAM flag set
    7. RETRO_MEMDESC_BIGENDIAN flag set
    8. Descriptor ptr is non-NULL
    9. Descriptor ptr matches retro_get_memory_data(SYSTEM_RAM)
    10. retro_get_memory_size(SYSTEM_RAM) == 0x200000
  • Memory map test added to CI workflow for all native (non-cross, non-emscripten, non-android) platforms
  • Builds clean on macOS (tested locally)
  • All 10 tests pass locally

Supersedes #112.

Made with Cursor

Copilot AI review requested due to automatic review settings April 23, 2026 17:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds libretro memory-map advertisement for Atari Jaguar system RAM to enable RetroAchievements/rcheevos to resolve emulated addresses to host memory, and introduces a CI-backed test to validate the environment callbacks and exposed RAM mapping.

Changes:

  • Advertise Jaguar main RAM via RETRO_ENVIRONMENT_SET_MEMORY_MAPS during retro_load_game.
  • Signal achievements support via RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS in retro_set_environment.
  • Add a new dynamic-loader test (test_memory_map) and run it in CI on native non-Windows builds.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

File Description
libretro.c Adds achievements support flag and advertises a system RAM memory map descriptor.
test/tools/test_memory_map.c New executable test that loads the core and validates memory-map + achievements environment calls.
.github/workflows/c-cpp.yml Builds/runs the new memory map test in CI (native, non-Windows).
.gitignore Ignores new test/tool binaries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/c-cpp.yml Outdated
Comment thread test/tools/test_memory_map.c
Comment thread libretro.c Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/tools/test_rcheevos_e2e.c Outdated
Comment thread test/tools/build_rcheevos_static.sh Outdated
Comment thread test/tools/build_rcheevos_static.sh Outdated
Comment thread test/tools/build_rcheevos_static.sh Outdated
Comment thread .github/workflows/c-cpp.yml Outdated
@JoeMatt JoeMatt force-pushed the feature/retroachievements-memory-map branch from b940ebd to 816cfe9 Compare April 23, 2026 18:22
@JoeMatt JoeMatt requested a review from Copilot April 23, 2026 18:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/tools/test_rcheevos_e2e.c Outdated
Comment thread CLAUDE.md Outdated
@JoeMatt JoeMatt requested a review from Copilot April 23, 2026 19:07
@JoeMatt JoeMatt linked an issue Apr 23, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/tools/test_memory_map.c
Comment thread .github/workflows/c-cpp.yml
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/tools/test_memory_map.c
Comment thread test/tools/test_rcheevos_e2e.sh Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/tools/test_memory_map.c Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/tools/test_rcheevos_e2e.c Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Call SET_MEMORY_MAPS in retro_load_game with 2 MB system RAM descriptor
  (BIGENDIAN | SYSTEM_RAM, start=0x000000, len=0x200000)
- Use static storage for descriptors to prevent dangling pointers
- Call SET_SUPPORT_ACHIEVEMENTS in retro_set_environment
- Add test/tools/test_memory_map.c with 10 automated checks
- Add memory map test to CI workflow for native platforms

Made-with: Cursor
JoeMatt and others added 10 commits April 23, 2026 17:01
Download pinned rcheevos, build librcheevos.a, verify rc_libretro_memory_*
against Virtual Jaguar with the same Jaguar console regions RetroArch uses.
CI runs after the memory map contract test; respects matrix CC for i686.

Made-with: Cursor
Co-authored-by: Copilot <[email protected]>
Guard before rc_libretro_memory_init; do not call with NULL g_mmap. If the map is absent or init fails, print SKIPPED and only destroy regions after a successful init.

Made-with: Cursor
- test_memory_map: capture SET_SUPPORT_ACHIEVEMENTS data per libretro.h (non-NULL bool, true).
- CI: actions/cache for build/rcheevos-static keyed by pin + OS + compiler + target.
- CLAUDE.md: distinguish no RA server vs GitHub tarball fetch.

Made-with: Cursor
… deps

- Run Test 1 immediately after retro_set_environment so regressions that
  move the call into retro_init fail.
- Document libdl on Linux for test_rcheevos_e2e.sh (dlopen via -ldl).

Made-with: Cursor
Copilot: avoid UB if num_descriptors >= 1 but descriptors is NULL.
Test 3 fails explicitly when num_descriptors==1 with NULL table;
Tests 4–9 FAIL as a block in that case instead of crashing.

Made-with: Cursor
@JoeMatt JoeMatt force-pushed the feature/retroachievements-memory-map branch from 509b6c8 to 932dd4e Compare April 23, 2026 21:01
@JoeMatt JoeMatt requested a review from Copilot April 23, 2026 21:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JoeMatt
Copy link
Copy Markdown
Collaborator Author

JoeMatt commented Apr 23, 2026

image tested works with retroachievements.com

@JoeMatt JoeMatt merged commit 6ed88a0 into libretro:master Apr 23, 2026
26 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] RetroAchievements support

2 participants