1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-09 17:29:36 +00:00

Ensure targets always nominate a machine.

This commit is contained in:
Thomas Harte 2020-03-15 00:13:38 -04:00
parent 36acc2dddd
commit f9c8470b20
26 changed files with 36 additions and 47 deletions

View File

@ -59,7 +59,6 @@ static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>>
Analyser::Static::TargetList Analyser::Static::Acorn::GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms) {
auto target = std::make_unique<Target>();
target->machine = Machine::Electron;
target->confidence = 0.5; // TODO: a proper estimation
target->has_dfs = false;
target->has_adfs = false;

View File

@ -23,7 +23,7 @@ struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<
bool should_shift_restart = false;
std::string loading_command;
Target() {
Target() : Analyser::Static::Target(Machine::Electron) {
if(needs_declare()) {
DeclareField(has_adfs);
DeclareField(has_dfs);

View File

@ -182,7 +182,6 @@ static bool CheckBootSector(const std::shared_ptr<Storage::Disk::Disk> &disk, co
Analyser::Static::TargetList Analyser::Static::AmstradCPC::GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms) {
TargetList destination;
auto target = std::make_unique<Target>();
target->machine = Machine::AmstradCPC;
target->confidence = 0.5;
target->model = Target::Model::CPC6128;

View File

@ -18,12 +18,12 @@ namespace Analyser {
namespace Static {
namespace AmstradCPC {
struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<Target> {
struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Target> {
ReflectableEnum(Model, CPC464, CPC664, CPC6128);
Model model = Model::CPC464;
std::string loading_command;
Target() {
Target() : Analyser::Static::Target(Machine::AmstradCPC) {
if(needs_declare()) {
DeclareField(model);
AnnounceEnum(Model);

View File

@ -11,7 +11,6 @@
Analyser::Static::TargetList Analyser::Static::AppleII::GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms) {
auto target = std::make_unique<Target>();
target->machine = Machine::AppleII;
target->media = media;
if(!target->media.disks.empty())

View File

@ -17,7 +17,7 @@ namespace Analyser {
namespace Static {
namespace AppleII {
struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<Target> {
struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Target> {
ReflectableEnum(Model,
II,
IIplus,
@ -33,7 +33,7 @@ struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<
Model model = Model::IIe;
DiskController disk_controller = DiskController::None;
Target() {
Target() : Analyser::Static::Target(Machine::AppleII) {
if(needs_declare()) {
DeclareField(model);
DeclareField(disk_controller);

View File

@ -184,7 +184,6 @@ static void DeterminePagingForCartridge(Target &target, const Storage::Cartridge
Analyser::Static::TargetList Analyser::Static::Atari2600::GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms) {
// TODO: sanity checking; is this image really for an Atari 2600?
auto target = std::make_unique<Target>();
target->machine = Machine::Atari2600;
target->confidence = 0.5;
target->media.cartridges = media.cartridges;
target->paging_model = Target::PagingModel::None;

View File

@ -34,6 +34,8 @@ struct Target: public ::Analyser::Static::Target {
// TODO: shouldn't these be properties of the cartridge?
PagingModel paging_model = PagingModel::None;
bool uses_superchip = false;
Target() : Analyser::Static::Target(Machine::Atari2600) {}
};
}

View File

@ -16,9 +16,8 @@ Analyser::Static::TargetList Analyser::Static::AtariST::GetTargets(const Media &
// As there is at least one usable media image, wave it through.
Analyser::Static::TargetList targets;
using Target = Analyser::Static::Target;
auto *target = new Target;
target->machine = Analyser::Machine::AtariST;
using Target = Analyser::Static::AtariST::Target;
auto *target = new Target();
target->media = media;
targets.push_back(std::unique_ptr<Analyser::Static::Target>(target));

View File

@ -9,11 +9,15 @@
#ifndef Analyser_Static_AtariST_Target_h
#define Analyser_Static_AtariST_Target_h
#include "../../../Reflection/Struct.h"
#include "../StaticAnalyser.hpp"
namespace Analyser {
namespace Static {
namespace AtariST {
struct Target: public ::Analyser::Static::Target {
struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Target> {
Target() : Analyser::Static::Target(Machine::AtariST) {}
};
}

View File

@ -54,8 +54,7 @@ static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>>
Analyser::Static::TargetList Analyser::Static::Coleco::GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms) {
TargetList targets;
auto target = std::make_unique<Target>();
target->machine = Machine::ColecoVision;
auto target = std::make_unique<Target>(Machine::ColecoVision);
target->confidence = 1.0f - 1.0f / 32768.0f;
target->media.cartridges = ColecoCartridgesFrom(media.cartridges);
if(!target->media.empty())

View File

@ -18,7 +18,7 @@ namespace Analyser {
namespace Static {
namespace Commodore {
struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<Target> {
struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Target> {
enum class MemoryModel {
Unexpanded,
EightKB,
@ -57,7 +57,7 @@ struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<
bool has_c1540 = false;
std::string loading_command;
Target() {
Target() : Analyser::Static::Target(Machine::Vic20) {
if(needs_declare()) {
DeclareField(enabled_ram.bank0);
DeclareField(enabled_ram.bank1);

View File

@ -21,7 +21,6 @@ namespace {
Analyser::Static::Target *AppleTarget(const Storage::Encodings::AppleGCR::Sector *sector_zero) {
using Target = Analyser::Static::AppleII::Target;
auto *target = new Target;
target->machine = Analyser::Machine::AppleII;
if(sector_zero && sector_zero->encoding == Storage::Encodings::AppleGCR::Sector::Encoding::FiveAndThree) {
target->disk_controller = Target::DiskController::ThirteenSector;
@ -35,7 +34,6 @@ Analyser::Static::Target *AppleTarget(const Storage::Encodings::AppleGCR::Sector
Analyser::Static::Target *OricTarget(const Storage::Encodings::AppleGCR::Sector *sector_zero) {
using Target = Analyser::Static::Oric::Target;
auto *target = new Target;
target->machine = Analyser::Machine::Oric;
target->rom = Target::ROM::Pravetz;
target->disk_interface = Target::DiskInterface::Pravetz;
target->loading_command = "CALL 800\n";

View File

@ -35,7 +35,6 @@ static std::unique_ptr<Analyser::Static::Target> CartridgeTarget(
}
auto target = std::make_unique<Analyser::Static::MSX::Target>();
target->machine = Analyser::Machine::MSX;
target->confidence = confidence;
if(type == Analyser::Static::MSX::Cartridge::Type::None) {
@ -295,7 +294,6 @@ Analyser::Static::TargetList Analyser::Static::MSX::GetTargets(const Media &medi
target->has_disk_drive = !media.disks.empty();
if(!target->media.empty()) {
target->machine = Machine::MSX;
target->confidence = 0.5;
destination.push_back(std::move(target));
}

View File

@ -29,7 +29,7 @@ struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<
);
Region region = Region::USA;
Target() {
Target(): Analyser::Static::Target(Machine::MSX) {
if(needs_declare()) {
DeclareField(has_disk_drive);
DeclareField(region);

View File

@ -18,7 +18,6 @@ Analyser::Static::TargetList Analyser::Static::Macintosh::GetTargets(const Media
using Target = Analyser::Static::Macintosh::Target;
auto *target = new Target;
target->machine = Analyser::Machine::Macintosh;
target->media = media;
targets.push_back(std::unique_ptr<Analyser::Static::Target>(target));

View File

@ -16,11 +16,11 @@ namespace Analyser {
namespace Static {
namespace Macintosh {
struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<Target> {
struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Target> {
ReflectableEnum(Model, Mac128k, Mac512k, Mac512ke, MacPlus);
Model model = Model::MacPlus;
Target() {
Target() : Analyser::Static::Target(Machine::Macintosh) {
// Boilerplate for declaring fields and potential values.
if(needs_declare()) {
DeclareField(model);

View File

@ -147,7 +147,6 @@ bool is_bd500(Storage::Encodings::MFM::Parser &parser) {
Analyser::Static::TargetList Analyser::Static::Oric::GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms) {
auto target = std::make_unique<Target>();
target->machine = Machine::Oric;
target->confidence = 0.5;
int basic10_votes = 0;

View File

@ -18,7 +18,7 @@ namespace Analyser {
namespace Static {
namespace Oric {
struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<Target> {
struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Target> {
ReflectableEnum(ROM,
BASIC10,
BASIC11,
@ -38,7 +38,7 @@ struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<
std::string loading_command;
bool should_start_jasmin = false;
Target() {
Target(): Analyser::Static::Target(Machine::Oric) {
if(needs_declare()) {
DeclareField(rom);
DeclareField(disk_interface);

View File

@ -20,8 +20,6 @@ Analyser::Static::TargetList Analyser::Static::Sega::GetTargets(const Media &med
TargetList targets;
auto target = std::make_unique<Target>();
target->machine = Machine::MasterSystem;
// Files named .sg are treated as for the SG1000; otherwise assume a Master System.
if(file_name.size() >= 2 && *(file_name.end() - 2) == 's' && *(file_name.end() - 1) == 'g') {
target->model = Target::Model::SG1000;

View File

@ -9,11 +9,13 @@
#ifndef Analyser_Static_Sega_Target_h
#define Analyser_Static_Sega_Target_h
#include "../StaticAnalyser.hpp"
namespace Analyser {
namespace Static {
namespace Sega {
struct Target: public ::Analyser::Static::Target {
struct Target: public Analyser::Static::Target {
enum class Model {
SG1000,
MasterSystem,
@ -35,6 +37,8 @@ struct Target: public ::Analyser::Static::Target {
Model model = Model::MasterSystem;
Region region = Region::Japan;
PagingScheme paging_scheme = PagingScheme::Sega;
Target() : Analyser::Static::Target(Machine::MasterSystem) {}
};
#define is_master_system(v) v >= Analyser::Static::Sega::Target::Model::MasterSystem

View File

@ -42,11 +42,12 @@ struct Media {
and instructions on how to launch the software attached, plus a measure of confidence in this target's correctness.
*/
struct Target {
Target(Machine machine) : machine(machine) {}
virtual ~Target() {}
Machine machine;
Media media;
float confidence;
float confidence = 0.0f;
};
typedef std::vector<std::unique_ptr<Target>> TargetList;

View File

@ -30,7 +30,7 @@ struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<
bool ZX80_uses_ZX81_ROM = false;
std::string loading_command;
Target() {
Target(): Analyser::Static::Target(Machine::ZX8081) {
if(needs_declare()) {
DeclareField(memory_model);
DeclareField(is_ZX81);

View File

@ -79,11 +79,11 @@
</CommandLineArgument>
<CommandLineArgument
argument = "--speed=5"
isEnabled = "NO">
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--rompath=/Users/thomasharte/Projects/CLK/ROMImages"
isEnabled = "NO">
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--help"

View File

@ -16,6 +16,7 @@
#include "../../../../../Analyser/Static/Acorn/Target.hpp"
#include "../../../../../Analyser/Static/AmstradCPC/Target.hpp"
#include "../../../../../Analyser/Static/AppleII/Target.hpp"
#include "../../../../../Analyser/Static/AtariST/Target.hpp"
#include "../../../../../Analyser/Static/Commodore/Target.hpp"
#include "../../../../../Analyser/Static/Macintosh/Target.hpp"
#include "../../../../../Analyser/Static/MSX/Target.hpp"
@ -46,7 +47,6 @@
if(self) {
using Target = Analyser::Static::Acorn::Target;
auto target = std::make_unique<Target>();
target->machine = Analyser::Machine::Electron;
target->has_dfs = !!dfs;
target->has_adfs = !!adfs;
_targets.push_back(std::move(target));
@ -59,7 +59,6 @@
if(self) {
using Target = Analyser::Static::AmstradCPC::Target;
auto target = std::make_unique<Target>();
target->machine = Analyser::Machine::AmstradCPC;
switch(model) {
case CSMachineCPCModel464: target->model = Analyser::Static::AmstradCPC::Target::Model::CPC464; break;
case CSMachineCPCModel664: target->model = Analyser::Static::AmstradCPC::Target::Model::CPC664; break;
@ -75,7 +74,6 @@
if(self) {
using Target = Analyser::Static::MSX::Target;
auto target = std::make_unique<Target>();
target->machine = Analyser::Machine::MSX;
target->has_disk_drive = !!hasDiskDrive;
switch(region) {
case CSMachineMSXRegionAmerican: target->region = Analyser::Static::MSX::Target::Region::USA; break;
@ -92,7 +90,6 @@
if(self) {
using Target = Analyser::Static::Oric::Target;
auto target = std::make_unique<Target>();
target->machine = Analyser::Machine::Oric;
switch(model) {
case CSMachineOricModelOric1: target->rom = Target::ROM::BASIC10; break;
case CSMachineOricModelOricAtmos: target->rom = Target::ROM::BASIC11; break;
@ -115,7 +112,6 @@
if(self) {
using Target = Analyser::Static::Commodore::Target;
auto target = std::make_unique<Target>();
target->machine = Analyser::Machine::Vic20;
switch(region) {
case CSMachineVic20RegionDanish: target->region = Target::Region::Danish; break;
case CSMachineVic20RegionSwedish: target->region = Target::Region::Swedish; break;
@ -150,7 +146,6 @@ static Analyser::Static::ZX8081::Target::MemoryModel ZX8081MemoryModelFromSize(K
if(self) {
using Target = Analyser::Static::ZX8081::Target;
auto target = std::make_unique<Target>();
target->machine = Analyser::Machine::ZX8081;
target->is_ZX81 = false;
target->ZX80_uses_ZX81_ROM = !!useZX81ROM;
target->memory_model = ZX8081MemoryModelFromSize(memorySize);
@ -164,7 +159,6 @@ static Analyser::Static::ZX8081::Target::MemoryModel ZX8081MemoryModelFromSize(K
if(self) {
using Target = Analyser::Static::ZX8081::Target;
auto target = std::make_unique<Target>();
target->machine = Analyser::Machine::ZX8081;
target->is_ZX81 = true;
target->memory_model = ZX8081MemoryModelFromSize(memorySize);
_targets.push_back(std::move(target));
@ -177,7 +171,6 @@ static Analyser::Static::ZX8081::Target::MemoryModel ZX8081MemoryModelFromSize(K
if(self) {
using Target = Analyser::Static::AppleII::Target;
auto target = std::make_unique<Target>();
target->machine = Analyser::Machine::AppleII;
switch(model) {
default: target->model = Target::Model::II; break;
case CSMachineAppleIIModelAppleIIPlus: target->model = Target::Model::IIplus; break;
@ -200,7 +193,6 @@ static Analyser::Static::ZX8081::Target::MemoryModel ZX8081MemoryModelFromSize(K
if(self) {
using Target = Analyser::Static::Macintosh::Target;
auto target = std::make_unique<Target>();
target->machine = Analyser::Machine::Macintosh;
using Model = Target::Model;
switch(model) {
@ -219,9 +211,8 @@ static Analyser::Static::ZX8081::Target::MemoryModel ZX8081MemoryModelFromSize(K
- (instancetype)initWithAtariSTModel:(CSMachineAtariSTModel)model {
self = [super init];
if(self) {
using Target = Analyser::Static::Macintosh::Target;
using Target = Analyser::Static::AtariST::Target;
auto target = std::make_unique<Target>();
target->machine = Analyser::Machine::AtariST;
_targets.push_back(std::move(target));
}
return self;

View File

@ -139,7 +139,8 @@ template <typename Owner> class StructImpl: public Struct {
private:
struct Field {
const std::type_info *type;
ssize_t offset, size;
ssize_t offset;
size_t size;
Field(const std::type_info &type, ssize_t offset, size_t size) :
type(&type), offset(offset), size(size) {}
};