Save data structure (Generation IV): Difference between revisions

From Bulbapedia, the community-driven Pokémon encyclopedia.
Jump to navigationJump to search
No edit summary
mNo edit summary
Line 5: Line 5:
The last 0x14 Bytes of each block small and big are used as a footer, with the following structure:
The last 0x14 Bytes of each block small and big are used as a footer, with the following structure:


*0x00 - 0x03: Used to connect small block with big block
*0x00 - 0x03: Used to connect a small block with a big block
*0x04 - 0x07: Number of the Save
*0x04 - 0x07: Number of the Save
*0x08 - 0x0B: size of block
*0x08 - 0x0B: Size of the block
*0x0C - 0x0F: K
*0x0C - 0x0F: K
*0x10 - 0x11: T
*0x10 - 0x11: T
*0x12 - 0x13: Checksum of the Block
*0x12 - 0x13: Checksum of the block


So let's say we have the following save block footers:
So let's say we have the following save block footers:

Revision as of 14:25, 9 January 2009

A Pokémon Diamond, Pearl, or Platinum .SAV file is broken up into two pairs of blocks... each pair has one small block, and one big block. The first small block starts at 0x00000 and ends at 0x0C0FF; the first big block starts at 0x0C100 and ends at 0x1E2E0. The second pair of blocks are at the same address plus 0x40000.

One block pair is always a backup of the other block pair.

The last 0x14 Bytes of each block small and big are used as a footer, with the following structure:

  • 0x00 - 0x03: Used to connect a small block with a big block
  • 0x04 - 0x07: Number of the Save
  • 0x08 - 0x0B: Size of the block
  • 0x0C - 0x0F: K
  • 0x10 - 0x11: T
  • 0x12 - 0x13: Checksum of the block

So let's say we have the following save block footers:


SMALL BLOCK 1

|D1 01 00 00| |42 04 00 00| 00 C1 00 00 23 06 06 20 00 00 7E 7A

BIG BLOCK 1

|D0 01 00 00| F1 02 00 00 E0 21 01 00 23 06 06 20 01 00 0D 39


SMALL BLOCK 2

|D0 01 00 00| |41 04 00 00| 00 C1 00 00 23 06 06 20 00 00 0C 7F

BIG BLOCK 2

|D1 01 00 00| F2 02 00 00 E0 21 01 00 23 06 06 20 01 00 F6 8A


Since the value of 0x0C0F0 - 0x0C0F3 is higher in small block 1 (42 04 00 00 > 41 04 00 00), we would use that as the current small block. Then, we match the value of 0x0C0EC - 0x0C0EF (which is D1 01 00 00) to our big block... meaning the current big block is actually big block 2 (assuming the big block's checksum is correct).