mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-30 19:30:17 +00:00
Takes steps to guarantee property naming; reintroduces Electron runtime options.
This commit is contained in:
parent
8c6ca89da2
commit
ec6664f590
@ -20,6 +20,35 @@ ReflectableEnum(Display,
|
||||
CompositeMonochrome
|
||||
);
|
||||
|
||||
//===
|
||||
// From here downward are a bunch of templates for individual option flags.
|
||||
// Using them saves you marginally in syntax, but the primary gain is to
|
||||
// ensure unified property naming.
|
||||
//===
|
||||
|
||||
template <typename Owner> class DisplayOption {
|
||||
public:
|
||||
Configurable::Display output;
|
||||
DisplayOption(Configurable::Display output) : output(output) {}
|
||||
|
||||
protected:
|
||||
void declare_display_option() {
|
||||
static_cast<Owner *>(this)->declare(&output, "output");
|
||||
AnnounceEnumNS(Configurable, Display);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Owner> class QuickloadOption {
|
||||
public:
|
||||
bool quickload;
|
||||
QuickloadOption(bool quickload) : quickload(quickload) {}
|
||||
|
||||
protected:
|
||||
void declare_quickload_option() {
|
||||
static_cast<Owner *>(this)->declare(&quickload, "quickload");
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* StandardOptions_hpp */
|
||||
|
@ -29,15 +29,12 @@ class Machine {
|
||||
static Machine *AmstradCPC(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher);
|
||||
|
||||
/// Defines the runtime options available for an Amstrad CPC.
|
||||
class Options: public Reflection::StructImpl<Options> {
|
||||
class Options: public Reflection::StructImpl<Options>, public Configurable::DisplayOption<Options> {
|
||||
friend Configurable::DisplayOption<Options>;
|
||||
public:
|
||||
Configurable::Display output = Configurable::Display::RGB;
|
||||
|
||||
Options(Configurable::OptionsType type) {
|
||||
// Declare fields if necessary.
|
||||
Options(Configurable::OptionsType type) : Configurable::DisplayOption<Options>(Configurable::Display::RGB) {
|
||||
if(needs_declare()) {
|
||||
DeclareField(output);
|
||||
AnnounceEnumNS(Configurable, Display);
|
||||
declare_display_option();
|
||||
limit_enum(&output, Configurable::Display::RGB, Configurable::Display::CompositeColour, -1);
|
||||
}
|
||||
}
|
||||
|
@ -27,15 +27,12 @@ class Machine {
|
||||
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<Options> {
|
||||
class Options: public Reflection::StructImpl<Options>, public Configurable::DisplayOption<Options> {
|
||||
friend Configurable::DisplayOption<Options>;
|
||||
public:
|
||||
Configurable::Display output = Configurable::Display::CompositeColour;
|
||||
|
||||
Options(Configurable::OptionsType type) {
|
||||
// Declare fields if necessary.
|
||||
Options(Configurable::OptionsType type) : Configurable::DisplayOption<Options>(Configurable::Display::CompositeColour) {
|
||||
if(needs_declare()) {
|
||||
DeclareField(output);
|
||||
AnnounceEnumNS(Configurable, Display);
|
||||
declare_display_option();
|
||||
limit_enum(&output, Configurable::Display::CompositeMonochrome, Configurable::Display::CompositeColour, -1);
|
||||
}
|
||||
}
|
||||
|
@ -42,16 +42,6 @@
|
||||
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::unique_ptr<Reflection::Struct> get_options() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
constexpr int CLOCK_RATE = 8021247;
|
||||
|
||||
using Target = Analyser::Static::Target;
|
||||
@ -153,6 +143,10 @@ 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_;
|
||||
}
|
||||
@ -683,29 +677,15 @@ class ConcreteMachine:
|
||||
|
||||
// MARK: - Configuration options.
|
||||
std::unique_ptr<Reflection::Struct> get_options() final {
|
||||
return nullptr;
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
||||
options->output = get_video_signal_configurable();
|
||||
return options;
|
||||
}
|
||||
|
||||
void set_options(const std::unique_ptr<Reflection::Struct> &options) final {
|
||||
void set_options(const std::unique_ptr<Reflection::Struct> &str) final {
|
||||
const auto options = dynamic_cast<Options *>(str.get());
|
||||
set_video_signal_configurable(options->output);
|
||||
}
|
||||
// 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;
|
||||
// }
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,8 @@
|
||||
#ifndef AtariST_hpp
|
||||
#define AtariST_hpp
|
||||
|
||||
#include "../../../Reflection/Struct.h"
|
||||
#include "../../../Configurable/Configurable.hpp"
|
||||
#include "../../../Configurable/StandardOptions.hpp"
|
||||
#include "../../../Analyser/Static/StaticAnalyser.hpp"
|
||||
#include "../../ROMMachine.hpp"
|
||||
|
||||
@ -18,14 +19,23 @@
|
||||
namespace Atari {
|
||||
namespace ST {
|
||||
|
||||
/// @returns The options available for an Atari ST.
|
||||
std::unique_ptr<Reflection::Struct> get_options();
|
||||
|
||||
class Machine {
|
||||
public:
|
||||
virtual ~Machine();
|
||||
|
||||
static Machine *AtariST(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher);
|
||||
|
||||
class Options: public Reflection::StructImpl<Options>, public Configurable::DisplayOption<Options> {
|
||||
friend Configurable::DisplayOption<Options>;
|
||||
public:
|
||||
Options(Configurable::OptionsType type) : Configurable::DisplayOption<Options>(
|
||||
type == Configurable::OptionsType::UserFriendly ? Configurable::Display::RGB : Configurable::Display::CompositeColour) {
|
||||
if(needs_declare()) {
|
||||
declare_display_option();
|
||||
limit_enum(&output, Configurable::Display::RGB, Configurable::Display::CompositeColour, -1);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -146,6 +146,10 @@ void Video::set_display_type(Outputs::Display::DisplayType display_type) {
|
||||
crt_.set_display_type(display_type);
|
||||
}
|
||||
|
||||
Outputs::Display::DisplayType Video::get_display_type() {
|
||||
return crt_.get_display_type();
|
||||
}
|
||||
|
||||
void Video::run_for(HalfCycles duration) {
|
||||
int integer_duration = int(duration.as_integral());
|
||||
assert(integer_duration >= 0);
|
||||
|
@ -54,6 +54,11 @@ class Video {
|
||||
*/
|
||||
void set_display_type(Outputs::Display::DisplayType);
|
||||
|
||||
/*!
|
||||
Gets the type of output.
|
||||
*/
|
||||
Outputs::Display::DisplayType get_display_type();
|
||||
|
||||
/*!
|
||||
Produces the next @c duration period of pixels.
|
||||
*/
|
||||
|
@ -32,19 +32,16 @@ class Machine {
|
||||
static Machine *Electron(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher);
|
||||
|
||||
/// Defines the runtime options available for an Electron.
|
||||
class Options: public Reflection::StructImpl<Options> {
|
||||
class Options: public Reflection::StructImpl<Options>, public Configurable::DisplayOption<Options>, public Configurable::QuickloadOption<Options> {
|
||||
friend Configurable::DisplayOption<Options>;
|
||||
friend Configurable::QuickloadOption<Options>;
|
||||
public:
|
||||
Configurable::Display output;
|
||||
bool quickload;
|
||||
|
||||
Options(Configurable::OptionsType type) :
|
||||
output(type == Configurable::OptionsType::UserFriendly ? Configurable::Display::RGB : Configurable::Display::CompositeColour),
|
||||
quickload(type == Configurable::OptionsType::UserFriendly) {
|
||||
|
||||
Configurable::DisplayOption<Options>(type == Configurable::OptionsType::UserFriendly ? Configurable::Display::RGB : Configurable::Display::CompositeColour),
|
||||
Configurable::QuickloadOption<Options>(type == Configurable::OptionsType::UserFriendly) {
|
||||
if(needs_declare()) {
|
||||
DeclareField(output);
|
||||
DeclareField(quickload);
|
||||
AnnounceEnumNS(Configurable, Display);
|
||||
declare_display_option();
|
||||
declare_quickload_option();
|
||||
limit_enum(&output, Configurable::Display::RGB, Configurable::Display::CompositeColour, -1);
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,6 @@ std::vector<std::string> Machine::AllMachines(bool meaningful_without_media_only
|
||||
std::map<std::string, std::unique_ptr<Reflection::Struct>> Machine::AllOptionsByMachineName() {
|
||||
std::map<std::string, std::unique_ptr<Reflection::Struct>> options;
|
||||
|
||||
// options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::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::Macintosh), Apple::Macintosh::get_options()));
|
||||
// options.emplace(std::make_pair(LongNameForTargetMachine(Analyser::Machine::MasterSystem), Sega::MasterSystem::get_options()));
|
||||
@ -189,6 +188,7 @@ std::map<std::string, std::unique_ptr<Reflection::Struct>> Machine::AllOptionsBy
|
||||
|
||||
Emplace(AmstradCPC, AmstradCPC::Machine);
|
||||
Emplace(AppleII, Apple::II::Machine);
|
||||
Emplace(AtariST, Atari::ST::Machine);
|
||||
Emplace(Electron, Electron::Machine);
|
||||
Emplace(ZX8081, ZX8081::Machine);
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#define ZX8081_hpp
|
||||
|
||||
#include "../../Configurable/Configurable.hpp"
|
||||
#include "../../Configurable/StandardOptions.hpp"
|
||||
#include "../../Analyser/Static/StaticAnalyser.hpp"
|
||||
#include "../ROMMachine.hpp"
|
||||
|
||||
@ -28,19 +29,19 @@ class Machine {
|
||||
virtual bool get_tape_is_playing() = 0;
|
||||
|
||||
/// Defines the runtime options available for a ZX80/81.
|
||||
class Options: public Reflection::StructImpl<Options> {
|
||||
class Options: public Reflection::StructImpl<Options>, public Configurable::QuickloadOption<Options> {
|
||||
friend Configurable::QuickloadOption<Options>;
|
||||
public:
|
||||
bool automatic_tape_motor_control;
|
||||
bool quickload;
|
||||
|
||||
Options(Configurable::OptionsType type):
|
||||
automatic_tape_motor_control(type == Configurable::OptionsType::UserFriendly),
|
||||
quickload(automatic_tape_motor_control) {
|
||||
Configurable::QuickloadOption<Options>(type == Configurable::OptionsType::UserFriendly) {
|
||||
|
||||
// Declare fields if necessary.
|
||||
if(needs_declare()) {
|
||||
DeclareField(automatic_tape_motor_control);
|
||||
DeclareField(quickload);
|
||||
declare_quickload_option();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user