pokeemerald ships with a set of compile-time configuration flags and a bespoke toolchain for building and manipulating GBA assets. This guide covers how to enable debug output, what the config flags do, and what each tool inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pret/pokeemerald/llms.txt
Use this file to discover all available pages before exploring further.
tools/ is for.
Config flags (include/config.h)
All compile-time options live in include/config.h.
NDEBUG
NDEBUG is defined by default, which disables all AGBPrint debug features. To enable printf-style debugging, comment it out:
Debug options (only active when NDEBUG is not defined)
WhenNDEBUG is absent, two additional switches become available:
PRETTY_PRINT_HANDLER — selects the printf formatter:
| Constant | Value | Notes |
|---|---|---|
PRETTY_PRINT_MINI_PRINTF | 0 | Custom mini_printf; supports %S for preproc-encoded strings |
PRETTY_PRINT_LIBC | 1 | Standard libc printf; may fail to link with some dkp arm-libc distributions |
LOG_HANDLER — selects where debug output is sent:
| Constant | Value | Target |
|---|---|---|
LOG_HANDLER_AGB_PRINT | 0 | AGBPrint hardware debug units |
LOG_HANDLER_NOCASH_PRINT | 1 | no$gba emulator |
LOG_HANDLER_MGBA_PRINT | 2 | mGBA emulator (recommended) |
NDEBUG is undefined:
BUGFIX and UBFIX
BUGFIX to apply fixes for identified minor vanilla bugs. UBFIX is automatically defined whenever MODERN or BUGFIX is set and corrects undefined-behavior issues that could prevent compilation with newer compilers:
Locale (ENGLISH)
ENGLISH sets:
UNITS_IMPERIAL— distances and weights shown in imperial unitsCHAR_DEC_SEPARATORtoCHAR_PERIOD— period used as decimal separator
ENGLISH to switch to metric units and a comma decimal separator.
Debug printing with mGBA
Build tools (tools/)
The tools/ directory contains all first-party tooling built as part of the pokeemerald build system.
gbagfx
Converts indexed PNG graphics to GBA 4bpp/8bpp tile format and back. Used for every sprite, tileset, and font graphic in the project.
preproc
Custom C preprocessor that handles pokeemerald’s string encoding. Converts string literals with special characters into GBA-compatible byte sequences.
scaninc
Scans source files for
#include directives to generate accurate Makefile dependency lists.mid2agb
Converts Standard MIDI Files (.mid) to AGB audio format (.s) for use with the M4A sound engine.
wav2agb
Converts WAV audio samples to the GBA PCM format used by M4A instrument voices.
jsonproc
Processes JSON map layout files (produced by porymap) into binary data that is assembled into the ROM.
rsfont
Handles font file conversion for the game’s text rendering system.
bin2c
Converts arbitrary binary files to C byte arrays, useful for embedding small binary blobs in source.
ramscrgen
Generates RAM script data used for dynamically constructed scripts at runtime.
gbafix
Fixes the GBA ROM header (Nintendo logo, checksum) so the ROM is accepted by hardware and emulators.
mapjson
Converts map data between the internal binary format and JSON, enabling round-trip editing with external tools.
Recommended external tools
porymap
Visual map editor for pokeemerald and pokefirered. Edits map layouts, object events, connections, and wild encounters, and exports JSON consumed by
tools/jsonproc.poryscript
High-level scripting language that compiles to GBA script binary. Strongly recommended for new event scripts. A VS Code extension is available.
Tilemap Studio
GUI tilemap viewer and editor. Useful for inspecting and modifying tilesets and map blocks outside of porymap.
mGBA
The best GBA emulator for pokeemerald development. Supports GDB remote debugging, a memory viewer, a tile viewer, and the
LOG_HANDLER_MGBA_PRINT debug output channel.All of these tools are listed under Useful additional tools in
INSTALL.md.