hrydgard/ppsspp — pull request #1542 by CPkmn (2013-04-27 03:29:01+00:00)
Title: [Experimental] Repair corrupt saves

Essentially this is a semi-SED implementation for PPSSPP. (since SED/FreeCheat doesn't work very well on emulators)

I say "semi" because this is for cases where you have some encrypted and some decrypted files** in your ms0:/PSP/SAVEDATA// folder which may result in the game thinking the save is corrupted.

For example, my testing case was Shining Ark.
While playing Shining Ark I had EncryptSave turned on (default) but later I got curious about what the plaintext save file looked like so I turned off EncryptSave and saved my game. In consecutive runs my save was reported as corrupted. The problem with this is Shining Ark doesn't change all of the files** (13) in its savedata folder every time it saves, so this resulted in some files** being saved decrypted (the ones it changed) and some files** being saved encrypted (the ones it didn't change) which resulted in my save as a whole being "corrupted" when I tried saving or loading the game.

Basically what this does is it replaces the file the game saves with a plaintext save file from "ms0:/PSP/SAVEDATA//INJECT/". This allows the user to fix corruption if they switch between "EncryptSave = True" and "EncryptSave = False" and not all of the files were saved decrypted.

The drawback with using this implementation for repairing a save file is if you save with this on and you have a plaintext save in the /INJECT/ folder, you won't actually save your progress. This is why I implemented an option to toggle it in the UI.

** = not including always plaintext files (like encrypt_info.bin and param.sfo)