Skip to main content

Overview

Constants in the Pokémon Red/Blue disassembly provide symbolic names for game data, making the code more readable and maintainable. All constant definitions are located in constants/*.asm files. The disassembly uses the const_def macro system to automatically enumerate sequential values, reducing errors and making it easy to add or remove entries.

How Constants Work

Constants are defined using RGBDS assembler syntax with helper macros:
; Start enumeration at 0
const_def
const NO_MON         ; $00
const RHYDON         ; $01
const KANGASKHAN     ; $02

; Start enumeration at a specific value
const_def 1
const STAT_HEALTH    ; $01
const STAT_ATTACK    ; $02
The const_def macro initializes a counter, and each const increments it automatically.

Pokémon IDs

File: constants/pokemon_constants.asmPokémon IDs index multiple data tables including names, evolutions, moves, cries, and Pokédex entries.
const_def
const NO_MON             ; $00
const RHYDON             ; $01
const KANGASKHAN         ; $02
const NIDORAN_M          ; $03
const CLEFAIRY           ; $04
const SPEAROW            ; $05
const VOLTORB            ; $06
Special Constants:
DEF NUM_POKEMON_INDEXES EQU const_value - 1

; Starter Pokémon
DEF STARTER1 EQU CHARMANDER
DEF STARTER2 EQU SQUIRTLE
DEF STARTER3 EQU BULBASAUR

; Ghost Marowak in Pokémon Tower
DEF RESTLESS_SOUL EQU MAROWAK
Pokémon IDs in Red/Blue are in internal order, not Pokédex order. For example, Rhydon is 01whileBulbasauris01 while Bulbasaur is 99.

Usage Examples

Checking Pokémon Species

ld a, [wCurSpecies]
cp PIKACHU
jr z, .isPikachu

Adding Item to Bag

ld hl, wNumBagItems
ld a, MASTER_BALL
ld [wcf91], a
ld a, 1  ; quantity
ld [wItemQuantity], a
call AddItemToInventory

Teaching a Move

ld a, THUNDERBOLT
ld [wMoveNum], a
ld [wcf91], a
call IsTMHMMove

Map Warps

ld a, OAKS_LAB
ld [wDestinationMap], a
call LoadMapData

Common Patterns

const_skip

Skips values in the enumeration (used for unused or reserved slots):
const TANGELA            ; $1E
const_skip               ; $1F
const_skip               ; $20
const GROWLITHE          ; $21

const_next

Jumps to a specific value (cannot go backwards):
const_next $C4
add_hm CUT               ; $C4

shift_const

Creates bit flag constants:
const_def
shift_const FLAG_BIT_0   ; 1 << 0 = $01
shift_const FLAG_BIT_1   ; 1 << 1 = $02
shift_const FLAG_BIT_2   ; 1 << 2 = $04

Reference Tables

Key Constant Files

FilePurposeCount
pokemon_constants.asmPokémon species IDs190
item_constants.asmItems, TMs, HMs250+
move_constants.asmMove IDs165
map_constants.asmMap IDs248
type_constants.asmType IDs16
battle_constants.asmBattle mechanicsMany
sprite_constants.asmSprite IDs100+
event_constants.asmEvent flagsMany
text_constants.asmText IDs500+

Exported Constants

DEF NUM_POKEMON_INDEXES EQU 190
DEF NUM_ITEMS EQU 83
DEF NUM_TMS EQU 50
DEF NUM_HMS EQU 5
DEF NUM_TM_HM EQU 55
DEF NUM_ATTACKS EQU 165
DEF NUM_MAPS EQU 248
DEF NUM_TYPES EQU 26

Best Practices

Use Symbolic Names

Always use constant names instead of hardcoded numbers for better readability and maintainability.

Check const_value

Use const_value to get the current enumeration value for array sizing and validation.

Document Skips

Add comments explaining why values are skipped with const_skip.

Group Related Constants

Keep related constants in the same file and section for easy reference.

Build docs developers (and LLMs) love