// SPDX-License-Identifier: GPL-3.0-or-later // Read-only optional ROM check: quickload newly compiled code on both guest CPUs. #include "../../src/core/MachineSession.h" #include "../../src/core/tcc1014mmu.h" #include #include #include using namespace VCC::Mac; static std::vector read(const char* path) { std::ifstream input(path, std::ios::binary); if (!input) throw std::runtime_error("Cannot open input"); return {std::istreambuf_iterator(input), std::istreambuf_iterator()}; } int main(int argc, char** argv) { try { if (argc < 3 || argc > 5) throw std::runtime_error("Usage: run-compiled COCO3_ROM PROGRAM_BIN [EXPECTED [FRAMES]]"); const int runFrames = argc == 5 ? std::stoi(argv[4]) : 120; if (runFrames < 1) throw std::runtime_error("Frame count must be positive"); const auto rom=read(argv[1]), binary=read(argv[2]); bool passed = true; for (auto cpu : {Processor::MC6809, Processor::HD6309}) { MachineSession machine; machine.load(rom,cpu);machine.resume(); for(unsigned n=0;n<180;++n)machine.advance(); machine.quickLoad(binary); for (int n = 0; n < runFrames; ++n) machine.advance(); std::string screen; for(unsigned n=0;n<512;++n) { unsigned c=SafeMemRead8(0x400+n)&63; screen+=char(c<32?c+64:c); } const char* name = cpu == Processor::MC6809 ? "6809" : "6309"; const char* expected = argc >= 4 ? argv[3] : "HELLO FROM CMOC"; if (screen.find(expected) == std::string::npos) { std::cerr << name << " expected " << expected << ", guest screen:\n" << machine.copyScreenText() << '\n'; passed = false; } else { std::cout << "PASS compiled CMOC program: " << name << '\n'; } } return passed ? 0 : 1; } catch(const std::exception& error) { std::cerr<