1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-28 09:54:49 +00:00

Adds tape-file static analysis for a hypothetical ZX Spectrum.

This commit is contained in:
Thomas Harte 2021-03-17 22:09:44 -04:00
parent 54491b35ef
commit e53586df1d
2 changed files with 46 additions and 3 deletions

View File

@ -24,7 +24,8 @@ enum class Machine {
MSX,
Oric,
Vic20,
ZX8081
ZX8081,
ZXSpectrum,
};
}

View File

@ -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;
}