From eb2b1cb0933a062f72610e8f11085a0a12d0a312 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 26 May 2024 22:02:40 -0400 Subject: [PATCH] Support FDC overclocking as 'fast loading'. --- Machines/Acorn/Archimedes/Archimedes.cpp | 56 ++++++++++++++++--- Machines/Acorn/Archimedes/Archimedes.hpp | 13 +++++ .../Archimedes/InputOutputController.hpp | 4 +- .../Acorn/Archimedes/MemoryController.hpp | 4 +- .../Base.lproj/QuickLoadCompositeOptions.xib | 4 +- .../Base.lproj/QuickLoadOptions.xib | 8 +-- .../Documents/MachineDocument.swift | 3 +- .../StaticAnalyser/CSStaticAnalyser.mm | 2 +- 8 files changed, 76 insertions(+), 18 deletions(-) diff --git a/Machines/Acorn/Archimedes/Archimedes.cpp b/Machines/Acorn/Archimedes/Archimedes.cpp index da974215f..706fae186 100644 --- a/Machines/Acorn/Archimedes/Archimedes.cpp +++ b/Machines/Acorn/Archimedes/Archimedes.cpp @@ -15,6 +15,8 @@ #include "MemoryController.hpp" #include "Sound.hpp" +#include "../../../Configurable/Configurable.hpp" + #include "../../AudioProducer.hpp" #include "../../KeyboardMachine.hpp" #include "../../MediaTarget.hpp" @@ -46,7 +48,8 @@ class ConcreteMachine: public MachineTypes::MouseMachine, public MachineTypes::TimedMachine, public MachineTypes::ScanProducer, - public Activity::Source + public Activity::Source, + public Configurable::Device { private: Log::Logger logger; @@ -187,6 +190,24 @@ class ConcreteMachine: const uint32_t swi_code = comment & static_cast(~(1 << 17)); switch(swi_code) { + // + // Optional high-level reimplementations, for fast loading. + // + + case 0x40240: { // ADFS_DiscOp + const uint32_t function = executor_.registers()[1] & 0xf; + switch(function) { + default: break; + + case 0x1: // Read sectors. + printf("Read sectors from %d for %d bytes into %08x\n", + executor_.registers()[2], + executor_.registers()[4], + executor_.registers()[3]); + break; + } + } break; + // // Passive monitoring traps, for automatic loading. // @@ -367,20 +388,23 @@ class ConcreteMachine: } // MARK: - TimedMachine. - int video_divider_ = 1; - void run_for(Cycles cycles) override { + bool use_original_speed() const { #ifndef NDEBUG // Debug mode: always run 'slowly' because that's less of a burden, and // because it allows me to peer at problems with greater leisure. - const bool use_original_speed = true; + return true; #else // As a first, blunt implementation: try to model something close // to original speed if there have been 10 frame rate overages in total. - const bool use_original_speed = executor_.bus.video().frame_rate_overages() > 10; + return executor_.bus.video().frame_rate_overages() > 10; #endif + } + + int video_divider_ = 1; + void run_for(Cycles cycles) override { const auto run = [&](Cycles cycles) { - if(use_original_speed) run_for(cycles); + if(use_original_speed()) run_for(cycles); else run_for(cycles); }; @@ -486,7 +510,13 @@ class ConcreteMachine: void tick_timers() { executor_.bus.tick_timers(); } void tick_sound() { executor_.bus.sound().tick(); } void tick_video() { executor_.bus.video().tick(); } - void tick_floppy() { executor_.bus.tick_floppy(); } + + bool accelerate_loading_ = true; + void tick_floppy() { + executor_.bus.tick_floppy( + accelerate_loading_ ? (use_original_speed() ? 12 : 18) : 1 + ); + } // MARK: - MediaTarget bool insert_media(const Analyser::Static::Media &media) override { @@ -499,6 +529,18 @@ class ConcreteMachine: return true; } + // MARK: - Configuration options. + std::unique_ptr get_options() final { + auto options = std::make_unique(Configurable::OptionsType::UserFriendly); + options->quickload = accelerate_loading_; + return options; + } + + void set_options(const std::unique_ptr &str) final { + const auto options = dynamic_cast(str.get()); + accelerate_loading_ = options->quickload; + } + // MARK: - AudioProducer Outputs::Speaker::Speaker *get_speaker() override { return executor_.bus.speaker(); diff --git a/Machines/Acorn/Archimedes/Archimedes.hpp b/Machines/Acorn/Archimedes/Archimedes.hpp index c967ad2eb..658e1c2ab 100644 --- a/Machines/Acorn/Archimedes/Archimedes.hpp +++ b/Machines/Acorn/Archimedes/Archimedes.hpp @@ -8,6 +8,8 @@ #pragma once +#include "../../../Configurable/Configurable.hpp" +#include "../../../Configurable/StandardOptions.hpp" #include "../../../Analyser/Static/StaticAnalyser.hpp" #include "../../ROMMachine.hpp" @@ -22,6 +24,17 @@ class Machine { const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher ); + + class Options: public Reflection::StructImpl, public Configurable::QuickloadOption { + friend Configurable::QuickloadOption; + public: + Options(Configurable::OptionsType type) : + Configurable::QuickloadOption(type == Configurable::OptionsType::UserFriendly) { + if(needs_declare()) { + declare_quickload_option(); + } + } + }; }; } diff --git a/Machines/Acorn/Archimedes/InputOutputController.hpp b/Machines/Acorn/Archimedes/InputOutputController.hpp index 6311a6fcc..11fd2e6f4 100644 --- a/Machines/Acorn/Archimedes/InputOutputController.hpp +++ b/Machines/Acorn/Archimedes/InputOutputController.hpp @@ -130,9 +130,9 @@ struct InputOutputController: public ClockingHint::Observer { } } - void tick_floppy() { + void tick_floppy(int clock_multiplier) { if(floppy_clocking_ != ClockingHint::Preference::None) { - floppy_.run_for(Cycles(1)); + floppy_.run_for(Cycles(clock_multiplier)); } } diff --git a/Machines/Acorn/Archimedes/MemoryController.hpp b/Machines/Acorn/Archimedes/MemoryController.hpp index 3a1614a0d..162a95b10 100644 --- a/Machines/Acorn/Archimedes/MemoryController.hpp +++ b/Machines/Acorn/Archimedes/MemoryController.hpp @@ -214,7 +214,9 @@ struct MemoryController { // Expose various IOC-owned things. // void tick_timers() { ioc_.tick_timers(); } - void tick_floppy() { ioc_.tick_floppy(); } + void tick_floppy(int clock_multiplier) { + ioc_.tick_floppy(clock_multiplier); + } void set_disk(std::shared_ptr disk, size_t drive) { ioc_.set_disk(disk, drive); } diff --git a/OSBindings/Mac/Clock Signal/Base.lproj/QuickLoadCompositeOptions.xib b/OSBindings/Mac/Clock Signal/Base.lproj/QuickLoadCompositeOptions.xib index 30c91fdce..6582d3b1c 100644 --- a/OSBindings/Mac/Clock Signal/Base.lproj/QuickLoadCompositeOptions.xib +++ b/OSBindings/Mac/Clock Signal/Base.lproj/QuickLoadCompositeOptions.xib @@ -1,8 +1,8 @@ - + - + diff --git a/OSBindings/Mac/Clock Signal/Base.lproj/QuickLoadOptions.xib b/OSBindings/Mac/Clock Signal/Base.lproj/QuickLoadOptions.xib index 758ead0c9..9fbc2efd5 100644 --- a/OSBindings/Mac/Clock Signal/Base.lproj/QuickLoadOptions.xib +++ b/OSBindings/Mac/Clock Signal/Base.lproj/QuickLoadOptions.xib @@ -1,20 +1,20 @@ - + - + - + - +