PocketJS AOT turns TypeScript and JSX source files into real GBADocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pocket-stack/pocketjs/llms.txt
Use this file to discover all available pages before exploring further.
.gba ROMs — no JavaScript engine ships on the cartridge. This guide walks through the prerequisites, the demo entry point, the compile command, and a minimal example of the authoring DSL so you can see the full pipeline end-to-end.
Prerequisites
The compiler, asset pipeline, and test suite all run under Bun. Bun is the only Node-compatible prerequisite needed to author and compile a game.
Linking the C runtime to produce a
.gba ROM requires arm-none-eabi-gcc and arm-none-eabi-objcopy. On macOS with Homebrew:If you only want the compiler output (the
.pjgb cartridge blob and the .ir.json/.debug.json metadata files) and do not need a runnable ROM, pass --no-rom to the build command and skip this step.mGBA plays
.gba ROMs produced by the AOT compiler. The headless E2E test suite also requires libmgba when running bun run test. A standard mGBA desktop install is sufficient for playing the ROM interactively.The compiler encodes the PJGB format from
aot/spec/pjgb.ts. The C runtime decodes it via a generated header. Regenerate runtime/pjgb_gen.h whenever the spec changes:The demo entry point
The demo game lives ataot/demo/game.tsx. It is a Pokémon-style overworld vertical slice with two maps (Littleroot Town and Route 101), NPCs with full dialogue trees, a choice menu, a battle→flag→item reward sequence, and a warp between maps. Reading it gives a complete picture of the authoring DSL.
Here is the essential shape of a minimal game file:
Build the demo
Run the full build from the repository root. Thebun run build script first refreshes the image generation assets (the GBA 4bpp sprite sheets), then invokes the compiler:
What the compiler produces
Thedist/ directory receives four output files:
| File | Description |
|---|---|
pocket-town.gba | The linked GBA ROM — load this in mGBA or on hardware. |
pocket-town.pjgb | The raw PJGB cartridge blob (without the ARM runtime). |
pocket-town.ir.json | Human-readable IR snapshot: maps, actors, warps, scripts, flags, texts. |
pocket-town.debug.json | Debug symbol map for the mGBA E2E test harness: flag addresses, map indices, text ids. |
Compile flags
| Flag | Description |
|---|---|
--out <file.gba> | Output path for the .gba ROM. Defaults to aot/dist/pocket-town.gba. Companion files (.pjgb, .ir.json, .debug.json) use the same base name. |
--no-rom | Skip the ARM cross-compiler step. Emits only .pjgb, .ir.json, and .debug.json. Useful if arm-none-eabi-gcc is not installed. |
Play the ROM
Open the compiled ROM in mGBA:aot/ directory:
Run the E2E test suite
The headless test suite runs the ROM in libmgBA, feeds it scripted input sequences, and asserts game state via the EWRAM debug block. Build the test harness once (requireslibmgba), then run:
What comes next
With the demo compiling and running, the natural next steps are:- Authoring — learn the full DSL surface: tile maps, entity prefabs, dialogue, choices, flags, warps, and residual scripts.
- Compiler — understand each pipeline stage and what the compiler validates.
- Cartridge Format — the PJGB binary layout and how the runtime reads each section.