From ead282332224e47187fd8fc97d39fd2e98bf3cb4 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 18 Mar 2020 18:26:22 -0400 Subject: [PATCH] Reintroduces MSX and Master System runtime options. --- Machines/MSX/MSX.cpp | 56 +++++++------------------- Machines/MSX/MSX.hpp | 19 +++++++-- Machines/MasterSystem/MasterSystem.cpp | 44 +++++--------------- Machines/MasterSystem/MasterSystem.hpp | 16 ++++++-- Machines/Utility/MachineForTarget.cpp | 4 +- 5 files changed, 55 insertions(+), 84 deletions(-) diff --git a/Machines/MSX/MSX.cpp b/Machines/MSX/MSX.cpp index 0ca91006e..7fd483d8a 100644 --- a/Machines/MSX/MSX.cpp +++ b/Machines/MSX/MSX.cpp @@ -52,16 +52,6 @@ namespace MSX { -//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 { public: AYPortHandler(Storage::Tape::BinaryTapePlayer &tape_player) : tape_player_(tape_player) { @@ -295,6 +285,10 @@ class ConcreteMachine: vdp_->set_display_type(display_type); } + Outputs::Display::DisplayType get_display_type() final { + return vdp_->get_display_type(); + } + Outputs::Speaker::Speaker *get_speaker() final { return &speaker_; } @@ -654,41 +648,19 @@ class ConcreteMachine: // MARK: - Configuration options. std::unique_ptr get_options() final { - return nullptr; + auto options = std::make_unique(Configurable::OptionsType::UserFriendly); + options->output = get_video_signal_configurable(); + options->quickload = allow_fast_tape_; + return options; } - void set_options(const std::unique_ptr &options) final { + void set_options(const std::unique_ptr &str) final { + const auto options = dynamic_cast(str.get()); + + set_video_signal_configurable(options->output); + allow_fast_tape_ = options->quickload; + set_use_fast_tape(); } -// 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 9f68a3645..902ad5a78 100644 --- a/Machines/MSX/MSX.hpp +++ b/Machines/MSX/MSX.hpp @@ -9,7 +9,8 @@ #ifndef MSX_hpp #define MSX_hpp -#include "../../Reflection/Struct.h" +#include "../../Configurable/Configurable.hpp" +#include "../../Configurable/StandardOptions.hpp" #include "../../Analyser/Static/StaticAnalyser.hpp" #include "../ROMMachine.hpp" @@ -17,12 +18,24 @@ namespace MSX { -std::unique_ptr get_options(); - class Machine { public: virtual ~Machine(); static Machine *MSX(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher); + + class Options: public Reflection::StructImpl, public Configurable::DisplayOption, public Configurable::QuickloadOption { + friend Configurable::DisplayOption; + friend Configurable::QuickloadOption; + public: + Options(Configurable::OptionsType type) : + Configurable::DisplayOption(type == Configurable::OptionsType::UserFriendly ? Configurable::Display::RGB : Configurable::Display::CompositeColour), + Configurable::QuickloadOption(type == Configurable::OptionsType::UserFriendly) { + if(needs_declare()) { + declare_display_option(); + declare_quickload_option(); + } + } + }; }; } diff --git a/Machines/MasterSystem/MasterSystem.cpp b/Machines/MasterSystem/MasterSystem.cpp index 614dc7d0f..06859d6bd 100644 --- a/Machines/MasterSystem/MasterSystem.cpp +++ b/Machines/MasterSystem/MasterSystem.cpp @@ -38,16 +38,6 @@ constexpr int sn76489_divider = 2; namespace Sega { namespace MasterSystem { -//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 { public: Joystick() : @@ -192,6 +182,10 @@ class ConcreteMachine: vdp_->set_display_type(display_type); } + Outputs::Display::DisplayType get_display_type() final { + return vdp_->get_display_type(); + } + Outputs::Speaker::Speaker *get_speaker() final { return &speaker_; } @@ -379,33 +373,15 @@ class ConcreteMachine: // MARK: - Configuration options. std::unique_ptr get_options() final { - return nullptr; + auto options = std::make_unique(Configurable::OptionsType::UserFriendly); + options->output = get_video_signal_configurable(); + return options; } - void set_options(const std::unique_ptr &options) final { + void set_options(const std::unique_ptr &str) final { + const auto options = dynamic_cast(str.get()); + set_video_signal_configurable(options->output); } -// 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 c63228490..348842be9 100644 --- a/Machines/MasterSystem/MasterSystem.hpp +++ b/Machines/MasterSystem/MasterSystem.hpp @@ -9,7 +9,8 @@ #ifndef MasterSystem_hpp #define MasterSystem_hpp -#include "../../Reflection/Struct.h" +#include "../../Configurable/Configurable.hpp" +#include "../../Configurable/StandardOptions.hpp" #include "../../Analyser/Static/StaticAnalyser.hpp" #include "../ROMMachine.hpp" @@ -18,12 +19,21 @@ namespace Sega { namespace MasterSystem { -std::unique_ptr get_options(); - class Machine { public: virtual ~Machine(); static Machine *MasterSystem(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher); + + class Options: public Reflection::StructImpl, public Configurable::DisplayOption { + friend Configurable::DisplayOption; + public: + Options(Configurable::OptionsType type) : + Configurable::DisplayOption(type == Configurable::OptionsType::UserFriendly ? Configurable::Display::RGB : Configurable::Display::CompositeColour) { + if(needs_declare()) { + declare_display_option(); + } + } + }; }; } diff --git a/Machines/Utility/MachineForTarget.cpp b/Machines/Utility/MachineForTarget.cpp index 0a56da7cf..bc45e42ce 100644 --- a/Machines/Utility/MachineForTarget.cpp +++ b/Machines/Utility/MachineForTarget.cpp @@ -177,8 +177,6 @@ std::map> Machine::AllOptionsBy std::map> 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())); @@ -190,6 +188,8 @@ std::map> Machine::AllOptionsBy Emplace(AtariST, Atari::ST::Machine); Emplace(ColecoVision, Coleco::Vision::Machine); Emplace(Electron, Electron::Machine); + Emplace(MasterSystem, Sega::MasterSystem::Machine); + Emplace(MSX, MSX::Machine); Emplace(ZX8081, ZX8081::Machine); #undef Emplace