RetroAchievements / rcheevos

Library to parse and evaluate achievements and leaderboards for RetroAchievements
MIT License
86 stars 33 forks source link

Add Scratchpad memory to PS1 #345

Closed PopovMark closed 2 months ago

PopovMark commented 3 months ago

Not sure if this is the correct place to request this, but here goes:

The Scratchpad is a cache-like memory region that is 1KB in size and starts at 1F800000 in the console memory. It is used occasionally for certain speed optimizations and other things. See this link for more details: https://psx-spx.consoledev.net/memorymap/

Currently, no libretro core, nor DuckStation's RA components can access this region, they can only access the 2048KB of main memory (console memory 00000000-001FFFFF). I propose that this region be mapped in RA memory right after the main memory, at 0x200000-0x2003FF.

Here's an example of a game that actively uses this region: https://retroachievements.org/game/5103 This has values noted in the code notes for crucial things like lives, E-tanks, progression flags and the like, and all of them cannot be accessed in any libretro core. I found them by digging in Duckstation's own memory finder, which can search this region with no issues. Same applies to the PS1 ports of all 6 OG Mega Man games, and most likely some others - if you ever search for cheatcodes and find one in a format like "1F800XXX XXXXXXXX", that means it's manipulating this memory region.

Also, it'll be a massive help if anyone ever decides to dev these two, I did some memory digging in advance and let's just say this region does a lot of heavy lifting when in gameplay. https://retroachievements.org/game/8295 https://retroachievements.org/game/3784

PopovMark commented 3 months ago

Holy jesus that was fast! Thanks, man!