1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-17 21:30:14 +00:00

Starts moving towards a Deflectable-based system of runtime options.

This commit is contained in:
Thomas Harte 2020-03-15 23:48:53 -04:00
parent 2031a33edf
commit 8e3bf0dbca
33 changed files with 524 additions and 548 deletions

View File

@ -19,7 +19,15 @@ MultiConfigurable::MultiConfigurable(const std::vector<std::unique_ptr<::Machine
}
}
std::vector<std::unique_ptr<Configurable::Option>> MultiConfigurable::get_options() {
void MultiConfigurable::set_options(const std::unique_ptr<Reflection::Struct> &options) {
}
std::unique_ptr<Reflection::Struct> MultiConfigurable::get_options(OptionsType type) {
// TODO: this'll need to mash options together, maybe? Or just take the front?
return nullptr;
}
/*std::vector<std::unique_ptr<Configurable::Option>> MultiConfigurable::get_options() {
std::vector<std::unique_ptr<Configurable::Option>> options;
// Produce the list of unique options.
@ -62,3 +70,4 @@ Configurable::SelectionSet MultiConfigurable::get_user_friendly_selections() {
}
return set;
}
*/

View File

@ -10,6 +10,7 @@
#define MultiConfigurable_hpp
#include "../../../../Machines/DynamicMachine.hpp"
#include "../../../../Configurable/Configurable.hpp"
#include <memory>
#include <vector>
@ -28,10 +29,12 @@ class MultiConfigurable: public Configurable::Device {
MultiConfigurable(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines);
// Below is the standard Configurable::Device interface; see there for documentation.
std::vector<std::unique_ptr<Configurable::Option>> 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<Reflection::Struct> &options) final;
std::unique_ptr<Reflection::Struct> get_options(OptionsType type) final;
// std::vector<std::unique_ptr<Configurable::Option>> 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<Configurable::Device *> devices_;

View File

@ -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);
}

View File

@ -9,89 +9,34 @@
#ifndef Configurable_h
#define Configurable_h
#include <map>
#include <memory>
#include <string>
#include <vector>
#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<std::string> options;
ListOption(const std::string &long_name, const std::string &short_name, const std::vector<std::string> &options) : Option(long_name, short_name), options(options) {}
virtual bool operator==(const Option &rhs) {
const ListOption *list_rhs = dynamic_cast<const ListOption *>(&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<std::string, std::unique_ptr<Selection>>;
/*!
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<std::unique_ptr<Option>> 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<Reflection::Struct> &options) = 0;
template <typename T> 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<T *>(selection->second.get());
}
enum class OptionsType {
Current,
Accurate,
UserFriendly
};
/// @returns Options of type @c type.
virtual std::unique_ptr<Reflection::Struct> get_options(OptionsType type) = 0;
};
}

View File

@ -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<Configurable::BooleanSelection>(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<Configurable::BooleanSelection>(selections_by_option, name);
if(!selection) return false;
result = selection->value;
return true;
}
}
/*
// MARK: - Standard option list builder
std::vector<std::unique_ptr<Configurable::Option>> Configurable::standard_options(Configurable::StandardOptions mask) {
std::vector<std::unique_ptr<Configurable::Option>> 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);
}
}*/

View File

@ -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<std::unique_ptr<Option>> 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);
}

View File

@ -40,10 +40,14 @@
namespace AmstradCPC {
std::vector<std::unique_ptr<Configurable::Option>> get_options() {
return Configurable::standard_options(
Configurable::StandardOptions(Configurable::DisplayRGB | Configurable::DisplayCompositeColour)
);
//std::vector<std::unique_ptr<Configurable::Option>> get_options() {
// return Configurable::standard_options(
// Configurable::StandardOptions(Configurable::DisplayRGB | Configurable::DisplayCompositeColour)
// );
//}
std::unique_ptr<Reflection::Struct> get_options() {
return nullptr;
}
/*!
@ -1114,28 +1118,34 @@ template <bool has_fdc> class ConcreteMachine:
}
// MARK: - Configuration options.
std::vector<std::unique_ptr<Configurable::Option>> get_options() final {
return AmstradCPC::get_options();
std::unique_ptr<Reflection::Struct> 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<Reflection::Struct> &options) {
}
// std::vector<std::unique_ptr<Configurable::Option>> 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<std::unique_ptr<Inputs::Joystick>> &get_joysticks() final {

View File

@ -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 <memory>
#include <vector>
namespace AmstradCPC {
/// @returns The options available for an Amstrad CPC.
std::vector<std::unique_ptr<Configurable::Option>> get_options();
std::unique_ptr<Reflection::Struct> get_options();
/*!
Models an Amstrad CPC.

View File

@ -37,11 +37,14 @@
namespace Apple {
namespace II {
std::vector<std::unique_ptr<Configurable::Option>> get_options() {
return Configurable::standard_options(
static_cast<Configurable::StandardOptions>(Configurable::DisplayCompositeMonochrome | Configurable::DisplayCompositeColour)
);
std::unique_ptr<Reflection::Struct> get_options() {
return nullptr;
}
//std::vector<std::unique_ptr<Configurable::Option>> get_options() {
// return Configurable::standard_options(
// static_cast<Configurable::StandardOptions>(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 <Analyser::Static::AppleII::Target::Model model> class ConcreteMachine:
}
// MARK:: Configuration options.
std::vector<std::unique_ptr<Configurable::Option>> get_options() final {
return Apple::II::get_options();
std::unique_ptr<Reflection::Struct> 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<Reflection::Struct> &options) final {
}
// std::vector<std::unique_ptr<Configurable::Option>> 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 {

View File

@ -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 <memory>
#include <vector>
namespace Apple {
namespace II {
/// @returns The options available for an Apple II.
std::vector<std::unique_ptr<Configurable::Option>> get_options();
std::unique_ptr<Reflection::Struct> get_options();
class Machine {
public:

View File

@ -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<std::unique_ptr<Configurable::Option>> get_options() {
return Configurable::standard_options(
static_cast<Configurable::StandardOptions>(Configurable::QuickBoot)
);
//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:
@ -522,35 +527,41 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
}
// MARK: - Configuration options.
std::vector<std::unique_ptr<Configurable::Option>> get_options() final {
return Apple::Macintosh::get_options();
std::unique_ptr<Reflection::Struct> 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<Reflection::Struct> &options) final {
}
// 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:
void set_component_prefers_clocking(ClockingHint::Source *component, ClockingHint::Preference clocking) final {

View File

@ -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 <memory>
namespace Apple {
namespace Macintosh {
std::vector<std::unique_ptr<Configurable::Option>> get_options();
std::unique_ptr<Reflection::Struct> get_options();
class Machine {
public:

View File

@ -42,10 +42,14 @@
namespace Atari {
namespace ST {
std::vector<std::unique_ptr<Configurable::Option>> get_options() {
return Configurable::standard_options(
static_cast<Configurable::StandardOptions>(Configurable::DisplayRGB | Configurable::DisplayCompositeColour)
);
//std::vector<std::unique_ptr<Configurable::Option>> get_options() {
// return Configurable::standard_options(
// static_cast<Configurable::StandardOptions>(Configurable::DisplayRGB | Configurable::DisplayCompositeColour)
// );
//}
std::unique_ptr<Reflection::Struct> get_options() {
return nullptr;
}
constexpr int CLOCK_RATE = 8021247;
@ -678,28 +682,30 @@ class ConcreteMachine:
}
// MARK: - Configuration options.
std::vector<std::unique_ptr<Configurable::Option>> get_options() final {
return Atari::ST::get_options();
std::unique_ptr<Reflection::Struct> 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<Reflection::Struct> &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;
// }
};
}

View File

@ -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 <memory>
namespace Atari {
namespace ST {
/// @returns The options available for an Atari ST.
std::vector<std::unique_ptr<Configurable::Option>> get_options();
std::unique_ptr<Reflection::Struct> get_options();
class Machine {
public:

View File

@ -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<std::unique_ptr<Configurable::Option>> get_options() {
return Configurable::standard_options(
static_cast<Configurable::StandardOptions>(Configurable::DisplaySVideo | Configurable::DisplayCompositeColour)
);
//std::vector<std::unique_ptr<Configurable::Option>> get_options() {
// return Configurable::standard_options(
// static_cast<Configurable::StandardOptions>(Configurable::DisplaySVideo | Configurable::DisplayCompositeColour)
// );
//}
std::unique_ptr<Reflection::Struct> get_options() {
return nullptr;
}
class Joystick: public Inputs::ConcreteJoystick {
@ -368,28 +373,34 @@ class ConcreteMachine:
}
// MARK: - Configuration options.
std::vector<std::unique_ptr<Configurable::Option>> get_options() final {
return Coleco::Vision::get_options();
std::unique_ptr<Reflection::Struct> 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<Reflection::Struct> &options) final {
}
// std::vector<std::unique_ptr<Configurable::Option>> 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) {

View File

@ -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 <memory>
namespace Coleco {
namespace Vision {
std::vector<std::unique_ptr<Configurable::Option>> get_options();
std::unique_ptr<Reflection::Struct> get_options();
class Machine {
public:

View File

@ -49,11 +49,14 @@ enum ROMSlot {
Drive
};
std::vector<std::unique_ptr<Configurable::Option>> get_options() {
return Configurable::standard_options(
static_cast<Configurable::StandardOptions>(Configurable::DisplaySVideo | Configurable::DisplayCompositeColour | Configurable::QuickLoadTape)
);
std::unique_ptr<Reflection::Struct> get_options() {
return nullptr;
}
//std::vector<std::unique_ptr<Configurable::Option>> get_options() {
// return Configurable::standard_options(
// static_cast<Configurable::StandardOptions>(Configurable::DisplaySVideo | Configurable::DisplayCompositeColour | Configurable::QuickLoadTape)
// );
//}
enum JoystickInput {
Up = 0x04,
@ -679,36 +682,42 @@ class ConcreteMachine:
}
// MARK: - Configuration options.
std::vector<std::unique_ptr<Configurable::Option>> get_options() final {
return Commodore::Vic20::get_options();
std::unique_ptr<Reflection::Struct> 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<Reflection::Struct> &options) final {
}
// std::vector<std::unique_ptr<Configurable::Option>> 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;

View File

@ -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 <memory>
#include <vector>
namespace Commodore {
namespace Vic20 {
/// @returns The options available for a Vic-20.
std::vector<std::unique_ptr<Configurable::Option>> get_options();
std::unique_ptr<Reflection::Struct> get_options();
class Machine {
public:

View File

@ -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<std::unique_ptr<Configurable::Option>> get_options() {
return Configurable::standard_options(
static_cast<Configurable::StandardOptions>(Configurable::DisplayRGB | Configurable::DisplayCompositeColour | Configurable::QuickLoadTape)
);
//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,
@ -448,36 +454,42 @@ class ConcreteMachine:
}
// MARK: - Configuration options.
std::vector<std::unique_ptr<Configurable::Option>> get_options() final {
return Electron::get_options();
std::unique_ptr<Reflection::Struct> 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<Reflection::Struct> &options) final {
}
// std::vector<std::unique_ptr<Configurable::Option>> 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 {

View File

@ -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 <cstdint>
#include <memory>
#include <vector>
namespace Electron {
/// @returns The options available for an Electron.
std::vector<std::unique_ptr<Configurable::Option>> get_options();
std::unique_ptr<Reflection::Struct> get_options();
/*!
@abstract Represents an Acorn Electron.

View File

@ -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<std::unique_ptr<Configurable::Option>> get_options() {
return Configurable::standard_options(
static_cast<Configurable::StandardOptions>(Configurable::DisplayRGB | Configurable::DisplaySVideo | Configurable::DisplayCompositeColour | Configurable::QuickLoadTape)
);
//std::vector<std::unique_ptr<Configurable::Option>> get_options() {
// return Configurable::standard_options(
// static_cast<Configurable::StandardOptions>(Configurable::DisplayRGB | Configurable::DisplaySVideo | Configurable::DisplayCompositeColour | Configurable::QuickLoadTape)
// );
//}
std::unique_ptr<Reflection::Struct> get_options() {
return nullptr;
}
class AYPortHandler: public GI::AY38910::PortHandler {
@ -648,36 +653,42 @@ class ConcreteMachine:
}
// MARK: - Configuration options.
std::vector<std::unique_ptr<Configurable::Option>> get_options() final {
return MSX::get_options();
std::unique_ptr<Reflection::Struct> 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<Reflection::Struct> &options) final {
}
// std::vector<std::unique_ptr<Configurable::Option>> 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 {

View File

@ -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 <memory>
#include <vector>
namespace MSX {
std::vector<std::unique_ptr<Configurable::Option>> get_options();
std::unique_ptr<Reflection::Struct> get_options();
class Machine {
public:

View File

@ -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<std::unique_ptr<Configurable::Option>> get_options() {
return Configurable::standard_options(
static_cast<Configurable::StandardOptions>(Configurable::DisplayRGB | Configurable::DisplayCompositeColour)
);
//std::vector<std::unique_ptr<Configurable::Option>> get_options() {
// return Configurable::standard_options(
// static_cast<Configurable::StandardOptions>(Configurable::DisplayRGB | Configurable::DisplayCompositeColour)
// );
//}
std::unique_ptr<Reflection::Struct> get_options() {
return nullptr;
}
class Joystick: public Inputs::ConcreteJoystick {
@ -373,28 +378,34 @@ class ConcreteMachine:
}
// MARK: - Configuration options.
std::vector<std::unique_ptr<Configurable::Option>> get_options() final {
return Sega::MasterSystem::get_options();
std::unique_ptr<Reflection::Struct> 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<Reflection::Struct> &options) final {
}
// std::vector<std::unique_ptr<Configurable::Option>> 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) {

View File

@ -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 <memory>
namespace Sega {
namespace MasterSystem {
std::vector<std::unique_ptr<Configurable::Option>> get_options();
std::unique_ptr<Reflection::Struct> get_options();
class Machine {
public:

View File

@ -50,14 +50,18 @@ enum ROM {
BASIC10 = 0, BASIC11, Microdisc, Colour
};
std::vector<std::unique_ptr<Configurable::Option>> get_options() {
return Configurable::standard_options(
static_cast<Configurable::StandardOptions>(
Configurable::DisplayRGB |
Configurable::DisplayCompositeColour |
Configurable::DisplayCompositeMonochrome |
Configurable::QuickLoadTape)
);
//std::vector<std::unique_ptr<Configurable::Option>> get_options() {
// return Configurable::standard_options(
// static_cast<Configurable::StandardOptions>(
// Configurable::DisplayRGB |
// Configurable::DisplayCompositeColour |
// Configurable::DisplayCompositeMonochrome |
// Configurable::QuickLoadTape)
// );
//}
std::unique_ptr<Reflection::Struct> get_options() {
return nullptr;
}
/*!
@ -623,35 +627,41 @@ template <Analyser::Static::Oric::Target::DiskInterface disk_interface> class Co
}
// MARK: - Configuration options.
std::vector<std::unique_ptr<Configurable::Option>> get_options() final {
return Oric::get_options();
std::unique_ptr<Reflection::Struct> 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<Reflection::Struct> &options) final {
}
// std::vector<std::unique_ptr<Configurable::Option>> 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) {

View File

@ -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 <memory>
namespace Oric {
/// @returns The options available for an Oric.
std::vector<std::unique_ptr<Configurable::Option>> get_options();
std::unique_ptr<Reflection::Struct> get_options();
/*!
Models an Oric 1/Atmos with or without a Microdisc.

View File

@ -173,19 +173,19 @@ std::vector<std::string> Machine::AllMachines(bool meaningful_without_media_only
return result;
}
std::map<std::string, std::vector<std::unique_ptr<Configurable::Option>>> Machine::AllOptionsByMachineName() {
std::map<std::string, std::vector<std::unique_ptr<Configurable::Option>>> options;
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::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;

View File

@ -77,7 +77,7 @@ std::vector<std::string> 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<std::string, std::vector<std::unique_ptr<Configurable::Option>>> AllOptionsByMachineName();
std::map<std::string, std::unique_ptr<Reflection::Struct>> AllOptionsByMachineName();
/*!
Returns a map from long machine name to appropriate instances of Target for the machine.

View File

@ -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<std::unique_ptr<Configurable::Option>> get_options() {
return Configurable::standard_options(
static_cast<Configurable::StandardOptions>(Configurable::AutomaticTapeMotorControl | Configurable::QuickLoadTape)
);
struct Options: public Reflection::StructImpl<Options> {
bool automatic_tape_motor_control = true;
bool quickload = true;
Options() {
if(needs_declare()) {
DeclareField(automatic_tape_motor_control);
DeclareField(quickload);
}
}
};
std::unique_ptr<Reflection::Struct> get_options() {
return std::make_unique<Options>();
}
template<bool is_zx81> class ConcreteMachine:
@ -413,37 +422,33 @@ template<bool is_zx81> class ConcreteMachine:
}
// MARK: - Configuration options.
std::vector<std::unique_ptr<Configurable::Option>> get_options() final {
return ZX8081::get_options();
std::unique_ptr<Reflection::Struct> get_options(OptionsType type) final {
auto options = std::make_unique<Options>();
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<Reflection::Struct> &options) {
if(Reflection::get<bool>(*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<bool>(*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<ConcreteMachine, false, is_zx81> z80_;
Video video_;

View File

@ -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 <memory>
namespace ZX8081 {
/// @returns The options available for a ZX80 or ZX81.
std::vector<std::unique_ptr<Configurable::Option>> get_options();
std::unique_ptr<Reflection::Struct> get_options();
class Machine {
public:

View File

@ -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 = "<group>"; };
4B055ABF1FAE98000060FFFF /* MachineForTarget.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MachineForTarget.hpp; sourceTree = "<group>"; };
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 = "<group>"; };
4B08A2741EE35D56008B7065 /* Z80InterruptTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Z80InterruptTests.swift; sourceTree = "<group>"; };
4B08A2761EE39306008B7065 /* TestMachine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestMachine.h; sourceTree = "<group>"; };
4B08A2771EE39306008B7065 /* TestMachine.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestMachine.mm; sourceTree = "<group>"; };
@ -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;

View File

@ -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<const std::string &>(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 <typename Type> 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<const bool *>(target.get(name));
return true;
}
return false;
}

View File

@ -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 <typename Type> 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.