mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-16 18:30:32 +00:00
Adds tape-file static analysis for a hypothetical ZX Spectrum.
This commit is contained in:
parent
54491b35ef
commit
e53586df1d
@ -24,7 +24,8 @@ enum class Machine {
|
||||
MSX,
|
||||
Oric,
|
||||
Vic20,
|
||||
ZX8081
|
||||
ZX8081,
|
||||
ZXSpectrum,
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,48 @@
|
||||
|
||||
#include "StaticAnalyser.hpp"
|
||||
|
||||
Analyser::Static::TargetList Analyser::Static::ZXSpectrum::GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms) {
|
||||
return {};
|
||||
#include "../../../Storage/Tape/Parsers/Spectrum.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsSpectrumTape(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
||||
using Parser = Storage::Tape::ZXSpectrum::Parser;
|
||||
Parser parser(Parser::MachineType::ZXSpectrum);
|
||||
|
||||
while(true) {
|
||||
const auto block = parser.find_block(tape);
|
||||
if(!block) break;
|
||||
|
||||
// Check for a Spectrum header block.
|
||||
if(block->type == 0x00) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Analyser::Static::TargetList Analyser::Static::ZXSpectrum::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) {
|
||||
TargetList destination;
|
||||
auto target = std::make_unique<Target>();
|
||||
target->confidence = 0.5;
|
||||
|
||||
if(!media.tapes.empty()) {
|
||||
bool has_spectrum_tape = false;
|
||||
for(auto &tape: media.tapes) {
|
||||
has_spectrum_tape |= IsSpectrumTape(tape);
|
||||
}
|
||||
|
||||
if(has_spectrum_tape) {
|
||||
target->media.tapes = media.tapes;
|
||||
}
|
||||
}
|
||||
|
||||
// If any media survived, add the target.
|
||||
if(!target->media.empty())
|
||||
destination.push_back(std::move(target));
|
||||
|
||||
return destination;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user