This repository is a complete, annotated disassembly of the original Game Boy Pokémon Red and Blue games. It faithfully reproduces the exact ROM images (verified by SHA1 hashes) using the RGBDS assembler toolchain. The codebase is organized into modular subsystems: engine (battle, overworld, events, items, menus), data (maps, Pokémon stats, moves, items, trainers, wild encounters), audio (music and SFX with a macro-based composition language), graphics (sprites, tilesets, fonts), and scripts (map-specific event scripts). It includes custom C tools for graphics optimization, compression, and Virtual Console patch generation. The architecture is a monolithic ROM image with bank switching, using a predef dispatch system for cross-bank calls. Key entry points include the game start routine in home/start.asm and the VBlank handler in home/vblank.asm. This is a high-quality reverse engineering project with extensive comments, consistent coding patterns, and a robust build system, making it an invaluable resource for ROM hacking, retro game development, and studying Game Boy internals.
pret/pokeruby is a reverse-engineering project that reconstructs the complete source code of Pokémon Ruby and Sapphire (Game Boy Advance) in C and ARM assembly. The build system compiles the entire game into byte-identical .gba ROMs, verified by pinned SHA1 checksums across a matrix of variants: Ruby/Sapphire, revisions 0/1/2, German localization, debug builds, and a modern-toolchain mode. The repository is the actual working source of the game engine, not documentation: it contains the battle system (turn logic, AI, animations via sprite templates and affine transforms), overworld/field state machines (weather, poison, cut, evolving, day care), Pokémon storage and save/load serialization, contest/link multiplayer subsystems, and the m4a sound driver, all written directly against GBA hardware registers and ARM7TDMI constraints. The architecture is a monolithic single-binary ROM rather than a service or library. Entry points are AgbMain() and the CB2_* main-loop callback system; game systems are orchestrated by a 16-slot task scheduler and a sprite/OAM manager. The build is driven by a sophisticated Makefile that feeds custom C++ asset pipelines — gbagfx (PNG↔GBA tile conversion, Huffman compression), preproc (charmap string embedding, INCBIN expansion), scaninc (include/incbin dependency resolution), mid2agb and wav2agb (MIDI/WAV to m4a data), mapjson/jsonproc (map JSON to assembly) — which generate C arrays and assembly that the hand-written sources consume. Data flows are: raw asset → tool → generated C/asm table → compile/link → .gba ROM → SHA1 comparison against the retail cartridge dump. Because this is a decompilation, the code carries inherent artifacts: sub_* function names, NONMATCHING stubs with NAKED asm fallbacks, unused/unreferenced data, and known UB comments. However, the project is professionally maintained with CI, organized headers, careful localization branching, and a clean separation between game code and build tooling. The tools/ directory is the most reusable asset — each utility is standalone and portable to any GBA homebrew or decomp effort — followed by small hardware-abstraction layers like include/gba/macro.h and src/trig.c.