63 lines
3.1 KiB
C++
63 lines
3.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 DISK BIN APPEND_BIN CAPTURE");
|
|
for (auto cpu : {Processor::MC6809, Processor::HD6309}) {
|
|
Session session(argv[1], argv[2], cpu, Profile::fd);
|
|
std::string prefix = cpu == Processor::MC6809 ? "6809-" : "6309-";
|
|
// First run starts a fresh log. The lesson's one-character edit appends on the second.
|
|
for (const auto& mode : {"fresh", "append"}) {
|
|
const bool append = std::string(mode) == "append";
|
|
session.type("CLS\r");
|
|
session.launch(argv[append ? 4 : 3]);
|
|
session.until("SPACE TO LAND ON MARS");
|
|
session.until("CHECKPOINT READER SEES:\nEARTH: BLUE SEA");
|
|
saveDisk(*session.floppy->image(0), prefix + mode + "-checkpoint.dsk");
|
|
session.frames(12);
|
|
session.type(" ");
|
|
session.until("SURVEY FILED");
|
|
session.until("FINAL READER SEES:\nEARTH: BLUE SEA\nMARS: RED RIDGE");
|
|
saveDisk(*session.floppy->image(0), prefix + mode + "-closed.dsk");
|
|
if (!append && cpu == Processor::MC6809 && std::string(argv[5]) == "capture") {
|
|
session.until("OK");
|
|
session.frames(4);
|
|
saveActiveFrame(*session.machine.snapshot().frame, "log.ppm");
|
|
}
|
|
session.verifyReturn();
|
|
}
|
|
session.floppy->setWriteProtected(0, true);
|
|
const auto previous = session.floppy->image(0)->bytes();
|
|
for (const auto binary : {argv[3], argv[4]}) {
|
|
session.type("CLS\r");
|
|
session.launch(binary);
|
|
// A DOS may detect protection at open or at the first flush.
|
|
for (unsigned n = 0; n < 2000; ++n) {
|
|
session.frames(1);
|
|
const auto text = session.machine.copyScreenText();
|
|
if (text.find("CANNOT START FIELD.LOG") != text.npos ||
|
|
text.find("CHECK DISK AND LOG") != text.npos) break;
|
|
require(n + 1 < 2000, "Expected a protected disk error: " + text);
|
|
}
|
|
require(previous == session.floppy->image(0)->bytes(), "Protected disk was changed");
|
|
session.verifyReturn();
|
|
}
|
|
// Read the first two records with the resident Disk BASIC ROM.
|
|
session.frames(12);
|
|
session.machine.basicLoadSource("10 CLS:OPEN \"I\",#1,\"FIELD.LOG\"\n"
|
|
"20 LINE INPUT #1,A$:PRINT A$\n"
|
|
"30 LINE INPUT #1,A$:PRINT A$\n"
|
|
"40 CLOSE #1\n", true);
|
|
session.until("EARTH: BLUE SEA\nMARS: RED RIDGE");
|
|
session.verifyReturn();
|
|
}
|
|
} catch (const std::exception& error) {
|
|
std::cerr << error.what() << std::endl;
|
|
return 1;
|
|
}
|
|
}
|