43 lines
2.2 KiB
Python
43 lines
2.2 KiB
Python
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Fly the published joystick exercise on both CPUs using the actual guest screen."""
|
|
import argparse
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import tempfile
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("runtime", type=Path, help="staged ToolchainBundle")
|
|
parser.add_argument("core", type=Path, help="libVCCCore.a")
|
|
parser.add_argument("roms", type=Path, help="folder with CoCo 3 and Disk BASIC ROMs")
|
|
parser.add_argument("--capture", type=Path, help="optional PNG of the charged probe in flight")
|
|
args = parser.parse_args()
|
|
runtime, core, roms = [x.resolve(strict=True) for x 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-survey-probe-") as folder:
|
|
work = Path(folder)
|
|
subprocess.run(["xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
|
|
"-I", root / "src", fixture / "run.cpp", core, "-o", "run"], cwd=work, check=True)
|
|
for optimization in ("-O0", "-O2"):
|
|
subprocess.run([runtime / "bin/cmoc", "--coco", "--org=2800", optimization, "-Werror",
|
|
"-o", "PROBE.BIN", root / "examples/cmoc/manual/probe.c",
|
|
"-lgime", "-linput", "-lbcontrol"], cwd=work, env=env, check=True)
|
|
(work / "PROBE.DSK").write_bytes(b"\xff" * (35 * 18 * 256))
|
|
subprocess.run([runtime / "bin/writecocofile", "PROBE.DSK", "PROBE.BIN"], cwd=work, check=True)
|
|
argv = ["./run", roms, "PROBE.DSK", "PROBE.BIN"]
|
|
if args.capture and optimization == "-O2":
|
|
argv.append("survey.ppm")
|
|
print("Checking", optimization, flush=True)
|
|
subprocess.run(argv, cwd=work, check=True)
|
|
if args.capture:
|
|
subprocess.run(["sips", "-s", "format", "png", "survey.ppm", "--out", args.capture.resolve()],
|
|
cwd=work, check=True, stdout=subprocess.DEVNULL)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|