diff --git a/InstructionSets/M50740/Executor.cpp b/InstructionSets/M50740/Executor.cpp index e554635b9..3be5a4935 100644 --- a/InstructionSets/M50740/Executor.cpp +++ b/InstructionSets/M50740/Executor.cpp @@ -8,6 +8,7 @@ #include "Executor.hpp" +#include #include using namespace InstructionSet::M50740; @@ -18,13 +19,31 @@ Executor::Executor() { Decoder decoder; for(size_t c = 0; c < 256; c++) { const auto instruction = decoder.instrucion_for_opcode(uint8_t(c)); - performers_[c] = performer_lookup_.performer(instruction.operation, instruction.addressing_mode); + + // Treat invalid as NOP, because I've got to do _something_. + if(instruction.operation == Operation::Invalid) { + performers_[c] = performer_lookup_.performer(Operation::NOP, instruction.addressing_mode); + } else { + performers_[c] = performer_lookup_.performer(instruction.operation, instruction.addressing_mode); + } } // TODO: read reset vector, etc. This is just the start of ROM. set_program_counter(0x1400); } +void Executor::set_rom(const std::vector &rom) { + // Copy into place, and reset. + const auto length = std::min(size_t(0x1000), rom.size()); + memcpy(&memory_[0x2000 - length], rom.data(), length); + reset(); +} + +void Executor::reset() { + // Just jump to the reset vector. + set_program_counter(uint16_t(memory_[0x1ffe] | (memory_[0x1fff] << 8))); +} + template void Executor::perform() { // Deal with all modes that don't access memory up here; // those that access memory will go through a slightly longer diff --git a/InstructionSets/M50740/Executor.hpp b/InstructionSets/M50740/Executor.hpp index b70a12f38..64b8133d9 100644 --- a/InstructionSets/M50740/Executor.hpp +++ b/InstructionSets/M50740/Executor.hpp @@ -13,6 +13,9 @@ #include "Parser.hpp" #include "../CachingExecutor.hpp" +#include +#include + namespace InstructionSet { namespace M50740 { @@ -22,6 +25,8 @@ using CachingExecutor = CachingExecutor &rom); + void reset(); private: // MARK: - CachingExecutor-facing interface. diff --git a/Machines/Apple/AppleIIgs/ADB.cpp b/Machines/Apple/AppleIIgs/ADB.cpp index eed717c02..2bf02ac2a 100644 --- a/Machines/Apple/AppleIIgs/ADB.cpp +++ b/Machines/Apple/AppleIIgs/ADB.cpp @@ -211,3 +211,7 @@ uint8_t GLU::read_microcontroller_address(uint16_t address) { return 0x40; return 0; } + +void GLU::set_microcontroller_rom(const std::vector &rom) { + executor_.set_rom(rom); +} diff --git a/Machines/Apple/AppleIIgs/ADB.hpp b/Machines/Apple/AppleIIgs/ADB.hpp index 20efe25b9..2d5745f28 100644 --- a/Machines/Apple/AppleIIgs/ADB.hpp +++ b/Machines/Apple/AppleIIgs/ADB.hpp @@ -11,6 +11,7 @@ #include #include +#include "../../../InstructionSets/M50740/Executor.hpp" namespace Apple { namespace IIgs { @@ -34,6 +35,8 @@ class GLU { void set_status(uint8_t); void clear_key_strobe(); + void set_microcontroller_rom(const std::vector &rom); + private: bool is_rom03_ = false; std::vector next_command_; @@ -52,6 +55,8 @@ class GLU { void set_configuration_bytes(uint8_t *); uint8_t read_microcontroller_address(uint16_t); + + InstructionSet::M50740::Executor executor_; }; } diff --git a/Machines/Apple/AppleIIgs/AppleIIgs.cpp b/Machines/Apple/AppleIIgs/AppleIIgs.cpp index 92f72ef59..1894a4163 100644 --- a/Machines/Apple/AppleIIgs/AppleIIgs.cpp +++ b/Machines/Apple/AppleIIgs/AppleIIgs.cpp @@ -88,13 +88,15 @@ class ConcreteMachine: break; } rom_descriptions.push_back(video_->rom_description(Video::Video::CharacterROM::EnhancedIIe)); + rom_descriptions.emplace_back(machine_name, "the Apple IIgs ADB microcontroller ROM", "341s0632-2", 4*1024, 0xe1c11fb0); const auto roms = rom_fetcher(rom_descriptions); - if(!roms[0] || !roms[1]) { + if(!roms[0] || !roms[1] || !roms[2]) { throw ROMMachine::Error::MissingROMs; } rom_ = *roms[0]; video_->set_character_rom(*roms[1]); + adb_glu_.set_microcontroller_rom(*roms[2]); // Run only the currently-interesting self test. rom_[0x36402] = 2; diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme index 7516c5447..672c62faf 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme +++ b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme @@ -27,6 +27,8 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" + enableAddressSanitizer = "YES" + enableUBSanitizer = "YES" disableMainThreadChecker = "YES" codeCoverageEnabled = "YES"> diff --git a/ROMImages/AppleIIGS/readme.txt b/ROMImages/AppleIIGS/readme.txt index 4362bfc75..02d568fda 100644 --- a/ROMImages/AppleIIGS/readme.txt +++ b/ROMImages/AppleIIGS/readme.txt @@ -2,5 +2,6 @@ ROM files would ordinarily go here; they are copyright Apple so are not included Expected files (as usual, using the most conventional pre-existing names): +341s0632-2.bin — the ADB microcontroller ROM; APPLE2GS.ROM - ROM version 1; and APPLE2GS.ROM2 - ROM version 3.