49 lines
2.3 KiB
Python
49 lines
2.3 KiB
Python
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Run the stored Speech/Sound API and Book 6 Mission Announcer on the emulator."""
|
|
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 actual guest display as a PNG")
|
|
parser.add_argument("--audio", type=Path, help="save the emulator's Mission Announcer stereo PCM as a WAV")
|
|
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
|
|
root = fixture.parents[2]
|
|
env = dict(os.environ, VCC_CMOC_COMPAT="0", PATH=str(runtime / "bin") + os.pathsep + os.environ["PATH"])
|
|
with tempfile.TemporaryDirectory(prefix="vcc-announcer-") 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", root / "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", "-lssc")
|
|
run(runtime / "bin/cmoc", "--coco", "--org=2800", opt, "-Werror", "-o", "ANNOUNCE.BIN",
|
|
root / "examples/cmoc/manual/announcer.c", "-lssc", "-linput", "-lbcontrol")
|
|
shutil.copyfile(root / "docs/manuals/software-storage-and-peripherals/media/BLANK.DSK", work / "VOL.DSK")
|
|
run(runtime / "bin/writecocofile", "VOL.DSK", "ANNOUNCE.BIN")
|
|
print(f"Checking {opt}", flush=True)
|
|
capture = (args.capture or args.audio) and opt == "-O2"
|
|
run("./run", roms, *(["capture"] if capture else []))
|
|
if args.audio and opt == "-O2":
|
|
shutil.copyfile(work / "announcer.wav", args.audio.resolve())
|
|
if args.capture and opt == "-O2":
|
|
run("sips", "-s", "format", "png", "announcer.ppm", "--out", args.capture.resolve())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|