GBA graphics overview
The GBA renders graphics using 8×8 pixel tiles stored in VRAM. Each tile uses either 4 bits per pixel (16-color palette) or 8 bits per pixel (256-color palette). The hardware composites up to four background layers and 128 sprites per frame.All source artwork must be indexed-color PNG files. The
tools/gbagfx tool converts them to the packed tile formats the GBA hardware expects.Sprite sheets
Sprite sheets live undergraphics/ as indexed PNG files. The Makefile converts them automatically using rules defined in graphics_file_rules.mk and spritesheet_rules.mk.
1
Create or edit the PNG
Export a power-of-two indexed PNG from your image editor. Ensure the color count matches the target palette depth (16 or 256 colors).
2
Check the conversion rule
Open
graphics_file_rules.mk or spritesheet_rules.mk to verify the rule for your target file. Rules look like:3
Run make
tools/gbagfx will convert the PNG to the appropriate 4bpp or 8bpp tile format.Tilesets
Each map uses two tilesets: a primary tileset shared across a region and a secondary tileset specific to an area. Tileset definitions are indata/tilesets/.
Primary tileset
Primary tileset
Contains tiles common to an entire region (e.g. grass, water, paths). Loaded once when entering a region and shared by all maps using the same primary.
Secondary tileset
Secondary tileset
Contains tiles unique to a specific map or area. Loaded in addition to the primary tileset when a map is entered.
tools/jsonproc via rules in json_data_rules.mk. The resulting binary is assembled into the ROM.
Build tools — graphics
gbagfx
Converts indexed PNG files to GBA 4bpp/8bpp tile format and back. The primary graphics conversion tool for all sprites and tilesets.
rsfont
Processes font files used by the game’s text engine. Converts font sheets to the internal format.
bin2c
Converts arbitrary binary files into C byte arrays for embedding data directly in source.
jsonproc
Processes JSON map layout data (from porymap or hand-edited files) into binary data assembled into the ROM.
gbagfx usage
M4A audio engine
The M4A engine (also called mp2k or Sappy) is the standard GBA audio driver used in nearly all first-party GBA titles. pokeemerald’s implementation lives in:Song data pipeline
1
Write or obtain a MIDI file
MIDI source files live in
sound/songs/midi/. Compose or edit using any standard MIDI sequencer. The M4A sequencer supports a subset of MIDI events.2
Convert MIDI to AGB format
3
Convert WAV samples
Instrument samples are stored as GBA-compatible PCM. Convert a WAV file with:
4
Register the song
Add the song constant to Then reference the assembled data in
include/constants/songs.h:data/sound_data.s.Sound data assembly
data/sound_data.s is the central file that assembles all song and sample data into the ROM. It #includes the .s output files produced by mid2agb and wav2agb.
Game-level sound API
src/sound.c exposes the functions used throughout the game:
Song numbers are the constants defined in
include/constants/songs.h.