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,94 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Build the complete Mission Recorder project and fly it using real guest ROMs."""
|
||||
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, help="staged ToolchainBundle")
|
||||
parser.add_argument("core", type=Path, help="libVCCCore.a for the host architecture")
|
||||
parser.add_argument("roms", type=Path, help="CoCo 3, Disk BASIC and both Speech/Sound ROMs")
|
||||
parser.add_argument("--capture", type=Path, help="save the optimized 6809's live flight 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]
|
||||
env = dict(os.environ, PATH=str(runtime / "bin") + os.pathsep + os.environ["PATH"])
|
||||
with tempfile.TemporaryDirectory(prefix="vcc-mission-recorder-") as folder:
|
||||
work = Path(folder)
|
||||
runner = work / "run"
|
||||
subprocess.run(["xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
|
||||
"-I", root / "src", fixture / "run.cpp", core, "-o", runner], check=True)
|
||||
tool = runtime / "bin/writecocofile"
|
||||
note = b"EARLIER CREW\rDO NOT OVERWRITE\r"
|
||||
blank = root / "platforms/macos/Resources/StarterMedia/Blank Disk.dsk"
|
||||
draft = b"PART OF A PREVIOUS FLIGHT\r"
|
||||
for config in ("Debug", "Release"):
|
||||
project = work / config
|
||||
shutil.copytree(root / "examples/cmoc/MissionRecorder", project)
|
||||
subprocess.run([runtime / "bin/make", "-j3", "disk", "VCC_CONFIGURATION=" + config],
|
||||
cwd=project, env=env, check=True)
|
||||
binary, disk = project / "RECORDER.bin", project / "RECORDER.dsk"
|
||||
occupied = project / "occupied.dsk"
|
||||
shutil.copyfile(disk, occupied)
|
||||
(project / "LOG01.TXT").write_bytes(note)
|
||||
subprocess.run([tool, "--binary", occupied, "LOG01.TXT"], cwd=project, check=True)
|
||||
(project / "LOG02.TMP").write_bytes(draft)
|
||||
subprocess.run([tool, "--binary", occupied, "LOG02.TMP"], cwd=project, check=True)
|
||||
for cpu in ("6809", "6309"):
|
||||
for path in ("direct", "disk", "quiet", "speech", "stereo", "missing", "discard"):
|
||||
media = occupied if path == "disk" else blank
|
||||
original = media.read_bytes()
|
||||
capture = args.capture and (cpu, config, path) == ("6809", "Release", "direct")
|
||||
subprocess.run([runner, roms, cpu, path, binary, media, *(["capture"] if capture else [])],
|
||||
cwd=project, check=True)
|
||||
result = project / "returned.dsk"
|
||||
if path == "discard":
|
||||
if result.read_bytes() != original:
|
||||
raise AssertionError("Discarding a flight changed its disk")
|
||||
else:
|
||||
log = "LOG03.TXT" if path == "disk" else "LOG01.TXT"
|
||||
def extract(name):
|
||||
return subprocess.check_output([tool, "--stdout", result, name], cwd=project)
|
||||
if extract(log) != (project / "printed.bin").read_bytes():
|
||||
raise AssertionError("The saved and printed reports differ")
|
||||
if path == "disk" and extract("LOG01.TXT") != note:
|
||||
raise AssertionError("The earlier report changed")
|
||||
if path == "disk" and extract("LOG02.TMP") != draft:
|
||||
raise AssertionError("An earlier unfinished flight was overwritten")
|
||||
if path == "disk" and extract("RECORDER.BIN") != binary.read_bytes():
|
||||
raise AssertionError("The guest damaged its program disk")
|
||||
if media.read_bytes() != original:
|
||||
raise AssertionError("The test modified its input image")
|
||||
if capture:
|
||||
subprocess.run(["sips", "-s", "format", "png", project / "flight.ppm",
|
||||
"--out", args.capture.resolve()], check=True)
|
||||
print(f"PASS {config}, {binary.stat().st_size} program bytes, {disk.stat().st_size} disk bytes",
|
||||
flush=True)
|
||||
|
||||
# Boot the optimized project disk on the two other BASIC storage profiles.
|
||||
# Read the result from the backing volume used by the guest.
|
||||
profile_runner = work / "profiles"
|
||||
subprocess.run(["xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
|
||||
"-I", root / "src", fixture / "profiles.cpp", core, "-o", profile_runner], check=True)
|
||||
card = work / "practice card"
|
||||
card.mkdir()
|
||||
(card / "startup.cfg").write_text("0=VOL.DSK\n", encoding="ascii")
|
||||
for cpu in ("6809", "6309"):
|
||||
for profile in ("rgb-hd", "sdc"):
|
||||
volume = card / "VOL.DSK"
|
||||
shutil.copyfile(work / "Release/RECORDER.dsk", volume)
|
||||
subprocess.run([profile_runner, roms, cpu, profile, volume], cwd=work, check=True)
|
||||
report = subprocess.check_output([tool, "--stdout", work / "returned.dsk", "LOG01.TXT"])
|
||||
if report != b"MISSION RECORDER\rSECTOR 07\r":
|
||||
raise AssertionError(f"{cpu} {profile}: unexpected report {report!r}")
|
||||
print(f"PASS {cpu} {profile}: saved starting sector and returned to BASIC", flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,31 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#include "../guest-captures.h"
|
||||
|
||||
using namespace BasicDiskTests;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
try {
|
||||
require(argc == 5, "Usage: profiles ROMs CPU rgb-hd|sdc disk");
|
||||
const auto profile = std::string(argv[3]) == "sdc" ? Profile::sdc : Profile::rgbHD;
|
||||
const auto cpu = std::string(argv[2]) == "6809" ? Processor::MC6809 : Processor::HD6309;
|
||||
Session guest(argv[1], argv[4], cpu, profile);
|
||||
guest.type("LOADM\"RECORDER\":EXEC\r");
|
||||
guest.until("SELECT AUDIO");
|
||||
guest.frames(15);
|
||||
guest.type("1");
|
||||
guest.frames(500); // Finish painting both GIME pages before pressing Space.
|
||||
guest.type(" ");
|
||||
guest.frames(120);
|
||||
require(guest.machine.debuggerMemoryRange(0x50000, 1, true).bytes[0] == 7,
|
||||
"Keyboard pilot did not record the starting sector in bank $28");
|
||||
guest.type("S");
|
||||
guest.frames(120); // Return to hardware text before querying the guest screen.
|
||||
guest.until("SAVED LOG01.TXT");
|
||||
guest.verifyReturn();
|
||||
saveVolume(guest, "returned.dsk");
|
||||
} catch (const std::exception& error) {
|
||||
std::cerr << error.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#include "../ssc/session.h"
|
||||
#include "../guest-captures.h"
|
||||
|
||||
// An electrically silent observer in the spare Multi-Pak slot counts writes.
|
||||
// Sound comes exclusively from the real emulated cartridges in slots 1 and 2.
|
||||
struct DacObserver final : CartridgeDevice {
|
||||
std::uint64_t changes = 0;
|
||||
std::uint8_t left = 128, right = 128;
|
||||
void reset() override { changes = 0; left = right = 128; }
|
||||
void horizontalSync(DeviceHost&) override {}
|
||||
std::uint8_t readMemory(std::uint16_t) const override { return 0xff; }
|
||||
std::uint8_t readPort(std::uint8_t, DeviceHost&) override { return 0; }
|
||||
void writePort(std::uint8_t port, std::uint8_t value, DeviceHost&) override {
|
||||
if (port == 0x7a) { left = value; ++changes; }
|
||||
if (port == 0x7b) { right = value; ++changes; }
|
||||
}
|
||||
};
|
||||
|
||||
template<class Condition>
|
||||
static void waitFor(Session& guest, Condition success, const std::string& message, unsigned limit = 900) {
|
||||
for (unsigned n = 0; n < limit; ++n) {
|
||||
guest.tick();
|
||||
if (success()) return;
|
||||
}
|
||||
throw std::runtime_error(message);
|
||||
}
|
||||
|
||||
static void frames(Session& guest, unsigned count) {
|
||||
while (count--) guest.tick();
|
||||
}
|
||||
|
||||
static std::uint32_t pixel(const Frame& frame, unsigned x, unsigned y) {
|
||||
const auto a = frame.activeArea;
|
||||
return frame.pixels.at((a.y + y * a.height / 192) * Frame::width + a.x + x * a.width / 320);
|
||||
}
|
||||
|
||||
static void expectShip(Session& guest, unsigned sector) {
|
||||
waitFor(guest, [&] {
|
||||
auto frame = guest.machine.snapshot().frame;
|
||||
if (!frame) return false;
|
||||
return pixel(*frame, 10 + 20 * sector, 54) != pixel(*frame, 2 + 20 * sector, 54);
|
||||
}, "Ship did not appear in sector " + std::to_string(sector));
|
||||
}
|
||||
|
||||
// gime_close() restores the text mode on a frame boundary. Text scanout
|
||||
// is unavailable for the remaining graphics frames after the save/quit key.
|
||||
static void untilText(Session& guest, const std::string& text, unsigned limit = 1200) {
|
||||
waitFor(guest, [&] {
|
||||
try {
|
||||
return guest.contains(text);
|
||||
} catch (const std::logic_error&) {
|
||||
return false;
|
||||
}
|
||||
}, "Did not see " + text, limit);
|
||||
}
|
||||
|
||||
static void verifyBasic(Session& guest) {
|
||||
untilText(guest, "OK");
|
||||
frames(guest, 12);
|
||||
guest.press(47, true); guest.press(39); guest.press(43, true);
|
||||
guest.press(35); guest.press(48); // ?7+3
|
||||
guest.until(" 10");
|
||||
}
|
||||
|
||||
static void fly(const fs::path& roms, Processor cpu, const std::string& mode,
|
||||
const fs::path& binary, const fs::path& image, bool capture) {
|
||||
const bool quiet = mode == "quiet", discard = mode == "discard", fromDisk = mode == "disk";
|
||||
auto chips = readFile(roms / "pic-7040-510.bin");
|
||||
auto voice = readFile(roms / "sp0256-al2.bin");
|
||||
require(chips.size() == 4096 && voice.size() == 2048, "Incorrect Speech/Sound ROM sizes");
|
||||
chips.insert(chips.end(), voice.begin(), voice.end());
|
||||
const bool missing = mode == "missing";
|
||||
const bool speech = !quiet && mode != "stereo";
|
||||
const bool stereo = !quiet && mode != "speech";
|
||||
auto ssc = speech && !missing ? std::make_shared<SpeechSoundDevice>(chips) : nullptr;
|
||||
auto dac = std::make_shared<DacObserver>();
|
||||
Session guest(cpu, readFile(roms / "coco3.rom"), readFile(roms / "disk11.rom"), ssc, stereo && !missing, dac);
|
||||
auto& machine = guest.machine;
|
||||
auto& printer = machine.printer();
|
||||
printer.setEnabled(true);
|
||||
auto ram = [&](unsigned address, unsigned count, bool physical = false) {
|
||||
return machine.debuggerMemoryRange(address, count, physical).bytes;
|
||||
};
|
||||
const auto irq = ram(0xfef7, 3), palette = ram(0xffb0, 16);
|
||||
const auto before = machine.debuggerSnapshot().mmu;
|
||||
const auto disk = readFile(image);
|
||||
if (fromDisk) guest.diskExec(disk, "RECORDER");
|
||||
else {
|
||||
guest.floppy->mount(0, DiskImage::load(disk, false));
|
||||
guest.launch(readFile(binary));
|
||||
}
|
||||
guest.until("SELECT AUDIO", 1200);
|
||||
frames(guest, 12);
|
||||
guest.audio.clear();
|
||||
const auto beforeSpeech = ssc ? ssc->diagnostics().AldSpeechCount() : 0;
|
||||
// The first screen can appear while the guest is still painting the second
|
||||
// landscape. Both GIME presentations must have completed before sending D.
|
||||
guest.press(33 + unsigned(speech) + 2 * unsigned(stereo));
|
||||
waitFor(guest, [&] { return ram(0xff9d, 1)[0] == 0x90; }, "First GIME page was never displayed");
|
||||
waitFor(guest, [&] { return ram(0xff9d, 1)[0] == 0x80; }, "Second GIME page was never displayed");
|
||||
expectShip(guest, 7);
|
||||
if (stereo) waitFor(guest, [&] { return dac->changes > 100; }, "Stereo player did not start");
|
||||
// The keyboard nudges the craft, then the physical right-stick reaches the edge.
|
||||
guest.press(4);
|
||||
expectShip(guest, 8);
|
||||
machine.setJoystick(0, 16383, 8191, 0, 0);
|
||||
expectShip(guest, 15);
|
||||
machine.setJoystick(0, 8191, 8191, 0, 0);
|
||||
|
||||
if (stereo) {
|
||||
require(ram(0xfef7, 3) != irq, "Stereo never installed its interrupt handler");
|
||||
unsigned left = 0, right = 0;
|
||||
for (auto sample : guest.audio) {
|
||||
left += sample.left > sample.right + 0.02f;
|
||||
right += sample.right > sample.left + 0.02f;
|
||||
}
|
||||
if (missing) require(!left && !right, "Stereo without an installed cartridge");
|
||||
else require(left > 50 && right > 50, "No distinct left and right PCM during steering");
|
||||
}
|
||||
// Press and release the first right joystick button; no test writes guest RAM.
|
||||
machine.setJoystick(0, 8191, 8191, 1, 0);
|
||||
waitFor(guest, [&] { return ram(0x50000, 1, true)[0] == 15; }, "Flight mark missing in physical bank $28");
|
||||
machine.setJoystick(0, 8191, 8191, 0, 0);
|
||||
if (ssc) {
|
||||
waitFor(guest, [&] { return ssc->diagnostics().AldSpeechCount() > beforeSpeech; },
|
||||
"Speech chip did not start the mark announcement");
|
||||
}
|
||||
// With no Orchestra cartridge contributing audio, the voiced phrase should
|
||||
// be audible on both channels, with no channel divergence.
|
||||
if (speech && !stereo) {
|
||||
guest.audio.clear();
|
||||
frames(guest, 90);
|
||||
guest.checkSignal(0);
|
||||
require(std::all_of(guest.audio.begin(), guest.audio.end(),
|
||||
[](auto sample) { return sample.left == sample.right; }), "Speech was not centered");
|
||||
}
|
||||
const auto spokenAtDeparture = ssc ? ssc->diagnostics().AldSpeechCount() : 0;
|
||||
const auto writesAtDeparture = dac->changes;
|
||||
// Leave the marked sector. The flight report must use the saved mark.
|
||||
machine.setJoystick(0, 0, 8191, 0, 0);
|
||||
expectShip(guest, 7);
|
||||
if (ssc && stereo) {
|
||||
require(ssc->diagnostics().AldSpeechCount() > spokenAtDeparture && dac->changes > writesAtDeparture,
|
||||
"Speech or stereo stalled while steering away from the mark");
|
||||
}
|
||||
machine.setJoystick(0, 8191, 8191, 0, 0);
|
||||
frames(guest, 30);
|
||||
const auto frame = machine.snapshot().frame;
|
||||
require(pixel(*frame, 310, 69) != pixel(*frame, 302, 69), "Saved mark disappeared after steering away");
|
||||
if (capture) BasicDiskTests::saveActiveFrame(*machine.snapshot().frame, "flight.ppm");
|
||||
|
||||
if (discard) {
|
||||
machine.setKeyboard(std::uint64_t{1} << 17); // Q
|
||||
untilText(guest, "FLIGHT DISCARDED");
|
||||
machine.setKeyboard(0);
|
||||
require(printer.bytes().empty(), "Discard printed a report");
|
||||
} else {
|
||||
machine.setKeyboard(std::uint64_t{1} << 19); // S, through the current draw
|
||||
if (fromDisk) {
|
||||
untilText(guest, "SAVE FAILED", 1600);
|
||||
require(guest.floppy->image(0)->bytes() == disk && printer.bytes().empty(),
|
||||
"The failed save touched the disk or printer");
|
||||
machine.setKeyboard(0);
|
||||
guest.floppy->setWriteProtected(0, false);
|
||||
frames(guest, 12);
|
||||
guest.press(18); // R
|
||||
}
|
||||
untilText(guest, fromDisk ? "SAVED LOG03.TXT" : "SAVED LOG01.TXT", 1800);
|
||||
machine.setKeyboard(0);
|
||||
}
|
||||
verifyBasic(guest);
|
||||
const auto after = machine.debuggerSnapshot().mmu;
|
||||
require(after.Task0 == before.Task0 && after.Task1 == before.Task1 &&
|
||||
after.ActiveTask == before.ActiveTask, "Effective MMU banks were not restored");
|
||||
require(ram(0xfef7, 3) == irq, "BASIC interrupt vector was not restored");
|
||||
require(ram(0xffb0, 16) == palette, "BASIC palette was not restored");
|
||||
const auto stopped = dac->changes;
|
||||
frames(guest, 15);
|
||||
require(dac->changes == stopped && dac->left == 128 && dac->right == 128,
|
||||
"Background DAC writes continued after exit or a channel was left on");
|
||||
if (!stereo) require(!dac->changes, "Software wrote to an unselected Orchestra DAC");
|
||||
if (discard) {
|
||||
require(guest.floppy->writeEvents(0) == 0 && printer.bytes().empty(), "Discard produced output");
|
||||
} else {
|
||||
require(guest.floppy->writeEvents(0) > 0, "No guest FD-502 writes");
|
||||
const auto& bytes = printer.bytes();
|
||||
require(std::string(bytes.begin(), bytes.end()) == "MISSION RECORDER\rSECTOR 15\r" &&
|
||||
printer.droppedBytes() == 0, "Unexpected TP-10 report");
|
||||
std::ofstream out("printed.bin", std::ios::binary);
|
||||
out.write(reinterpret_cast<const char*>(bytes.data()), bytes.size());
|
||||
require(out.good(), "Could not save printer output for comparison");
|
||||
}
|
||||
if (ssc) require(ssc->diagnostics().CpuIllegalCount() == 0, "Speech cartridge executed an illegal instruction");
|
||||
BasicDiskTests::saveDisk(*guest.floppy->image(0), "returned.dsk");
|
||||
std::cout << "PASS " << (cpu == Processor::MC6809 ? "6809" : "6309") << " " << mode
|
||||
<< ", " << dac->changes << " DAC writes, "
|
||||
<< (ssc ? ssc->diagnostics().AldSpeechCount() - beforeSpeech : 0) << " phonemes, "
|
||||
<< guest.floppy->readEvents(0) << " reads, " << guest.floppy->writeEvents(0) << " writes\n";
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
try {
|
||||
require(argc == 6 || argc == 7, "Usage: run ROMS CPU direct|disk|quiet|speech|stereo|missing|discard BIN DSK [capture]");
|
||||
fly(argv[1], std::string(argv[2]) == "6809" ? Processor::MC6809 : Processor::HD6309,
|
||||
argv[3], argv[4], argv[5], argc == 7);
|
||||
} catch (const std::exception& error) {
|
||||
std::cerr << error.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user