# SPDX-License-Identifier: GPL-3.0-or-later """Run the Orchestra-90 background player and Stereo Flyby on the emulated CoCo.""" import argparse import os from pathlib import Path import shutil import subprocess import tempfile def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("runtime", type=Path) parser.add_argument("core", type=Path) parser.add_argument("roms", type=Path) parser.add_argument("--capture", type=Path, help="write the optimized 6809 live display to a PNG") parser.add_argument("--audio", type=Path, help="write the corresponding 44.1 kHz stereo recording") args = parser.parse_args() runtime, core, roms = (p.resolve(strict=True) for p in (args.runtime, args.core, args.roms)) fixture = Path(__file__).resolve().parent repo = fixture.parents[2] env = dict(os.environ, PATH=str(runtime / "bin") + os.pathsep + os.environ["PATH"], VCC_CMOC_COMPAT="0") with tempfile.TemporaryDirectory(prefix="vcc-stereo-flyby-") as temp: work = Path(temp) def run(*cmd): subprocess.run(cmd, cwd=work, env=env, check=True) run("xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0", "-I", repo / "src", fixture / "run.cpp", core, "-o", "run") for opt in ("-O0", "-O2"): run(runtime / "bin/cmoc", "--coco", "--org=2800", opt, "-Werror", "-o", "QUAL.BIN", fixture / "qualification.c", "-lorch90") run(runtime / "bin/cmoc", "--coco", "--org=2800", opt, "-Werror", "-o", "FLYBY.BIN", repo / "examples/cmoc/manual/flyby.c", "-lorch90", "-linput", "-lbcontrol") shutil.copyfile(repo / "docs/manuals/software-storage-and-peripherals/media/BLANK.DSK", work / "VOL.DSK") run(runtime / "bin/writecocofile", "VOL.DSK", "FLYBY.BIN") capture = opt == "-O2" and (args.capture or args.audio) print(f"Checking {opt}", flush=True) run("./run", roms, *(["capture"] if capture else [])) if capture and args.capture: run("sips", "-s", "format", "png", "flyby.ppm", "--out", args.capture.resolve()) if capture and args.audio: shutil.copyfile(work / "flyby.wav", args.audio.resolve()) if __name__ == "__main__": main()