07 — Into the Rift

Five dungeon floors. Thirty-five files. Three build errors.


The Design

Every loot game needs an endgame. Without one, the player hits the credits and the gear system loses its reason to exist. The Rift Zone is the answer: a post-Champion gauntlet of five dungeon floors, each harder than the last. Corrupted wild Pokémon. A boss trainer. Shard rewards that feed the crafting loop.

In the lore, it is the wound the Primal Guardians left behind. In the code, it is where gear matters most.

Cutting the Maps

FireRed’s map system wants six things from every map:

  1. Layout — dimensions, tileset references, blockdata (the actual tile grid)
  2. Map data — connections, warps, events, NPC positions
  3. Scripts — event logic in a custom assembly-like language
  4. Text — dialogue strings
  5. Encounters — wild Pokémon tables
  6. Registration — entries in layouts.json, map_groups.json, and event_scripts.s

Five maps. Thirty-five files.

Blockdata

Each map tile is a u16 value:

Bits 0-9:   Metatile ID (which 16×16 tile pattern to display)
Bits 10-11: Collision (0=passable, 1=impassable)
Bits 12-15: Elevation (for bridges, stairs, etc.)

A 20×15 map is 600 tiles — 1,200 bytes. A Python script generates cave rooms using the CeruleanCave tileset:

The Warp Chain

The five tiers connect in a straight line:

Cinnabar Island → Tier 1 (bottom) → Tier 2 (bottom) → Tier 3 (bottom)
→ Tier 4 (bottom) → Tier 5 (top exits to Cinnabar)

Each bottom warp drops to the next tier’s entrance. Tier 5’s top warp returns to Cinnabar. No backtracking. No map selection screen.

Boss Trainers

Five Rift Shades, each cut around a corruption theme:

Tier Name Theme Level Range Party
1 The Dark Caller Darkness 50-52 Houndoom, Murkrow, Sneasel
2 The Rotting One Poison/Decay 55-57 Muk, Weezing, Crobat, Vileplume
3 The Hollow Mind Ghost/Death 60-62 Gengar, Misdreavus, Dusclops, Sableye
4 The Silent Scream Psychic/Madness 65-67 Alakazam, Hypno, Mr. Mime, Gardevoir, Starmie
5 The Rift Itself Pure Corruption 70-75 Tyranitar, Gengar, Dragonite, Salamence, Metagross, Alakazam

The final Shade runs a full six Pokémon — the maximum. Its dialogue acknowledges the player:

“You carry the fire of the Guardians… but I AM the wound they left behind!”

Shard Rewards

Defeating a boss triggers shard rewards through a script-to-C bridge:

// Script:
setvar VAR_0x8000, 15
special SpecialAddGearShards
setvar VAR_0x8000, 5
special SpecialAddRadiantShards
// C:
void SpecialAddGearShards(void) {
    AddGearShards(gSpecialVar_0x8000);
}

Rewards climb with each tier:

Three Errors, Three Fixes

First build attempt: 3 errors.

Error 1: TRAINER_PIC_BOSS undefined

TRAINER_PIC_BOSS does not exist. Fixed to TRAINER_PIC_CHAMPION_RIVAL — the closest sprite to a powerful, unknown figure. Check include/constants/trainers.h for valid trainer pic IDs. Intuitive names often do not exist.

Error 2: OBJ_EVENT_GFX_PSYCHIC_M undefined

Same problem with NPC sprites. Fixed to OBJ_EVENT_GFX_GENTLEMAN. Check include/constants/event_objects.h. Available sprites are a small subset of what you would expect.

Error 3: Script labels undefined

All 10 script files — 5 scripts.inc and 5 text.inc — compiled fine on their own. The linker could not find any of their labels.

The map build system auto-generates header.inc, events.inc, and connections.inc from map.json. It does not touch scripts.inc or text.inc. Those need manual .include directives in data/event_scripts.s:

@ In data/event_scripts.s — must be added manually:
.include "data/maps/RiftZone_Tier1/scripts.inc"
.include "data/maps/RiftZone_Tier1/text.inc"
@ ... repeat for all 5 tiers

The build system handles 90% of map integration on its own. The last 10% is manual and undocumented. Worth knowing before you spend an afternoon on it.

Wild Encounters

Each tier carries 12 corruption-themed species across land, water, and fishing:

All Dark, Poison, and Ghost types. The corruption theme runs clear to the bottom floor.

What the GBA Has Left

After the Rift Zone:

The GBA is nearly full. Every new feature from here needs surgical precision about resource usage.

By the Numbers

Metric Value
Commits ~10
Copilot requests ~20
Tool executions ~186
Sub-agents 6

Next: 08 — What’s Next