From 8d87e9eb1ce6ee6d3b1c5bee58137e336b376555 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 13 Oct 2019 21:32:34 -0400 Subject: [PATCH] The ACIA actually has two clocks, though on an ST they're both 500,000 Hz. --- Components/6850/6850.cpp | 12 ++++++++---- Components/6850/6850.hpp | 19 ++++++++++++++++--- Machines/AtariST/AtariST.cpp | 8 ++++---- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Components/6850/6850.cpp b/Components/6850/6850.cpp index eb4e99c2b..01cd64296 100644 --- a/Components/6850/6850.cpp +++ b/Components/6850/6850.cpp @@ -13,9 +13,13 @@ using namespace Motorola::ACIA; -ACIA::ACIA(int clock_rate) { - transmit.set_writer_clock_rate(clock_rate); - request_to_send.set_writer_clock_rate(clock_rate); +const HalfCycles ACIA::SameAsTransmit; + +ACIA::ACIA(HalfCycles transmit_clock_rate, HalfCycles receive_clock_rate) : + transmit_clock_rate_(transmit_clock_rate), + receive_clock_rate_((receive_clock_rate != SameAsTransmit) ? receive_clock_rate : transmit_clock_rate) { + transmit.set_writer_clock_rate(transmit_clock_rate.as_int()); + request_to_send.set_writer_clock_rate(transmit_clock_rate.as_int()); } uint8_t ACIA::read(int address) { @@ -149,6 +153,6 @@ ClockingHint::Preference ACIA::preferred_clocking() { return (transmit.write_data_time_remaining() > 0) ? ClockingHint::Preference::JustInTime : ClockingHint::Preference::None; } -bool ACIA::get_interrupt_line() { +bool ACIA::get_interrupt_line() const { return interrupt_request_; } diff --git a/Components/6850/6850.hpp b/Components/6850/6850.hpp index a8ea3f96e..5111d5c89 100644 --- a/Components/6850/6850.hpp +++ b/Components/6850/6850.hpp @@ -19,7 +19,13 @@ namespace ACIA { class ACIA: public ClockingHint::Source { public: - ACIA(int clock_rate); + static constexpr const HalfCycles SameAsTransmit = HalfCycles(0); + + /*! + Constructs a new instance of ACIA which will receive a transmission clock at a rate of + @c transmit_clock_rate, and a receive clock at a rate of @c receive_clock_rate. + */ + ACIA(HalfCycles transmit_clock_rate, HalfCycles receive_clock_rate = SameAsTransmit); /*! Reads from the ACIA. @@ -39,9 +45,13 @@ class ACIA: public ClockingHint::Source { */ void write(int address, uint8_t value); - void run_for(HalfCycles); + /*! + Advances @c transmission_cycles in time, which should be + counted relative to the @c transmit_clock_rate. + */ + void run_for(HalfCycles transmission_cycles); - bool get_interrupt_line(); + bool get_interrupt_line() const; // Input lines. Serial::Line receive; @@ -69,6 +79,9 @@ class ACIA: public ClockingHint::Source { bool interrupt_request_ = false; ClockingHint::Preference preferred_clocking() final; + + HalfCycles transmit_clock_rate_; + HalfCycles receive_clock_rate_; }; } diff --git a/Machines/AtariST/AtariST.cpp b/Machines/AtariST/AtariST.cpp index 5cff738c1..6277489ff 100644 --- a/Machines/AtariST/AtariST.cpp +++ b/Machines/AtariST/AtariST.cpp @@ -39,8 +39,8 @@ class ConcreteMachine: public: ConcreteMachine(const Target &target, const ROMMachine::ROMFetcher &rom_fetcher) : mc68000_(*this), - keyboard_acia_(CLOCK_RATE / 10), - midi_acia_(CLOCK_RATE / 10), + keyboard_acia_(Cycles(500000)), + midi_acia_(Cycles(500000)), ay_(audio_queue_), speaker_(ay_) { set_clock_rate(CLOCK_RATE); @@ -372,8 +372,8 @@ class ConcreteMachine: HalfCycles cycles_until_video_event_; JustInTimeActor mfp_; - JustInTimeActor keyboard_acia_; - JustInTimeActor midi_acia_; + JustInTimeActor keyboard_acia_; + JustInTimeActor midi_acia_; Concurrency::DeferringAsyncTaskQueue audio_queue_; GI::AY38910::AY38910 ay_;