Files
VCCPlusOSS/tests/toolchain/expedition-demo/run.cpp
T

114 lines
4.0 KiB
C++

// SPDX-License-Identifier: GPL-3.0-or-later
#include "../guest-captures.h"
using namespace BasicDiskTests;
// The SDC-DOS mount command also needs three punctuation keys.
static void enter(Session& guest, const std::string& command)
{
for (char c : command) {
if (c == ',' || c == '.' || c == '/') {
guest.machine.setKeyboard(std::uint64_t(1) << (c == ',' ? 44 : c == '.' ? 46 : 47));
guest.frames(5);
guest.machine.setKeyboard(0);
guest.frames(5);
} else {
guest.type(std::string(1, c));
}
}
}
static void checkChart(Session& guest)
{
guest.until("Q QUIT");
guest.frames(8);
const auto text = guest.machine.copyScreenText();
for (auto name : {" EARTH.DSK", " MARS.DSK", " EXPLORE.DSK", "SDC0: EXPLORE.DSK", "SDC1: EMPTY"})
require(text.find(name) != text.npos, "Chart is missing " + std::string(name) + "\n" + text);
}
static void checkMounts(Session& guest, const std::string& planet)
{
const auto disks = guest.sdc->snapshot().drives;
require(disks[0].mounted && fs::path(disks[0].name).filename() == "EXPLORE.DSK", "Program disk changed");
require(disks[1].mounted && fs::path(disks[1].name).filename() == planet, "Unexpected planet disk");
require(disks[1].reads > 0 && !disks[1].writes && !disks[0].writes, "Expected read-only planet visit");
}
static void fly(const fs::path& roms, const fs::path& card, const fs::path& binary, Processor cpu, const std::string& mode)
{
const std::string mars = mode == "edited" ? "MARS: ICE CAP\nLAND NEAR THE POLE." : "MARS: RED RIDGE\nLAND BEYOND THE DUST FIELD.";
Session guest(roms, card / "EXPLORE.DSK", cpu, Profile::sdc, false);
guest.sdc->setWriteProtected(true);
enter(guest, "DRIVE 0,\"/EXPLORE.DSK\"\r");
guest.until("OK");
require(fs::path(guest.sdc->snapshot().drives[0].name).filename() == "EXPLORE.DSK", "BASIC did not mount program disk");
enter(guest, "LOADM\"EXPLORE:0\":EXEC\r");
checkChart(guest);
guest.type("1");
guest.until("SDC1: EARTH.DSK");
guest.until("EARTH: BLUE OCEAN\nSPLASH DOWN BESIDE THE BUOY.");
checkMounts(guest, "EARTH.DSK");
guest.until("Q QUIT");
guest.frames(8);
guest.type("2");
guest.until("SDC1: MARS.DSK");
guest.until(mars);
guest.until("Q QUIT");
checkMounts(guest, "MARS.DSK");
if (mode == "capture" && cpu == Processor::MC6809) {
guest.frames(3);
saveActiveFrame(*guest.machine.snapshot().frame, "expedition.ppm");
}
guest.type("3");
guest.until("COULD NOT MOUNT /MISSING.DSK");
guest.until(mars);
guest.until("SDC1: MARS.DSK");
checkMounts(guest, "MARS.DSK");
guest.until("Q QUIT");
guest.frames(8);
guest.type("Q");
guest.until("EXPEDITION COMPLETE");
guest.verifyReturn();
guest.verifyMedia();
guest.type("CLS\rDIR 0\r");
guest.until("EXPLORE");
guest.until("BIN");
guest.until("OK");
guest.frames(12);
guest.type("CLS\rDIR 1\r");
guest.until("LANDING");
guest.until("TXT");
guest.until("OK");
guest.frames(12);
// Running the same binary directly uses the card that is still mounted.
guest.launch(binary);
guest.until("DISKS ON THE PRACTICE CARD");
guest.until("Q QUIT");
guest.frames(8);
guest.until("SDC1: MARS.DSK");
guest.type("1");
guest.until("SPLASH DOWN BESIDE THE BUOY.");
checkMounts(guest, "EARTH.DSK");
guest.until("Q QUIT");
guest.frames(8);
guest.type("Q");
guest.until("EXPEDITION COMPLETE");
guest.verifyReturn();
}
int main(int argc, char** argv)
{
try {
require(argc == 5, "Usage: run ROMDIR CARD BIN CAPTURE");
for (auto cpu : {Processor::MC6809, Processor::HD6309}) {
fly(argv[1], argv[2], argv[3], cpu, argv[4]);
std::cout << "PASS " << (cpu == Processor::MC6809 ? "6809" : "6309") << " expedition under SDC-DOS\n";
}
} catch (const std::exception& error) {
std::cerr << error.what() << std::endl;
return 1;
}
}