Overview
The Pokémon Red/Blue disassembly uses the RGBDS (Rednex Game Boy Development System) toolchain to assemble the source code into Game Boy ROM files. The build process is controlled by a comprehensive Makefile that handles assembly, linking, graphics processing, and ROM validation.Prerequisites
Before building, you need to install:- make - Build automation tool
- gcc or clang - C compiler for building tools
- git - Version control (for cloning the repository)
- RGBDS 1.0.1 - Game Boy development toolchain
rgbasm- Assemblerrgblink- Linkerrgbfix- ROM header fixerrgbgfx- Graphics converter
The project requires RGBDS version 1.0.1 specifically. Older versions will not work, and newer versions may have compatibility issues.
Build Targets
The Makefile provides several build targets for different purposes:Main ROM Targets
Build All ROMs
Build both Pokémon Red and Blue:This creates:
pokered.gbc- Pokémon Red ROMpokeblue.gbc- Pokémon Blue ROMpokeblue_debug.gbc- Debug build of Blue
Utility Targets
tools
compare
clean
tidy
Build Process
Step-by-Step Assembly
The build system follows this workflow:Tool Compilation
Custom C tools are compiled first:
- gfx - Processes graphics files
- pkmncompress - Compresses Pokémon sprites
- scan_includes - Scans assembly dependencies
- make_patch - Generates Virtual Console patches
Dependency Scanning
The
scan_includes tool recursively scans all .asm files to build a dependency tree. This ensures files are reassembled when any included file changes.Graphics Processing
PNG images are converted to Game Boy tile formats:
.png→.2bpp(2 bits per pixel).png→.1bpp(1 bit per pixel).2bpp→.pic(compressed sprites)
Assembly
Source files are assembled with Flags explained:
rgbasm:-Q8- Set number precision to 8 bits-P includes.asm- Pre-include common definitions-D _RED- Define version constant (RED/BLUE/DEBUG)-Weverything -Wtruncation=1- Enable all warnings
Linking
Object files are linked into a ROM:Flags explained:
-d- Create map and symbol files-p 0x00- Set padding byte (0xFF for debug)-l layout.link- Use memory layout file-m- Output map file-n- Output symbol file
Object Files and Sections
The ROM is built from these main object files:audio.o- Sound effects and musichome.o- Core engine code in ROM0main.o- Main game logicmaps.o- Map data and scriptsram.o- RAM definitionstext.o- Dialogue and textgfx/pics.o- Pokémon spritesgfx/sprites.o- Trainer and NPC spritesgfx/tilesets.o- Map tilesets
Build Configuration
Version Defines
The Makefile defines constants to control version-specific code:_RED- Pokémon Red features_BLUE- Pokémon Blue features_DEBUG- Debug menu and party_RED_VC- Virtual Console Red modifications_BLUE_VC- Virtual Console Blue modifications
Using a Local RGBDS
If you have different projects requiring different RGBDS versions, you can use a local installation:RGBDS variable as a prefix for all tool commands:
Debug Symbols
To generate symbol and map files for debugging:-E flag to rgbasm, which exports all symbols to the .sym file.
The CI system always builds with
DEBUG=1 to generate symbols for the symbols branch.Graphics Processing
The build system automatically processes graphics with special rules:Standard Conversion
PNG images are converted to Game Boy tile format:Special Processing
Many graphics have custom processing flags:Battle Animations
Battle Animations
Intro Sprites
Intro Sprites
Tilesets
Tilesets
Pokémon Sprites
Pokémon Sprites
Troubleshooting
Common Build Errors
'rgbasm' not found
'rgbasm' not found
Problem: RGBDS is not installed or not in PATH.Solution: Install RGBDS 1.0.1 following the installation guide, or use
make RGBDS=/path/to/rgbds/.Version mismatch errors
Version mismatch errors
Problem: Using wrong RGBDS version.Solution: The project requires RGBDS 1.0.1 exactly. Check version with
rgbasm -V.'No rule to make target'
'No rule to make target'
Problem: Missing source files or graphics.Solution: Ensure you’ve cloned the complete repository. Re-run
git clone if necessary.SHA-1 mismatch on 'make compare'
SHA-1 mismatch on 'make compare'
Problem: Built ROM doesn’t match original.Solution: This is expected if you’ve made changes. To verify your build environment works, try on a clean clone first.
Graphics processing fails
Graphics processing fails
Problem: PNG files can’t be processed.Solution: Ensure RGBDS was built with libpng support. Reinstall RGBDS with
pkg-config and libpng-dev installed.Parallel Builds
Speed up compilation with parallel jobs:Verifying Your Build
To verify that your build matches the original releases:roms.sha1:
pokered.gbc→ea9bcae617fdf159b045185467ae58b2e4a48b9apokeblue.gbc→d7037c83e1ae5b39bde3c30787637ba1d4c48ce2pokeblue_debug.gbc→5b1456177671b79b263c614ea0e7cc9ac542e9c4
Memory Layout
Thelayout.link file defines how code and data are organized in the ROM:
- ROM0 - Fixed bank (3FFF)
- Interrupt vectors, core engine, header
- ROMX - Switchable banks (7FFF)
- Banks 1-$2C contain game logic, data, and assets
- WRAM0 - Working RAM (CFFF)
- VRAM - Video RAM (9FFF)
- SRAM - Save data (external cartridge RAM)
- HRAM - High RAM (FFFE)
Build Output
A successful build produces:- ROM files -
.gbcexecutables - Symbol files -
.symcontaining label addresses - Map files -
.mapshowing section layout - Patch files -
.patchfor Virtual Console (if built) - Graphics -
.1bpp,.2bpp,.picprocessed tiles
The symbols branch of the repository contains
.sym and .map files from the official build for reference.