From 6225abd7519f9254614312febe51c734004dad13 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 7 Jul 2021 20:57:04 -0400 Subject: [PATCH] Adds 6MHz Enterprise option. --- Analyser/Static/Enterprise/Target.hpp | 4 +++ Machines/Enterprise/Enterprise.cpp | 37 +++++++++++++++++++-------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/Analyser/Static/Enterprise/Target.hpp b/Analyser/Static/Enterprise/Target.hpp index 71805a10f..957852c5f 100644 --- a/Analyser/Static/Enterprise/Target.hpp +++ b/Analyser/Static/Enterprise/Target.hpp @@ -24,11 +24,13 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl class ConcreteMachine: +template class ConcreteMachine: public Activity::Source, public Configurable::Device, public CPU::Z80::BusHandler, @@ -88,6 +88,12 @@ template class ConcreteMachine: return uint8_t(0x100 - ram_size / 0x4000); } + static constexpr double clock_rate = is_6mhz ? 6'000'000.0 : 4'000'000.0; + using NickType = + std::conditional_t, + JustInTimeActor>; + public: ConcreteMachine(const Analyser::Static::Enterprise::Target &target, const ROMMachine::ROMFetcher &rom_fetcher) : min_ram_slot_(min_ram_slot(target)), @@ -97,8 +103,8 @@ template class ConcreteMachine: speaker_(dave_audio_) { // Request a clock of 4Mhz; this'll be mapped upwards for Nick and downwards for Dave elsewhere. - set_clock_rate(4'000'000.0); - speaker_.set_input_rate(float(get_clock_rate()) / float(dave_divider)); + set_clock_rate(clock_rate); + speaker_.set_input_rate(float(clock_rate) / float(dave_divider)); ROM::Request request; using Target = Analyser::Static::Enterprise::Target; @@ -275,7 +281,7 @@ template class ConcreteMachine: penalty = dave_delay_; } break; - case PartialMachineCycle::ReadOpcodeStart: + case PartialMachineCycle::ReadOpcodeStart: { if(is_video_[address >> 14]) { // Query Nick for the amount of delay that would occur with one cycle left // in this read opcode. @@ -285,7 +291,7 @@ template class ConcreteMachine: } else if(wait_mode_ != WaitMode::None) { penalty = dave_delay_; } - break; + } break; // Video pauses: insert right at the end of the bus cycle. case PartialMachineCycle::Write: @@ -596,7 +602,7 @@ template class ConcreteMachine: None, OnM1, OnAllAccesses - } wait_mode_ = WaitMode::None; + } wait_mode_ = WaitMode::OnAllAccesses; bool is_video_[4]{}; // MARK: - ScanProducer @@ -691,7 +697,7 @@ template class ConcreteMachine: // MARK: - Chips. CPU::Z80::Processor z80_; - JustInTimeActor nick_; + NickType nick_; bool previous_nick_interrupt_line_ = false; // Cf. timing guesses above. @@ -741,10 +747,19 @@ Machine *Machine::Enterprise(const Analyser::Static::Target *target, const ROMMa using Target = Analyser::Static::Enterprise::Target; const Target *const enterprise_target = dynamic_cast(target); - if(enterprise_target->dos == Target::DOS::None) - return new Enterprise::ConcreteMachine(*enterprise_target, rom_fetcher); - else - return new Enterprise::ConcreteMachine(*enterprise_target, rom_fetcher); +#define BuildMachine(exdos, sixmhz) \ + if((enterprise_target->dos == Target::DOS::None) != exdos && (enterprise_target->speed == Target::Speed::SixMHz) == sixmhz) { \ + return new Enterprise::ConcreteMachine(*enterprise_target, rom_fetcher); \ + } + + BuildMachine(false, false); + BuildMachine(false, true); + BuildMachine(true, false); + BuildMachine(true, true); + +#undef BuildMachine + + return nullptr; } Machine::~Machine() {}