Format:Pokémon Generation 3 save file
| On this wiki | Facts · Code · Notes · Topics |
|---|
Save file of Pokémon Ruby, Sapphire, Emerald, FireRed and LeafGreen (GBA flash, 128 KiB .sav): two rotating save slots of 14 sectors of 0x1000 bytes, each sector with a footer (section id, checksum, signature 0x08012025, save counter), plus Hall of Fame and extra sectors.
The battery/flash save of the Generation 3 Pokémon games on Platform:Game Boy Advance (Ruby, Sapphire, Emerald, FireRed, LeafGreen). Layouts below come from Tool:PKHeX (SAV3.cs) and the Software:Pokémon Emerald decompilation (include/save.h, src/save.c; names and numbers only). The structure is shared by all five games; only the size and content of the three data objects differ.
Overview
- The decompilation counts 32 sectors of 0x1000 bytes: sectors 0-13 are save slot A, 14-27 are save slot B, then Hall of Fame (28-29), Trainer Hill (30, Emerald) and a recorded battle (31). PKHeX calls the area from 0x1C000 on "extra data" (Hall of Fame twice, e-Reader data, a final block).
- The game alternates between the two slots on each save and, inside a slot, rotates which physical sector holds which section, so the same flash page is not rewritten every time. A reader must therefore locate sections by the id in each footer, never by position.
- Of every 0x1000-byte sector only the first 0xF80 (3968) bytes carry data; the last 0x80 are the footer, of which only the final 12 bytes are used.
| Offset in sector | Size | Field |
|---|---|---|
| 0xF80-0xFF3 | 116 bytes | unused |
| 0xFF4 | u16 | section id (0-13 in a slot) |
| 0xFF6 | u16 | checksum of the data bytes |
| 0xFF8 | u32 | signature 0x08012025 (bytes 25 20 01 08)
|
| 0xFFC | u32 | save counter (same value in all sectors of one save) |
The checksum adds the data as little-endian u32 words and folds the sum: (sum >> 16) + sum, truncated to 16 bits. PKHeX sums all 0xF80 bytes of every sector; the decompilation sums only the real size of each section. Both agree because the unused tail is zero. Details and a test vector: Fact:Pokémon Generation 3 save file/behavior/Gen 3 sector checksum.
Sections and objects
Section ids 0-13 belong to three logical objects that the game cuts into sector-sized pieces:
- id 0: the small object (trainer info, options, Pokédex), SaveBlock2 in the decompilation. PKHeX lists its used size as 0x890 (Ruby/Sapphire), 0xF24 (FireRed/LeafGreen), 0xF2C (Emerald).
- ids 1-4: the large object (SaveBlock1: party, bag, flags, map state), 4 sectors; the last piece holds 0xC40 (Ruby/Sapphire), 0xEE8 (FireRed/LeafGreen) or 0xF08 (Emerald) bytes.
- ids 5-13: the PC storage (9 sectors, 0x83D0 bytes in use): 14 boxes of 30 Pokémon in the 80-byte form of Format:PK3.
Ids: Fact:Pokémon Generation 3 save file/enum/Gen 3 save section ids.
Choosing the active slot
PKHeX accepts a slot only if all 14 ids 0-13 are present in it, then takes the slot whose sector-0 footer has the higher save counter; equal counters mean slot A. The decompilation writes slot counter % 2 and increments the counter on each save.
Code & repositories
- https://github.com/kwsch/PKHeX @
641c26ba100225f3605e5a44b61b3b16e15a3774· license: GPL-3.0 (declared by the contributor; GitHub's detector did not recognize LICENSE)
Pokémon save and entity editor; PKHeX.Core is the reference for save sectors, checksums and PK3-PK9 encryption (PokeCrypto.cs, SAV3.cs, PK3.cs, SAV1.cs, SAV2.cs).
Tested on: source read, not run: source read, not run · checked 2026-10-18 - https://github.com/pret/pokeemerald @
731ad5bfd6e6f265508d0efcca0ba42f9dcf5881· license: unknown
Matching decompilation of Pokemon Emerald; include/save.h and src/save.c give the sector size, footer fields, signature and section ids (names and numbers only, no license).
Tested on: source read, not run: source read, not run · checked 2026-10-18
Pitfalls
- Hall of Fame and the later sectors have their own checksum; PKHeX stores it at 0xFF4 of those sectors (not at 0xFF6 as in the main sectors) and skips sectors that are entirely 0x00 or 0xFF.
- Emulator and flash-cart saves are sometimes only 64 KiB (one slot); PKHeX flags such files as misconfigured size.
- The Japanese games use 5-character names, the others 7; PKHeX detects a Japanese save when the u16 at offset 6 of the small object is zero.
See also
Format:PK3 (Pokémon inside the saves), Format:Pokémon Generation 1 and 2 save files, Format:PK4 and PK5, Format:PK8, PA8 and PK9. Bulbapedia has a long save-structure article (CC BY-NC-SA; not copied here).
Unverified: the 0x20000 total (32 x 0x1000) and the 116-byte unused range come from reading SECTORS_COUNT and the SaveSector struct, not from dumping a real file; the pokefirered and pokeruby decompilations were not read, so the FireRed/LeafGreen and Ruby/Sapphire sizes rest on PKHeX's comments alone.