From b6e81242e7c960a44fd63a54805d7e1543d48e70 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 17 Mar 2020 21:53:26 -0400 Subject: [PATCH] Reintroduces Apple II runtime options. --- Machines/AmstradCPC/AmstradCPC.hpp | 2 +- Machines/Apple/AppleII/AppleII.cpp | 41 +++++++-------------------- Machines/Apple/AppleII/AppleII.hpp | 21 +++++++++++--- Machines/Apple/AppleII/Video.cpp | 4 +++ Machines/Apple/AppleII/Video.hpp | 3 ++ Machines/Utility/MachineForTarget.cpp | 2 +- 6 files changed, 36 insertions(+), 37 deletions(-) diff --git a/Machines/AmstradCPC/AmstradCPC.hpp b/Machines/AmstradCPC/AmstradCPC.hpp index d122b2bb8..bb5ff1052 100644 --- a/Machines/AmstradCPC/AmstradCPC.hpp +++ b/Machines/AmstradCPC/AmstradCPC.hpp @@ -28,7 +28,7 @@ class Machine { /// Creates and returns an Amstrad CPC. static Machine *AmstradCPC(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher); - /// Defines the runtime options available for a ZX80/81. + /// Defines the runtime options available for an Amstrad CPC. class Options: public Reflection::StructImpl { public: Configurable::Display output = Configurable::Display::RGB; diff --git a/Machines/Apple/AppleII/AppleII.cpp b/Machines/Apple/AppleII/AppleII.cpp index f1a6db001..7cff092cc 100644 --- a/Machines/Apple/AppleII/AppleII.cpp +++ b/Machines/Apple/AppleII/AppleII.cpp @@ -37,15 +37,6 @@ namespace Apple { namespace II { -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)) template class ConcreteMachine: @@ -433,6 +424,10 @@ template class ConcreteMachine: video_.set_display_type(display_type); } + Outputs::Display::DisplayType get_display_type() final { + return video_.get_display_type(); + } + Outputs::Speaker::Speaker *get_speaker() final { return &speaker_; } @@ -870,31 +865,15 @@ template 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) { + const auto options = dynamic_cast(str.get()); + set_video_signal_configurable(options->output); } -// 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 647587c21..73b168b6e 100644 --- a/Machines/Apple/AppleII/AppleII.hpp +++ b/Machines/Apple/AppleII/AppleII.hpp @@ -9,7 +9,8 @@ #ifndef AppleII_hpp #define AppleII_hpp -#include "../../../Reflection/Struct.h" +#include "../../../Configurable/Configurable.hpp" +#include "../../../Configurable/StandardOptions.hpp" #include "../../../Analyser/Static/StaticAnalyser.hpp" #include "../../ROMMachine.hpp" @@ -18,15 +19,27 @@ namespace Apple { namespace II { -/// @returns The options available for an Apple II. -std::unique_ptr get_options(); - class Machine { public: virtual ~Machine(); /// Creates and returns an AppleII. static Machine *AppleII(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher); + + /// Defines the runtime options available for an Apple II. + class Options: public Reflection::StructImpl { + public: + Configurable::Display output = Configurable::Display::CompositeColour; + + Options(Configurable::OptionsType type) { + // Declare fields if necessary. + if(needs_declare()) { + DeclareField(output); + AnnounceEnumNS(Configurable, Display); + limit_enum(&output, Configurable::Display::CompositeMonochrome, Configurable::Display::CompositeColour, -1); + } + } + }; }; } diff --git a/Machines/Apple/AppleII/Video.cpp b/Machines/Apple/AppleII/Video.cpp index a5b0b38b2..398eb91c9 100644 --- a/Machines/Apple/AppleII/Video.cpp +++ b/Machines/Apple/AppleII/Video.cpp @@ -55,6 +55,10 @@ void VideoBase::set_display_type(Outputs::Display::DisplayType display_type) { crt_.set_display_type(display_type); } +Outputs::Display::DisplayType VideoBase::get_display_type() { + return crt_.get_display_type(); +} + /* Rote setters and getters. */ diff --git a/Machines/Apple/AppleII/Video.hpp b/Machines/Apple/AppleII/Video.hpp index e227bc656..cd005742f 100644 --- a/Machines/Apple/AppleII/Video.hpp +++ b/Machines/Apple/AppleII/Video.hpp @@ -46,6 +46,9 @@ class VideoBase { /// Sets the type of output. void set_display_type(Outputs::Display::DisplayType); + /// Gets the type of output. + Outputs::Display::DisplayType get_display_type(); + /* Descriptions for the setters below are taken verbatim from the Apple IIe Technical Reference. Addresses are the conventional diff --git a/Machines/Utility/MachineForTarget.cpp b/Machines/Utility/MachineForTarget.cpp index 7a50e60f8..44bbb4056 100644 --- a/Machines/Utility/MachineForTarget.cpp +++ b/Machines/Utility/MachineForTarget.cpp @@ -176,7 +176,6 @@ std::vector Machine::AllMachines(bool meaningful_without_media_only std::map> Machine::AllOptionsByMachineName() { std::map> 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())); @@ -190,6 +189,7 @@ std::map> Machine::AllOptionsBy options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::machine), std::make_unique(Configurable::OptionsType::UserFriendly))); Emplace(AmstradCPC, AmstradCPC::Machine); + Emplace(AppleII, Apple::II::Machine); Emplace(ZX8081, ZX8081::Machine); #undef Emplace