mrehkopf / sd2snes

SD card based multi-purpose cartridge for the SNES
http://sd2snes.de
GNU General Public License v2.0
590 stars 115 forks source link

SaveRAM fixes #144

Closed RedGuyyyy closed 4 years ago

RedGuyyyy commented 4 years ago

The original intent of the SaveRAM region change was to avoid starving the USB interface. A bug caused each partial region check to compute the CRC across full SaveRAM which not only didn't fix the problem but also delayed writing SaveRAM changes to SD. These commits fix the bug.

Alternatively, the region checking could be removed to avoid changing the way the SaveRAM CRC is computed. Region checking may introduce other bugs due to additional complexity. Starvation only really becomes a problem with large SaveRAM (e.g. ROM hacks and some special chip games) and when the USB is very active.

A fix for changing the SaveRAM base in the MSU loop is also included. But it's unlikely a MSU hack will ever be added to the table that changes the base/size on CRC match.