Files

57 lines
2.1 KiB
C++

// SPDX-License-Identifier: GPL-3.0-or-later
#include "../guest-captures.h"
using namespace BasicDiskTests;
int main(int argc, char** argv)
{
try {
require(argc == 6, "Usage: run ROMDIR BIN CPU PROFILE PHASE");
const auto cpu = std::string(argv[3]) == "6809" ? Processor::MC6809 : Processor::HD6309;
const std::string mode = argv[4], phase = argv[5];
const auto profile = mode == "disk" ? Profile::fd : mode == "rgb-hd" ? Profile::rgbHD : Profile::sdc;
Session guest(argv[1], "card/VOL.DSK", cpu, profile);
if (phase == "recover" || phase == "capture")
guest.type("LOADM\"BACKUP\":EXEC\r");
else
guest.launch(argv[2]);
if (phase == "interrupt" || phase == "save") {
guest.until("BACKUP IN PLACE");
guest.until("PRESS A KEY TO INSTALL");
if (phase == "interrupt") {
// Terminate the whole guest process here. Only its disk goes
// to the next invocation, which starts from the boot ROM.
saveVolume(guest, "result.dsk");
return 0;
}
guest.type("Y");
guest.until("UPDATED ATLAS SAVED");
} else if (phase == "recover" || phase == "capture") {
guest.until("ORIGINAL ATLAS RESTORED");
guest.until("MARS: RED RIDGE");
} else if (phase == "keep-draft") {
guest.until("ORIGINAL ATLAS RESTORED");
guest.until("KEPT UNEXPECTED ATLAS.NEW");
} else if (phase == "repeat") {
guest.until("ATLAS ALREADY UPDATED");
} else if (phase == "refuse") {
guest.until("SAVE STOPPED - CHECK DISK");
} else {
throw std::logic_error("Unknown test phase " + phase);
}
guest.until("OK");
if (phase == "capture") {
guest.frames(3);
saveActiveFrame(*guest.machine.snapshot().frame, "recovered.ppm");
}
guest.verifyReturn();
saveVolume(guest, "result.dsk");
} catch (const std::exception& error) {
std::cerr << error.what() << std::endl;
return 1;
}
}