2017-06-04 21:04:06 +00:00
|
|
|
//
|
|
|
|
// StaticAnalyser.cpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 04/06/2017.
|
|
|
|
// Copyright © 2017 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "StaticAnalyser.hpp"
|
|
|
|
|
2017-06-07 21:30:53 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-01-25 03:35:54 +00:00
|
|
|
void Analyser::Static::ZX8081::AddTargets(const Media &media, std::vector<std::unique_ptr<Target>> &destination, TargetPlatform::IntType potential_platforms) {
|
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()) {
|
2018-01-25 03:35:54 +00:00
|
|
|
std::unique_ptr<Target> target(new Target);
|
|
|
|
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-01-25 03:35:54 +00:00
|
|
|
target->zx8081.isZX81 = files.front().isZX81;
|
2017-08-27 19:20:22 +00:00
|
|
|
break;
|
|
|
|
|
2018-01-25 03:35:54 +00:00
|
|
|
case TargetPlatform::ZX80: target->zx8081.isZX81 = false; break;
|
|
|
|
case TargetPlatform::ZX81: target->zx8081.isZX81 = 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-01-25 03:35:54 +00:00
|
|
|
target->zx8081.memory_model = ZX8081MemoryModel::SixteenKB;
|
2017-06-11 23:12:20 +00:00
|
|
|
} else {
|
2018-01-25 03:35:54 +00:00
|
|
|
target->zx8081.memory_model = ZX8081MemoryModel::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-01-25 03:35:54 +00:00
|
|
|
if(target->zx8081.isZX81) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-01-25 03:35:54 +00:00
|
|
|
destination.push_back(std::move(target));
|
2017-06-07 21:30:53 +00:00
|
|
|
}
|
|
|
|
}
|
2017-06-04 21:04:06 +00:00
|
|
|
}
|