Flash layout
The 32 sectors are divided into fixed-purpose regions. Sector numbers are defined ininclude/save.h.
SECTORS_COUNT = 32; NUM_SECTORS_PER_SLOT = 14.
Sector structure
Each 4 KB sector is split into a data region and a footer:include/save.h:
The game uses approximately 96% of available flash capacity.
SaveBlock1 has roughly 84 bytes of headroom and SaveBlock2 has roughly 120 bytes before you must reorganize the sector layout.Dual-slot rotation
NUM_SAVE_SLOTS = 2. Sectors 0–13 are Save Slot 1 and sectors 14–27 are Save Slot 2. On every normal save the game writes to the slot with the lower counter value. If a write is interrupted the other slot still holds a valid copy, preventing total save loss.
Save types
Save status codes
The current status is stored in
gSaveFileStatus (extern u16 gSaveFileStatus).
Key functions
Link save
For link-cable trades and the Battle Frontier,SaveBlock1 is written incrementally across multiple frames using a task: