From 8e3bf0dbcab196ec2f1390e4a8984ef38dd4d307 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 15 Mar 2020 23:48:53 -0400 Subject: [PATCH] Starts moving towards a Deflectable-based system of runtime options. --- .../Implementation/MultiConfigurable.cpp | 11 ++- .../Implementation/MultiConfigurable.hpp | 11 ++- Configurable/Configurable.cpp | 27 ------ Configurable/Configurable.hpp | 93 ++++--------------- Configurable/StandardOptions.cpp | 24 +---- Configurable/StandardOptions.hpp | 76 +-------------- Machines/AmstradCPC/AmstradCPC.cpp | 56 ++++++----- Machines/AmstradCPC/AmstradCPC.hpp | 5 +- Machines/Apple/AppleII/AppleII.cpp | 51 +++++----- Machines/Apple/AppleII/AppleII.hpp | 5 +- Machines/Apple/Macintosh/Macintosh.cpp | 71 ++++++++------ Machines/Apple/Macintosh/Macintosh.hpp | 6 +- Machines/Atari/ST/AtariST.cpp | 52 ++++++----- Machines/Atari/ST/AtariST.hpp | 6 +- Machines/ColecoVision/ColecoVision.cpp | 57 +++++++----- Machines/ColecoVision/ColecoVision.hpp | 6 +- Machines/Commodore/Vic-20/Vic20.cpp | 71 +++++++------- Machines/Commodore/Vic-20/Vic20.hpp | 5 +- Machines/Electron/Electron.cpp | 74 ++++++++------- Machines/Electron/Electron.hpp | 6 +- Machines/MSX/MSX.cpp | 73 ++++++++------- Machines/MSX/MSX.hpp | 5 +- Machines/MasterSystem/MasterSystem.cpp | 57 +++++++----- Machines/MasterSystem/MasterSystem.hpp | 6 +- Machines/Oric/Oric.cpp | 78 +++++++++------- Machines/Oric/Oric.hpp | 6 +- Machines/Utility/MachineForTarget.cpp | 24 ++--- Machines/Utility/MachineForTarget.hpp | 2 +- Machines/ZX8081/ZX8081.cpp | 57 ++++++------ Machines/ZX8081/ZX8081.hpp | 6 +- .../Clock Signal.xcodeproj/project.pbxproj | 12 +-- Reflection/Struct.cpp | 22 +++++ Reflection/Struct.h | 11 +++ 33 files changed, 524 insertions(+), 548 deletions(-) delete mode 100644 Configurable/Configurable.cpp diff --git a/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurable.cpp b/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurable.cpp index 8e85c9410..c77ff6de0 100644 --- a/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurable.cpp +++ b/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurable.cpp @@ -19,7 +19,15 @@ MultiConfigurable::MultiConfigurable(const std::vector> MultiConfigurable::get_options() { +void MultiConfigurable::set_options(const std::unique_ptr &options) { +} + +std::unique_ptr MultiConfigurable::get_options(OptionsType type) { + // TODO: this'll need to mash options together, maybe? Or just take the front? + return nullptr; +} + +/*std::vector> MultiConfigurable::get_options() { std::vector> options; // Produce the list of unique options. @@ -62,3 +70,4 @@ Configurable::SelectionSet MultiConfigurable::get_user_friendly_selections() { } return set; } +*/ diff --git a/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurable.hpp b/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurable.hpp index ac4aecae9..7d4672987 100644 --- a/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurable.hpp +++ b/Analyser/Dynamic/MultiMachine/Implementation/MultiConfigurable.hpp @@ -10,6 +10,7 @@ #define MultiConfigurable_hpp #include "../../../../Machines/DynamicMachine.hpp" +#include "../../../../Configurable/Configurable.hpp" #include #include @@ -28,10 +29,12 @@ class MultiConfigurable: public Configurable::Device { MultiConfigurable(const std::vector> &machines); // Below is the standard Configurable::Device interface; see there for documentation. - std::vector> get_options() final; - void set_selections(const Configurable::SelectionSet &selection_by_option) final; - Configurable::SelectionSet get_accurate_selections() final; - Configurable::SelectionSet get_user_friendly_selections() final; + void set_options(const std::unique_ptr &options) final; + std::unique_ptr get_options(OptionsType type) final; +// std::vector> get_options() final; +// void set_selections(const Configurable::SelectionSet &selection_by_option) final; +// Configurable::SelectionSet get_accurate_selections() final; +// Configurable::SelectionSet get_user_friendly_selections() final; private: std::vector devices_; diff --git a/Configurable/Configurable.cpp b/Configurable/Configurable.cpp deleted file mode 100644 index 1834d3eb4..000000000 --- a/Configurable/Configurable.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// -// Configurable.cpp -// Clock Signal -// -// Created by Thomas Harte on 18/11/2017. -// Copyright 2017 Thomas Harte. All rights reserved. -// - -#include "Configurable.hpp" - -using namespace Configurable; - -ListSelection *BooleanSelection::list_selection() { - return new ListSelection(value ? "yes" : "no"); -} - -ListSelection *ListSelection::list_selection() { - return new ListSelection(value); -} - -BooleanSelection *ListSelection::boolean_selection() { - return new BooleanSelection(value != "no" && value != "n" && value != "false" && value != "f"); -} - -BooleanSelection *BooleanSelection::boolean_selection() { - return new BooleanSelection(value); -} diff --git a/Configurable/Configurable.hpp b/Configurable/Configurable.hpp index 833989951..9876e02d4 100644 --- a/Configurable/Configurable.hpp +++ b/Configurable/Configurable.hpp @@ -9,89 +9,34 @@ #ifndef Configurable_h #define Configurable_h -#include -#include -#include -#include +#include "../Reflection/Struct.h" namespace Configurable { /*! - The Option class hierarchy provides a way for components, machines, etc, to provide a named - list of typed options to which they can respond. -*/ -struct Option { - std::string long_name; - std::string short_name; - virtual ~Option() {} + A Configurable::Device provides a reflective struct listing the available runtime options for this machine. + It can provide it populated with 'accurate' options, 'user-friendly' options or just whatever the user + currently has selected. - Option(const std::string &long_name, const std::string &short_name) : long_name(long_name), short_name(short_name) {} + 'Accurate' options should correspond to the way that this device was usually used during its lifespan. + E.g. a ColecoVision might accurately be given composite output. - virtual bool operator==(const Option &rhs) { - return long_name == rhs.long_name && short_name == rhs.short_name; - } -}; - -struct BooleanOption: public Option { - BooleanOption(const std::string &long_name, const std::string &short_name) : Option(long_name, short_name) {} -}; - -struct ListOption: public Option { - std::vector options; - ListOption(const std::string &long_name, const std::string &short_name, const std::vector &options) : Option(long_name, short_name), options(options) {} - - virtual bool operator==(const Option &rhs) { - const ListOption *list_rhs = dynamic_cast(&rhs); - if(!list_rhs) return false; - return long_name == rhs.long_name && short_name == rhs.short_name && options == list_rhs->options; - } -}; - -struct BooleanSelection; -struct ListSelection; - -/*! - Selections are responses to Options. -*/ -struct Selection { - virtual ~Selection() {} - virtual ListSelection *list_selection() = 0; - virtual BooleanSelection *boolean_selection() = 0; -}; - -struct BooleanSelection: public Selection { - bool value; - - ListSelection *list_selection(); - BooleanSelection *boolean_selection(); - BooleanSelection(bool value) : value(value) {} -}; - -struct ListSelection: public Selection { - std::string value; - - ListSelection *list_selection(); - BooleanSelection *boolean_selection(); - ListSelection(const std::string value) : value(value) {} -}; - -using SelectionSet = std::map>; - -/*! - A Configuratble provides the options that it responds to and allows selections to be set. + 'User-friendly' options should be more like those that a user today might most expect from an emulator. + E.g. the ColecoVision might bump itself up to S-Video output. */ struct Device { - virtual std::vector> get_options() = 0; - virtual void set_selections(const SelectionSet &selection_by_option) = 0; - virtual SelectionSet get_accurate_selections() = 0; - virtual SelectionSet get_user_friendly_selections() = 0; -}; + /// Sets the current options. + virtual void set_options(const std::unique_ptr &options) = 0; -template T *selection(const Configurable::SelectionSet &selections_by_option, const std::string &name) { - auto selection = selections_by_option.find(name); - if(selection == selections_by_option.end()) return nullptr; - return dynamic_cast(selection->second.get()); -} + enum class OptionsType { + Current, + Accurate, + UserFriendly + }; + + /// @returns Options of type @c type. + virtual std::unique_ptr get_options(OptionsType type) = 0; +}; } diff --git a/Configurable/StandardOptions.cpp b/Configurable/StandardOptions.cpp index 1cb0badf2..1dce510b7 100644 --- a/Configurable/StandardOptions.cpp +++ b/Configurable/StandardOptions.cpp @@ -8,27 +8,7 @@ #include "StandardOptions.hpp" -namespace { - -/*! - Appends a Boolean selection of @c selection for option @c name to @c selection_set. -*/ -void append_bool(Configurable::SelectionSet &selection_set, const std::string &name, bool selection) { - selection_set[name] = std::make_unique(selection); -} - -/*! - Enquires for a Boolean selection for option @c name from @c selections_by_option, storing it to @c result if found. -*/ -bool get_bool(const Configurable::SelectionSet &selections_by_option, const std::string &name, bool &result) { - auto selection = Configurable::selection(selections_by_option, name); - if(!selection) return false; - result = selection->value; - return true; -} - -} - +/* // MARK: - Standard option list builder std::vector> Configurable::standard_options(Configurable::StandardOptions mask) { std::vector> options; @@ -105,4 +85,4 @@ bool Configurable::get_display(const Configurable::SelectionSet &selections_by_o bool Configurable::get_quick_boot(const Configurable::SelectionSet &selections_by_option, bool &result) { return get_bool(selections_by_option, "quickboot", result); -} +}*/ diff --git a/Configurable/StandardOptions.hpp b/Configurable/StandardOptions.hpp index fa042ee65..53bc0f600 100644 --- a/Configurable/StandardOptions.hpp +++ b/Configurable/StandardOptions.hpp @@ -9,87 +9,17 @@ #ifndef StandardOptions_hpp #define StandardOptions_hpp -#include "Configurable.hpp" +#include "../Reflection/Enum.h" namespace Configurable { -enum StandardOptions { - DisplayRGB = (1 << 0), - DisplaySVideo = (1 << 1), - DisplayCompositeColour = (1 << 2), - DisplayCompositeMonochrome = (1 << 3), - QuickLoadTape = (1 << 4), - AutomaticTapeMotorControl = (1 << 5), - QuickBoot = (1 << 6), -}; - -enum class Display { +ReflectableEnum(Display, RGB, SVideo, CompositeColour, CompositeMonochrome -}; +); -/*! - @returns An option list comprised of the standard names for all the options indicated by @c mask. -*/ -std::vector> standard_options(StandardOptions mask); - -/*! - Appends to @c selection_set a selection of @c selection for QuickLoadTape. -*/ -void append_quick_load_tape_selection(SelectionSet &selection_set, bool selection); - -/*! - Appends to @c selection_set a selection of @c selection for AutomaticTapeMotorControl. -*/ -void append_automatic_tape_motor_control_selection(SelectionSet &selection_set, bool selection); - -/*! - Appends to @c selection_set a selection of @c selection for DisplayRGBComposite. -*/ -void append_display_selection(SelectionSet &selection_set, Display selection); - -/*! - Appends to @c selection_set a selection of @c selection for QuickBoot. -*/ -void append_quick_boot_selection(SelectionSet &selection_set, bool selection); - -/*! - Attempts to discern a QuickLoadTape selection from @c selections_by_option. - - @param selections_by_option The user selections. - @param result The location to which the selection will be stored if found. - @returns @c true if a selection is found; @c false otherwise. -*/ -bool get_quick_load_tape(const SelectionSet &selections_by_option, bool &result); - -/*! - Attempts to discern an AutomaticTapeMotorControl selection from @c selections_by_option. - - @param selections_by_option The user selections. - @param result The location to which the selection will be stored if found. - @returns @c true if a selection is found; @c false otherwise. -*/ -bool get_automatic_tape_motor_control_selection(const SelectionSet &selections_by_option, bool &result); - -/*! - Attempts to discern a display RGB/composite selection from @c selections_by_option. - - @param selections_by_option The user selections. - @param result The location to which the selection will be stored if found. - @returns @c true if a selection is found; @c false otherwise. -*/ -bool get_display(const SelectionSet &selections_by_option, Display &result); - -/*! - Attempts to QuickBoot a QuickLoadTape selection from @c selections_by_option. - - @param selections_by_option The user selections. - @param result The location to which the selection will be stored if found. - @returns @c true if a selection is found; @c false otherwise. -*/ -bool get_quick_boot(const SelectionSet &selections_by_option, bool &result); } diff --git a/Machines/AmstradCPC/AmstradCPC.cpp b/Machines/AmstradCPC/AmstradCPC.cpp index ec6565d74..956dc62de 100644 --- a/Machines/AmstradCPC/AmstradCPC.cpp +++ b/Machines/AmstradCPC/AmstradCPC.cpp @@ -40,10 +40,14 @@ namespace AmstradCPC { -std::vector> get_options() { - return Configurable::standard_options( - Configurable::StandardOptions(Configurable::DisplayRGB | Configurable::DisplayCompositeColour) - ); +//std::vector> get_options() { +// return Configurable::standard_options( +// Configurable::StandardOptions(Configurable::DisplayRGB | Configurable::DisplayCompositeColour) +// ); +//} + +std::unique_ptr get_options() { + return nullptr; } /*! @@ -1114,28 +1118,34 @@ template class ConcreteMachine: } // MARK: - Configuration options. - std::vector> get_options() final { - return AmstradCPC::get_options(); + std::unique_ptr get_options(OptionsType type) final { + return nullptr; } - void set_selections(const Configurable::SelectionSet &selections_by_option) final { - Configurable::Display display; - if(Configurable::get_display(selections_by_option, display)) { - set_video_signal_configurable(display); - } - } - - Configurable::SelectionSet get_accurate_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_display_selection(selection_set, Configurable::Display::RGB); - return selection_set; - } - - Configurable::SelectionSet get_user_friendly_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_display_selection(selection_set, Configurable::Display::RGB); - return selection_set; + void set_options(const std::unique_ptr &options) { } +// std::vector> get_options() final { +// return AmstradCPC::get_options(); +// } +// +// void set_selections(const Configurable::SelectionSet &selections_by_option) final { +// Configurable::Display display; +// if(Configurable::get_display(selections_by_option, display)) { +// set_video_signal_configurable(display); +// } +// } +// +// Configurable::SelectionSet get_accurate_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_display_selection(selection_set, Configurable::Display::RGB); +// return selection_set; +// } +// +// Configurable::SelectionSet get_user_friendly_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_display_selection(selection_set, Configurable::Display::RGB); +// return selection_set; +// } // MARK: - Joysticks const std::vector> &get_joysticks() final { diff --git a/Machines/AmstradCPC/AmstradCPC.hpp b/Machines/AmstradCPC/AmstradCPC.hpp index e523a69c0..98eece1f5 100644 --- a/Machines/AmstradCPC/AmstradCPC.hpp +++ b/Machines/AmstradCPC/AmstradCPC.hpp @@ -9,17 +9,16 @@ #ifndef AmstradCPC_hpp #define AmstradCPC_hpp -#include "../../Configurable/Configurable.hpp" +#include "../../Reflection/Struct.h" #include "../../Analyser/Static/StaticAnalyser.hpp" #include "../ROMMachine.hpp" #include -#include namespace AmstradCPC { /// @returns The options available for an Amstrad CPC. -std::vector> get_options(); +std::unique_ptr get_options(); /*! Models an Amstrad CPC. diff --git a/Machines/Apple/AppleII/AppleII.cpp b/Machines/Apple/AppleII/AppleII.cpp index 3c6c25c44..3c7fd9d3d 100644 --- a/Machines/Apple/AppleII/AppleII.cpp +++ b/Machines/Apple/AppleII/AppleII.cpp @@ -37,11 +37,14 @@ namespace Apple { namespace II { -std::vector> get_options() { - return Configurable::standard_options( - static_cast(Configurable::DisplayCompositeMonochrome | Configurable::DisplayCompositeColour) - ); +std::unique_ptr get_options() { + return nullptr; } +//std::vector> get_options() { +// return Configurable::standard_options( +// static_cast(Configurable::DisplayCompositeMonochrome | Configurable::DisplayCompositeColour) +// ); +//} #define is_iie() ((model == Analyser::Static::AppleII::Target::Model::IIe) || (model == Analyser::Static::AppleII::Target::Model::EnhancedIIe)) @@ -866,26 +869,32 @@ template class ConcreteMachine: } // MARK:: Configuration options. - std::vector> get_options() final { - return Apple::II::get_options(); + std::unique_ptr get_options(OptionsType type) final { + return nullptr; } - void set_selections(const Configurable::SelectionSet &selections_by_option) final { - Configurable::Display display; - if(Configurable::get_display(selections_by_option, display)) { - set_video_signal_configurable(display); - } - } - - Configurable::SelectionSet get_accurate_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); - return selection_set; - } - - Configurable::SelectionSet get_user_friendly_selections() final { - return get_accurate_selections(); + void set_options(const std::unique_ptr &options) final { } +// std::vector> get_options() final { +// return Apple::II::get_options(); +// } +// +// void set_selections(const Configurable::SelectionSet &selections_by_option) final { +// Configurable::Display display; +// if(Configurable::get_display(selections_by_option, display)) { +// set_video_signal_configurable(display); +// } +// } +// +// Configurable::SelectionSet get_accurate_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); +// return selection_set; +// } +// +// Configurable::SelectionSet get_user_friendly_selections() final { +// return get_accurate_selections(); +// } // MARK: MediaTarget bool insert_media(const Analyser::Static::Media &media) final { diff --git a/Machines/Apple/AppleII/AppleII.hpp b/Machines/Apple/AppleII/AppleII.hpp index ad4fededd..647587c21 100644 --- a/Machines/Apple/AppleII/AppleII.hpp +++ b/Machines/Apple/AppleII/AppleII.hpp @@ -9,18 +9,17 @@ #ifndef AppleII_hpp #define AppleII_hpp -#include "../../../Configurable/Configurable.hpp" +#include "../../../Reflection/Struct.h" #include "../../../Analyser/Static/StaticAnalyser.hpp" #include "../../ROMMachine.hpp" #include -#include namespace Apple { namespace II { /// @returns The options available for an Apple II. -std::vector> get_options(); +std::unique_ptr get_options(); class Machine { public: diff --git a/Machines/Apple/Macintosh/Macintosh.cpp b/Machines/Apple/Macintosh/Macintosh.cpp index b9ceedf4c..59fb68239 100644 --- a/Machines/Apple/Macintosh/Macintosh.cpp +++ b/Machines/Apple/Macintosh/Macintosh.cpp @@ -21,6 +21,7 @@ #include "../../KeyboardMachine.hpp" #include "../../MediaTarget.hpp" #include "../../MouseMachine.hpp" +#include "../../../Configurable/Configurable.hpp" #include "../../../Inputs/QuadratureMouse/QuadratureMouse.hpp" #include "../../../Outputs/Log.hpp" @@ -56,10 +57,14 @@ constexpr int CLOCK_RATE = 7833600; namespace Apple { namespace Macintosh { -std::vector> get_options() { - return Configurable::standard_options( - static_cast(Configurable::QuickBoot) - ); +//std::vector> get_options() { +// return Configurable::standard_options( +// static_cast(Configurable::QuickBoot) +// ); +//} + +std::unique_ptr get_options() { + return nullptr; } template class ConcreteMachine: @@ -522,35 +527,41 @@ template class ConcreteMachin } // MARK: - Configuration options. - std::vector> get_options() final { - return Apple::Macintosh::get_options(); + std::unique_ptr get_options(OptionsType type) final { + return nullptr; } - 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; + void set_options(const std::unique_ptr &options) final { } +// std::vector> 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: void set_component_prefers_clocking(ClockingHint::Source *component, ClockingHint::Preference clocking) final { diff --git a/Machines/Apple/Macintosh/Macintosh.hpp b/Machines/Apple/Macintosh/Macintosh.hpp index 58623ea7c..e29665d10 100644 --- a/Machines/Apple/Macintosh/Macintosh.hpp +++ b/Machines/Apple/Macintosh/Macintosh.hpp @@ -9,14 +9,16 @@ #ifndef Macintosh_hpp #define Macintosh_hpp -#include "../../../Configurable/Configurable.hpp" +#include "../../../Reflection/Struct.h" #include "../../../Analyser/Static/StaticAnalyser.hpp" #include "../../ROMMachine.hpp" +#include + namespace Apple { namespace Macintosh { -std::vector> get_options(); +std::unique_ptr get_options(); class Machine { public: diff --git a/Machines/Atari/ST/AtariST.cpp b/Machines/Atari/ST/AtariST.cpp index 7be6a7747..afcc3182c 100644 --- a/Machines/Atari/ST/AtariST.cpp +++ b/Machines/Atari/ST/AtariST.cpp @@ -42,10 +42,14 @@ namespace Atari { namespace ST { -std::vector> get_options() { - return Configurable::standard_options( - static_cast(Configurable::DisplayRGB | Configurable::DisplayCompositeColour) - ); +//std::vector> get_options() { +// return Configurable::standard_options( +// static_cast(Configurable::DisplayRGB | Configurable::DisplayCompositeColour) +// ); +//} + +std::unique_ptr get_options() { + return nullptr; } constexpr int CLOCK_RATE = 8021247; @@ -678,28 +682,30 @@ class ConcreteMachine: } // MARK: - Configuration options. - std::vector> get_options() final { - return Atari::ST::get_options(); + std::unique_ptr get_options(OptionsType type) final { + return nullptr; } - void set_selections(const Configurable::SelectionSet &selections_by_option) final { - Configurable::Display display; - if(Configurable::get_display(selections_by_option, display)) { - set_video_signal_configurable(display); - } - } - - Configurable::SelectionSet get_accurate_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); - return selection_set; - } - - Configurable::SelectionSet get_user_friendly_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_display_selection(selection_set, Configurable::Display::RGB); - return selection_set; + void set_options(const std::unique_ptr &options) final { } +// void set_selections(const Configurable::SelectionSet &selections_by_option) final { +// Configurable::Display display; +// if(Configurable::get_display(selections_by_option, display)) { +// set_video_signal_configurable(display); +// } +// } +// +// Configurable::SelectionSet get_accurate_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); +// return selection_set; +// } +// +// Configurable::SelectionSet get_user_friendly_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_display_selection(selection_set, Configurable::Display::RGB); +// return selection_set; +// } }; } diff --git a/Machines/Atari/ST/AtariST.hpp b/Machines/Atari/ST/AtariST.hpp index 6345620cd..abd71e3ed 100644 --- a/Machines/Atari/ST/AtariST.hpp +++ b/Machines/Atari/ST/AtariST.hpp @@ -9,15 +9,17 @@ #ifndef AtariST_hpp #define AtariST_hpp -#include "../../../Configurable/Configurable.hpp" +#include "../../../Reflection/Struct.h" #include "../../../Analyser/Static/StaticAnalyser.hpp" #include "../../ROMMachine.hpp" +#include + namespace Atari { namespace ST { /// @returns The options available for an Atari ST. -std::vector> get_options(); +std::unique_ptr get_options(); class Machine { public: diff --git a/Machines/ColecoVision/ColecoVision.cpp b/Machines/ColecoVision/ColecoVision.cpp index 02aacc6df..0d5c5847b 100644 --- a/Machines/ColecoVision/ColecoVision.cpp +++ b/Machines/ColecoVision/ColecoVision.cpp @@ -16,6 +16,7 @@ #include "../CRTMachine.hpp" #include "../JoystickMachine.hpp" +#include "../../Configurable/Configurable.hpp" #include "../../Configurable/StandardOptions.hpp" #include "../../ClockReceiver/ForceInline.hpp" @@ -33,10 +34,14 @@ constexpr int sn76489_divider = 2; namespace Coleco { namespace Vision { -std::vector> get_options() { - return Configurable::standard_options( - static_cast(Configurable::DisplaySVideo | Configurable::DisplayCompositeColour) - ); +//std::vector> get_options() { +// return Configurable::standard_options( +// static_cast(Configurable::DisplaySVideo | Configurable::DisplayCompositeColour) +// ); +//} + +std::unique_ptr get_options() { + return nullptr; } class Joystick: public Inputs::ConcreteJoystick { @@ -368,28 +373,34 @@ class ConcreteMachine: } // MARK: - Configuration options. - std::vector> get_options() final { - return Coleco::Vision::get_options(); + std::unique_ptr get_options(OptionsType type) final { + return nullptr; } - void set_selections(const Configurable::SelectionSet &selections_by_option) final { - Configurable::Display display; - if(Configurable::get_display(selections_by_option, display)) { - set_video_signal_configurable(display); - } - } - - Configurable::SelectionSet get_accurate_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); - return selection_set; - } - - Configurable::SelectionSet get_user_friendly_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_display_selection(selection_set, Configurable::Display::SVideo); - return selection_set; + void set_options(const std::unique_ptr &options) final { } +// std::vector> get_options() final { +// return Coleco::Vision::get_options(); +// } +// +// void set_selections(const Configurable::SelectionSet &selections_by_option) final { +// Configurable::Display display; +// if(Configurable::get_display(selections_by_option, display)) { +// set_video_signal_configurable(display); +// } +// } +// +// Configurable::SelectionSet get_accurate_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); +// return selection_set; +// } +// +// Configurable::SelectionSet get_user_friendly_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_display_selection(selection_set, Configurable::Display::SVideo); +// return selection_set; +// } private: inline void page_megacart(uint16_t address) { diff --git a/Machines/ColecoVision/ColecoVision.hpp b/Machines/ColecoVision/ColecoVision.hpp index 750e5bcbe..c245981a0 100644 --- a/Machines/ColecoVision/ColecoVision.hpp +++ b/Machines/ColecoVision/ColecoVision.hpp @@ -9,14 +9,16 @@ #ifndef ColecoVision_hpp #define ColecoVision_hpp -#include "../../Configurable/Configurable.hpp" +#include "../../Reflection/Struct.h" #include "../../Analyser/Static/StaticAnalyser.hpp" #include "../ROMMachine.hpp" +#include + namespace Coleco { namespace Vision { -std::vector> get_options(); +std::unique_ptr get_options(); class Machine { public: diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 94e328c00..b07c522b5 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -49,11 +49,14 @@ enum ROMSlot { Drive }; -std::vector> get_options() { - return Configurable::standard_options( - static_cast(Configurable::DisplaySVideo | Configurable::DisplayCompositeColour | Configurable::QuickLoadTape) - ); +std::unique_ptr get_options() { + return nullptr; } +//std::vector> get_options() { +// return Configurable::standard_options( +// static_cast(Configurable::DisplaySVideo | Configurable::DisplayCompositeColour | Configurable::QuickLoadTape) +// ); +//} enum JoystickInput { Up = 0x04, @@ -679,36 +682,42 @@ class ConcreteMachine: } // MARK: - Configuration options. - std::vector> get_options() final { - return Commodore::Vic20::get_options(); + std::unique_ptr get_options(OptionsType type) final { + return nullptr; } - void set_selections(const Configurable::SelectionSet &selections_by_option) final { - bool quickload; - if(Configurable::get_quick_load_tape(selections_by_option, quickload)) { - allow_fast_tape_hack_ = quickload; - set_use_fast_tape(); - } - - Configurable::Display display; - if(Configurable::get_display(selections_by_option, display)) { - set_video_signal_configurable(display); - } - } - - Configurable::SelectionSet get_accurate_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_quick_load_tape_selection(selection_set, false); - Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); - return selection_set; - } - - Configurable::SelectionSet get_user_friendly_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_quick_load_tape_selection(selection_set, true); - Configurable::append_display_selection(selection_set, Configurable::Display::SVideo); - return selection_set; + void set_options(const std::unique_ptr &options) final { } +// std::vector> get_options() final { +// return Commodore::Vic20::get_options(); +// } +// +// void set_selections(const Configurable::SelectionSet &selections_by_option) final { +// bool quickload; +// if(Configurable::get_quick_load_tape(selections_by_option, quickload)) { +// allow_fast_tape_hack_ = quickload; +// set_use_fast_tape(); +// } +// +// Configurable::Display display; +// if(Configurable::get_display(selections_by_option, display)) { +// set_video_signal_configurable(display); +// } +// } +// +// Configurable::SelectionSet get_accurate_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_quick_load_tape_selection(selection_set, false); +// Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); +// return selection_set; +// } +// +// Configurable::SelectionSet get_user_friendly_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_quick_load_tape_selection(selection_set, true); +// Configurable::append_display_selection(selection_set, Configurable::Display::SVideo); +// return selection_set; +// } void set_component_prefers_clocking(ClockingHint::Source *component, ClockingHint::Preference clocking) final { tape_is_sleeping_ = clocking == ClockingHint::Preference::None; diff --git a/Machines/Commodore/Vic-20/Vic20.hpp b/Machines/Commodore/Vic-20/Vic20.hpp index ea5e7d0b7..8c442809f 100644 --- a/Machines/Commodore/Vic-20/Vic20.hpp +++ b/Machines/Commodore/Vic-20/Vic20.hpp @@ -9,18 +9,17 @@ #ifndef Vic20_hpp #define Vic20_hpp -#include "../../../Configurable/Configurable.hpp" +#include "../../../Reflection/Struct.h" #include "../../../Analyser/Static/StaticAnalyser.hpp" #include "../../ROMMachine.hpp" #include -#include namespace Commodore { namespace Vic20 { /// @returns The options available for a Vic-20. -std::vector> get_options(); +std::unique_ptr get_options(); class Machine { public: diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index 2c1fc3ac5..7546d98ce 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -12,6 +12,7 @@ #include "../MediaTarget.hpp" #include "../CRTMachine.hpp" #include "../KeyboardMachine.hpp" +#include "../../Configurable/Configurable.hpp" #include "../../ClockReceiver/ClockReceiver.hpp" #include "../../ClockReceiver/ForceInline.hpp" @@ -32,12 +33,17 @@ namespace Electron { -std::vector> get_options() { - return Configurable::standard_options( - static_cast(Configurable::DisplayRGB | Configurable::DisplayCompositeColour | Configurable::QuickLoadTape) - ); +//std::vector> get_options() { +// return Configurable::standard_options( +// static_cast(Configurable::DisplayRGB | Configurable::DisplayCompositeColour | Configurable::QuickLoadTape) +// ); +//} + +std::unique_ptr get_options() { + return nullptr; } + class ConcreteMachine: public Machine, public CRTMachine::Machine, @@ -448,36 +454,42 @@ class ConcreteMachine: } // MARK: - Configuration options. - std::vector> get_options() final { - return Electron::get_options(); + std::unique_ptr get_options(OptionsType type) final { + return nullptr; } - void set_selections(const Configurable::SelectionSet &selections_by_option) final { - bool quickload; - if(Configurable::get_quick_load_tape(selections_by_option, quickload)) { - allow_fast_tape_hack_ = quickload; - set_use_fast_tape_hack(); - } - - Configurable::Display display; - if(Configurable::get_display(selections_by_option, display)) { - set_video_signal_configurable(display); - } - } - - Configurable::SelectionSet get_accurate_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_quick_load_tape_selection(selection_set, false); - Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); - return selection_set; - } - - Configurable::SelectionSet get_user_friendly_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_quick_load_tape_selection(selection_set, true); - Configurable::append_display_selection(selection_set, Configurable::Display::RGB); - return selection_set; + void set_options(const std::unique_ptr &options) final { } +// std::vector> get_options() final { +// return Electron::get_options(); +// } +// +// void set_selections(const Configurable::SelectionSet &selections_by_option) final { +// bool quickload; +// if(Configurable::get_quick_load_tape(selections_by_option, quickload)) { +// allow_fast_tape_hack_ = quickload; +// set_use_fast_tape_hack(); +// } +// +// Configurable::Display display; +// if(Configurable::get_display(selections_by_option, display)) { +// set_video_signal_configurable(display); +// } +// } +// +// Configurable::SelectionSet get_accurate_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_quick_load_tape_selection(selection_set, false); +// Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); +// return selection_set; +// } +// +// Configurable::SelectionSet get_user_friendly_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_quick_load_tape_selection(selection_set, true); +// Configurable::append_display_selection(selection_set, Configurable::Display::RGB); +// return selection_set; +// } // MARK: - Activity Source void set_activity_observer(Activity::Observer *observer) final { diff --git a/Machines/Electron/Electron.hpp b/Machines/Electron/Electron.hpp index 90cf12993..b6c712c5a 100644 --- a/Machines/Electron/Electron.hpp +++ b/Machines/Electron/Electron.hpp @@ -9,18 +9,16 @@ #ifndef Electron_hpp #define Electron_hpp -#include "../../Configurable/Configurable.hpp" +#include "../../Reflection/Struct.h" #include "../../Analyser/Static/StaticAnalyser.hpp" #include "../ROMMachine.hpp" -#include #include -#include namespace Electron { /// @returns The options available for an Electron. -std::vector> get_options(); +std::unique_ptr get_options(); /*! @abstract Represents an Acorn Electron. diff --git a/Machines/MSX/MSX.cpp b/Machines/MSX/MSX.cpp index 9f8fccb0d..38313ea3e 100644 --- a/Machines/MSX/MSX.cpp +++ b/Machines/MSX/MSX.cpp @@ -37,6 +37,7 @@ #include "../JoystickMachine.hpp" #include "../MediaTarget.hpp" #include "../KeyboardMachine.hpp" +#include "../../Configurable/Configurable.hpp" #include "../../Outputs/Log.hpp" #include "../../Outputs/Speaker/Implementation/CompoundSource.hpp" @@ -51,10 +52,14 @@ namespace MSX { -std::vector> get_options() { - return Configurable::standard_options( - static_cast(Configurable::DisplayRGB | Configurable::DisplaySVideo | Configurable::DisplayCompositeColour | Configurable::QuickLoadTape) - ); +//std::vector> get_options() { +// return Configurable::standard_options( +// static_cast(Configurable::DisplayRGB | Configurable::DisplaySVideo | Configurable::DisplayCompositeColour | Configurable::QuickLoadTape) +// ); +//} + +std::unique_ptr get_options() { + return nullptr; } class AYPortHandler: public GI::AY38910::PortHandler { @@ -648,36 +653,42 @@ class ConcreteMachine: } // MARK: - Configuration options. - std::vector> get_options() final { - return MSX::get_options(); + std::unique_ptr get_options(OptionsType type) final { + return nullptr; } - void set_selections(const Configurable::SelectionSet &selections_by_option) final { - bool quickload; - if(Configurable::get_quick_load_tape(selections_by_option, quickload)) { - allow_fast_tape_ = quickload; - set_use_fast_tape(); - } - - Configurable::Display display; - if(Configurable::get_display(selections_by_option, display)) { - set_video_signal_configurable(display); - } - } - - Configurable::SelectionSet get_accurate_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_quick_load_tape_selection(selection_set, false); - Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); - return selection_set; - } - - Configurable::SelectionSet get_user_friendly_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_quick_load_tape_selection(selection_set, true); - Configurable::append_display_selection(selection_set, Configurable::Display::RGB); - return selection_set; + void set_options(const std::unique_ptr &options) final { } +// std::vector> get_options() final { +// return MSX::get_options(); +// } +// +// void set_selections(const Configurable::SelectionSet &selections_by_option) final { +// bool quickload; +// if(Configurable::get_quick_load_tape(selections_by_option, quickload)) { +// allow_fast_tape_ = quickload; +// set_use_fast_tape(); +// } +// +// Configurable::Display display; +// if(Configurable::get_display(selections_by_option, display)) { +// set_video_signal_configurable(display); +// } +// } +// +// Configurable::SelectionSet get_accurate_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_quick_load_tape_selection(selection_set, false); +// Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); +// return selection_set; +// } +// +// Configurable::SelectionSet get_user_friendly_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_quick_load_tape_selection(selection_set, true); +// Configurable::append_display_selection(selection_set, Configurable::Display::RGB); +// return selection_set; +// } // MARK: - Sleeper void set_component_prefers_clocking(ClockingHint::Source *component, ClockingHint::Preference clocking) final { diff --git a/Machines/MSX/MSX.hpp b/Machines/MSX/MSX.hpp index 1088786e2..9f68a3645 100644 --- a/Machines/MSX/MSX.hpp +++ b/Machines/MSX/MSX.hpp @@ -9,16 +9,15 @@ #ifndef MSX_hpp #define MSX_hpp -#include "../../Configurable/Configurable.hpp" +#include "../../Reflection/Struct.h" #include "../../Analyser/Static/StaticAnalyser.hpp" #include "../ROMMachine.hpp" #include -#include namespace MSX { -std::vector> get_options(); +std::unique_ptr get_options(); class Machine { public: diff --git a/Machines/MasterSystem/MasterSystem.cpp b/Machines/MasterSystem/MasterSystem.cpp index ea4d46cfb..5fb0cb70b 100644 --- a/Machines/MasterSystem/MasterSystem.cpp +++ b/Machines/MasterSystem/MasterSystem.cpp @@ -16,6 +16,7 @@ #include "../CRTMachine.hpp" #include "../JoystickMachine.hpp" #include "../KeyboardMachine.hpp" +#include "../../Configurable/Configurable.hpp" #include "../../ClockReceiver/ForceInline.hpp" #include "../../ClockReceiver/JustInTime.hpp" @@ -37,10 +38,14 @@ constexpr int sn76489_divider = 2; namespace Sega { namespace MasterSystem { -std::vector> get_options() { - return Configurable::standard_options( - static_cast(Configurable::DisplayRGB | Configurable::DisplayCompositeColour) - ); +//std::vector> get_options() { +// return Configurable::standard_options( +// static_cast(Configurable::DisplayRGB | Configurable::DisplayCompositeColour) +// ); +//} + +std::unique_ptr get_options() { + return nullptr; } class Joystick: public Inputs::ConcreteJoystick { @@ -373,28 +378,34 @@ class ConcreteMachine: } // MARK: - Configuration options. - std::vector> get_options() final { - return Sega::MasterSystem::get_options(); + std::unique_ptr get_options(OptionsType type) final { + return nullptr; } - void set_selections(const Configurable::SelectionSet &selections_by_option) final { - Configurable::Display display; - if(Configurable::get_display(selections_by_option, display)) { - set_video_signal_configurable(display); - } - } - - Configurable::SelectionSet get_accurate_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); - return selection_set; - } - - Configurable::SelectionSet get_user_friendly_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_display_selection(selection_set, Configurable::Display::RGB); - return selection_set; + void set_options(const std::unique_ptr &options) final { } +// std::vector> get_options() final { +// return Sega::MasterSystem::get_options(); +// } +// +// void set_selections(const Configurable::SelectionSet &selections_by_option) final { +// Configurable::Display display; +// if(Configurable::get_display(selections_by_option, display)) { +// set_video_signal_configurable(display); +// } +// } +// +// Configurable::SelectionSet get_accurate_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); +// return selection_set; +// } +// +// Configurable::SelectionSet get_user_friendly_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_display_selection(selection_set, Configurable::Display::RGB); +// return selection_set; +// } private: static TI::TMS::Personality tms_personality_for_model(Analyser::Static::Sega::Target::Model model) { diff --git a/Machines/MasterSystem/MasterSystem.hpp b/Machines/MasterSystem/MasterSystem.hpp index b192dfae7..c63228490 100644 --- a/Machines/MasterSystem/MasterSystem.hpp +++ b/Machines/MasterSystem/MasterSystem.hpp @@ -9,14 +9,16 @@ #ifndef MasterSystem_hpp #define MasterSystem_hpp -#include "../../Configurable/Configurable.hpp" +#include "../../Reflection/Struct.h" #include "../../Analyser/Static/StaticAnalyser.hpp" #include "../ROMMachine.hpp" +#include + namespace Sega { namespace MasterSystem { -std::vector> get_options(); +std::unique_ptr get_options(); class Machine { public: diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index 21d54f189..7417e6ef2 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -50,14 +50,18 @@ enum ROM { BASIC10 = 0, BASIC11, Microdisc, Colour }; -std::vector> get_options() { - return Configurable::standard_options( - static_cast( - Configurable::DisplayRGB | - Configurable::DisplayCompositeColour | - Configurable::DisplayCompositeMonochrome | - Configurable::QuickLoadTape) - ); +//std::vector> get_options() { +// return Configurable::standard_options( +// static_cast( +// Configurable::DisplayRGB | +// Configurable::DisplayCompositeColour | +// Configurable::DisplayCompositeMonochrome | +// Configurable::QuickLoadTape) +// ); +//} + +std::unique_ptr get_options() { + return nullptr; } /*! @@ -623,35 +627,41 @@ template class Co } // MARK: - Configuration options. - std::vector> get_options() final { - return Oric::get_options(); + std::unique_ptr get_options(OptionsType type) final { + return nullptr; } - void set_selections(const Configurable::SelectionSet &selections_by_option) final { - bool quickload; - if(Configurable::get_quick_load_tape(selections_by_option, quickload)) { - set_use_fast_tape_hack(quickload); - } - - Configurable::Display display; - if(Configurable::get_display(selections_by_option, display)) { - set_video_signal_configurable(display); - } - } - - Configurable::SelectionSet get_accurate_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_quick_load_tape_selection(selection_set, false); - Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); - return selection_set; - } - - Configurable::SelectionSet get_user_friendly_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_quick_load_tape_selection(selection_set, true); - Configurable::append_display_selection(selection_set, Configurable::Display::RGB); - return selection_set; + void set_options(const std::unique_ptr &options) final { } +// std::vector> get_options() final { +// return Oric::get_options(); +// } +// +// void set_selections(const Configurable::SelectionSet &selections_by_option) final { +// bool quickload; +// if(Configurable::get_quick_load_tape(selections_by_option, quickload)) { +// set_use_fast_tape_hack(quickload); +// } +// +// Configurable::Display display; +// if(Configurable::get_display(selections_by_option, display)) { +// set_video_signal_configurable(display); +// } +// } +// +// Configurable::SelectionSet get_accurate_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_quick_load_tape_selection(selection_set, false); +// Configurable::append_display_selection(selection_set, Configurable::Display::CompositeColour); +// return selection_set; +// } +// +// Configurable::SelectionSet get_user_friendly_selections() final { +// Configurable::SelectionSet selection_set; +// Configurable::append_quick_load_tape_selection(selection_set, true); +// Configurable::append_display_selection(selection_set, Configurable::Display::RGB); +// return selection_set; +// } void set_activity_observer(Activity::Observer *observer) final { switch(disk_interface) { diff --git a/Machines/Oric/Oric.hpp b/Machines/Oric/Oric.hpp index 8e3977bdf..57c6fdba3 100644 --- a/Machines/Oric/Oric.hpp +++ b/Machines/Oric/Oric.hpp @@ -9,14 +9,16 @@ #ifndef Oric_hpp #define Oric_hpp -#include "../../Configurable/Configurable.hpp" +#include "../../Reflection/Struct.h" #include "../../Analyser/Static/StaticAnalyser.hpp" #include "../ROMMachine.hpp" +#include + namespace Oric { /// @returns The options available for an Oric. -std::vector> get_options(); +std::unique_ptr 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 638cfbf85..baa9e515b 100644 --- a/Machines/Utility/MachineForTarget.cpp +++ b/Machines/Utility/MachineForTarget.cpp @@ -173,19 +173,19 @@ std::vector Machine::AllMachines(bool meaningful_without_media_only return result; } -std::map>> Machine::AllOptionsByMachineName() { - std::map>> options; +std::map> Machine::AllOptionsByMachineName() { + std::map> options; - options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::AmstradCPC), AmstradCPC::get_options())); - options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::AppleII), Apple::II::get_options())); - options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::AtariST), Atari::ST::get_options())); - options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::ColecoVision), Coleco::Vision::get_options())); - options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::Electron), Electron::get_options())); - options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::Macintosh), Apple::Macintosh::get_options())); - options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::MasterSystem), Sega::MasterSystem::get_options())); - options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::MSX), MSX::get_options())); - options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::Oric), Oric::get_options())); - options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::Vic20), Commodore::Vic20::get_options())); +// options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::AmstradCPC), AmstradCPC::get_options())); +// options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::AppleII), Apple::II::get_options())); +// options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::AtariST), Atari::ST::get_options())); +// options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::ColecoVision), Coleco::Vision::get_options())); +// options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::Electron), Electron::get_options())); +// options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::Macintosh), Apple::Macintosh::get_options())); +// options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::MasterSystem), Sega::MasterSystem::get_options())); +// options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::MSX), MSX::get_options())); +// options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::Oric), Oric::get_options())); +// options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::Vic20), Commodore::Vic20::get_options())); options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::ZX8081), ZX8081::get_options())); return options; diff --git a/Machines/Utility/MachineForTarget.hpp b/Machines/Utility/MachineForTarget.hpp index a51508f47..c1228d610 100644 --- a/Machines/Utility/MachineForTarget.hpp +++ b/Machines/Utility/MachineForTarget.hpp @@ -77,7 +77,7 @@ std::vector AllMachines(bool meaningful_without_media_only, bool lo /*! Returns a map from long machine name to the list of options that machine exposes, for all machines. */ -std::map>> AllOptionsByMachineName(); +std::map> AllOptionsByMachineName(); /*! Returns a map from long machine name to appropriate instances of Target for the machine. diff --git a/Machines/ZX8081/ZX8081.cpp b/Machines/ZX8081/ZX8081.cpp index 9a5be9e08..4a47e40b6 100644 --- a/Machines/ZX8081/ZX8081.cpp +++ b/Machines/ZX8081/ZX8081.cpp @@ -18,7 +18,6 @@ #include "../../Storage/Tape/Parsers/ZX8081.hpp" #include "../../ClockReceiver/ForceInline.hpp" -#include "../../Configurable/StandardOptions.hpp" #include "../Utility/MemoryFuzzer.hpp" #include "../Utility/Typer.hpp" @@ -51,10 +50,20 @@ enum ROMType: uint8_t { ZX80 = 0, ZX81 }; -std::vector> get_options() { - return Configurable::standard_options( - static_cast(Configurable::AutomaticTapeMotorControl | Configurable::QuickLoadTape) - ); +struct Options: public Reflection::StructImpl { + bool automatic_tape_motor_control = true; + bool quickload = true; + + Options() { + if(needs_declare()) { + DeclareField(automatic_tape_motor_control); + DeclareField(quickload); + } + } +}; + +std::unique_ptr get_options() { + return std::make_unique(); } template class ConcreteMachine: @@ -413,37 +422,33 @@ template class ConcreteMachine: } // MARK: - Configuration options. - std::vector> get_options() final { - return ZX8081::get_options(); + std::unique_ptr get_options(OptionsType type) final { + auto options = std::make_unique(); + switch(type) { + case OptionsType::Current: + options->automatic_tape_motor_control = use_automatic_tape_motor_control_; + options->quickload = allow_fast_tape_hack_; + break; + case OptionsType::Accurate: + case OptionsType::UserFriendly: + options->automatic_tape_motor_control = + options->quickload = type == OptionsType::UserFriendly; + break; + } + return options; } - void set_selections(const Configurable::SelectionSet &selections_by_option) final { - bool quickload; - if(Configurable::get_quick_load_tape(selections_by_option, quickload)) { - allow_fast_tape_hack_ = quickload; + void set_options(const std::unique_ptr &options) { + if(Reflection::get(*options, "quickload", allow_fast_tape_hack_)) { set_use_fast_tape(); } bool autotapemotor; - if(Configurable::get_automatic_tape_motor_control_selection(selections_by_option, autotapemotor)) { + if(Reflection::get(*options, "automatic_tape_motor_control", autotapemotor)) { set_use_automatic_tape_motor_control(autotapemotor); } } - Configurable::SelectionSet get_accurate_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_quick_load_tape_selection(selection_set, false); - Configurable::append_automatic_tape_motor_control_selection(selection_set, false); - return selection_set; - } - - Configurable::SelectionSet get_user_friendly_selections() final { - Configurable::SelectionSet selection_set; - Configurable::append_quick_load_tape_selection(selection_set, true); - Configurable::append_automatic_tape_motor_control_selection(selection_set, true); - return selection_set; - } - private: CPU::Z80::Processor z80_; Video video_; diff --git a/Machines/ZX8081/ZX8081.hpp b/Machines/ZX8081/ZX8081.hpp index 301d8529a..f35d2b9c7 100644 --- a/Machines/ZX8081/ZX8081.hpp +++ b/Machines/ZX8081/ZX8081.hpp @@ -9,14 +9,16 @@ #ifndef ZX8081_hpp #define ZX8081_hpp -#include "../../Configurable/Configurable.hpp" +#include "../../Reflection/Struct.h" #include "../../Analyser/Static/StaticAnalyser.hpp" #include "../ROMMachine.hpp" +#include + namespace ZX8081 { /// @returns The options available for a ZX80 or ZX81. -std::vector> get_options(); +std::unique_ptr get_options(); class Machine { public: diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 407c7943d..2e5b8d107 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -101,8 +101,6 @@ 4B055AEF1FAE9BF00060FFFF /* Typer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2B3A471F9B8FA70062DABF /* Typer.cpp */; }; 4B055AF11FAE9C160060FFFF /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC76E6A1C98F43700E6EF73 /* Accelerate.framework */; }; 4B055AF21FAE9C1C0060FFFF /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B055AF01FAE9C080060FFFF /* OpenGL.framework */; }; - 4B07835A1FC11D10001D12BB /* Configurable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B0783591FC11D10001D12BB /* Configurable.cpp */; }; - 4B07835B1FC11D42001D12BB /* Configurable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B0783591FC11D10001D12BB /* Configurable.cpp */; }; 4B08A2751EE35D56008B7065 /* Z80InterruptTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B08A2741EE35D56008B7065 /* Z80InterruptTests.swift */; }; 4B08A2781EE39306008B7065 /* TestMachine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B08A2771EE39306008B7065 /* TestMachine.mm */; }; 4B08A56920D72BEF0016CE5A /* Activity.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B08A56720D72BEF0016CE5A /* Activity.xib */; }; @@ -364,7 +362,6 @@ 4B778F5C23A5F3070000D260 /* MSX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B0E61051FF34737002A9DBD /* MSX.cpp */; }; 4B778F5D23A5F3230000D260 /* Commodore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B8805F21DCFD22A003085B1 /* Commodore.cpp */; }; 4B778F5E23A5F3230000D260 /* Oric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B8805F91DCFF807003085B1 /* Oric.cpp */; }; - 4B778F5F23A5F3300000D260 /* Configurable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B0783591FC11D10001D12BB /* Configurable.cpp */; }; 4B778F6023A5F3460000D260 /* Disk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B8944EC201967B4007DE474 /* Disk.cpp */; }; 4B778F6123A5F3560000D260 /* Disk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B8944FC201967B4007DE474 /* Disk.cpp */; }; 4B778F6223A5F35F0000D260 /* File.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B894500201967B4007DE474 /* File.cpp */; }; @@ -916,7 +913,6 @@ 4B055ABE1FAE98000060FFFF /* MachineForTarget.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MachineForTarget.cpp; sourceTree = ""; }; 4B055ABF1FAE98000060FFFF /* MachineForTarget.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MachineForTarget.hpp; sourceTree = ""; }; 4B055AF01FAE9C080060FFFF /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; - 4B0783591FC11D10001D12BB /* Configurable.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Configurable.cpp; sourceTree = ""; }; 4B08A2741EE35D56008B7065 /* Z80InterruptTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Z80InterruptTests.swift; sourceTree = ""; }; 4B08A2761EE39306008B7065 /* TestMachine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestMachine.h; sourceTree = ""; }; 4B08A2771EE39306008B7065 /* TestMachine.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestMachine.mm; sourceTree = ""; }; @@ -2131,7 +2127,6 @@ isa = PBXGroup; children = ( 4B31B88F1FBFBCD800C140D5 /* Configurable.hpp */, - 4B0783591FC11D10001D12BB /* Configurable.cpp */, 4BFE7B851FC39BF100160B38 /* StandardOptions.cpp */, 4BFE7B861FC39BF100160B38 /* StandardOptions.hpp */, ); @@ -4443,7 +4438,6 @@ 4B055A7E1FAE84AA0060FFFF /* main.cpp in Sources */, 4B894537201967B4007DE474 /* Z80.cpp in Sources */, 4B055A9F1FAE85DA0060FFFF /* HFE.cpp in Sources */, - 4B07835B1FC11D42001D12BB /* Configurable.cpp in Sources */, 4BD191F52191180E0042E144 /* ScanTarget.cpp in Sources */, 4B055AEC1FAE9BA20060FFFF /* Z80Base.cpp in Sources */, 4B0F94FF208C1A1600FE41D9 /* NIB.cpp in Sources */, @@ -4502,7 +4496,6 @@ 4B894538201967B4007DE474 /* Tape.cpp in Sources */, 4B54C0CB1F8D92590050900F /* Keyboard.cpp in Sources */, 4BEA525E1DF33323007E74F2 /* Tape.cpp in Sources */, - 4B07835A1FC11D10001D12BB /* Configurable.cpp in Sources */, 4B2BF19623E10F0100C3AD60 /* CSHighPrecisionTimer.m in Sources */, 4B8334951F5E25B60097E338 /* C1540.cpp in Sources */, 4B89453C201967B4007DE474 /* StaticAnalyser.cpp in Sources */, @@ -4777,7 +4770,6 @@ 4B778F5623A5F2AF0000D260 /* CPM.cpp in Sources */, 4B778F1C23A5ED3F0000D260 /* TimedEventLoop.cpp in Sources */, 4B3BA0D01D318B44005DD7A7 /* MOS6532Bridge.mm in Sources */, - 4B778F5F23A5F3300000D260 /* Configurable.cpp in Sources */, 4B778F3823A5F11C0000D260 /* SegmentParser.cpp in Sources */, 4B778F0723A5EC150000D260 /* CommodoreTAP.cpp in Sources */, 4B778F4123A5F19A0000D260 /* MemoryPacker.cpp in Sources */, @@ -4981,7 +4973,7 @@ "$(USER_LIBRARY_DIR)/Frameworks", ); GCC_C_LANGUAGE_STANDARD = gnu11; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -5003,7 +4995,7 @@ ); GCC_C_LANGUAGE_STANDARD = gnu11; GCC_OPTIMIZATION_LEVEL = 2; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; diff --git a/Reflection/Struct.cpp b/Reflection/Struct.cpp index cbe533987..b3fb8bdfd 100644 --- a/Reflection/Struct.cpp +++ b/Reflection/Struct.cpp @@ -8,6 +8,8 @@ #include "Struct.h" +// MARK: - Setters + template <> bool Reflection::set(Struct &target, const std::string &name, int value) { const auto target_type = target.type_of(name); if(!target_type) return false; @@ -52,6 +54,26 @@ template <> bool Reflection::set(Struct &target, const std::string &name, const return set(target, name, string); } +// MARK: - Fuzzy setter + bool Reflection::fuzzy_set(Struct &target, const std::string &name, const std::string &value) { return false; } + +// MARK: - Getters + +template bool Reflection::get(Struct &target, const std::string &name, Type &value) { + return false; +} + +template <> bool Reflection::get(Struct &target, const std::string &name, bool &value) { + const auto target_type = target.type_of(name); + if(!target_type) return false; + + if(*target_type == typeid(bool)) { + value = *reinterpret_cast(target.get(name)); + return true; + } + + return false; +} diff --git a/Reflection/Struct.h b/Reflection/Struct.h index 256d53876..4b1af1ea4 100644 --- a/Reflection/Struct.h +++ b/Reflection/Struct.h @@ -71,6 +71,17 @@ template <> bool set(Struct &target, const std::string &name, const char *value) */ bool fuzzy_set(Struct &target, const std::string &name, const std::string &value); + +/*! + Attempts to get the property @c name to @c value ; will perform limited type conversions. + + @returns @c true if the property was successfully read; @c false otherwise. +*/ +template bool get(Struct &target, const std::string &name, Type &value); + +template <> bool get(Struct &target, const std::string &name, bool &value); + + // TODO: move this elsewhere. It's just a sketch anyway. struct Serialisable { /// Serialises this object, appending it to @c target.