Skip to content

Advertise Jaguar memory map for RetroAchievements support#112

Closed
JoeMatt wants to merge 2 commits intolibretro:masterfrom
Provenance-Emu:claude/add-retroachievements-support-q7zNv
Closed

Advertise Jaguar memory map for RetroAchievements support#112
JoeMatt wants to merge 2 commits intolibretro:masterfrom
Provenance-Emu:claude/add-retroachievements-support-q7zNv

Conversation

@JoeMatt
Copy link
Copy Markdown
Collaborator

@JoeMatt JoeMatt commented Apr 17, 2026

Call RETRO_ENVIRONMENT_SET_MEMORY_MAPS in retro_load_game so frontends like RetroArch can resolve emulated Jaguar addresses to host buffers. This enables rcheevos to read the 2 MB main RAM at 0x000000, tagged big-endian to match Jaguar native byte order.

Call RETRO_ENVIRONMENT_SET_MEMORY_MAPS in retro_load_game so frontends
like RetroArch can resolve emulated Jaguar addresses to host buffers.
This enables rcheevos to read the 2 MB main RAM at 0x000000, tagged
big-endian to match Jaguar native byte order.
@JoeMatt JoeMatt self-assigned this Apr 17, 2026
Copilot AI review requested due to automatic review settings April 17, 2026 21:14
@JoeMatt JoeMatt linked an issue Apr 17, 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

Note

Copilot was unable to run its full agentic suite in this review.

Adds a libretro memory map advertisement for Atari Jaguar main RAM so frontends (e.g., RetroArch) can translate emulated addresses to host buffers for features like RetroAchievements.

Changes:

  • Defines a memory descriptor for Jaguar main RAM (2 MB @ 0x000000, big-endian).
  • Calls RETRO_ENVIRONMENT_SET_MEMORY_MAPS during retro_load_game.

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

Comment thread libretro.c
Comment on lines +1000 to +1014
{
struct retro_memory_descriptor descs[1];
struct retro_memory_map memmap;

memset(descs, 0, sizeof(descs));
descs[0].flags = RETRO_MEMDESC_SYSTEM_RAM | RETRO_MEMDESC_BIGENDIAN;
descs[0].ptr = jaguarMainRAM;
descs[0].start = 0x000000;
descs[0].len = 0x200000;
descs[0].addrspace = "RAM";

memmap.descriptors = descs;
memmap.num_descriptors = sizeof(descs) / sizeof(descs[0]);
environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &memmap);
}
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

The descs array (and memmap) are stack-allocated and go out of scope when retro_load_game returns, but frontends may keep and query the memory map later. This can leave the frontend with dangling pointers for memmap.descriptors, causing incorrect reads or crashes. Make the descriptors and the retro_memory_map storage persist for the lifetime of the loaded game (e.g., static/global storage, or heap-allocate and free on retro_unload_game).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Comment thread libretro.c Outdated
Comment thread libretro.c
Comment on lines +1007 to +1008
descs[0].start = 0x000000;
descs[0].len = 0x200000;
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

These are magic constants for the main RAM mapping. To reduce the chance of future mismatches, prefer using a named constant (e.g., JAGUAR_MAIN_RAM_SIZE) or sizeof (if jaguarMainRAM is a real array in this translation unit) for len.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <[email protected]>
@JoeMatt
Copy link
Copy Markdown
Collaborator Author

JoeMatt commented Apr 23, 2026

duped by #117

@JoeMatt JoeMatt closed this Apr 23, 2026
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.

3 participants