2017-06-04 21:04:06 +00:00
|
|
|
//
|
|
|
|
// StaticAnalyser.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 04/06/2017.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2017 Thomas Harte. All rights reserved.
|
2017-06-04 21:04:06 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#include "StaticAnalyser.hpp"
|
|
|
|
|
2017-06-07 21:30:53 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2018-03-09 20:36:11 +00:00
|
|
|
#include "Target.hpp"
|
2018-01-25 02:48:44 +00:00
|
|
|
#include "../../../Storage/Tape/Parsers/ZX8081.hpp"
|
2017-06-07 21:30:53 +00:00
|
|
|
|
2017-06-08 23:09:51 +00:00
|
|
|
static std::vector<Storage::Data::ZX8081::File> GetFiles(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
|
|
|
std::vector<Storage::Data::ZX8081::File> files;
|
2017-06-07 21:30:53 +00:00
|
|
|
Storage::Tape::ZX8081::Parser parser;
|
|
|
|
|
|
|
|
while(!tape->is_at_end()) {
|
2017-06-08 23:09:51 +00:00
|
|
|
std::shared_ptr<Storage::Data::ZX8081::File> next_file = parser.get_next_file(tape);
|
2017-06-07 21:30:53 +00:00
|
|
|
if(next_file != nullptr) {
|
|
|
|
files.push_back(*next_file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return files;
|
|
|
|
}
|
|
|
|
|
2020-05-30 05:06:43 +00:00
|
|
|
Analyser::Static::TargetList Analyser::Static::ZX8081::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType potential_platforms) {
|
2018-04-14 23:46:38 +00:00
|
|
|
TargetList destination;
|
2017-08-17 14:48:29 +00:00
|
|
|
if(!media.tapes.empty()) {
|
|
|
|
std::vector<Storage::Data::ZX8081::File> files = GetFiles(media.tapes.front());
|
|
|
|
media.tapes.front()->reset();
|
2017-06-07 21:30:53 +00:00
|
|
|
if(!files.empty()) {
|
2020-05-10 03:49:37 +00:00
|
|
|
Target *const target = new Target;
|
2018-03-09 20:36:11 +00:00
|
|
|
destination.push_back(std::unique_ptr<::Analyser::Static::Target>(target));
|
2018-01-25 03:35:54 +00:00
|
|
|
target->machine = Machine::ZX8081;
|
2017-08-27 19:20:22 +00:00
|
|
|
|
|
|
|
// Guess the machine type from the file only if it isn't already known.
|
|
|
|
switch(potential_platforms & (TargetPlatform::ZX80 | TargetPlatform::ZX81)) {
|
|
|
|
default:
|
2018-04-03 02:42:41 +00:00
|
|
|
target->is_ZX81 = files.front().isZX81;
|
2017-08-27 19:20:22 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-03 02:42:41 +00:00
|
|
|
case TargetPlatform::ZX80: target->is_ZX81 = false; break;
|
2018-04-06 21:42:24 +00:00
|
|
|
case TargetPlatform::ZX81: target->is_ZX81 = true; break;
|
2017-08-27 19:20:22 +00:00
|
|
|
}
|
|
|
|
|
2017-07-22 00:43:56 +00:00
|
|
|
/*if(files.front().data.size() > 16384) {
|
2018-01-25 03:35:54 +00:00
|
|
|
target->zx8081.memory_model = ZX8081MemoryModel::SixtyFourKB;
|
2017-07-22 00:43:56 +00:00
|
|
|
} else*/ if(files.front().data.size() > 1024) {
|
2018-03-09 20:36:11 +00:00
|
|
|
target->memory_model = Target::MemoryModel::SixteenKB;
|
2017-06-11 23:12:20 +00:00
|
|
|
} else {
|
2018-03-09 20:36:11 +00:00
|
|
|
target->memory_model = Target::MemoryModel::Unexpanded;
|
2017-06-11 23:12:20 +00:00
|
|
|
}
|
2018-01-25 03:35:54 +00:00
|
|
|
target->media.tapes = media.tapes;
|
2017-07-10 02:07:12 +00:00
|
|
|
|
|
|
|
// TODO: how to run software once loaded? Might require a BASIC detokeniser.
|
2018-04-03 02:42:41 +00:00
|
|
|
if(target->is_ZX81) {
|
2018-01-25 03:35:54 +00:00
|
|
|
target->loading_command = "J\"\"\n";
|
2017-07-10 02:07:12 +00:00
|
|
|
} else {
|
2018-01-25 03:35:54 +00:00
|
|
|
target->loading_command = "W\n";
|
2017-07-10 02:07:12 +00:00
|
|
|
}
|
|
|
|
|
2017-06-07 21:30:53 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-14 16:12:12 +00:00
|
|
|
return destination;
|
2017-06-04 21:04:06 +00:00
|
|
|
}
|