Overview
Pokémon Red/Blue uses carefully designed data structures to represent game state in memory. Understanding these structures is essential for modifying Pokémon stats, battle mechanics, and save data. All data structures are defined using RGBDSrsreset and rb/rw directives or through structure macros in macros/ram.asm.
Pokémon Data Structures
Base Stats Structure
File:constants/pokemon_data_constants.asm
Base stats define the inherent properties of each species, stored in data/pokemon/base_stats/*.asm.
Party Pokémon Structure
Size: 44 bytes (0x2C) Party Pokémon include current stats for immediate use:Box Pokémon vs Party Pokémon:
- Box Pokémon: 33 bytes (0x21) - compact storage
- Party Pokémon: 44 bytes (0x2C) - includes calculated stats for battle
Battle Pokémon Structure
Size: 44 bytes (0x2C) Used for active battle participants (wBattleMon and wEnemyMon):
Determinant Values (DVs)
DVs are stored as a 16-bit value with 4 bits per stat:Move Data Structure
Size: 6 bytes per move File:constants/battle_constants.asm
Map Data Structures
Map Header Structure
File:data/maps/maps.asm
Each map has a header defining its properties:
Map Object Structure
File:constants/map_object_constants.asm
Defines NPCs, signs, and warps:
Sprite Data Structures
Sprite State Data 1
Size: 16 bytes per sprite File:macros/ram.asm
Sprite State Data 2
Size: 16 bytes per sprite Stores map position and movement AI:Battle Data Structures
Battle Status Flags
File:constants/battle_constants.asm
Status Byte 1:
Damage Calculation
Formula:Stat Calculation
Formula:- Gained from defeating Pokémon
- Each stat has separate EXP (0-65535)
- At max (65535): adds 63 stat points at level 100
Save Data Structure
File:ram/sram.asm
Save data is stored in cartridge SRAM:
Data Structure Tables
Size Reference
| Structure | Size | Count | Total |
|---|---|---|---|
| Base Stats | 28 bytes | 190 species | 5,320 bytes |
| Party Mon | 44 bytes | 6 max | 264 bytes |
| Box Mon | 33 bytes | 20 per box | 660 bytes/box |
| Battle Mon | 44 bytes | 2 (player+enemy) | 88 bytes |
| Move Data | 6 bytes | 165 moves | 990 bytes |
| Sprite State 1 | 16 bytes | 16 sprites | 256 bytes |
| Sprite State 2 | 16 bytes | 16 sprites | 256 bytes |
Memory Alignment
Important: Many structures must be aligned to specific boundaries:
- Sprite data: 256-byte aligned (low byte = $00)
- Map data: Bank-aligned
- Graphics: Tile-aligned (16 bytes)
Usage Examples
Reading Pokémon Stats
Modifying DVs
Creating Map Objects
Best Practices
Use Structure Offsets
Always use named offsets (MON_HP, MON_LEVEL) instead of hardcoded values.
Validate Data
Check bounds and validity when reading player-controlled data.
Preserve Alignment
Be careful when modifying structure sizes - they may need specific alignment.
Document Custom Structures
If you add new structures, document the layout and purpose clearly.
Related Pages
- Constants Reference - Constant values and IDs
- Macros Reference - Structure definition macros
- Engine Modules - How structures are used