Pokemon Mystery Dungeon Explorers of Sky Save Structure

From ProjectPokemon Wiki
Revision as of 12:30, 14 May 2013 by UniqueGeek (talk | contribs) (Added the essentials for overall save structure and calculating the checksum.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The save file for Pokémon Mystery Dungeon Explorers of Sky is 128KB and has three root blocks. The first two store the actual data and are 50KB large each. The third block has not been researched yet. If the checksum on one of the first two blocks is invalid, the other will be loaded. If both are invalid, the save will be deleted.

Checksum

The checksum is 4 bytes long and is at the beginning of any of the three root blocks. To calculate the checksum, split the data from 0x4 to 0xB65A into 4 byte words, add each word together and truncate the result to 32 bits. VB Code to fix the checksum for both sections, where _rawData is an array of byte containing the save file:

   Public Sub FixChecksum()
       Dim words As New List(Of UInt32)
       For count As Integer = 4 To 46682 Step 4
           words.Add(BitConverter.ToUInt32(_rawData, count))
       Next
       Dim sum As UInt64 = 0
       For Each item In words
           sum += item
       Next
       Dim buffer() As Byte = BitConverter.GetBytes(sum)
       For x As Byte = 0 To 3
           _rawData(x) = buffer(x)
           _rawData(x + &HC800) = buffer(x)
       Next
   End Sub