Publish VCC Plus OSS source distribution for 3.6.2 build 60

This commit is contained in:
Brian Holman committed 2026-11-13 00:14:03 -07:00
commit c652a5276d
1192 files changed
+272368

No files matched your search

+115
View File
@@ -0,0 +1,115 @@
# SPDX-License-Identifier: GPL-3.0-or-later
"""Cold-boot the Book 6 Atlas backup after an interruption between renames."""
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="save the actual recovery screen as a PNG")
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]
blank = root / "docs/manuals/software-storage-and-peripherals/media/BLANK.DSK"
bin_dir = runtime / "bin"
tool = bin_dir / "writecocofile"
env = dict(os.environ, VCC_CMOC_COMPAT="1", PATH=str(bin_dir) + os.pathsep + os.environ["PATH"])
# Existing visits to Earth and Mars must survive both the save and recovery.
names = [b"MERCURY: CRATERS", b"VENUS: CLOUDS", b"EARTH: BLUE SEA", b"MARS: RED RIDGE"]
original = b"".join(name.ljust(23, b"\0") + flag for name, flag in zip(names, (b"\0", b"\0", b"V", b"V")))
updated = original[:72] + b"MARS: DUST STORM".ljust(23, b"\0") + original[-1:]
note = b"ANOTHER CREW'S FILE\r"
with tempfile.TemporaryDirectory(prefix="vcc-atlas-backup-") as tmp:
work = Path(tmp)
card = work / "card"
card.mkdir()
disk = card / "VOL.DSK"
(card / "startup.cfg").write_text("0=VOL.DSK\n")
result = work / "result.dsk"
def run(*command, **kwargs):
return subprocess.run(command, cwd=work, env=env, check=True, **kwargs)
def add(dsk, filename, contents):
(work / filename).write_bytes(contents)
run(tool, "--binary", dsk, filename)
def check_files(expected):
for filename in ("ATLAS.DAT", "ATLAS.BAK", "ATLAS.NEW", "CREW.TXT"):
extraction = subprocess.run([tool, "--stdout", result, filename], cwd=work, capture_output=True)
if filename in expected:
if extraction.returncode or extraction.stdout != expected[filename]:
raise AssertionError(f"Wrong contents for {filename}: {extraction.stderr!r} {extraction.stdout!r}")
elif not extraction.returncode or b"not found on disk image" not in extraction.stdout + extraction.stderr:
raise AssertionError(f"Expected absent {filename}: {extraction.stdout!r} {extraction.stderr!r}")
def boot(cpu, profile, phase, image):
shutil.copyfile(image, disk)
result.unlink(missing_ok=True)
run("./run", roms, "BACKUP.BIN", cpu, profile, phase)
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(bin_dir / "cmoc", "--coco", opt, "-Werror", "--org=2800", "-o", "BACKUP.BIN",
root / "examples/cmoc/manual/atlasbackup.c", "-lvcccompat", "-ldecbfile")
seed = work / "seed.dsk"
shutil.copyfile(blank, seed)
run(tool, seed, "BACKUP.BIN")
add(seed, "CREW.TXT", note)
fresh = work / "fresh.dsk"
shutil.copyfile(seed, fresh)
other_draft = work / "other-draft.dsk"
shutil.copyfile(seed, other_draft)
add(other_draft, "ATLAS.BAK", original)
# Looks like the correct edition, but the Mars visit flag differs.
unrelated = updated[:-1] + b"\0"
add(other_draft, "ATLAS.NEW", unrelated)
malformed = work / "malformed.dsk"
shutil.copyfile(seed, malformed)
add(malformed, "ATLAS.BAK", original[:-1])
add(malformed, "ATLAS.NEW", updated)
add(seed, "ATLAS.DAT", original)
for cpu in ("6809", "6309"):
for profile in ("disk", "rgb-hd", "sdc"):
boot(cpu, profile, "interrupt", seed)
check_files({"ATLAS.BAK": original, "ATLAS.NEW": updated, "CREW.TXT": note})
capture = args.capture and (opt, cpu, profile) == ("-O2", "6809", "disk")
boot(cpu, profile, "capture" if capture else "recover", result)
check_files({"ATLAS.DAT": original, "CREW.TXT": note})
if capture:
run("sips", "-s", "format", "png", "recovered.ppm", "--out", args.capture.resolve())
boot(cpu, profile, "save", result)
check_files({"ATLAS.DAT": updated, "ATLAS.BAK": original, "CREW.TXT": note})
saved = result.read_bytes()
boot(cpu, profile, "repeat", result)
if result.read_bytes() != saved:
raise AssertionError("Reopening a completed save changed the disk")
boot(cpu, profile, "refuse", malformed)
if result.read_bytes() != malformed.read_bytes():
raise AssertionError("An invalid backup caused disk changes")
boot(cpu, profile, "keep-draft", other_draft)
check_files({"ATLAS.DAT": original, "ATLAS.NEW": unrelated, "CREW.TXT": note})
if profile == "disk":
boot(cpu, profile, "save", fresh)
unvisited = b"".join(name.ljust(24, b"\0") for name in names)
check_files({"ATLAS.DAT": unvisited[:72] + b"MARS: DUST STORM".ljust(24, b"\0"),
"ATLAS.BAK": unvisited, "CREW.TXT": note})
print(f"PASS {cpu} {opt} {profile}: interrupted, recovered, saved, reopened; "
"whole atlas, visit flags and unrelated file preserved", flush=True)
if __name__ == "__main__":
main()
+56
View File
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include "../guest-captures.h"
using namespace BasicDiskTests;
int main(int argc, char** argv)
{
try {
require(argc == 6, "Usage: run ROMDIR BIN CPU PROFILE PHASE");
const auto cpu = std::string(argv[3]) == "6809" ? Processor::MC6809 : Processor::HD6309;
const std::string mode = argv[4], phase = argv[5];
const auto profile = mode == "disk" ? Profile::fd : mode == "rgb-hd" ? Profile::rgbHD : Profile::sdc;
Session guest(argv[1], "card/VOL.DSK", cpu, profile);
if (phase == "recover" || phase == "capture")
guest.type("LOADM\"BACKUP\":EXEC\r");
else
guest.launch(argv[2]);
if (phase == "interrupt" || phase == "save") {
guest.until("BACKUP IN PLACE");
guest.until("PRESS A KEY TO INSTALL");
if (phase == "interrupt") {
// Terminate the whole guest process here. Only its disk goes
// to the next invocation, which starts from the boot ROM.
saveVolume(guest, "result.dsk");
return 0;
}
guest.type("Y");
guest.until("UPDATED ATLAS SAVED");
} else if (phase == "recover" || phase == "capture") {
guest.until("ORIGINAL ATLAS RESTORED");
guest.until("MARS: RED RIDGE");
} else if (phase == "keep-draft") {
guest.until("ORIGINAL ATLAS RESTORED");
guest.until("KEPT UNEXPECTED ATLAS.NEW");
} else if (phase == "repeat") {
guest.until("ATLAS ALREADY UPDATED");
} else if (phase == "refuse") {
guest.until("SAVE STOPPED - CHECK DISK");
} else {
throw std::logic_error("Unknown test phase " + phase);
}
guest.until("OK");
if (phase == "capture") {
guest.frames(3);
saveActiveFrame(*guest.machine.snapshot().frame, "recovered.ppm");
}
guest.verifyReturn();
saveVolume(guest, "result.dsk");
} catch (const std::exception& error) {
std::cerr << error.what() << std::endl;
return 1;
}
}