diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index e80d3a4d8..91a5879a8 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -13,6 +13,7 @@ using namespace Oric; Machine::Machine() : _cycles_since_video_update(0) { set_clock_rate(1000000); + _via.set_interrupt_delegate(this); } void Machine::configure_as_target(const StaticAnalyser::Target &target) @@ -32,15 +33,24 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin } else { - if(isReadOperation(operation)) - *value = _ram[address]; + if((address & 0xff00) == 0x0300) + { + if(isReadOperation(operation)) *value = _via.get_register(address); + else _via.set_register(address, *value); + } else { - if(address >= 0x9800) update_video(); - _ram[address] = *value; + if(isReadOperation(operation)) + *value = _ram[address]; + else + { + if(address >= 0x9800) update_video(); + _ram[address] = *value; + } } } + _via.run_for_half_cycles(2); _cycles_since_video_update++; return 1; } @@ -65,3 +75,8 @@ void Machine::close_output() { _videoOutput.reset(); } + +void Machine::mos6522_did_change_interrupt_status(void *mos6522) +{ + set_irq_line(_via.get_interrupt_line()); +} diff --git a/Machines/Oric/Oric.hpp b/Machines/Oric/Oric.hpp index 2fbededf9..93698d3fa 100644 --- a/Machines/Oric/Oric.hpp +++ b/Machines/Oric/Oric.hpp @@ -10,6 +10,7 @@ #define Oric_hpp #include "../../Processors/6502/CPU6502.hpp" +#include "../../Components/6522/6522.hpp" #include "../../Storage/Tape/Tape.hpp" #include "../ConfigurationTarget.hpp" @@ -23,10 +24,16 @@ namespace Oric { +class VIA: public MOS::MOS6522, public MOS::MOS6522IRQDelegate { + public: + using MOS6522IRQDelegate::set_interrupt_status; +}; + class Machine: public CPU6502::Processor, public CRTMachine::Machine, - public ConfigurationTarget::Machine { + public ConfigurationTarget::Machine, + public MOS::MOS6522IRQDelegate::Delegate { public: Machine(); @@ -47,6 +54,9 @@ class Machine: virtual std::shared_ptr get_speaker() { return nullptr; } virtual void run_for_cycles(int number_of_cycles) { CPU6502::Processor::run_for_cycles(number_of_cycles); } + // to satisfy MOS::MOS6522IRQDelegate::Delegate + void mos6522_did_change_interrupt_status(void *mos6522); + private: // RAM and ROM uint8_t _ram[65536], _rom[16384]; @@ -55,6 +65,9 @@ class Machine: // Outputs std::unique_ptr _videoOutput; + + // + VIA _via; }; }