Savegames: Difference between revisions
No edit summary |
|||
Line 351: | Line 351: | ||
Savefiles are stored on the FLASH in a custom filesystem called SAVE. SAVE has a header which describes where the various bits of the filesystem live. | Savefiles are stored on the FLASH in a custom filesystem called SAVE. SAVE has a header which describes where the various bits of the filesystem live. | ||
* The SAVE filesystem works with a backup. There are two SAVE blocks inside the partition concatenated. | * The SAVE filesystem works with a backup. There are two SAVE blocks inside the partition concatenated. Which SAVE block is the updated one is unknown yet.. (I'm guessing from experience that (image[0x100B] & 0x20) == 0x20 --> 1st SAVE --[[User:Elisherer|Elisherer]] 01:30, 18 October 2011 (CEST)) | ||
Finding the | '''Finding the folders table:''' | ||
* If | * If DATA partition exists: At folder table exact offset from the SAVE struct (from the beginning of the struct). | ||
* Otherwise | * Otherwise: The 'folder table offset' * 'folder table media' (=0x200) from the 'filestore offset'. (usually 0 from filebase) | ||
Finding the | '''Finding the files table:''' | ||
* If the | * If DATA partition exists: At file table exact offset from the SAVE struct (from the beginning of the struct). | ||
* Otherwise | * Otherwise: The 'file table offset' * 'file table media' (=0x200) from the 'filestore offset'. | ||
'''Detemining the filestore base:''' | |||
* If DATA partition exists: At file base from the DATA's DIFI struct into the DATA partition. | |||
* Otherwise: At the 'filestore offset' from the beginning of the SAVE struct. | |||
Folder's entry structure: | |||
<pre> | <pre> | ||
struct | struct folder_entry { | ||
u32 | u32 parent_folder_index; | ||
u8 filename[0x10]; | |||
u32 folder_index; | |||
u32 unk1; | |||
u32 unk2; // flags? | |||
u32 unk3; | |||
u32 unk4; | |||
} | |||
</pre> | |||
File's entry structure: | |||
<pre> | |||
struct file_entry { | |||
u32 parent_folder_index; | |||
u8 filename[0x10]; | u8 filename[0x10]; | ||
u32 index; | u32 index; | ||
u32 unk1; // magic? | u32 unk1; // magic? | ||
u32 block_offset; | u32 block_offset; | ||
u64 file_size; | |||
u32 unk2 | u32 unk2; // flags? | ||
u32 unk3; | |||
u32 | |||
} | } | ||
</pre> | </pre> | ||
The first entry is the | The first entry is the both tables is the count of the table, the parent directory index will be the amount of table rows. The root includes the itself, so there are amount - 1 folders in the root directory. The entries that follow after the root are the actual folders/files. | ||
Reading the files out is as simple as taking the file base offset and adding (block_offset * 0x200) to it. | |||
Here's a follow-up example from the Legend of Zelda: Ocarina of Time 3D: | Here's a follow-up example from the Legend of Zelda: Ocarina of Time 3D: | ||
Line 394: | Line 412: | ||
</pre> | </pre> | ||
{| class="wikitable" | |||
|- | |||
! Start | |||
! Length | |||
! Description | |||
|- | |||
| 0x00 | |||
| 4 | |||
| Magic ("SAVE") | |||
|- | |||
| 0x04 | |||
| 4 | |||
| Magic padding | |||
|- | |||
| 0x08 | |||
| 8 | |||
| Unknown | |||
|- | |||
| 0x10 | |||
| 8 | |||
| Partition Size | |||
|- | |||
| 0x18 | |||
| 4 | |||
| Unknown | |||
|- | |||
| 0x1C | |||
| 8 | |||
| Unknown | |||
|- | |||
| 0x24 | |||
| 4 | |||
| Unknown | |||
|- | |||
| 0x28 | |||
| 8 | |||
| Unknown (First table offset) | |||
|- | |||
| 0x30 | |||
| 4 | |||
} | | Unknown (num of u32 in table) | ||
|- | |||
| 0x34 | |||
| 4 | |||
| Unknown (size of media) | |||
|- | |||
| 0x38 | |||
| 8 | |||
| Unknown (Second table offset) | |||
|- | |||
| 0x40 | |||
| 4 | |||
| Unknown (num of u32 in table) | |||
|- | |||
| 0x44 | |||
| 4 | |||
| Unknown (size of media) | |||
|- | |||
| 0x48 | |||
| 8 | |||
| Unknown (Second table offset) | |||
|- | |||
| 0x50 | |||
| 4 | |||
| Unknown (num of u32 in table) | |||
|- | |||
| 0x54 | |||
| 4 | |||
| Unknown (size of media) | |||
|- | |||
| 0x58 | |||
| 8 | |||
| File store offset (from SAVE) | |||
|- | |||
| 0x60 | |||
| 4 | |||
| File store length (medias) | |||
|- | |||
| 0x64 | |||
| 4 | |||
| File store media size | |||
|- | |||
| 0x68 | |||
| 4/8 | |||
| Folders Table offset (8 bytes in DATA) | |||
|- | |||
| 0x6C | |||
| 4 | |||
| Folders Table Length (medias) (Only in no DATA) | |||
|- | |||
| 0x70 | |||
| 4 | |||
| Folders Table unknown | |||
|- | |||
| 0x74 | |||
| 4 | |||
| Folders Table Media size | |||
|- | |||
| 0x78 | |||
| 4/8 | |||
| Files Table offset (8 bytes in DATA) | |||
|- | |||
| 0x7C | |||
| 4 | |||
| Files Table Length (medias) (Only in no DATA) | |||
|- | |||
| 0x80 | |||
| 4 | |||
| Files Table unknown | |||
|- | |||
| 0x84 | |||
| 4 | |||
| Files Table Media size | |||
|- | |||
|} | |||
=== Initialization === | === Initialization === |