PCSX2/pcsx2 — pull request #359 by AdmiralCurtiss (2014-11-25 23:47:59+00:00)
Title: Memory Card as folder instead of a big raw file.

This adds a class (and some helper structures) that implements memory card reads and writes into the host file system instead of a raw memory card file.

I was mostly doing this because I was curious if it was possible to implement the same sort of thing Dolphin added recently for the PS2 as well, and it kinda is, although the way and order the PS2 writes FAT data make it quite difficult at times. I ended up caching all modified pages of data in memory and only flushing to disk when the emulator is shutting down, which isn't great but at least works consistently. Memory Card FAT is recreated whenever it's opened, so you can freely add and remove files from the folder.

It's probably far from perfect and could use some optimization, especially when it comes to finding a good time to flush the in-memory data, but it works quite well for regular use of creating and overwriting saves. Deleting isn't implemented yet. I imagine that savestates could mess with it quite a bit, but that's probably the case with the raw files as well.

Here's a picture of it running in the PS2 file browser: https://cloud.githubusercontent.com/assets/4522237/5193663/b7cb128e-7503-11e4-8cbe-8fade86e678d.png

To test it out, comment out the FileMemoryCard impl in Component_FileMcd and comment in the FolderMemoryCardAggregator instead. Ideally, there should be an option to allow the user to switch between the two modes. A few other small GUI changes would also be needed so you can select folders instead of files as memory cards.

Tell me what you think and if this could be a good addition to the emulator with a bit more polish.