RetroAchievements / RAIntegration

The DLL responsible to integrate emulators with RetroAchievements.org
https://retroachievements.org
MIT License
95 stars 22 forks source link

Bug Report - in SNES SA-1 addresses 0x020000 to 0x0200ff are not exposed correctly #747

Open Blazekickn opened 3 years ago

Blazekickn commented 3 years ago

image

Shown above is a SMW hack that uses SA-1. Player Power-Up address is supposed to be at 0x020019 (SA-1 offsets the ram by 0x020000 from where it would be in the base game) but instead the region is filled with 0x60. 0x02010b is Level ID and that shows correctly and matches with the vanilla SMW, along with the rest of my notes.

Blazekickn commented 3 years ago

worth noting that i was using RASnes9x, I tested it in RALibretro and it still wasn't correct but showed different junk data (Mostly 00s)

Jamiras commented 3 years ago

RA memory addresses usually do not correspond to actual system addresses. With the exception of systems where the entire memory is mapped (NES/GB), it's usually system memory followed by cartridge memory. That's true for SNES as well. RA addresses $000000-$1FFFFF correspond to the 2MB of system memory normally addressed from $7E0000-$7FFFFF. RA addresses $200000-$3FFFFF are for the cartridge memory normally addressed from $FE0000-$FFFFFF.

It looks like the SA-1 chip largely remaps the memory.

When you activate SA-1, two types of RAM are added and one is deleted. In other words, I-RAM and BW-RAM are added while SRAM is deleted.

As best as I can tell, the I-RAM lives from $003000-$0031FF, and the BW-RAM from $400000-$41FFFF. As the BW-RAM is mostly a direct replacement for the SRAM, it would make sense for the cores to treat it as such, and that's probably what you're seeing from $20000-$3FFFF in the memory inspector. The I-RAM probably needs an additional mapping entry.

The difference between SNES9x and libretro is probably in the mapping. SNES9x is mapping the SRAM directly and probably captures the BW-RAM. libretro exposes a memory map and the SRAM is captured from $FE0000-$FFFFFF. If the core exposes BW-RAM at $400000-$41FFFF, it may not be possible to share the same addresses in the memory inspector. I'm unable to test at this time.

Further investigation is required.