1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +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
#define Analyser_Static_Acorn_Target_h
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp"
#include <string>
@ -16,11 +17,18 @@ namespace Analyser {
namespace Static {
namespace Acorn {
struct Target: public ::Analyser::Static::Target {
struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
bool has_adfs = false;
bool has_dfs = false;
bool should_shift_restart = false;
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
#define Analyser_Static_AmstradCPC_Target_h
#include "../../../Reflection/Enum.h"
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp"
#include <string>
@ -16,15 +18,17 @@ namespace Analyser {
namespace Static {
namespace AmstradCPC {
struct Target: public ::Analyser::Static::Target {
enum class Model {
CPC464,
CPC664,
CPC6128
};
struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
ReflectableEnum(Model, int, CPC464, CPC664, CPC6128);
Model model = Model::CPC464;
std::string loading_command;
Target() {
if(needs_declare()) {
DeclareField(model);
AnnounceEnum(Model);
}
}
};
}

View File

@ -9,27 +9,38 @@
#ifndef Target_h
#define Target_h
#include "../../../Reflection/Enum.h"
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp"
namespace Analyser {
namespace Static {
namespace AppleII {
struct Target: public ::Analyser::Static::Target {
enum class Model {
struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
ReflectableEnum(Model, int,
II,
IIplus,
IIe,
EnhancedIIe
};
enum class DiskController {
);
ReflectableEnum(DiskController, int,
None,
SixteenSector,
ThirteenSector
};
);
Model model = Model::IIe;
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
#define Analyser_Static_Commodore_Target_h
#include "../../../Reflection/Enum.h"
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp"
#include <string>
@ -16,20 +18,20 @@ namespace Analyser {
namespace Static {
namespace Commodore {
struct Target: public ::Analyser::Static::Target {
struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
enum class MemoryModel {
Unexpanded,
EightKB,
ThirtyTwoKB
};
enum class Region {
ReflectableEnum(Region, int,
American,
Danish,
Japanese,
European,
Swedish
};
);
/// Maps from a named memory model to a bank enabled/disabled set.
void set_memory_model(MemoryModel memory_model) {
@ -54,6 +56,19 @@ struct Target: public ::Analyser::Static::Target {
Region region = Region::European;
bool has_c1540 = false;
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
#define Analyser_Static_MSX_Target_h
#include "../../../Reflection/Enum.h"
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp"
#include <string>
@ -16,15 +18,24 @@ namespace Analyser {
namespace Static {
namespace MSX {
struct Target: public ::Analyser::Static::Target {
struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
bool has_disk_drive = false;
std::string loading_command;
enum class Region {
ReflectableEnum(Region, int,
Japan,
USA,
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> {
ReflectableEnum(Model, int, Mac128k, Mac512k, Mac512ke, MacPlus);
Model model = Model::MacPlus;
Target() {
// Boilerplate for declaring fields and potential values.
if(needs_declare()) {
declare(&model, "model");
DeclareField(model);
AnnounceEnum(Model);
}
}
Model model = Model::MacPlus;
};
}

View File

@ -9,6 +9,8 @@
#ifndef Analyser_Static_Oric_Target_h
#define Analyser_Static_Oric_Target_h
#include "../../../Reflection/Enum.h"
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp"
#include <string>
@ -16,25 +18,34 @@ namespace Analyser {
namespace Static {
namespace Oric {
struct Target: public ::Analyser::Static::Target {
enum class ROM {
struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
ReflectableEnum(ROM, int,
BASIC10,
BASIC11,
Pravetz
};
);
enum class DiskInterface {
ReflectableEnum(DiskInterface, int,
None,
Microdisc,
Pravetz,
Jasmin,
BD500,
None
};
BD500
);
ROM rom = ROM::BASIC11;
DiskInterface disk_interface = DiskInterface::None;
std::string loading_command;
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
#define Analyser_Static_ZX8081_Target_h
#include "../../../Reflection/Enum.h"
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp"
#include <string>
@ -16,17 +18,26 @@ namespace Analyser {
namespace Static {
namespace ZX8081 {
struct Target: public ::Analyser::Static::Target {
enum class MemoryModel {
struct Target: public ::Analyser::Static::Target, public Reflection::Struct<Target> {
ReflectableEnum(MemoryModel, int,
Unexpanded,
SixteenKB,
SixtyFourKB
};
);
MemoryModel memory_model = MemoryModel::Unexpanded;
bool is_ZX81 = false;
bool ZX80_uses_ZX81_ROM = false;
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;
Analyser::Static::Macintosh::Target nothing;
}
namespace Apple {

View File

@ -19,7 +19,7 @@
namespace Reflection {
#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__;
#define EnumDeclaration(Name) #Name, __declaration##Name

View File

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