#!/usr/bin/env bash # Regenerate oracle/reference/*.json from galemu for every run in # oracle/runs.json. galemu's venv must have galemu and z80-python installed; # the ROM set is read from rom/galaxian.zip (never committed). # Usage: oracle/make_references.sh [run-name ...] set -euo pipefail ROOT=$(cd "$(dirname "$0")/.." && pwd) PY=${PY:-$(dirname "$ROOT")/galemu/.venv/bin/python} ROM=${ROM:-$ROOT/rom/galaxian.zip} mkdir -p "$ROOT/oracle/reference" python3 - "$ROOT/oracle/runs.json" "$@" <<'PY' | while IFS=$'\t' read -r name args; do import json, sys runs = json.load(open(sys.argv[1])) wanted = set(sys.argv[2:]) for run in runs: if wanted and run["name"] not in wanted: continue args = ["--frames", str(run["frames"])] if "frames" in run else ["--instructions", str(run["instructions"])] if run.get("vblank"): args.append("--vblank") if not run["memory_writes"]: args.append("--no-memory-writes") for spec in run["inputs"]: args += ["--input", spec] print(run["name"] + "\t" + " ".join(args)) PY start=$(date +%s) # shellcheck disable=SC2086 "$PY" "$ROOT/oracle/galemu_run.py" --rom-path "$ROM" $args --output "$ROOT/oracle/reference/$name.json" echo "$name: $(stat -c %s "$ROOT/oracle/reference/$name.json") bytes, $(( $(date +%s) - start )) s" done