mirror of
https://github.com/TomHarte/CLK.git
synced 2025-04-10 22:37:30 +00:00
Wire TAPs and similar directly to their targets.
This commit is contained in:
parent
f089a85908
commit
2f546842a7
@ -65,7 +65,8 @@ AcornCartridgesFrom(const std::vector<std::shared_ptr<Storage::Cartridge::Cartri
|
||||
Analyser::Static::TargetList Analyser::Static::Acorn::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &file_name,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool
|
||||
) {
|
||||
auto target8bit = std::make_unique<ElectronTarget>();
|
||||
auto targetArchimedes = std::make_unique<ArchimedesTarget>();
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::Acorn {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -12,10 +12,11 @@
|
||||
Analyser::Static::TargetList Analyser::Static::Amiga::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool is_confident
|
||||
) {
|
||||
// This analyser can comprehend disks and mass-storage devices only.
|
||||
if(media.disks.empty()) return {};
|
||||
if(media.disks.empty() && !is_confident) return {};
|
||||
|
||||
// As there is at least one usable media image, wave it through.
|
||||
Analyser::Static::TargetList targets;
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::Amiga {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -210,7 +210,8 @@ bool IsAmstradTape(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
||||
Analyser::Static::TargetList Analyser::Static::AmstradCPC::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool
|
||||
) {
|
||||
TargetList destination;
|
||||
auto target = std::make_unique<Target>();
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::AmstradCPC {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,8 @@
|
||||
Analyser::Static::TargetList Analyser::Static::AppleII::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool
|
||||
) {
|
||||
auto target = std::make_unique<Target>();
|
||||
target->media = media;
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::AppleII {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,8 @@
|
||||
Analyser::Static::TargetList Analyser::Static::AppleIIgs::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool
|
||||
) {
|
||||
auto target = std::make_unique<Target>();
|
||||
target->media = media;
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::AppleIIgs {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -191,7 +191,8 @@ static void DeterminePagingForCartridge(Target &target, const Storage::Cartridge
|
||||
Analyser::Static::TargetList Analyser::Static::Atari2600::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool
|
||||
) {
|
||||
// TODO: sanity checking; is this image really for an Atari 2600?
|
||||
auto target = std::make_unique<Target>();
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::Atari2600 {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,8 @@
|
||||
Analyser::Static::TargetList Analyser::Static::AtariST::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool
|
||||
) {
|
||||
// This analyser can comprehend disks and mass-storage devices only.
|
||||
if(media.disks.empty()) return {};
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::AtariST {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -55,12 +55,17 @@ ColecoCartridgesFrom(const std::vector<std::shared_ptr<Storage::Cartridge::Cartr
|
||||
Analyser::Static::TargetList Analyser::Static::Coleco::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
const bool is_confident
|
||||
) {
|
||||
TargetList targets;
|
||||
auto target = std::make_unique<Target>(Machine::ColecoVision);
|
||||
target->confidence = 1.0f - 1.0f / 32768.0f;
|
||||
target->media.cartridges = ColecoCartridgesFrom(media.cartridges);
|
||||
if(is_confident) {
|
||||
target->media = media;
|
||||
} else {
|
||||
target->media.cartridges = ColecoCartridgesFrom(media.cartridges);
|
||||
}
|
||||
if(!target->media.empty())
|
||||
targets.push_back(std::move(target));
|
||||
return targets;
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::Coleco {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -165,7 +165,8 @@ std::optional<BASICAnalysis> analyse(const File &file) {
|
||||
Analyser::Static::TargetList Analyser::Static::Commodore::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &file_name,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType platforms,
|
||||
bool is_confident
|
||||
) {
|
||||
TargetList destination;
|
||||
auto target = std::make_unique<Target>();
|
||||
@ -174,36 +175,54 @@ Analyser::Static::TargetList Analyser::Static::Commodore::GetTargets(
|
||||
std::vector<File> files;
|
||||
bool is_disk = false;
|
||||
|
||||
// Strip out inappropriate cartridges.
|
||||
target->media.cartridges = Vic20CartridgesFrom(media.cartridges);
|
||||
|
||||
// Find all valid Commodore files on disks.
|
||||
for(auto &disk : media.disks) {
|
||||
std::vector<File> disk_files = GetFiles(disk);
|
||||
if(!disk_files.empty()) {
|
||||
is_disk = true;
|
||||
files.insert(
|
||||
files.end(),
|
||||
std::make_move_iterator(disk_files.begin()),
|
||||
std::make_move_iterator(disk_files.end())
|
||||
);
|
||||
target->media.disks.push_back(disk);
|
||||
if(!device) device = 8;
|
||||
if(is_confident) {
|
||||
target->media = media;
|
||||
if(target->media.disks.empty()) {
|
||||
target->loading_command = "LOAD\"\",1,1\nRUN\n";
|
||||
} else {
|
||||
target->loading_command = "LOAD\"*\",8,1\nRUN\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Find all valid Commodore files on tapes.
|
||||
for(auto &tape : media.tapes) {
|
||||
std::vector<File> tape_files = GetFiles(tape);
|
||||
tape->reset();
|
||||
if(!tape_files.empty()) {
|
||||
files.insert(
|
||||
files.end(),
|
||||
std::make_move_iterator(tape_files.begin()),
|
||||
std::make_move_iterator(tape_files.end())
|
||||
);
|
||||
target->media.tapes.push_back(tape);
|
||||
if(!device) device = 1;
|
||||
if(platforms & TargetPlatform::C64) {
|
||||
return {}; // C64 not yet implemented.
|
||||
} else if(platforms & TargetPlatform::Vic20) {
|
||||
target->machine = Machine::Vic20;
|
||||
// TODO: pick a memory model.
|
||||
} else {
|
||||
target->machine = Machine::Plus4;
|
||||
}
|
||||
} else {
|
||||
// Strip out inappropriate cartridges.
|
||||
target->media.cartridges = Vic20CartridgesFrom(media.cartridges);
|
||||
|
||||
// Find all valid Commodore files on disks.
|
||||
for(auto &disk : media.disks) {
|
||||
std::vector<File> disk_files = GetFiles(disk);
|
||||
if(!disk_files.empty()) {
|
||||
is_disk = true;
|
||||
files.insert(
|
||||
files.end(),
|
||||
std::make_move_iterator(disk_files.begin()),
|
||||
std::make_move_iterator(disk_files.end())
|
||||
);
|
||||
target->media.disks.push_back(disk);
|
||||
if(!device) device = 8;
|
||||
}
|
||||
}
|
||||
|
||||
// Find all valid Commodore files on tapes.
|
||||
for(auto &tape : media.tapes) {
|
||||
std::vector<File> tape_files = GetFiles(tape);
|
||||
tape->reset();
|
||||
if(!tape_files.empty()) {
|
||||
files.insert(
|
||||
files.end(),
|
||||
std::make_move_iterator(tape_files.begin()),
|
||||
std::make_move_iterator(tape_files.end())
|
||||
);
|
||||
target->media.tapes.push_back(tape);
|
||||
if(!device) device = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -277,7 +296,6 @@ Analyser::Static::TargetList Analyser::Static::Commodore::GetTargets(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// The Vic-20 never has RAM after 0x8000.
|
||||
if(file.ending_address >= 0x8000) {
|
||||
target->machine = Machine::Plus4;
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::Commodore {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -50,7 +50,8 @@ Analyser::Static::Target *OricTarget(const Storage::Encodings::AppleGCR::Sector
|
||||
Analyser::Static::TargetList Analyser::Static::DiskII::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool
|
||||
) {
|
||||
// This analyser can comprehend disks only.
|
||||
if(media.disks.empty()) return {};
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::DiskII {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,8 @@ bool insensitive_equal(const std::string &lhs, const std::string &rhs) {
|
||||
Analyser::Static::TargetList Analyser::Static::Enterprise::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool
|
||||
) {
|
||||
// This analyser can comprehend disks only.
|
||||
if(media.disks.empty()) return {};
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::Enterprise {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,8 @@
|
||||
Analyser::Static::TargetList Analyser::Static::FAT12::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &file_name,
|
||||
TargetPlatform::IntType platforms
|
||||
TargetPlatform::IntType platforms,
|
||||
bool
|
||||
) {
|
||||
// This analyser can comprehend disks only.
|
||||
if(media.disks.empty()) return {};
|
||||
@ -39,7 +40,7 @@ Analyser::Static::TargetList Analyser::Static::FAT12::GetTargets(
|
||||
// If the disk image is very small or large, map it to the PC. That's the only option old enough
|
||||
// to have used 5.25" media.
|
||||
if(disk->get_maximum_head_position() <= Storage::Disk::HeadPosition(40)) {
|
||||
return Analyser::Static::PCCompatible::GetTargets(media, file_name, platforms);
|
||||
return Analyser::Static::PCCompatible::GetTargets(media, file_name, platforms, true);
|
||||
}
|
||||
|
||||
// Attempt to grab MFM track 0, sector 1: the boot sector.
|
||||
@ -53,7 +54,7 @@ Analyser::Static::TargetList Analyser::Static::FAT12::GetTargets(
|
||||
|
||||
// If no sectors were found, assume this disk was either single density or high density, which both imply the PC.
|
||||
if(sector_map.empty() || sector_map.size() > 10) {
|
||||
return Analyser::Static::PCCompatible::GetTargets(media, file_name, platforms);
|
||||
return Analyser::Static::PCCompatible::GetTargets(media, file_name, platforms, true);
|
||||
}
|
||||
|
||||
const Storage::Encodings::MFM::Sector *boot_sector = nullptr;
|
||||
@ -82,7 +83,7 @@ Analyser::Static::TargetList Analyser::Static::FAT12::GetTargets(
|
||||
if(
|
||||
std::search(sample.begin(), sample.end(), string.begin(), string.end()) != sample.end()
|
||||
) {
|
||||
return Analyser::Static::PCCompatible::GetTargets(media, file_name, platforms);
|
||||
return Analyser::Static::PCCompatible::GetTargets(media, file_name, platforms, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,5 +102,5 @@ Analyser::Static::TargetList Analyser::Static::FAT12::GetTargets(
|
||||
// could redirect to an MSX2 with MSX-DOS2? Though it'd be nicer if I had a machine that was pure CP/M.
|
||||
|
||||
// Being unable to prove that this is a PC disk, throw it to the Enterprise.
|
||||
return Analyser::Static::Enterprise::GetTargets(media, file_name, platforms);
|
||||
return Analyser::Static::Enterprise::GetTargets(media, file_name, platforms, false);
|
||||
}
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::FAT12 {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -188,7 +188,8 @@ static Analyser::Static::TargetList CartridgeTargetsFrom(
|
||||
Analyser::Static::TargetList Analyser::Static::MSX::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool
|
||||
) {
|
||||
TargetList destination;
|
||||
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::MSX {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -12,10 +12,11 @@
|
||||
Analyser::Static::TargetList Analyser::Static::Macintosh::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool is_confident
|
||||
) {
|
||||
// This analyser can comprehend disks and mass-storage devices only.
|
||||
if(media.disks.empty() && media.mass_storage_devices.empty()) return {};
|
||||
if(media.disks.empty() && media.mass_storage_devices.empty() && !is_confident) return {};
|
||||
|
||||
// As there is at least one usable media image, wave it through.
|
||||
Analyser::Static::TargetList targets;
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::Macintosh {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -184,7 +184,8 @@ bool is_bd500(Storage::Encodings::MFM::Parser &parser) {
|
||||
Analyser::Static::TargetList Analyser::Static::Oric::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool
|
||||
) {
|
||||
auto target = std::make_unique<Target>();
|
||||
target->confidence = 0.5;
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::Oric {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,8 @@
|
||||
Analyser::Static::TargetList Analyser::Static::PCCompatible::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool
|
||||
) {
|
||||
// This analyser can comprehend disks only.
|
||||
if(media.disks.empty()) return {};
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::PCCompatible {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,8 @@
|
||||
Analyser::Static::TargetList Analyser::Static::Sega::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &file_name,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool
|
||||
) {
|
||||
if(media.cartridges.empty())
|
||||
return {};
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::Sega {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -129,7 +129,10 @@ public:
|
||||
// Check whether the instance itself has any input on target platforms.
|
||||
TargetPlatform::Distinguisher *const distinguisher =
|
||||
dynamic_cast<TargetPlatform::Distinguisher *>(instance.get());
|
||||
if(distinguisher) potential_platforms_ &= distinguisher->target_platforms();
|
||||
if(distinguisher) {
|
||||
was_distinguished = true;
|
||||
potential_platforms_ &= distinguisher->target_platforms();
|
||||
}
|
||||
}
|
||||
|
||||
/// Concstructs a new instance of @c InstanceT supplying @c args and adds it to the back of @c list using @c insert_instance.
|
||||
@ -160,6 +163,7 @@ public:
|
||||
}
|
||||
|
||||
Media media;
|
||||
bool was_distinguished = false;
|
||||
|
||||
private:
|
||||
const std::string &file_name_;
|
||||
@ -209,7 +213,7 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform::
|
||||
accumulator.try_standard<Cartridge::BinaryDump>(TargetPlatform::Coleco, "col");
|
||||
accumulator.try_standard<Tape::CSW>(TargetPlatform::AllTape, "csw");
|
||||
|
||||
accumulator.try_standard<Disk::DiskImageHolder<Disk::D64>>(TargetPlatform::Commodore, "d64");
|
||||
accumulator.try_standard<Disk::DiskImageHolder<Disk::D64>>(TargetPlatform::Commodore8bit, "d64");
|
||||
accumulator.try_standard<MassStorage::DAT>(TargetPlatform::Acorn, "dat");
|
||||
accumulator.try_standard<Disk::DiskImageHolder<Disk::DMK>>(TargetPlatform::MSX, "dmk");
|
||||
accumulator.try_standard<Disk::DiskImageHolder<Disk::AppleDSK>>(TargetPlatform::DiskII, "do");
|
||||
@ -223,7 +227,7 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform::
|
||||
accumulator.try_standard<Disk::DiskImageHolder<Disk::FAT12>>(TargetPlatform::MSX, "dsk");
|
||||
accumulator.try_standard<Disk::DiskImageHolder<Disk::OricMFMDSK>>(TargetPlatform::Oric, "dsk");
|
||||
|
||||
accumulator.try_standard<Disk::DiskImageHolder<Disk::G64>>(TargetPlatform::Commodore, "g64");
|
||||
accumulator.try_standard<Disk::DiskImageHolder<Disk::G64>>(TargetPlatform::Commodore8bit, "g64");
|
||||
|
||||
accumulator.try_standard<MassStorage::HDV>(TargetPlatform::AppleII, "hdv");
|
||||
accumulator.try_standard<Disk::DiskImageHolder<Disk::HFE>>(
|
||||
@ -268,10 +272,10 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform::
|
||||
if(accumulator.name_matches("prg")) {
|
||||
// Try instantiating as a ROM; failing that accept as a tape.
|
||||
try {
|
||||
accumulator.insert<Cartridge::PRG>(TargetPlatform::Commodore, file_name);
|
||||
accumulator.insert<Cartridge::PRG>(TargetPlatform::Commodore8bit, file_name);
|
||||
} catch(...) {
|
||||
try {
|
||||
accumulator.insert<Tape::PRG>(TargetPlatform::Commodore, file_name);
|
||||
accumulator.insert<Tape::PRG>(TargetPlatform::Commodore8bit, file_name);
|
||||
} catch(...) {}
|
||||
}
|
||||
}
|
||||
@ -286,7 +290,7 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform::
|
||||
accumulator.try_standard<Disk::DiskImageHolder<Disk::FAT12>>(TargetPlatform::AtariST, "st");
|
||||
accumulator.try_standard<Disk::DiskImageHolder<Disk::STX>>(TargetPlatform::AtariST, "stx");
|
||||
|
||||
accumulator.try_standard<Tape::CommodoreTAP>(TargetPlatform::Commodore, "tap");
|
||||
accumulator.try_standard<Tape::CommodoreTAP>(TargetPlatform::Commodore8bit, "tap");
|
||||
accumulator.try_standard<Tape::OricTAP>(TargetPlatform::Oric, "tap");
|
||||
accumulator.try_standard<Tape::ZXSpectrumTAP>(TargetPlatform::ZXSpectrum, "tap");
|
||||
accumulator.try_standard<Tape::TZX>(TargetPlatform::MSX, "tsx");
|
||||
@ -335,13 +339,25 @@ TargetList Analyser::Static::GetTargets(const std::string &file_name) {
|
||||
TargetPlatform::IntType potential_platforms = 0;
|
||||
Media media = GetMediaAndPlatforms(file_name, potential_platforms);
|
||||
|
||||
// TODO: std::popcount here.
|
||||
int total_options = 0;
|
||||
TargetPlatform::IntType mask = 1;
|
||||
while(mask) {
|
||||
total_options += bool(potential_platforms & mask);
|
||||
mask <<= 1;
|
||||
}
|
||||
const bool is_confident = total_options == 1;
|
||||
// i.e. This analyser `is_confident` if file analysis suggested only one potential target platform.
|
||||
// The machine-specific static analyser will still run in case it can provide meaningful annotations on
|
||||
// loading command, machine configuration, etc, but the flag will be passed onwards to mean "don't reject this".
|
||||
|
||||
// Hand off to platform-specific determination of whether these
|
||||
// things are actually compatible and, if so, how to load them.
|
||||
const auto append = [&](TargetPlatform::IntType platform, auto evaluator) {
|
||||
if(!(potential_platforms & platform)) {
|
||||
return;
|
||||
}
|
||||
auto new_targets = evaluator(media, file_name, potential_platforms);
|
||||
auto new_targets = evaluator(media, file_name, potential_platforms, is_confident);
|
||||
targets.insert(
|
||||
targets.end(),
|
||||
std::make_move_iterator(new_targets.begin()),
|
||||
@ -357,7 +373,7 @@ TargetList Analyser::Static::GetTargets(const std::string &file_name) {
|
||||
append(TargetPlatform::Atari2600, Atari2600::GetTargets);
|
||||
append(TargetPlatform::AtariST, AtariST::GetTargets);
|
||||
append(TargetPlatform::Coleco, Coleco::GetTargets);
|
||||
append(TargetPlatform::Commodore, Commodore::GetTargets);
|
||||
append(TargetPlatform::Commodore8bit, Commodore::GetTargets);
|
||||
append(TargetPlatform::DiskII, DiskII::GetTargets);
|
||||
append(TargetPlatform::Enterprise, Enterprise::GetTargets);
|
||||
append(TargetPlatform::FAT12, FAT12::GetTargets);
|
||||
|
@ -31,7 +31,8 @@ static std::vector<Storage::Data::ZX8081::File> GetFiles(const std::shared_ptr<S
|
||||
Analyser::Static::TargetList Analyser::Static::ZX8081::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType potential_platforms
|
||||
TargetPlatform::IntType potential_platforms,
|
||||
bool
|
||||
) {
|
||||
TargetList destination;
|
||||
if(!media.tapes.empty()) {
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::ZX8081 {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -106,7 +106,8 @@ bool IsSpectrumDisk(const std::shared_ptr<Storage::Disk::Disk> &disk) {
|
||||
Analyser::Static::TargetList Analyser::Static::ZXSpectrum::GetTargets(
|
||||
const Media &media,
|
||||
const std::string &,
|
||||
TargetPlatform::IntType
|
||||
TargetPlatform::IntType,
|
||||
bool
|
||||
) {
|
||||
TargetList destination;
|
||||
auto target = std::make_unique<Target>();
|
||||
|
@ -14,6 +14,6 @@
|
||||
|
||||
namespace Analyser::Static::ZXSpectrum {
|
||||
|
||||
TargetList GetTargets(const Media &, const std::string &file_name, TargetPlatform::IntType potential_platforms);
|
||||
TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "../../../Outputs/Speaker/Implementation/LowpassSpeaker.hpp"
|
||||
#include "../../../Configurable/StandardOptions.hpp"
|
||||
|
||||
#include "../../../Analyser/Static/Commodore/Target.hpp"
|
||||
|
||||
#include "../../../Storage/Tape/Tape.hpp"
|
||||
#include "../SerialBus.hpp"
|
||||
#include "../1540/C1540.hpp"
|
||||
@ -171,7 +173,7 @@ class ConcreteMachine:
|
||||
public Machine,
|
||||
public Utility::TypeRecipient<CharacterMapper> {
|
||||
public:
|
||||
ConcreteMachine(const Analyser::Static::Target &target, const ROMMachine::ROMFetcher &rom_fetcher) :
|
||||
ConcreteMachine(const Analyser::Static::Commodore::Target &target, const ROMMachine::ROMFetcher &rom_fetcher) :
|
||||
m6502_(*this),
|
||||
interrupts_(*this),
|
||||
timers_(interrupts_),
|
||||
@ -220,9 +222,10 @@ public:
|
||||
joysticks_.emplace_back(std::make_unique<Joystick>());
|
||||
|
||||
insert_media(target.media);
|
||||
// if(!target.loading_command.empty()) {
|
||||
// type_string(target.loading_command);
|
||||
// }
|
||||
if(!target.loading_command.empty()) {
|
||||
// Prefix a space as a delaying technique.
|
||||
type_string(std::string(" ") + target.loading_command);
|
||||
}
|
||||
}
|
||||
|
||||
~ConcreteMachine() {
|
||||
@ -694,7 +697,7 @@ std::unique_ptr<Machine> Machine::Plus4(
|
||||
const Analyser::Static::Target *target,
|
||||
const ROMMachine::ROMFetcher &rom_fetcher
|
||||
) {
|
||||
using Target = Analyser::Static::Target;
|
||||
using Target = Analyser::Static::Commodore::Target;
|
||||
const Target *const commodore_target = dynamic_cast<const Target *>(target);
|
||||
return std::make_unique<ConcreteMachine>(*commodore_target, rom_fetcher);
|
||||
}
|
||||
|
@ -102,3 +102,18 @@ Storage::Tape::Pulse CommodoreTAP::Serialiser::next_pulse() {
|
||||
|
||||
return current_pulse_;
|
||||
}
|
||||
|
||||
// MARK: - TargetPlatform::Distinguisher
|
||||
|
||||
TargetPlatform::Type CommodoreTAP::target_platforms() {
|
||||
return serialiser_.target_platforms();
|
||||
}
|
||||
|
||||
TargetPlatform::Type CommodoreTAP::Serialiser::target_platforms() {
|
||||
switch(platform_) {
|
||||
default: return TargetPlatform::Type::Commodore;
|
||||
case Platform::C64: return TargetPlatform::Type::C64;
|
||||
case Platform::Vic20: return TargetPlatform::Type::Vic20;
|
||||
case Platform::C16: return TargetPlatform::Type::Plus4;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "../Tape.hpp"
|
||||
#include "../../FileHolder.hpp"
|
||||
|
||||
#include "../../TargetPlatforms.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
@ -19,7 +21,7 @@ namespace Storage::Tape {
|
||||
/*!
|
||||
Provides a @c Tape containing a Commodore-format tape image, which is simply a timed list of downward-going zero crossings.
|
||||
*/
|
||||
class CommodoreTAP: public Tape {
|
||||
class CommodoreTAP: public Tape, public TargetPlatform::Distinguisher {
|
||||
public:
|
||||
/*!
|
||||
Constructs a @c CommodoreTAP containing content from the file with name @c file_name.
|
||||
@ -33,9 +35,13 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
TargetPlatform::Type target_platforms() override;
|
||||
|
||||
struct Serialiser: public TapeSerialiser {
|
||||
Serialiser(const std::string &file_name);
|
||||
|
||||
TargetPlatform::Type target_platforms();
|
||||
|
||||
private:
|
||||
bool is_at_end() const override;
|
||||
void reset() override;
|
||||
|
@ -52,7 +52,7 @@ PRG::PRG(const std::string &file_name) : Tape(serialiser_), serialiser_(file_nam
|
||||
|
||||
PRG::Serialiser::Serialiser(const std::string &file_name) :
|
||||
file_(file_name, FileHolder::FileMode::Read),
|
||||
timings_(false)
|
||||
timings_(true)
|
||||
{
|
||||
// There's really no way to validate other than that if this file is larger than 64kb,
|
||||
// of if load address + length > 65536 then it's broken.
|
||||
|
@ -321,13 +321,13 @@ void UEF::Serialiser::queue_bit(const int bit) {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - TypeDistinguisher
|
||||
// MARK: - TargetPlatform::Distinguisher
|
||||
|
||||
TargetPlatform::Type UEF::target_platforms() {
|
||||
return serialiser_.target_platform_type();
|
||||
return serialiser_.target_platforms();
|
||||
}
|
||||
|
||||
TargetPlatform::Type UEF::Serialiser::target_platform_type() {
|
||||
TargetPlatform::Type UEF::Serialiser::target_platforms() {
|
||||
return platform_type_;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ private:
|
||||
Serialiser(const std::string &file_name);
|
||||
~Serialiser();
|
||||
|
||||
TargetPlatform::Type target_platform_type();
|
||||
TargetPlatform::Type target_platforms();
|
||||
|
||||
private:
|
||||
void reset() override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user