// SPDX-License-Identifier: GPL-3.0-or-later #include "../guest-captures.h" using namespace BasicDiskTests; static void openAtlas(Session& guest, const fs::path& binary) { guest.launch(binary); guest.until("PICK A PLANET (1-4), THEN ENTER"); } static void expectTrip(Session& guest, int position, const std::string& chosen, const std::string& visit) { guest.until("YOUR PICK AT BYTE " + std::to_string(position) + "\n" + chosen + "\nHOME BASE\nEARTH: BLUE SEA\nBACK TO YOUR BOOKMARK\n" + chosen + "\nFIRST CARD\nMERCURY: CRATERS\n" + visit); guest.until("OK"); } static void visitPracticeDisk(const fs::path& roms, const fs::path& binary, Processor cpu, Profile profile, bool capture) { Session guest(roms, "blank/VOL.DSK", cpu, profile); openAtlas(guest, binary); guest.type("4\r"); expectTrip(guest, 72, "MARS: RED RIDGE", "VISIT SAVED\nATLAS CLOSED"); if (capture) { guest.frames(3); saveActiveFrame(*guest.machine.snapshot().frame, "atlas.ppm"); } guest.verifyReturn(); saveVolume(guest, "saved-atlas.dsk"); // A second launch reads the disk flag, without needing to write it again. setVolumeProtected(guest, true); const auto original = volume(guest); openAtlas(guest, binary); guest.type("4\r"); expectTrip(guest, 72, "MARS: RED RIDGE", "ALREADY VISITED\nATLAS CLOSED"); guest.verifyReturn(); // Venus is still unvisited. A protected write must fail without damage. openAtlas(guest, binary); guest.type("2X\r"); guest.until("EXTRA CHARACTER: X\nPICK A PLANET (1-4), THEN ENTER"); if (capture) { guest.frames(3); saveActiveFrame(*guest.machine.snapshot().frame, "atlas-input.ppm"); } guest.type("MARS\r"); guest.until("START WITH A DIGIT"); guest.type("4294967298\r"); guest.until("CHOOSE A NUMBER FROM 1 TO 4"); guest.type("0X2\r"); expectTrip(guest, 24, "VENUS: CLOUDS", "CANNOT SAVE VISIT"); guest.verifyReturn(); openAtlas(guest, binary); guest.type("2\r"); expectTrip(guest, 24, "VENUS: CLOUDS", "CANNOT SAVE VISIT"); guest.verifyReturn(); require(volume(guest) == original, "Protected atlas changed"); } static void visitEditedDisk(const fs::path& roms, Processor cpu, Profile profile) { Session guest(roms, "edited/VOL.DSK", cpu, profile); guest.type("LOADM\"ATLAS\":EXEC\r"); guest.until("PICK A PLANET (1-4), THEN ENTER"); guest.type("4\r"); expectTrip(guest, 72, "MARS: DUST STORM", "VISIT SAVED\nATLAS CLOSED"); guest.verifyReturn(); saveVolume(guest, "edited-atlas.dsk"); } static void visitUnchangedDisk(const fs::path& roms, const fs::path& binary, Processor cpu, Profile profile, const fs::path& disk, const std::string& expected) { Session guest(roms, disk, cpu, profile); openAtlas(guest, binary); guest.type("4\r"); guest.until(expected); guest.verifyReturn(); guest.verifyMedia(); } int main(int argc, char** argv) { try { require(argc == 6, "Usage: run ROMDIR BIN CPU PROFILE CAPTURE"); const auto cpu = std::string(argv[3]) == "6809" ? Processor::MC6809 : Processor::HD6309; const std::string mode = argv[4]; const auto profile = mode == "disk" ? Profile::fd : mode == "rgb-hd" ? Profile::rgbHD : Profile::sdc; visitPracticeDisk(argv[1], argv[2], cpu, profile, std::string(argv[5]) == "capture"); visitEditedDisk(argv[1], cpu, profile); visitUnchangedDisk(argv[1], argv[2], cpu, profile, "short/VOL.DSK", "CANNOT READ ATLAS CARD"); visitUnchangedDisk(argv[1], argv[2], cpu, profile, "full/VOL.DSK", "NO ROOM FOR VISIT MARK\nATLAS CLOSED"); } catch (const std::exception& error) { std::cerr << error.what() << std::endl; return 1; } }