diff --git a/Configurable/StandardOptions.hpp b/Configurable/StandardOptions.hpp index ef6d3df38..4980b3315 100644 --- a/Configurable/StandardOptions.hpp +++ b/Configurable/StandardOptions.hpp @@ -49,6 +49,17 @@ template <typename Owner> class QuickloadOption { } }; +template <typename Owner> class QuickbootOption { + public: + bool quickboot; + QuickbootOption(bool quickboot) : quickboot(quickboot) {} + + protected: + void declare_quickboot_option() { + static_cast<Owner *>(this)->declare(&quickboot, "quickboot"); + } +}; + } #endif /* StandardOptions_hpp */ diff --git a/Machines/Apple/Macintosh/Macintosh.cpp b/Machines/Apple/Macintosh/Macintosh.cpp index c71fcf103..890db6619 100644 --- a/Machines/Apple/Macintosh/Macintosh.cpp +++ b/Machines/Apple/Macintosh/Macintosh.cpp @@ -57,16 +57,6 @@ constexpr int CLOCK_RATE = 7833600; namespace Apple { namespace Macintosh { -//std::vector<std::unique_ptr<Configurable::Option>> get_options() { -// return Configurable::standard_options( -// static_cast<Configurable::StandardOptions>(Configurable::QuickBoot) -// ); -//} - -std::unique_ptr<Reflection::Struct> get_options() { - return nullptr; -} - template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachine: public Machine, public CRTMachine::Machine, @@ -528,42 +518,30 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin // MARK: - Configuration options. std::unique_ptr<Reflection::Struct> get_options() final { - return nullptr; + auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly); + options->quickboot = quickboot_; + return options; } - void set_options(const std::unique_ptr<Reflection::Struct> &options) final { + void set_options(const std::unique_ptr<Reflection::Struct> &str) final { + // TODO: should this really be a runtime option? + // It should probably be a construction option. + + const auto options = dynamic_cast<Options *>(str.get()); + quickboot_ = options->quickboot; + if(quickboot_) { + // Cf. Big Mess o' Wires' disassembly of the Mac Plus ROM, and the + // test at $E00. TODO: adapt as(/if?) necessary for other Macs. + ram_[0x02ae] = 0x40; + ram_[0x02af] = 0x00; + ram_[0x02b0] = 0x00; + ram_[0x02b1] = 0x00; + } } -// std::vector<std::unique_ptr<Configurable::Option>> get_options() final { -// return Apple::Macintosh::get_options(); -// } -// -// void set_selections(const Configurable::SelectionSet &selections_by_option) final { -// bool quick_boot; -// if(Configurable::get_quick_boot(selections_by_option, quick_boot)) { -// if(quick_boot) { -// // Cf. Big Mess o' Wires' disassembly of the Mac Plus ROM, and the -// // test at $E00. TODO: adapt as(/if?) necessary for other Macs. -// ram_[0x02ae] = 0x40; -// ram_[0x02af] = 0x00; -// ram_[0x02b0] = 0x00; -// ram_[0x02b1] = 0x00; -// } -// } -// } -// -// Configurable::SelectionSet get_accurate_selections() final { -// Configurable::SelectionSet selection_set; -// Configurable::append_quick_boot_selection(selection_set, false); -// return selection_set; -// } -// -// Configurable::SelectionSet get_user_friendly_selections() final { -// Configurable::SelectionSet selection_set; -// Configurable::append_quick_boot_selection(selection_set, true); -// return selection_set; -// } private: + bool quickboot_ = false; + void set_component_prefers_clocking(ClockingHint::Source *component, ClockingHint::Preference clocking) final { scsi_bus_is_clocked_ = scsi_bus_.preferred_clocking() != ClockingHint::Preference::None; } diff --git a/Machines/Apple/Macintosh/Macintosh.hpp b/Machines/Apple/Macintosh/Macintosh.hpp index e29665d10..5c42b555f 100644 --- a/Machines/Apple/Macintosh/Macintosh.hpp +++ b/Machines/Apple/Macintosh/Macintosh.hpp @@ -9,23 +9,31 @@ #ifndef Macintosh_hpp #define Macintosh_hpp -#include "../../../Reflection/Struct.h" +#include "../../../Configurable/Configurable.hpp" +#include "../../../Configurable/StandardOptions.hpp" #include "../../../Analyser/Static/StaticAnalyser.hpp" #include "../../ROMMachine.hpp" -#include <memory> - namespace Apple { namespace Macintosh { -std::unique_ptr<Reflection::Struct> get_options(); - class Machine { public: virtual ~Machine(); /// Creates and returns a Macintosh. static Machine *Macintosh(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher); + + class Options: public Reflection::StructImpl<Options>, public Configurable::QuickbootOption<Options> { + friend Configurable::QuickbootOption<Options>; + public: + Options(Configurable::OptionsType type) : + Configurable::QuickbootOption<Options>(type == Configurable::OptionsType::UserFriendly) { + if(needs_declare()) { + declare_quickboot_option(); + } + } + }; }; diff --git a/Machines/ColecoVision/ColecoVision.cpp b/Machines/ColecoVision/ColecoVision.cpp index 142c82c47..5a773f883 100644 --- a/Machines/ColecoVision/ColecoVision.cpp +++ b/Machines/ColecoVision/ColecoVision.cpp @@ -34,10 +34,6 @@ constexpr int sn76489_divider = 2; namespace Coleco { namespace Vision { -std::unique_ptr<Reflection::Struct> get_options() { - return nullptr; -} - class Joystick: public Inputs::ConcreteJoystick { public: Joystick() : diff --git a/Machines/ColecoVision/ColecoVision.hpp b/Machines/ColecoVision/ColecoVision.hpp index 0e0dc8de5..4e5f0ce2c 100644 --- a/Machines/ColecoVision/ColecoVision.hpp +++ b/Machines/ColecoVision/ColecoVision.hpp @@ -14,8 +14,6 @@ #include "../../Analyser/Static/StaticAnalyser.hpp" #include "../ROMMachine.hpp" -#include <memory> - namespace Coleco { namespace Vision { diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index defd1abd5..b65ec7da9 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -33,17 +33,6 @@ namespace Electron { -//std::vector<std::unique_ptr<Configurable::Option>> get_options() { -// return Configurable::standard_options( -// static_cast<Configurable::StandardOptions>(Configurable::DisplayRGB | Configurable::DisplayCompositeColour | Configurable::QuickLoadTape) -// ); -//} - -std::unique_ptr<Reflection::Struct> get_options() { - return nullptr; -} - - class ConcreteMachine: public Machine, public CRTMachine::Machine, diff --git a/Machines/Oric/Oric.hpp b/Machines/Oric/Oric.hpp index d9f8540b1..44167d77d 100644 --- a/Machines/Oric/Oric.hpp +++ b/Machines/Oric/Oric.hpp @@ -18,9 +18,6 @@ namespace Oric { -/// @returns The options available for an Oric. -std::unique_ptr<Reflection::Struct> get_options(); - /*! Models an Oric 1/Atmos with or without a Microdisc. */ diff --git a/Machines/Utility/MachineForTarget.cpp b/Machines/Utility/MachineForTarget.cpp index 1681ea1c7..ca306a2c1 100644 --- a/Machines/Utility/MachineForTarget.cpp +++ b/Machines/Utility/MachineForTarget.cpp @@ -176,8 +176,6 @@ std::vector<std::string> Machine::AllMachines(bool meaningful_without_media_only std::map<std::string, std::unique_ptr<Reflection::Struct>> Machine::AllOptionsByMachineName() { std::map<std::string, std::unique_ptr<Reflection::Struct>> options; -// options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::Macintosh), Apple::Macintosh::get_options())); - #define Emplace(machine, class) \ options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::machine), std::make_unique<class::Options>(Configurable::OptionsType::UserFriendly))); @@ -186,6 +184,7 @@ std::map<std::string, std::unique_ptr<Reflection::Struct>> Machine::AllOptionsBy Emplace(AtariST, Atari::ST::Machine); Emplace(ColecoVision, Coleco::Vision::Machine); Emplace(Electron, Electron::Machine); + Emplace(Macintosh, Apple::Macintosh::Machine); Emplace(MasterSystem, Sega::MasterSystem::Machine); Emplace(MSX, MSX::Machine); Emplace(Oric, Oric::Machine);