mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-25 16:31:42 +00:00
Relocated the ZX80/81 concept of a 'file' out from Tape into Data, given that it's an exact duplicate of memory.
This commit is contained in:
parent
c47128f433
commit
7e10c7f9d8
@ -98,6 +98,7 @@
|
||||
4B92EACA1B7C112B00246143 /* 6502TimingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B92EAC91B7C112B00246143 /* 6502TimingTests.swift */; };
|
||||
4B96F7221D75119A0058BB2D /* Tape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B96F7201D75119A0058BB2D /* Tape.cpp */; };
|
||||
4B9CCDA11DA279CA0098B625 /* Vic20OptionsPanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B9CCDA01DA279CA0098B625 /* Vic20OptionsPanel.swift */; };
|
||||
4BA0F68E1EEA0E8400E9489E /* ZX8081.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BA0F68C1EEA0E8400E9489E /* ZX8081.cpp */; };
|
||||
4BA22B071D8817CE0008C640 /* Disk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BA22B051D8817CE0008C640 /* Disk.cpp */; };
|
||||
4BA61EB01D91515900B3C876 /* NSData+StdVector.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BA61EAF1D91515900B3C876 /* NSData+StdVector.mm */; };
|
||||
4BA799951D8B656E0045123D /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BA799931D8B656E0045123D /* StaticAnalyser.cpp */; };
|
||||
@ -611,6 +612,8 @@
|
||||
4B96F7211D75119A0058BB2D /* Tape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Tape.hpp; path = ../../StaticAnalyser/Acorn/Tape.hpp; sourceTree = "<group>"; };
|
||||
4B9CCDA01DA279CA0098B625 /* Vic20OptionsPanel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Vic20OptionsPanel.swift; sourceTree = "<group>"; };
|
||||
4B9CCDA21DA27C3F0098B625 /* CSJoystickMachine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSJoystickMachine.h; sourceTree = "<group>"; };
|
||||
4BA0F68C1EEA0E8400E9489E /* ZX8081.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ZX8081.cpp; path = Data/ZX8081.cpp; sourceTree = "<group>"; };
|
||||
4BA0F68D1EEA0E8400E9489E /* ZX8081.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ZX8081.hpp; path = Data/ZX8081.hpp; sourceTree = "<group>"; };
|
||||
4BA22B051D8817CE0008C640 /* Disk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Disk.cpp; path = ../../StaticAnalyser/Commodore/Disk.cpp; sourceTree = "<group>"; };
|
||||
4BA22B061D8817CE0008C640 /* Disk.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Disk.hpp; path = ../../StaticAnalyser/Commodore/Disk.hpp; sourceTree = "<group>"; };
|
||||
4BA61EAE1D91515900B3C876 /* NSData+StdVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+StdVector.h"; sourceTree = "<group>"; };
|
||||
@ -1355,15 +1358,15 @@
|
||||
4B69FB391C4D908A00B5F0AA /* Storage */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4B5FADB81DE3151600AEC565 /* FileHolder.cpp */,
|
||||
4BB697C91D4B6D3E00248BDF /* TimedEventLoop.cpp */,
|
||||
4B5FADB91DE3151600AEC565 /* FileHolder.hpp */,
|
||||
4BAB62AE1D32730D00DF5BA0 /* Storage.hpp */,
|
||||
4BB697CA1D4B6D3E00248BDF /* TimedEventLoop.hpp */,
|
||||
4BEE0A691D72496600532C7B /* Cartridge */,
|
||||
4B8805F81DCFF6CD003085B1 /* Data */,
|
||||
4BAB62AA1D3272D200DF5BA0 /* Disk */,
|
||||
4B69FB3A1C4D908A00B5F0AA /* Tape */,
|
||||
4B5FADB81DE3151600AEC565 /* FileHolder.cpp */,
|
||||
4B5FADB91DE3151600AEC565 /* FileHolder.hpp */,
|
||||
);
|
||||
name = Storage;
|
||||
path = ../../Storage;
|
||||
@ -1428,7 +1431,9 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4B8805F51DCFF6C9003085B1 /* Commodore.cpp */,
|
||||
4BA0F68C1EEA0E8400E9489E /* ZX8081.cpp */,
|
||||
4B8805F61DCFF6C9003085B1 /* Commodore.hpp */,
|
||||
4BA0F68D1EEA0E8400E9489E /* ZX8081.hpp */,
|
||||
);
|
||||
name = Data;
|
||||
sourceTree = "<group>";
|
||||
@ -2594,6 +2599,7 @@
|
||||
4BE77A2E1D84ADFB00BC3827 /* File.cpp in Sources */,
|
||||
4B5FADBD1DE31D1500AEC565 /* OricMFMDSK.cpp in Sources */,
|
||||
4B14978B1EE4AC5E00CE2596 /* StaticAnalyser.cpp in Sources */,
|
||||
4BA0F68E1EEA0E8400E9489E /* ZX8081.cpp in Sources */,
|
||||
4B77069D1EC904570053B588 /* Z80.cpp in Sources */,
|
||||
4BAB62B51D327F7E00DF5BA0 /* G64.cpp in Sources */,
|
||||
4BD468F71D8DF41D0084958B /* 1770.cpp in Sources */,
|
||||
|
@ -13,12 +13,12 @@
|
||||
|
||||
#include "../../Storage/Tape/Parsers/ZX8081.hpp"
|
||||
|
||||
static std::vector<Storage::Tape::ZX8081::File> GetFiles(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
||||
std::vector<Storage::Tape::ZX8081::File> files;
|
||||
static std::vector<Storage::Data::ZX8081::File> GetFiles(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
||||
std::vector<Storage::Data::ZX8081::File> files;
|
||||
Storage::Tape::ZX8081::Parser parser;
|
||||
|
||||
while(!tape->is_at_end()) {
|
||||
std::shared_ptr<Storage::Tape::ZX8081::File> next_file = parser.get_next_file(tape);
|
||||
std::shared_ptr<Storage::Data::ZX8081::File> next_file = parser.get_next_file(tape);
|
||||
if(next_file != nullptr) {
|
||||
files.push_back(*next_file);
|
||||
}
|
||||
@ -34,7 +34,7 @@ void StaticAnalyser::ZX8081::AddTargets(
|
||||
std::list<StaticAnalyser::Target> &destination) {
|
||||
|
||||
if(!tapes.empty()) {
|
||||
std::vector<Storage::Tape::ZX8081::File> files = GetFiles(tapes.front());
|
||||
std::vector<Storage::Data::ZX8081::File> files = GetFiles(tapes.front());
|
||||
if(!files.empty()) {
|
||||
// TODO: check files for machine type, memory size.
|
||||
StaticAnalyser::Target target;
|
||||
|
13
Storage/Data/ZX8081.cpp
Normal file
13
Storage/Data/ZX8081.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
//
|
||||
// ZX8081.cpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 08/06/2017.
|
||||
// Copyright © 2017 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#include "ZX8081.hpp"
|
||||
|
||||
std::shared_ptr<Storage::Data::ZX8081::File> Storage::Data::ZX8081::FileFromData(const std::vector<uint8_t> &data) {
|
||||
return nullptr;
|
||||
}
|
32
Storage/Data/ZX8081.hpp
Normal file
32
Storage/Data/ZX8081.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// ZX8081.hpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 08/06/2017.
|
||||
// Copyright © 2017 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef ZX8081_hpp
|
||||
#define ZX8081_hpp
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
namespace Storage {
|
||||
namespace Data {
|
||||
namespace ZX8081 {
|
||||
|
||||
struct File {
|
||||
std::vector<uint8_t> data;
|
||||
std::string name;
|
||||
bool isZX81;
|
||||
};
|
||||
|
||||
std::shared_ptr<File> FileFromData(const std::vector<uint8_t> &data);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ZX8081_hpp */
|
@ -91,7 +91,7 @@ int Parser::get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::shared_ptr<File> Parser::get_next_file_data(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
||||
std::shared_ptr<std::vector<uint8_t>> Parser::get_next_file_data(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
||||
if(tape->is_at_end()) return nullptr;
|
||||
SymbolType symbol = get_next_symbol(tape);
|
||||
if(symbol != SymbolType::FileGap) {
|
||||
@ -103,21 +103,18 @@ std::shared_ptr<File> Parser::get_next_file_data(const std::shared_ptr<Storage::
|
||||
if(tape->is_at_end()) return nullptr;
|
||||
return_symbol(symbol);
|
||||
|
||||
std::shared_ptr<File> result(new File);
|
||||
std::shared_ptr<std::vector<uint8_t>> result(new std::vector<uint8_t>);
|
||||
int byte;
|
||||
while(!tape->is_at_end()) {
|
||||
byte = get_next_byte(tape);
|
||||
if(byte == -1) return result;
|
||||
result->data.push_back((uint8_t)byte);
|
||||
result->push_back((uint8_t)byte);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::shared_ptr<File> Parser::get_next_file(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
||||
std::shared_ptr<File> file = get_next_file_data(tape);
|
||||
if(!file) return file;
|
||||
|
||||
// TODO: is this ZX80? ZX81? Sensible at all?
|
||||
|
||||
return file;
|
||||
std::shared_ptr<Storage::Data::ZX8081::File> Parser::get_next_file(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
||||
std::shared_ptr<std::vector<uint8_t>> file_data = get_next_file_data(tape);
|
||||
if(!file_data) return nullptr;
|
||||
return Storage::Data::ZX8081::FileFromData(*file_data);
|
||||
}
|
||||
|
@ -10,6 +10,9 @@
|
||||
#define Storage_Tape_Parsers_ZX8081_hpp
|
||||
|
||||
#include "TapeParser.hpp"
|
||||
|
||||
#include "../../Data/ZX8081.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
@ -18,12 +21,6 @@ namespace Storage {
|
||||
namespace Tape {
|
||||
namespace ZX8081 {
|
||||
|
||||
struct File {
|
||||
std::vector<uint8_t> data;
|
||||
std::string name;
|
||||
bool isZX81;
|
||||
};
|
||||
|
||||
enum class WaveType {
|
||||
Pulse, Gap, LongGap, Unrecognised
|
||||
};
|
||||
@ -46,7 +43,7 @@ class Parser: public Storage::Tape::Parser<WaveType, SymbolType> {
|
||||
attempts to parse those as a valid ZX80 or ZX81 file. If no file is found,
|
||||
returns nullptr.
|
||||
*/
|
||||
std::shared_ptr<File> get_next_file(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
||||
std::shared_ptr<Storage::Data::ZX8081::File> get_next_file(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
||||
|
||||
private:
|
||||
bool pulse_was_high_;
|
||||
@ -54,7 +51,7 @@ class Parser: public Storage::Tape::Parser<WaveType, SymbolType> {
|
||||
void process_pulse(Storage::Tape::Tape::Pulse pulse);
|
||||
void inspect_waves(const std::vector<WaveType> &waves);
|
||||
|
||||
std::shared_ptr<File> get_next_file_data(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
||||
std::shared_ptr<std::vector<uint8_t>> get_next_file_data(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user