Paper Mario stores game state in two parallel arrays inside each save slot: a packed bit array for boolean flags (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/pmret/papermario/llms.txt
Use this file to discover all available pages before exploring further.
globalFlags) and a byte array for counters and multi-state values (globalBytes). These arrays are exposed to EVT scripts through the GF (global flag) and GB (global byte) variable encoding, giving every script in the game read/write access to persistent state without going through a C API call.
Save file layout
The game supports four independent save slots. The global settings file (SaveGlobals) is separate and holds data shared across all slots — sound mode, the most recently selected file, and the language setting on PAL versions.
SaveData record begins with the magic string "Mario Story 006" and two 32-bit CRC fields used to detect corruption. The fio_load_game / fio_save_game / fio_erase_game functions in src/fio.h are the only callers that read or write raw save data directly.
Global flags (GF_)
Global flags are single-bit boolean values stored in the globalFlags[64] field of SaveData — 64 words of 32 bits each, giving 2,048 addressable bits. In practice only indices up to 0x7FF are used.
Each flag is named in include/saved_flag_names.h inside the GameFlags enum:
Naming convention
GF_<area>_<event> where:
GF_identifies a global (saved) flag, as opposed to a localLF_(local flag) or area-scopedAF_.<area>is the four-letter map area code — for exampleKMR(Koopa Meadows),TRD(Koopa Fortress),MAC(Toad Town),KKJ(Bowser’s Castle). Flags not tied to a single area useEVT,NPC, orBTL.<event>is a PascalCase description —Met_Goombario,Item_ShootingStar,Defeated_KoopaBros.
GF_Unused_<area>_<hex>.
Example: chapter-start flags
Global bytes (GB_)
Global bytes are 8-bit values stored in globalBytes[512] inside SaveData. Each byte can hold a value from 0 to 255. They are used for counters, multi-state machines, and any value that needs more than two states.
Each byte is named in include/saved_byte_names.h inside the GameBytes enum:
Naming convention
GB_<area>_<description> — the same area-code convention as flags, but with a GB_ prefix. Unused slots are GB_Unused_<area>_<hex>.
Notable bytes
| Constant | Index | Description |
|---|---|---|
GB_StoryProgress | 0x000 | Current chapter checkpoint; maps directly to the StoryProgress enum |
GB_KMR20_MarioReadDiaryFlags_00 | 0x00C | Tracks which diary pages Mario has read |
GB_MAC01_Merlon_SpinJumpCount | 0x01B | Number of spin jumps performed for Merlon’s tutorial |
GB_MAC00_DojoRank | 0x01C | Player’s rank at the Toad Town Dojo (0–4) |
GB_MAC03_LilOinkCount | 0x01D | Number of Lil’ Oinks in the pen |
GB_MAC01_Rowf_NumBadges | 0x02C | How many badges Rowf has unlocked |
GB_TIK15_RipCheato_PurchaseCount | 0x038 | Items bought from Rip Cheato |
GB_IWA00_Whacka_HitCount | 0x07B | Number of times Whacka has been struck |
GB_KKJ_CaughtCount | 0x04F | How many times Peach has been caught per mission |
GB_OMO_TrainDestination | 0x0D7 | Current Shy Guy’s Toy Box train route destination |
GB_CompletedQuizzes | 0x160 | Total Chuck Quizmo quizzes answered correctly |
GB_FinalBowserHP | 0x18A | Bowser’s HP carried from Phase 1 into Phase 2 |
GB_WorldLocation | 0x1A9 | Encodes Mario’s current world-map position |
Using GF and GB in EVT scripts
Inside an EVT script, you reference a global flag or byte by passing its enum value as an argument to the appropriate script command. The EVT interpreter decodes the encoded integer at runtime — you never dereference it yourself.GameFlag(INDEX) and GameByte(INDEX) are macros that subtract large offsets from the index so that the result falls in a special negative range. The EVT runtime identifies the variable type from that range. Passing a raw index like 0x001 instead of GF_StartedChapter1 will not work — always use the named enum constant.Area flags and area bytes
In addition to global flags and bytes, each save slot stores a smaller set of area-scoped values that are cleared whenever you enter a new world area:areaFlags[8]— 256 bits of area-local boolean flags, accessed withAreaFlag(INDEX)/AF_names.areaBytes[16]— 16 bytes of area-local state, accessed withAreaByte(INDEX).
Save file I/O functions
The C API for reading and writing save data is declared insrc/fio.h:
0–3), corresponding to the four save files shown on the file-select screen.
