// SPDX-License-Identifier: GPL-3.0-or-later #include "../guest-captures.h" using namespace BasicDiskTests; static void sendReport(Session& guest) { guest.until("PRESS SPACE TO SEND REPORT"); guest.type(" "); guest.until("REPORT SENT TO PRINTER PORT"); const auto screen = guest.machine.copyScreenText(); require(screen.find("BLUE SEA") == std::string::npos && screen.find("RED RIDGE") == std::string::npos, "Printer lines leaked onto the CoCo display"); guest.until("OK"); } static void checkBytes(const PrinterCapture& printer, const std::string& expected) { const auto& actual = printer.bytes(); require(std::string(actual.begin(), actual.end()) == expected && printer.droppedBytes() == 0, "Unexpected raw printer data (" + std::to_string(actual.size()) + " bytes): " + std::string(actual.begin(), actual.end())); } int main(int argc, char** argv) { try { require(argc == 5, "Usage: run ROMDIR CPU PROFILE CAPTURE"); const auto cpu = std::string(argv[2]) == "6809" ? Processor::MC6809 : Processor::HD6309; const std::string mode = argv[3]; const auto profile = mode == "disk" ? Profile::fd : mode == "rgb-hd" ? Profile::rgbHD : Profile::sdc; Session guest(argv[1], "card/VOL.DSK", cpu, profile); auto& printer = guest.machine.printer(); require(!printer.enabled(), "Capture should start off"); guest.launch("FLIGHT.BIN"); sendReport(guest); checkBytes(printer, ""); guest.verifyReturn(); guest.type("CLS\r"); printer.setEnabled(true); guest.launch("FLIGHT.BIN"); sendReport(guest); const std::string report = "TP-10 FLIGHT REPORT\r01 EARTH BLUE SEA\r02 MARS RED RIDGE\rEND OF REPORT\r"; checkBytes(printer, report); guest.verifyReturn(); guest.type("CLS\r"); guest.type("LOADM\"FLIGHT\":EXEC\r"); sendReport(guest); checkBytes(printer, report + report); if (std::string(argv[4]) == "capture") { guest.frames(3); saveActiveFrame(*guest.machine.snapshot().frame, "flight.ppm"); } guest.verifyReturn(); guest.launch("QUAL.BIN"); guest.until("PRINTER CHECKS PASSED"); guest.verifyReturn(); checkBytes(printer, report + report + "0009 IO X %\rPREFIX"); guest.verifyMedia(); } catch (const std::exception& error) { std::cerr << error.what() << '\n'; return 1; } }