# mgba: mGBA fetched and built behind the family's two mGBA tools (mgba-tools 0.1.0) mGBA (Jeffrey Pfau and contributors) run as a closed-box detector through two programs of ours, both built against mGBA at one pin (`CHANGELOG.md`): - **`gba`**: `mgba_driver`, a minimal headless driver for mGBA's core: it loads a ROM (and the BIOS, if given), holds keys over frame ranges, prints the lines the ROM writes through mGBA's debug port, chosen registers and words, and saves the last frame and the save memory. It is linked against `libmgba.a` (built with `mgba-headless`, Lua scripting on) and Lua 5.4.7. For gba-python (`scripts/referee_run.py`, `scripts/judge_text.py`) and arm7tdmi-python's `thumb_undefined` test. - **`arm-disasm`**: `mgba_disasm`, mGBA's ARM and Thumb decoder behind a small driver that reads requests (`A word address`, `T halfword address`, `P first second address`) on standard input and prints one line of mGBA's disassembly for each. For arm7tdmi-python's `scripts/disasm_judge.py`. Gathered here on 2026-11-25 (decisions page T3) from the two MIT repositories, which kept mGBA's source, Lua, both drivers and the builds: gba-python's `scripts/mgba_driver.c` and arm7tdmi-python's `referees/mgba/` are now `mgba_driver/` and `mgba_disasm/` here. The programs run as separate executables with their own command lines; they do not write the shared contract's manifest yet (`build.py` has the contract's `--version` and exit codes). ## Paths | Path under `$EMU_TOOLS_GPL` | What | | --- | --- | | `tools/mgba/build.py` | fetches mGBA at the pin (GitHub's archive of the commit) and Lua 5.4.7 (its release tarball, SHA-256 checked) into `upstream/` and builds: `python3 -I build.py --machine gba` or `--machine arm-disasm`; `JOBS` sets make's and Ninja's jobs (2 by default) | | `tools/mgba/build/gba/mgba_driver` | the GBA driver (git-ignored): `mgba_driver ROM [--bios BIOS] --frames N [--reg NAME] [--png FILE] [--sram FILE] ...` (gba-python's `referee_run.py` shows every option) | | `tools/mgba/build/gba/mgba-headless` | mGBA's own headless runner, built on the way (not used by the consumers today) | | `tools/mgba/build/arm-disasm/mgba_disasm` | the disassembler (git-ignored) | | `tools/mgba/build//build-info.json` | the pins and options of that build | | `tools/mgba/tests/smoke.py` | the smoke test | ## The builds Each keeps its consumer's options, so it is the program the consumer built before: - `gba` (from gba-python's `build_referees.py`): Lua with `make linux MYCFLAGS=-fPIC`; mGBA with CMake and Ninja, Release, `BUILD_HEADLESS BUILD_STATIC ENABLE_SCRIPTING USE_PNG USE_ZLIB` on and Qt, SDL, OpenGL, GLES, FFmpeg, editline, minizip, libzip, SQLite, ELF, json-c, FreeType, LZMA, Discord RPC, epoxy, the GDB stub and the shared library off, `USE_LUA=5.4` with our Lua; then `cc -O2 -flto=auto` with the defines mGBA's `core.c` was compiled with (read from `build.ninja`: `struct mCore`'s layout depends on them), linked with `libmgba.a`, `liblua.a`, libpng, zlib, libm, pthreads and libdl. - `arm-disasm` (from arm7tdmi-python's `build_referees.py`): `gcc -O1 -std=gnu11 -DENABLE_DEBUGGERS -DHAVE_STRLCPY` of `mgba_disasm.c` with mGBA's `src/arm/decoder.c`, `decoder-arm.c` and `decoder-thumb.c`, the stand-in header first on the include path. A build already present is kept; nothing is deleted. A half-fetched tree stops `build.py` until it is moved aside. ## What it measures mGBA's pictures, registers, debug-port text and save memory for test ROMs, and mGBA's disassembly of ARM and Thumb words. **Every output is OBSERVED** (mGBA at the pin): an emulator observed as a closed box, never a hardware fact; any document or hardware measurement overrules it. ## Upstream, licence and pin - **mGBA**, , **MPL-2.0** (file-level copyleft), pinned at `fd9dc5c2cbf234365068855851107e762fc6211b` (2026-10-18). Checked against `emulator-lineage/docs/sources.md` (closed box only). MPL-2.0 code may sit in this GPL-3.0-or-later repository through its secondary-licence clause (`../../README.md`). - **Lua 5.4.7**, , **MIT**, the release tarball with SHA-256 `9fbf5e28ef86c69858f6d3d34eccc32e911c1a28b4120ff3e84aaa70cfbf1e30`; fetched only to build mGBA with scripting. - **Our files:** `mgba_driver/mgba_driver.c` is **MIT** (alewman; owner's decision of 2026-11-20 in gba-python: mGBA's file-level copyleft leaves our own file free); it keeps that licence here. `mgba_disasm/` is **MPL-2.0** (alewman; it re-declares one mGBA prototype). `build.py` is GPL-3.0-or-later here, its steps first published under MIT in gba-python and arm7tdmi-python (`../../notices/MIT-emulator-family.txt`). - Neither upstream is committed here. If a built program is ever shared, mGBA's source at the pin (and Lua's, for `gba`), the driver and this folder go with it.