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

+211
View File
@@ -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;
}
}