1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-19 23:29:05 +00:00

Adds reflection to all of the other computer targets.

This commit is contained in:
Thomas Harte 2020-03-11 23:25:29 -04:00
parent 044a2b67e1
commit fd052189ca
11 changed files with 105 additions and 36 deletions

View File

@ -9,6 +9,7 @@
#ifndef Analyser_Static_Acorn_Target_h #ifndef Analyser_Static_Acorn_Target_h
#define Analyser_Static_Acorn_Target_h #define Analyser_Static_Acorn_Target_h
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp" #include "../StaticAnalyser.hpp"
#include <string> #include <string>
@ -16,11 +17,18 @@ namespace Analyser {
namespace Static { namespace Static {
namespace Acorn { namespace Acorn {
struct Target: public ::Analyser::Static::Target { struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
bool has_adfs = false; bool has_adfs = false;
bool has_dfs = false; bool has_dfs = false;
bool should_shift_restart = false; bool should_shift_restart = false;
std::string loading_command; std::string loading_command;
Target() {
if(needs_declare()) {
DeclareField(has_adfs);
DeclareField(has_dfs);
}
}
}; };
} }

View File

@ -9,6 +9,8 @@
#ifndef Analyser_Static_AmstradCPC_Target_h #ifndef Analyser_Static_AmstradCPC_Target_h
#define Analyser_Static_AmstradCPC_Target_h #define Analyser_Static_AmstradCPC_Target_h
#include "../../../Reflection/Enum.h"
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp" #include "../StaticAnalyser.hpp"
#include <string> #include <string>
@ -16,15 +18,17 @@ namespace Analyser {
namespace Static { namespace Static {
namespace AmstradCPC { namespace AmstradCPC {
struct Target: public ::Analyser::Static::Target { struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
enum class Model { ReflectableEnum(Model, int, CPC464, CPC664, CPC6128);
CPC464,
CPC664,
CPC6128
};
Model model = Model::CPC464; Model model = Model::CPC464;
std::string loading_command; std::string loading_command;
Target() {
if(needs_declare()) {
DeclareField(model);
AnnounceEnum(Model);
}
}
}; };
} }

View File

@ -9,27 +9,38 @@
#ifndef Target_h #ifndef Target_h
#define Target_h #define Target_h
#include "../../../Reflection/Enum.h"
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp" #include "../StaticAnalyser.hpp"
namespace Analyser { namespace Analyser {
namespace Static { namespace Static {
namespace AppleII { namespace AppleII {
struct Target: public ::Analyser::Static::Target { struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
enum class Model { ReflectableEnum(Model, int,
II, II,
IIplus, IIplus,
IIe, IIe,
EnhancedIIe EnhancedIIe
}; );
enum class DiskController { ReflectableEnum(DiskController, int,
None, None,
SixteenSector, SixteenSector,
ThirteenSector ThirteenSector
}; );
Model model = Model::IIe; Model model = Model::IIe;
DiskController disk_controller = DiskController::None; DiskController disk_controller = DiskController::None;
Target() {
if(needs_declare()) {
DeclareField(model);
DeclareField(disk_controller);
AnnounceEnum(Model);
AnnounceEnum(DiskController);
}
}
}; };
} }

View File

@ -9,6 +9,8 @@
#ifndef Analyser_Static_Commodore_Target_h #ifndef Analyser_Static_Commodore_Target_h
#define Analyser_Static_Commodore_Target_h #define Analyser_Static_Commodore_Target_h
#include "../../../Reflection/Enum.h"
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp" #include "../StaticAnalyser.hpp"
#include <string> #include <string>
@ -16,20 +18,20 @@ namespace Analyser {
namespace Static { namespace Static {
namespace Commodore { namespace Commodore {
struct Target: public ::Analyser::Static::Target { struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
enum class MemoryModel { enum class MemoryModel {
Unexpanded, Unexpanded,
EightKB, EightKB,
ThirtyTwoKB ThirtyTwoKB
}; };
enum class Region { ReflectableEnum(Region, int,
American, American,
Danish, Danish,
Japanese, Japanese,
European, European,
Swedish Swedish
}; );
/// Maps from a named memory model to a bank enabled/disabled set. /// Maps from a named memory model to a bank enabled/disabled set.
void set_memory_model(MemoryModel memory_model) { void set_memory_model(MemoryModel memory_model) {
@ -54,6 +56,19 @@ struct Target: public ::Analyser::Static::Target {
Region region = Region::European; Region region = Region::European;
bool has_c1540 = false; bool has_c1540 = false;
std::string loading_command; std::string loading_command;
Target() {
if(needs_declare()) {
DeclareField(enabled_ram.bank0);
DeclareField(enabled_ram.bank1);
DeclareField(enabled_ram.bank2);
DeclareField(enabled_ram.bank3);
DeclareField(enabled_ram.bank5);
DeclareField(region);
DeclareField(has_c1540);
AnnounceEnum(Region);
}
}
}; };
} }

View File

@ -9,6 +9,8 @@
#ifndef Analyser_Static_MSX_Target_h #ifndef Analyser_Static_MSX_Target_h
#define Analyser_Static_MSX_Target_h #define Analyser_Static_MSX_Target_h
#include "../../../Reflection/Enum.h"
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp" #include "../StaticAnalyser.hpp"
#include <string> #include <string>
@ -16,15 +18,24 @@ namespace Analyser {
namespace Static { namespace Static {
namespace MSX { namespace MSX {
struct Target: public ::Analyser::Static::Target { struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
bool has_disk_drive = false; bool has_disk_drive = false;
std::string loading_command; std::string loading_command;
enum class Region { ReflectableEnum(Region, int,
Japan, Japan,
USA, USA,
Europe Europe
} region = Region::USA; );
Region region = Region::USA;
Target() {
if(needs_declare()) {
DeclareField(has_disk_drive);
DeclareField(region);
AnnounceEnum(Region);
}
}
}; };
} }

View File

@ -18,16 +18,15 @@ namespace Macintosh {
struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> { struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
ReflectableEnum(Model, int, Mac128k, Mac512k, Mac512ke, MacPlus); ReflectableEnum(Model, int, Mac128k, Mac512k, Mac512ke, MacPlus);
Model model = Model::MacPlus;
Target() { Target() {
// Boilerplate for declaring fields and potential values. // Boilerplate for declaring fields and potential values.
if(needs_declare()) { if(needs_declare()) {
declare(&model, "model"); DeclareField(model);
AnnounceEnum(Model); AnnounceEnum(Model);
} }
} }
Model model = Model::MacPlus;
}; };
} }

View File

@ -9,6 +9,8 @@
#ifndef Analyser_Static_Oric_Target_h #ifndef Analyser_Static_Oric_Target_h
#define Analyser_Static_Oric_Target_h #define Analyser_Static_Oric_Target_h
#include "../../../Reflection/Enum.h"
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp" #include "../StaticAnalyser.hpp"
#include <string> #include <string>
@ -16,25 +18,34 @@ namespace Analyser {
namespace Static { namespace Static {
namespace Oric { namespace Oric {
struct Target: public ::Analyser::Static::Target { struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
enum class ROM { ReflectableEnum(ROM, int,
BASIC10, BASIC10,
BASIC11, BASIC11,
Pravetz Pravetz
}; );
enum class DiskInterface { ReflectableEnum(DiskInterface, int,
None,
Microdisc, Microdisc,
Pravetz, Pravetz,
Jasmin, Jasmin,
BD500, BD500
None );
};
ROM rom = ROM::BASIC11; ROM rom = ROM::BASIC11;
DiskInterface disk_interface = DiskInterface::None; DiskInterface disk_interface = DiskInterface::None;
std::string loading_command; std::string loading_command;
bool should_start_jasmin = false; bool should_start_jasmin = false;
Target() {
if(needs_declare()) {
DeclareField(rom);
DeclareField(disk_interface);
AnnounceEnum(ROM);
AnnounceEnum(DiskInterface);
}
}
}; };
} }

View File

@ -9,6 +9,8 @@
#ifndef Analyser_Static_ZX8081_Target_h #ifndef Analyser_Static_ZX8081_Target_h
#define Analyser_Static_ZX8081_Target_h #define Analyser_Static_ZX8081_Target_h
#include "../../../Reflection/Enum.h"
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp" #include "../StaticAnalyser.hpp"
#include <string> #include <string>
@ -16,17 +18,26 @@ namespace Analyser {
namespace Static { namespace Static {
namespace ZX8081 { namespace ZX8081 {
struct Target: public ::Analyser::Static::Target { struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
enum class MemoryModel { ReflectableEnum(MemoryModel, int,
Unexpanded, Unexpanded,
SixteenKB, SixteenKB,
SixtyFourKB SixtyFourKB
}; );
MemoryModel memory_model = MemoryModel::Unexpanded; MemoryModel memory_model = MemoryModel::Unexpanded;
bool is_ZX81 = false; bool is_ZX81 = false;
bool ZX80_uses_ZX81_ROM = false; bool ZX80_uses_ZX81_ROM = false;
std::string loading_command; std::string loading_command;
Target() {
if(needs_declare()) {
DeclareField(memory_model);
DeclareField(is_ZX81);
DeclareField(ZX80_uses_ZX81_ROM);
AnnounceEnum(MemoryModel);
}
}
}; };
} }

View File

@ -51,9 +51,6 @@ namespace {
constexpr int CLOCK_RATE = 7833600; constexpr int CLOCK_RATE = 7833600;
Analyser::Static::Macintosh::Target nothing;
} }
namespace Apple { namespace Apple {

View File

@ -19,7 +19,7 @@
namespace Reflection { namespace Reflection {
#define ReflectableEnum(Name, Type, ...) \ #define ReflectableEnum(Name, Type, ...) \
enum class Name: Type { Mac128k, Mac512k, Mac512ke, MacPlus }; \ enum class Name: Type { __VA_ARGS__ }; \
constexpr static const char *__declaration##Name = #__VA_ARGS__; constexpr static const char *__declaration##Name = #__VA_ARGS__;
#define EnumDeclaration(Name) #Name, __declaration##Name #define EnumDeclaration(Name) #Name, __declaration##Name

View File

@ -17,6 +17,8 @@
namespace Reflection { namespace Reflection {
#define DeclareField(Name) declare(&Name, #Name)
template <typename Owner> class Struct { template <typename Owner> class Struct {
public: public:
/*! /*!