// // Archimedes.cpp // Clock Signal // // Created by Thomas Harte on 04/03/2024. // Copyright © 2024 Thomas Harte. All rights reserved. // #include "Archimedes.hpp" #include "../../AudioProducer.hpp" #include "../../KeyboardMachine.hpp" #include "../../MediaTarget.hpp" #include "../../ScanProducer.hpp" #include "../../TimedMachine.hpp" #include "../../../InstructionSets/ARM/Executor.hpp" namespace Archimedes { struct Memory { std::vector rom; template bool write(uint32_t address, IntT source, InstructionSet::ARM::Mode mode, bool trans) { (void)mode; (void)trans; printf("W of %08x to %08x [%lu]\n", source, address, sizeof(IntT)); if(has_moved_rom_ && address < ram_.size()) { *reinterpret_cast(&ram_[address]) = source; } return true; } template bool read(uint32_t address, IntT &source, InstructionSet::ARM::Mode mode, bool trans) { (void)mode; (void)trans; if(address >= 0x3800000) { has_moved_rom_ = true; source = *reinterpret_cast(&rom[address - 0x3800000]); } else if(!has_moved_rom_) { // TODO: this is true only very transiently. source = *reinterpret_cast(&rom[address]); } else if(address < ram_.size()) { source = *reinterpret_cast(&ram_[address]); } else { source = 0; printf("Unknown read from %08x [%lu]\n", address, sizeof(IntT)); } return true; } private: bool has_moved_rom_ = false; std::array ram_{}; }; class ConcreteMachine: public Machine, public MachineTypes::TimedMachine, public MachineTypes::ScanProducer { public: ConcreteMachine( const Analyser::Static::Target &target, const ROMMachine::ROMFetcher &rom_fetcher ) { (void)target; (void)rom_fetcher; } private: // MARK: - ScanProducer. void set_scan_target(Outputs::Display::ScanTarget *scan_target) override { (void)scan_target; } Outputs::Display::ScanStatus get_scaled_scan_status() const override { return Outputs::Display::ScanStatus(); } // MARK: - TimedMachine. void run_for(Cycles cycles) override { (void)cycles; } // MARK: - ARM execution InstructionSet::ARM::Executor executor_; }; } using namespace Archimedes; std::unique_ptr Machine::Archimedes(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher) { return std::make_unique(*target, rom_fetcher); }