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

@@ -0,0 +1,65 @@
# SPDX-License-Identifier: GPL-3.0-or-later
"""Test the recoverable save in Book 6's return-trip lesson on each Disk BASIC storage setup."""
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 completed Mars flight and a companion -retry 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"
source = root / "examples/cmoc/manual/returntrip.c"
tool = runtime / "bin/writecocofile"
env = dict(os.environ, VCC_CMOC_COMPAT="1", PATH=str(runtime / "bin") + os.pathsep + os.environ["PATH"])
earth = b"VISIT 1: EARTH\r"
mars = earth + b"VISIT 2: MARS\r"
with tempfile.TemporaryDirectory(prefix="vcc-return-trip-") as tmp:
work = Path(tmp)
def run(*command, **kwargs):
return subprocess.run(command, cwd=work, env=env, check=True, **kwargs)
run("xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
"-I", root / "src", fixture / "returntrip.cpp", core, "-o", "run")
(work / "TRIP.LOG").write_bytes(b"ANOTHER CREW'S FLIGHT PLAN\r")
shutil.copyfile(blank, work / "other.dsk")
run(tool, "--binary", "other.dsk", "TRIP.LOG")
for folder in ("card", "other"):
(work / folder).mkdir()
(work / folder / "startup.cfg").write_text("0=VOL.DSK\n")
for opt in ("-O0", "-O2"):
run(runtime / "bin/cmoc", "--coco", opt, "-Werror", "--org=2800", "-o", "TRIP.BIN",
source, "-lvcccompat", "-ldecbfile")
shutil.copyfile(blank, work / "launch.dsk")
run(tool, "launch.dsk", "TRIP.BIN")
for cpu in ("6809", "6309"):
for profile in ("disk", "rgb-hd", "sdc"):
shutil.copyfile(work / "launch.dsk", work / "card/VOL.DSK")
shutil.copyfile(work / "other.dsk", work / "other/VOL.DSK")
capture = args.capture and (cpu, opt, profile) == ("6809", "-O2", "disk")
run("./run", roms, "TRIP.BIN", cpu, profile, "capture" if capture else "check")
for disk, expected in (("earth.dsk", earth), ("mars.dsk", mars)):
actual = run(tool, "--stdout", disk, "TRIP.LOG", stdout=subprocess.PIPE).stdout
if actual != expected:
raise AssertionError(f"{cpu} {opt} {profile} {disk}: {actual!r}")
if capture:
for suffix in ("", "-retry"):
target = args.capture.with_stem(args.capture.stem + suffix)
run("sips", "-s", "format", "png", f"trip{suffix}.ppm", "--out", target.resolve())
print(f"PASS {cpu} {opt} {profile}: Earth, protected quit and refusal, successful flush retry, "
"exact Earth and Mars bytes, completed trip, unrelated file, BASIC return", flush=True)
if __name__ == "__main__":
main()
@@ -0,0 +1,56 @@
# SPDX-License-Identifier: GPL-3.0-or-later
"""Run the C book's field log exercise, inspect its flushed disk and try its append edit."""
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)
parser.add_argument("core", type=Path)
parser.add_argument("roms", type=Path)
parser.add_argument("--capture", type=Path, help="write a PNG of the completed first survey")
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]
example = root / "examples/cmoc/manual/fieldlog.c"
blank = root / "docs/manuals/software-storage-and-peripherals/media/BLANK.DSK"
env = dict(os.environ, VCC_CMOC_COMPAT="1", PATH=str(runtime / "bin") + os.pathsep + os.environ["PATH"])
with tempfile.TemporaryDirectory(prefix="vcc-field-log-") as tmp:
work = Path(tmp)
def run(*command, **kwargs):
return subprocess.run(command, cwd=work, env=env, check=True, **kwargs)
run("xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
"-I", root / "src", fixture / "run.cpp", core, "-o", "run")
original = example.read_text()
edit = 'fopen(LOG_NAME, "w")'
assert original.count(edit) == 1, "The lesson's append edit no longer matches the source"
(work / "append.c").write_text(original.replace(edit, 'fopen(LOG_NAME, "a")'))
for opt in ("-O0", "-O2"):
for src, binary in ((example, "LOG.BIN"), ("append.c", "APPEND.BIN")):
run(runtime / "bin/cmoc", "--coco", opt, "-Werror", "--org=2800",
"-o", binary, src, "-lvcccompat", "-ldecbfile")
capture = args.capture and opt == "-O2"
run("./run", roms, blank, "LOG.BIN", "APPEND.BIN", "capture" if capture else "check")
for cpu in ("6809", "6309"):
first, second = b"EARTH: BLUE SEA\r", b"MARS: RED RIDGE\r"
for mode, prior in (("fresh", b""), ("append", first + second)):
for stage, expected in (("checkpoint", prior + first), ("closed", prior + first + second)):
disk = f"{cpu}-{mode}-{stage}.dsk"
actual = run(runtime / "bin/writecocofile", "--stdout", disk, "FIELD.LOG",
stdout=subprocess.PIPE).stdout
if actual != expected:
raise RuntimeError(f"{disk}: expected {expected!r}, got {actual!r}")
print(f"PASS {opt}: fresh/append, independent disk read before/after close, protection, BASIC return", flush=True)
if capture:
run("sips", "-s", "format", "png", "log.ppm", "--out", args.capture.resolve())
if __name__ == "__main__":
main()
@@ -0,0 +1,74 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include "../guest-captures.h"
using namespace BasicDiskTests;
static void visit(const fs::path& roms, const fs::path& binary, Processor cpu, Profile profile, bool capture)
{
Session guest(roms, "card/VOL.DSK", cpu, profile);
guest.launch(binary);
guest.until("AT BYTE ZERO\nFILING EARTH\nREOPENED TRIP.LOG\nVISIT 1: EARTH");
guest.verifyReturn();
saveVolume(guest, "earth.dsk");
setVolumeProtected(guest, true);
const auto earth = volume(guest);
const std::string prompt = "R: RETRY Q: QUIT";
guest.launch(binary);
guest.until(prompt);
guest.type("Q");
guest.until("CHECK DISK AND LOG");
guest.verifyReturn();
require(volume(guest) == earth, "Protected trip changed the disk");
// Run the disk copy and leave this Mars flight waiting in the guest.
guest.type("CLS\r");
require(guest.machine.copyScreenText().find(prompt) == std::string::npos, "Old retry prompt is still visible");
guest.type("LOADM\"TRIP\":EXEC\r");
guest.until(prompt);
if (capture) {
guest.frames(3);
saveActiveFrame(*guest.machine.snapshot().frame, "trip-retry.ppm");
}
guest.type("R");
guest.until("RETRYING SAVE\nSAVE FAILED\nKEEP THE SAME DISK IN DRIVE 0\nIF PROTECTED, TURN PROTECT OFF\n" + prompt);
require(volume(guest) == earth, "Retry while protected changed the disk");
setVolumeProtected(guest, false);
// The learner returns from changing protection in the host. Let the
// ROM observe the released key before the learner presses R again.
guest.frames(30);
guest.type("R");
guest.until("REOPENED TRIP.LOG\nVISIT 1: EARTH\nVISIT 2: MARS");
guest.until("OK");
if (capture) {
guest.frames(3);
saveActiveFrame(*guest.machine.snapshot().frame, "trip.ppm");
}
guest.verifyReturn();
saveVolume(guest, "mars.dsk");
const auto mars = volume(guest);
guest.launch(binary);
guest.until("BOTH VISITS ALREADY FILED\nREOPENED TRIP.LOG\nVISIT 1: EARTH\nVISIT 2: MARS");
guest.verifyReturn();
require(volume(guest) == mars, "Third trip changed a completed log");
}
int main(int argc, char** argv)
{
try {
require(argc == 6, "Usage: returntrip ROMDIR BIN CPU PROFILE CAPTURE");
const auto cpu = std::string(argv[3]) == "6809" ? Processor::MC6809 : Processor::HD6309;
const std::string mode = argv[4];
const auto profile = mode == "disk" ? Profile::fd : mode == "rgb-hd" ? Profile::rgbHD : Profile::sdc;
visit(argv[1], argv[2], cpu, profile, std::string(argv[5]) == "capture");
Session other(argv[1], "other/VOL.DSK", cpu, profile);
other.launch(argv[2]);
other.until("UNRECOGNIZED TRIP.LOG\nCHECK DISK AND LOG");
other.verifyReturn();
require(volume(other) == other.original, "Trip changed an unrelated file");
} catch (const std::exception& error) {
std::cerr << error.what() << std::endl;
return 1;
}
}
+62
View File
@@ -0,0 +1,62 @@
// 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 DISK BIN APPEND_BIN CAPTURE");
for (auto cpu : {Processor::MC6809, Processor::HD6309}) {
Session session(argv[1], argv[2], cpu, Profile::fd);
std::string prefix = cpu == Processor::MC6809 ? "6809-" : "6309-";
// First run starts a fresh log. The lesson's one-character edit appends on the second.
for (const auto& mode : {"fresh", "append"}) {
const bool append = std::string(mode) == "append";
session.type("CLS\r");
session.launch(argv[append ? 4 : 3]);
session.until("SPACE TO LAND ON MARS");
session.until("CHECKPOINT READER SEES:\nEARTH: BLUE SEA");
saveDisk(*session.floppy->image(0), prefix + mode + "-checkpoint.dsk");
session.frames(12);
session.type(" ");
session.until("SURVEY FILED");
session.until("FINAL READER SEES:\nEARTH: BLUE SEA\nMARS: RED RIDGE");
saveDisk(*session.floppy->image(0), prefix + mode + "-closed.dsk");
if (!append && cpu == Processor::MC6809 && std::string(argv[5]) == "capture") {
session.until("OK");
session.frames(4);
saveActiveFrame(*session.machine.snapshot().frame, "log.ppm");
}
session.verifyReturn();
}
session.floppy->setWriteProtected(0, true);
const auto previous = session.floppy->image(0)->bytes();
for (const auto binary : {argv[3], argv[4]}) {
session.type("CLS\r");
session.launch(binary);
// A DOS may detect protection at open or at the first flush.
for (unsigned n = 0; n < 2000; ++n) {
session.frames(1);
const auto text = session.machine.copyScreenText();
if (text.find("CANNOT START FIELD.LOG") != text.npos ||
text.find("CHECK DISK AND LOG") != text.npos) break;
require(n + 1 < 2000, "Expected a protected disk error: " + text);
}
require(previous == session.floppy->image(0)->bytes(), "Protected disk was changed");
session.verifyReturn();
}
// Read the first two records with the resident Disk BASIC ROM.
session.frames(12);
session.machine.basicLoadSource("10 CLS:OPEN \"I\",#1,\"FIELD.LOG\"\n"
"20 LINE INPUT #1,A$:PRINT A$\n"
"30 LINE INPUT #1,A$:PRINT A$\n"
"40 CLOSE #1\n", true);
session.until("EARTH: BLUE SEA\nMARS: RED RIDGE");
session.verifyReturn();
}
} catch (const std::exception& error) {
std::cerr << error.what() << std::endl;
return 1;
}
}