Changes

no edit summary
Line 131: Line 131:  
| 0xDFC || 0x4 || Set to 0 by default by the emulator. With config <code>"Cmp", "CodeMultiAddr"</code> this is set to 1. Config <code>"Cmp", "BlockDynamicPC"</code> from [[Super_Mario_3D_All-Stars|SM3DAS]] is not supported. The plugin doesn't use this field, since support for "BlockDynamicPC" was removed. All code which used to use this now assumes val!=2, with code for ==2 being removed.
 
| 0xDFC || 0x4 || Set to 0 by default by the emulator. With config <code>"Cmp", "CodeMultiAddr"</code> this is set to 1. Config <code>"Cmp", "BlockDynamicPC"</code> from [[Super_Mario_3D_All-Stars|SM3DAS]] is not supported. The plugin doesn't use this field, since support for "BlockDynamicPC" was removed. All code which used to use this now assumes val!=2, with code for ==2 being removed.
 
|}
 
|}
 +
 +
= SaveData =
 +
Account savedata has the following layout:
 +
 +
* "/system-save.json": .json Emulator settings/etc, padded to size 0x10000 with 0x00-bytes.
 +
* "/saves/", containing sub-dirs with the same dirnames as romfs:/titles/, for games with savedata stored. These sub-dirs contain:
 +
** "cartridge.sram": Savedata image for the emulated game.
 +
** "suspendpoint{N}/": When a suspend-point exists, it has this dirname, where {N} starts with 1. This contains:
 +
*** "state": [[#SuspendPoint]]
 +
*** "state.png": Screenshot of the emulated game.
 +
 +
There's also TemporaryStorage savedata, which is used for storing [[#SuspendPoint]]s used with network-transfers.
 +
 +
= SuspendPoint =
 +
The SuspendPoint is stored in a mostly standard cpio archive. The cpio parser code calculates a checksum over each file by XORing each u16 in the file, then comparing it with u16 cpio_entry_header+0x8. The result is stored as a flag in the output cpio file entry structure. This checksum is only set for SuspendPoints, not RomFs data - none of the cpio parser callers currently validate the checksum flag.
 +
 +
This archive is stored in [[#SaveData]], and is also transferred over the network with online-play-friends when the user loads a suspend-point in the GUI. This is also done automatically when a network session is created, for emu-sync-state. Emu-sync-state only used with session-creation, after that the only way to trigger suspend-point usage is via the suspend-menu GUI.
 +
 +
The SuspendPoint loader code loops through the file entries, comparing the entry file extension (following '.' in the filename) with various supported extensions and handling it as needed. No files are mandatory, there are no errors thrown for missing files. The order of the files in the archive doesn't matter either. The saved files have filename ".{extension}". The following extensions are handled:
 +
* "json": Contains various emulator state, including CPU/IO registers etc. "g_nN64CpuPC" is used with the g_nN64CpuPC global var. IO regs are copied to/from global state directly, without calling any IO handler funcs.
 +
* "bin": N64 DRAM. While this is zlib compressed, in some cases it's used raw - it's unknown what exactly triggers decompression.
 +
* "sav": Savedata image for the emulated game.
 +
* "imem"
 +
* "dmem"
 +
* "cpk": Data for "Controller Pak", only exists for games which have config "SIDevice_PakType" set to "Controller Pak". The code loading this will skip it if the config wasn't set to "Controller Pak".
 +
* "gbin"
    
= Versions =
 
= Versions =