RetroAchievements / RAEmus

RetroAchievements.org standalone emulators
https://retroachievements.org
64 stars 9 forks source link

Remove mirrored RAM from the NES memory map #52

Closed rzumer closed 5 years ago

rzumer commented 5 years ago

Based on the documented memory map the NES memory is mirrored three times. There is a low cost to removing the mirrored regions, and it would make development easier by reducing the memory space by 75%. This change would be backwards-compatible as well.

In order to do this, first a script should be ran over the achievements in the database in order to replace memory references to the lower quartile addresses. Then changes can be made to the RA emulators and libretro cores (with FCEUmm as a priority, since it is bundled with RALibretro for development).

Jamiras commented 5 years ago

It's not that simple. The NES memory is exposed in its entirety: https://github.com/RetroAchievements/RAIntegration/blob/master/src/data/ConsoleContext.cpp#L270-L285

Of particular importance is the SRAM located at $6000-$7FFF. Several games rely on that memory space.

Memory exposed to the toolkit is registered as chunks that get stacked together. Removing some section of memory from the middle of the stack will offset everything after it. If we eliminated $0800-$1FFF, then the SRAM would be shifted to $4800-$57FF, which would break anything relying on the SRAM.

If you want to limit your search vector, use the "System Memory" search range, which was added specifically for this reason.

image

Also note that the watermarks added in https://github.com/RetroAchievements/RAIntegration/pull/328 should help inform the user when they're looking at duplicated data.

Jamiras commented 5 years ago

I believe the mapped memory regions are now fully identified in https://github.com/RetroAchievements/RAIntegration/blob/master/src/data/ConsoleContext.cpp. The documentation should be updated to match.

rzumer commented 5 years ago

I see, I was assuming the documentation to be complete. Will update the documentation to match. The region labels look like a good improvement in that regard.

Being able to toggle monitoring of individual banks on or off for development would be a good alternative solution to the issue of rarely/never used memory regions sitting in the middle of the mapped space.