Save data structure (Generation IV): Difference between revisions

Item placeholders offsets
(I don't claim to be an expert on this)
(Item placeholders offsets)
Line 5: Line 5:
In Diamond and Pearl, the first small block starts at 0x00000 and ends at 0x0C0FF, the first big block starts at 0x0C100 and ends at 0x1E2DF. In Platinum, the first small block starts at 0x00000 and ends at 0x0CF2B, the first big block starts at 0x0CF2C and ends at 0x1F10F. The second pair of blocks are at the same address plus 0x40000 for all the three games.
In Diamond and Pearl, the first small block starts at 0x00000 and ends at 0x0C0FF, the first big block starts at 0x0C100 and ends at 0x1E2DF. In Platinum, the first small block starts at 0x00000 and ends at 0x0CF2B, the first big block starts at 0x0CF2C and ends at 0x1F10F. The second pair of blocks are at the same address plus 0x40000 for all the three games.


One block pair is always a backup of the other block pair.
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:
== Small block ==
The small block has the following data:
{| border="1" style="border: 1px solid #999; border-collapse: collapse;"
|- style="background: #ccc;" align="center"
! Offset
! Contents
|- style="background: #eee;" align="center"
| 0x00630 - 0x008C3
| Items placeholder
|- style="background: #ddd;" align="center"
| 0x008C4 - 0x0098B
| Key Items placeholder
|- style="background: #eee;" align="center"
| 0x0098C - 0x00B4B
| TMs & HMs placeholder
|- style="background: #ddd;" align="center"
| 0x00B4C - 0x00BEB
| Medicines placeholder
|- style="background: #eee;" align="center"
| 0x00BDC - 0x00CEB
| Berries placeholder
|- style="background: #ddd;" align="center"
| 0x00CEC - 0x00D27
| Poké Balls placeholder
|- style="background: #eee;" align="center"
| 0x00D28 - 0x00D5B
| Battle Items placeholder
|- style="background: #ddd;" align="center"
| 0x00D5C - 0x00D8B
| Mail placeholder
|- style="background: #eee;" align="center"
| 0x0CF18 - 0x0CF2B
| Footer
|}
 
=== Item placeholders ===
In these placeholders, each item takes 4 bytes with the following structure:
{| border="1" style="border: 1px solid #999; border-collapse: collapse;"
|- style="background: #ccc;" align="center"
! Offset
! Contents
|- style="background: #eee;" align="center"
| 0x00 - 0x01
| Item id
|- style="background: #ddd;" align="center"
| 0x02 - 0x03
| Item amount
|}
Each item has an unique id to get identified. See the [[list of items by index number (DS)]] for these ids.


== Footer ==
The last 0x14 bytes of each block (small and big) are used as a footer. It has the following structure:
{| border="1" style="border: 1px solid #999; border-collapse: collapse;"
{| border="1" style="border: 1px solid #999; border-collapse: collapse;"
|- style="background: #ccc;" align="center"
|- style="background: #ccc;" align="center"
Line 14: Line 64:
! Contents
! Contents
|- style="background: #eee;" align="center"
|- style="background: #eee;" align="center"
| 0x00-0x03  
| 0x00 - 0x03  
| Used to connect a small block with a big block
| Used to connect a small block with a big block
|- style="background: #ddd;" align="center"
|- style="background: #ddd;" align="center"
| 0x04-0x07  
| 0x04 - 0x07  
| Number of the save
| Number of the save
|- style="background: #eee;" align="center"
|- style="background: #eee;" align="center"
| 0x08-0x0B
| 0x08 - 0x0B
| Size of the block
| Size of the block
|- style="background: #ddd;" align="center"
|- style="background: #ddd;" align="center"
| 0x0C-0x0F  
| 0x0C - 0x0F  
| K
| K
|- style="background: #eee;" align="center"
|- style="background: #eee;" align="center"
| 0x10-0x11
| 0x10 - 0x11
| T
| T
|- style="background: #ddd;" align="center"
|- style="background: #ddd;" align="center"
| 0x12-0x13
| 0x12 - 0x13
| Checksum of the block
| Checksum of the block
|}
|}


The game uses a [[wp:Cyclic redundancy check|CRC-16-CCITT]] algorithm for the checksums. These checksums are calculated from a whole block without taking the footer.
=== Checksum ===
The game uses a {{wp|Cyclic redundancy check|CRC-16-CCITT}} algorithm for the checksums. These checksums are calculated from a whole block without taking the footer.


== Example ==
=== Example ===
  SMALL BLOCK 1
  SMALL BLOCK 1
  D1 01 00 00 | 42 04 00 00 | 00 C1 00 00 | 23 06 06 20 | 00 00 | 7E 7A
  D1 01 00 00 | 42 04 00 00 | 00 C1 00 00 | 23 06 06 20 | 00 00 | 7E 7A
68

edits