diff --git a/Machines/Enterprise/Dave.cpp b/Machines/Enterprise/Dave.cpp index 7d354f98c..3b7ca2ab0 100644 --- a/Machines/Enterprise/Dave.cpp +++ b/Machines/Enterprise/Dave.cpp @@ -200,10 +200,29 @@ uint8_t TimedInterruptSource::get_new_interrupts() { } void TimedInterruptSource::write(uint16_t address, uint8_t value) { - (void)address; - (void)value; + address &= 15; + switch(address) { + default: break; + + case 0: case 2: + channels_[address >> 1].reload = (channels_[address >> 1].reload & 0xff00) | value; + break; + case 1: case 3: + channels_[address >> 1].reload = uint16_t((channels_[address >> 1].reload & 0x00ff) | ((value & 0xf) << 8)); + break; + + case 7: + channels_[0].sync = value & 0x01; + channels_[1].sync = value & 0x02; + rate_ = InterruptRate((value >> 5) & 3); + break; + } } void TimedInterruptSource::run_for(Cycles cycles) { (void)cycles; } + +Cycles TimedInterruptSource::get_next_sequence_point() const { + return Cycles::max(); +} diff --git a/Machines/Enterprise/Dave.hpp b/Machines/Enterprise/Dave.hpp index 3953bc211..92b14bafb 100644 --- a/Machines/Enterprise/Dave.hpp +++ b/Machines/Enterprise/Dave.hpp @@ -125,8 +125,22 @@ class TimedInterruptSource { void run_for(Cycles); + Cycles get_next_sequence_point() const; + private: uint8_t interrupts_ = 0; + + enum class InterruptRate { + OnekHz, + FiftyHz, + ToneGenerator0, + ToneGenerator1, + } rate_ = InterruptRate::OnekHz; + + struct Channel { + uint16_t value, reload; + bool sync; + } channels_[2]; }; }