# galaga-remix A fork of [emu-galaga](https://github.com/alewman/emu-galaga) for new interpretations of Galaga: a new renderer drawn from the game's RAM (neon, particles, explosions), then changes to the game itself (new dive patterns), with the unmodified board as the reference that every change is measured against. Forked 2026-09-28 at `6ede087`; the git remote `upstream` is the original. Work so far: - [docs/ram-map.md](docs/ram-map.md): what the game keeps where, measured on the board and cross-checked with the community disassembly. - `galaga-probe` (`src/bin/galaga-probe.rs`): plays the board with a random player and records every frame's RAM plus an access profile (which PC touches which byte, `src/galaga/profile.rs`); `tools/probe_data.py` loads the capture. - `galaga::objects` (`src/galaga/objects.rs`): the 64 object slots as screen-space boxes with the game's state byte, the interface a renderer reads; `tests/objects.rs` pins it to the video pipeline. - Input movies and a tool-assisted player ([docs/movies.md](docs/movies.md)): `galaga-tas` searches for a run that never loses a life (checkpoints, candidate futures, rewinds), `galaga-movie` replays one and renders it to video, and the page replays one with `?movie=`. `movies/tas-seed1.json` reaches stage 29 in 20 minutes without losing a life. - The neon look ([docs/neon.md](docs/neon.md)): the game drawn again in WebGL2 from its own layers, with glow, particle explosions, trails, screen shake and optional flight paths. Settings → Look, or **N**; **T** for flight paths. `tests/layers.rs` proves the layers are the arcade picture. - Flight paths as text and path mods ([docs/paths.md](docs/paths.md)): `galaga-paths` lists every enemy flight path as readable ops, the text reassembles to the ROM's exact bytes, and mods in `mods/` lay new paths over the sub CPU (`bee-figure-eight`; `remix-dives`, which picks bee and butterfly dives at random through the `random_jump` interpreter extension; `remix`, which adds new entrance choreography). Play one with `?mod=mods/remix.paths`; `galaga-pathshot` draws a stretch of play's flights for designing them. Everything below is the upstream README, still true of the board here. --- ## emu-galaga The 1981 Namco Galaga arcade board in the browser, for players, at **https://emu.supertux.com**. Three certified Z80 cores ([z80-rust-fast](https://github.com/alewman/z80-rust-fast), unchanged, by commit), a board written in Rust from the hardware documents in `docs/` and checked against MAME frame by frame, compiled to WebAssembly, behind a page that is a cabinet rather than a lab notebook. This is the successor to the Galaxian demo at https://galaxian.supertux.com (repository `z80-wasm`), which proves the pipeline on the page. This one keeps the proof in the repository and gives the visitor the game: the ROM set is verified and remembered on the device, attract mode starts on its own, free play by default, a running game is saved when the page is hidden and offered back on the next visit, keyboard, gamepad and touch, installable and offline. On a phone the controls are an arcade's: a stick on the left (left and right only; a thumb that lands on it steers wherever it slides until lifted), FIRE on the right, Start (and Coin, when free play is off) between them. Turned on its side, the picture takes the full height and the controls float in the black either side. Rewind: hold Backspace, a controller's left trigger, or the bar's ⏪ button; the board keeps a deflated snapshot every 4 frames, about a minute (3.4 MB), and each held frame loads the newest one (0.19 ms under Node). A controller the browser leaves unmapped (Firefox on Windows with a Switch Pro) has its d-pad read from its hat-switch axis. Rewind hands a replay to the player, resets the neon trails, and is off while `?keys=1` records (it would break the movie). The controls are the family's (emulator-lineage `docs/proposals/2026-11-play-controls.md`), through `web/controls.js`, a copy of play-nes's whose second line names the play-nes commit (play-nes's `scripts/controls-drift.sh` checks it). The bar has pause; Start and Coin sit top-left on a phone on its side. Keyboard: ← → or A D move, Space, Z or X fire, Enter or 1 start (2 for two players), Shift, 5 or C coin, P or Pause pause (not Esc, which leaves full screen), R or Backspace (held) rewind, F5 / F7 keep and load a state of your own (kept per mod, as a snapshot holds RAM and not the program; not during a replay that patches the game), F9 sound, and the remix's own: N the look (neon or arcade), T the flight paths, F a replay's speed. A controller: any face button fires, Back coins, Start starts (held, two players), the right shoulder or the right stick pressed (R3) pauses. Settings can buzz on each touch press (Android; off at first) and are kept as `galaga-remix-settings` (until 2026-11-23 `settings`, read once so dip switches and the look carry over). The manifest is `manifest.json` because the server sends `.webmanifest` as octet-stream with nosniff. ## Where it stands (2026-09-11) All six stages of [docs/build-approach.md](docs/build-approach.md) are done. **The board reproduces MAME 0.285's reference runs** (`oracle/runs.json`, regenerated by `oracle/make_references.sh` through `oracle/mame_dump.lua`; the references hold RAM contents and device writes, no ROM bytes): | Run | RAM at every record | Events | Screenshots | | --- | --- | --- | --- | | boot-720 (power-on self-test) | identical, 25 records | all 421 identical | 2 of 2 pixel-identical | | attract-1800 (30 s: test, title, demo) | identical, 31 records | all 60,885 identical | 5 of 5 pixel-identical | | game-2400 (coin, start, moves, shots) | identical, 41 records | all identical | 5 of 5 pixel-identical | Nothing is pinned: the board reproduces MAME's scheduler, down to the slice boundaries its two MCUs impose (`docs/cpu-and-timing.md`). An earlier one-note difference in the sound CPU, caused by a shared-RAM race the old scheduler ordered differently, went with it (2026-10-02). **Sound**: the WSG rendered from the identical register stream correlates 0.969 sample for sample with MAME's recording of the attract demo at equal RMS. The 54xx noise chip is a hand-written model fitted to MAME's recordings of the power-on bang and a player death (envelope correlation 0.965, level within 8 %, spectrum at L1 distance 0.19); `docs/sound-hardware.md` records what was measured and where the model departs from MAME's source. **The page**: `web/`, plain ES modules, no framework. `node web/check-browser.mjs` serves `dist/`, feeds the ROM set to the page in headless Chromium, boots through the self-test into attract mode, starts a game with key events, rewinds with Backspace and R, checks the page's keys, F5/F7, a faked controller and the settings key's move, and screenshots desktop and phone layouts. `ROMS=rom/galaga.zip node web/check-touch.mjs` puts fingers on the stick and buttons, in portrait and on its side, pauses from the bar, buzzes with haptics on, and rewinds by touch. ## Pins | What | Value | | --- | --- | | z80-rust-fast | commit `5015d98` (`Cargo.toml`), main after PR #1 | | z80-python, whose certification the core's rests on | `cab1598` | | MAME, the board oracle | 0.285 on the build machine | | rustc | 1.93.1 (`rust-toolchain.toml`) | | wasm-bindgen | 0.2.128, crate and CLI | | wasm-opt | binaryen version_132 | | `.wasm` | 301,148 bytes built, 256,612 after `wasm-opt -Oz` (the `wasm/` crate) | ## Building and checking ``` cargo test --release # the oracle and screenshot tests need rom/galaga (extracted set); they skip without it cargo run --release --bin galaga-oracle # the comparison, with --write DIR for diffing and EMU_GALAGA_WATCH* for tracing cargo run --release --bin galaga-audio -- attract-1800 out.wav # sound of a run, to compare with MAME's -wavwrite scripts/build-dist.sh # wasm + page into dist/ node web/check-browser.mjs # the page in headless Chromium with rom/galaga.zip scripts/deploy.sh # dist/ to emu.supertux.com (this machine's docker stack) ``` CI runs fmt, clippy (native and wasm32), the tests (ROM-dependent ones skip) and builds `dist/` on every push. ## A link for phones `?rom=` fetches the set on load, from that host straight into the browser. Verified 2026-09-11: the archive.org item `galaga_1981` holds a byte-identical copy of the set (SHA-1 `bf07d0b8…`), and its `/cors/` path carries the headers browsers need (the page rewrites `/download/` to it): ``` https://emu.supertux.com/?rom=https://archive.org/download/galaga_1981/galaga.zip ``` ## ROM notice This repository contains no Galaga ROMs, PROMs, graphics, or recordings, and never will. The page runs from the visitor's own legally obtained MAME `galaga` parent set, verified member by member in the browser and never uploaded. See [docs/rom-manifest.md](docs/rom-manifest.md). ## Deploying `emu.supertux.com` is this machine's docker stack: `deploy/emu.yml` (an `nginx:alpine` container behind Traefik, a copy of the stack's Galaxian service with the name changed) and `scripts/deploy.sh`, which builds `dist/`, rsyncs it to `/docker/appdata/emu`, installs the compose file if it changed, starts the container if it is not running, and prints the deployed commit, which the page's About panel shows. ## License MIT, see `LICENSE`. Hardware facts in `docs/` are restated from MAME's source (every file consulted is BSD-3-Clause, listed in `docs/README.md`) with the source named on each; the two algorithms transcribed from it, the 05xx starfield and the MB88xx-derived 51xx reply pipeline, say so in place.