Publish VCC Plus OSS source distribution for 3.6.2 build 60
This commit is contained in:
commit
c652a5276d
1192 files changed
+272368
No files matched your search
@@ -0,0 +1,54 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Cross-read tapes recorded by the real BASIC ROM and by the packaged CMOC SDK."""
|
||||
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 guest's flight replay screen")
|
||||
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]
|
||||
lessons = root / "examples/cmoc/manual"
|
||||
disk = root / "docs/manuals/software-storage-and-peripherals/media/BLANK.DSK"
|
||||
env = dict(os.environ, PATH=str(runtime / "bin") + os.pathsep + os.environ["PATH"], VCC_CMOC_COMPAT="1")
|
||||
with tempfile.TemporaryDirectory(prefix="vcc-cassette-demo-") as tmp:
|
||||
def run(*command):
|
||||
subprocess.run(command, cwd=tmp, 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")
|
||||
card = Path(tmp) / "card"
|
||||
card.mkdir()
|
||||
practice = card / "VOL.DSK"
|
||||
shutil.copyfile(disk, practice)
|
||||
(card / "startup.cfg").write_text("0=VOL.DSK\n")
|
||||
for opt in ("-O0", "-O2"):
|
||||
for source, binary in ((lessons / "flightrecorder.c", "FLIGHT.BIN"),
|
||||
(fixture / "qualification.c", "QUAL.BIN")):
|
||||
run(runtime / "bin/cmoc", "--coco", opt, "-Werror", "--org=2800",
|
||||
"-o", binary, source, "-lvcccompat")
|
||||
for cpu in ("6809", "6309"):
|
||||
starter = root / "platforms/macos/Resources/StarterMedia/Hello World.cas"
|
||||
run("./run", roms, practice, cpu, lessons, starter, "disk")
|
||||
if opt == "-O2":
|
||||
for setup in ("wav", "rgb-hd", "sdc"):
|
||||
run("./run", roms, practice, cpu, lessons, starter, setup)
|
||||
print(f"PASS {cpu} {opt} {setup}: recorded in C and read in BASIC, and vice versa", flush=True)
|
||||
if args.capture and (cpu, opt) == ("6809", "-O2"):
|
||||
run("sips", "-s", "format", "png", "flight.ppm", "--out", args.capture.resolve())
|
||||
print(f"PASS {cpu} {opt}: BASIC/C cassette exchange, empty files, cross-block records and damaged tapes",
|
||||
flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,68 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#include <coco.h>
|
||||
#include <vcc/cassette.h>
|
||||
|
||||
#define CHECK(expr) do { if (!(expr)) { printf("FAIL LINE %u\n", (unsigned)__LINE__); return 1; } } while (0)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char line[251];
|
||||
unsigned i;
|
||||
cls(1);
|
||||
printf("EMPTY OR BLOCK CHECK\n");
|
||||
char choice = waitkey(0);
|
||||
if (choice == 'W' || choice == 'P') {
|
||||
CHECK(vcc_tape_open_write(choice == 'W' ? "Flight" : "FLIGHT") == VCC_TAPE_OK);
|
||||
if (choice == 'P') {
|
||||
for (i = 0; i < 2; ++i) {
|
||||
memset(line, i ? 'B' : 'A', 180);
|
||||
line[180] = 0;
|
||||
CHECK(vcc_tape_write_line(line) == VCC_TAPE_OK);
|
||||
}
|
||||
CHECK(vcc_tape_write_line("") == VCC_TAPE_OK);
|
||||
}
|
||||
} else {
|
||||
CHECK(vcc_tape_open_read(choice == 'E' ? "Flight" : "FLIGHT") == VCC_TAPE_OK);
|
||||
CHECK(vcc_tape_open_write("OTHER") == VCC_TAPE_BUSY);
|
||||
if (choice == 'T') {
|
||||
int status;
|
||||
do {
|
||||
status = vcc_tape_read_line(line, sizeof line);
|
||||
} while (status == VCC_TAPE_OK);
|
||||
CHECK(status < 0);
|
||||
vcc_tape_close();
|
||||
printf("MOUNT GOOD TAPE AND PRESS R\n");
|
||||
CHECK(waitkey(0) == 'R');
|
||||
CHECK(vcc_tape_open_read("FLIGHT") == VCC_TAPE_OK);
|
||||
CHECK(vcc_tape_read_line(line, sizeof line) == VCC_TAPE_OK);
|
||||
CHECK(strcmp(line, "EARTH TIDE POOL") == 0);
|
||||
CHECK(vcc_tape_read_line(line, sizeof line) == VCC_TAPE_OK);
|
||||
CHECK(strcmp(line, "MARS DUST DEVIL") == 0);
|
||||
} else if (choice == 'L') {
|
||||
char small[6] = "KEEP";
|
||||
small[5] = 'X';
|
||||
CHECK(vcc_tape_read_line(small, 5) == VCC_TAPE_LONG);
|
||||
CHECK(small[0] == 0 && small[5] == 'X');
|
||||
CHECK(vcc_tape_read_line(line, sizeof line) == VCC_TAPE_OK);
|
||||
CHECK(strcmp(line, "MARS DUST DEVIL") == 0);
|
||||
} else if (choice == 'B') {
|
||||
/* Two long records make the second span a 255-byte ROM data block. */
|
||||
for (i = 0; i < 2; ++i) {
|
||||
CHECK(vcc_tape_read_line(line, sizeof line) == VCC_TAPE_OK);
|
||||
CHECK(strlen(line) == 180);
|
||||
for (unsigned j = 0; j < 180; ++j)
|
||||
CHECK(line[j] == (i ? 'B' : 'A'));
|
||||
}
|
||||
CHECK(vcc_tape_read_line(line, sizeof line) == VCC_TAPE_OK);
|
||||
CHECK(line[0] == 0); /* A blank line is a record; an empty file has none. */
|
||||
CHECK(vcc_tape_read_line(line, sizeof line) == VCC_TAPE_OK);
|
||||
CHECK(strcmp(line, "TAIL") == 0); /* Final BASIC PRINT used a semicolon. */
|
||||
} else {
|
||||
CHECK(choice == 'E');
|
||||
}
|
||||
CHECK(vcc_tape_read_line(line, sizeof line) == VCC_TAPE_EOF);
|
||||
}
|
||||
CHECK(vcc_tape_close() == VCC_TAPE_OK);
|
||||
printf("CASSETTE CHECK PASSED\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#include "../guest-captures.h"
|
||||
|
||||
using namespace BasicDiskTests;
|
||||
|
||||
static void atPrompt(Session& g)
|
||||
{
|
||||
g.verifyReturn();
|
||||
g.type("CLS\r");
|
||||
g.frames(15);
|
||||
}
|
||||
|
||||
static std::string basicSource(const fs::path& path)
|
||||
{
|
||||
auto bytes = readFile(path);
|
||||
return {bytes.begin(), bytes.end()};
|
||||
}
|
||||
|
||||
static void basic(Session& g, const std::string& source)
|
||||
{
|
||||
g.machine.basicLoadSource(source, true);
|
||||
}
|
||||
|
||||
static void selectC(Session& g, const char* binary, const char* prompt, const char* choice)
|
||||
{
|
||||
g.launch(binary);
|
||||
g.until(prompt);
|
||||
g.type(choice);
|
||||
}
|
||||
|
||||
static void play(Session& g, const Bytes& image, TapeFormat format = TapeFormat::CAS)
|
||||
{
|
||||
auto& tape = g.machine.cassette();
|
||||
tape.mount(image, format);
|
||||
tape.play();
|
||||
}
|
||||
|
||||
static Bytes finishRecording(Session& g, const char* marker)
|
||||
{
|
||||
g.until(marker);
|
||||
g.until("OK");
|
||||
auto& tape = g.machine.cassette();
|
||||
require(tape.snapshot().writeEvents && !tape.snapshot().motor, "Recording should finish with the motor off");
|
||||
auto image = tape.exportImage();
|
||||
require(!image.empty(), "Recorder did not produce an image");
|
||||
atPrompt(g);
|
||||
return image;
|
||||
}
|
||||
|
||||
static void checkScreen(Session& g, const std::string& expected)
|
||||
{
|
||||
auto screen = g.machine.copyScreenText();
|
||||
require(screen.find(expected) != std::string::npos, "Unexpected flight records:\n" + screen);
|
||||
}
|
||||
|
||||
static std::size_t blockSync(const Bytes& tape, unsigned type)
|
||||
{
|
||||
const Bytes pattern = {0x55, 0x3c, static_cast<std::uint8_t>(type)};
|
||||
auto p = std::search(tape.begin(), tape.end(), pattern.begin(), pattern.end());
|
||||
require(p != tape.end(), "Expected filename/data/EOF block in the real recording");
|
||||
return static_cast<std::size_t>(p - tape.begin()) + 1;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
try {
|
||||
require(argc == 7, "Usage: run ROM-DIRECTORY DISK CPU LESSONS STARTER-CAS SETUP");
|
||||
const fs::path lessons = argv[4];
|
||||
const auto reader = basicSource(lessons / "flightread.bas");
|
||||
const auto writer = basicSource(lessons / "flightwrite.bas");
|
||||
const auto cpu = std::string(argv[3]) == "6809" ? Processor::MC6809 : Processor::HD6309;
|
||||
const std::string setup = argv[6];
|
||||
const auto profile = setup == "sdc" ? Profile::sdc : setup == "rgb-hd" ? Profile::rgbHD : Profile::fd;
|
||||
const auto format = setup == "wav" ? TapeFormat::WAV : TapeFormat::CAS;
|
||||
Session g(argv[1], argv[2], cpu, profile);
|
||||
auto& tape = g.machine.cassette();
|
||||
|
||||
tape.record(format);
|
||||
selectC(g, "FLIGHT.BIN", "W WRITE R READ", "W");
|
||||
const auto fromC = finishRecording(g, "FLIGHT SAVED");
|
||||
play(g, fromC, format);
|
||||
basic(g, reader);
|
||||
g.until("END OF FLIGHT");
|
||||
checkScreen(g, "EARTH BLUE SEA\nMARS RED RIDGE\nEND OF FLIGHT");
|
||||
atPrompt(g);
|
||||
|
||||
tape.record(format);
|
||||
basic(g, writer);
|
||||
const auto fromBASIC = finishRecording(g, "FLIGHT SAVED");
|
||||
play(g, fromBASIC, format);
|
||||
selectC(g, "FLIGHT.BIN", "W WRITE R READ", "R");
|
||||
g.until("END OF FLIGHT");
|
||||
checkScreen(g, "EARTH TIDE POOL\nMARS DUST DEVIL\nEND OF FLIGHT");
|
||||
g.until("OK");
|
||||
g.frames(3);
|
||||
if (setup != "disk") {
|
||||
atPrompt(g);
|
||||
g.verifyMedia();
|
||||
return 0;
|
||||
}
|
||||
saveActiveFrame(*g.machine.snapshot().frame, "flight.ppm");
|
||||
atPrompt(g);
|
||||
|
||||
tape.record(TapeFormat::CAS);
|
||||
selectC(g, "QUAL.BIN", "EMPTY OR BLOCK CHECK", "W");
|
||||
play(g, finishRecording(g, "CASSETTE CHECK PASSED"));
|
||||
basic(g, "10 OPEN \"I\",#-1,\"Flight\"\n20 IF NOT EOF(-1) THEN PRINT \"FAIL LINE 20\":END\n"
|
||||
"30 CLOSE #-1:PRINT \"EMPTY IN BASIC\"\n");
|
||||
g.until("EMPTY IN BASIC");
|
||||
atPrompt(g);
|
||||
|
||||
tape.record(TapeFormat::CAS);
|
||||
basic(g, "10 OPEN \"O\",#-1,\"Flight\"\n20 CLOSE #-1:PRINT \"BASIC EMPTY SAVED\"\n");
|
||||
play(g, finishRecording(g, "BASIC EMPTY SAVED"));
|
||||
selectC(g, "QUAL.BIN", "EMPTY OR BLOCK CHECK", "E");
|
||||
g.until("CASSETTE CHECK PASSED");
|
||||
atPrompt(g);
|
||||
|
||||
tape.record(TapeFormat::CAS);
|
||||
basic(g, "10 OPEN \"O\",#-1,\"FLIGHT\"\n20 PRINT #-1,STRING$(180,65)\n"
|
||||
"30 PRINT #-1,STRING$(180,66)\n40 PRINT #-1,\"\"\n45 PRINT #-1,\"TAIL\";\n50 CLOSE #-1:PRINT \"BLOCKS SAVED\"\n");
|
||||
play(g, finishRecording(g, "BLOCKS SAVED"));
|
||||
selectC(g, "QUAL.BIN", "EMPTY OR BLOCK CHECK", "B");
|
||||
g.until("CASSETTE CHECK PASSED");
|
||||
atPrompt(g);
|
||||
|
||||
tape.record(TapeFormat::CAS);
|
||||
selectC(g, "QUAL.BIN", "EMPTY OR BLOCK CHECK", "P");
|
||||
play(g, finishRecording(g, "CASSETTE CHECK PASSED"));
|
||||
basic(g, "10 CLEAR 1024:OPEN \"I\",#-1,\"FLIGHT\"\n"
|
||||
"20 FOR I=65 TO 66:LINE INPUT #-1,A$\n"
|
||||
"30 IF A$<>STRING$(180,I) THEN PRINT \"FAIL LINE 30\":END\n40 NEXT I\n"
|
||||
"50 LINE INPUT #-1,A$:IF LEN(A$)<>0 THEN PRINT \"FAIL LINE 50\":END\n"
|
||||
"60 IF NOT EOF(-1) THEN PRINT \"FAIL LINE 60\":END\n70 CLOSE #-1:PRINT \"C BLOCKS VERIFIED\"\n");
|
||||
g.until("C BLOCKS VERIFIED");
|
||||
atPrompt(g);
|
||||
|
||||
// The reader must pass an unrelated named file, consume a too-long line, then read the next.
|
||||
tape.record(TapeFormat::CAS);
|
||||
basic(g, "5 OPEN \"O\",#-1,\"OTHER\":PRINT #-1,\"IGNORE ME\":CLOSE #-1\n" + writer);
|
||||
play(g, finishRecording(g, "FLIGHT SAVED"));
|
||||
selectC(g, "QUAL.BIN", "EMPTY OR BLOCK CHECK", "L");
|
||||
g.until("CASSETTE CHECK PASSED");
|
||||
atPrompt(g);
|
||||
|
||||
// Program files can have consecutive blocks with short leaders. Search past the
|
||||
// bundled tokenized BASIC program to reach a BASIC-written sequential data file.
|
||||
auto mixed = readFile(argv[5]);
|
||||
mixed.insert(mixed.end(), fromBASIC.begin(), fromBASIC.end());
|
||||
for (bool fast : {false, true}) {
|
||||
tape.setFast(fast);
|
||||
play(g, mixed);
|
||||
selectC(g, "FLIGHT.BIN", "W WRITE R READ", "R");
|
||||
g.until("END OF FLIGHT");
|
||||
checkScreen(g, "EARTH TIDE POOL\nMARS DUST DEVIL\nEND OF FLIGHT");
|
||||
atPrompt(g);
|
||||
}
|
||||
tape.setFast(false);
|
||||
|
||||
// Cut the real BASIC recording within a data block, at the end marker, and before its checksum.
|
||||
const auto data = blockSync(fromBASIC, 1);
|
||||
const auto end = blockSync(fromBASIC, 255);
|
||||
for (auto length : {data + 6, end, end + 3}) {
|
||||
play(g, Bytes(fromBASIC.begin(), fromBASIC.begin() + length));
|
||||
selectC(g, "FLIGHT.BIN", "W WRITE R READ", "R");
|
||||
g.until("TAPE ERROR");
|
||||
const auto screen = g.machine.copyScreenText();
|
||||
require(screen.find("END OF FLIGHT") == screen.npos, "A short tape was accepted as EOF");
|
||||
require(!tape.snapshot().motor, "C left the motor running after a read error");
|
||||
atPrompt(g);
|
||||
}
|
||||
play(g, Bytes(fromBASIC.begin(), fromBASIC.begin() + end));
|
||||
selectC(g, "QUAL.BIN", "EMPTY OR BLOCK CHECK", "T");
|
||||
g.until("MOUNT GOOD TAPE AND PRESS R");
|
||||
require(!tape.snapshot().motor, "Close after read error left motor on");
|
||||
play(g, fromBASIC);
|
||||
g.type("R");
|
||||
g.until("CASSETTE CHECK PASSED");
|
||||
atPrompt(g);
|
||||
|
||||
auto damaged = fromC;
|
||||
const auto dataSync = blockSync(damaged, 1);
|
||||
damaged[dataSync + 3 + damaged.at(dataSync + 2)] ^= 1; // corrupt only the checksum
|
||||
play(g, damaged);
|
||||
basic(g, reader);
|
||||
g.until("?IO ERROR");
|
||||
// Reset the ROM after its error before starting the separate physical-end test.
|
||||
g.machine.softReset();
|
||||
g.machine.resume();
|
||||
g.frames(300);
|
||||
g.type("CLS\r");
|
||||
g.frames(15);
|
||||
|
||||
// The unmodified BASIC ROM has no missing-carrier timeout. Check the guest at physical end,
|
||||
// then observe another five guest seconds; a truncated C tape must never yield the EOF marker.
|
||||
play(g, Bytes(fromC.begin(), fromC.begin() + blockSync(fromC, 255)));
|
||||
basic(g, reader);
|
||||
for (unsigned i = 0; i < 1500 && tape.snapshot().position < tape.snapshot().length; ++i) g.frames(1);
|
||||
require(tape.snapshot().position == tape.snapshot().length, "BASIC did not reach the cut");
|
||||
g.frames(300);
|
||||
const auto screen = g.machine.copyScreenText();
|
||||
require(screen.find("END OF FLIGHT") == screen.npos && tape.snapshot().motor &&
|
||||
tape.snapshot().mode == TapeMode::Stopped, "BASIC reported a completed file on a truncated tape:\n" + screen);
|
||||
g.verifyMedia();
|
||||
} catch (const std::exception& error) {
|
||||
std::cerr << error.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user