diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index c4d64e492..ce3d17b02 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -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 = ""; }; 4B9CCDA01DA279CA0098B625 /* Vic20OptionsPanel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Vic20OptionsPanel.swift; sourceTree = ""; }; 4B9CCDA21DA27C3F0098B625 /* CSJoystickMachine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSJoystickMachine.h; sourceTree = ""; }; + 4BA0F68C1EEA0E8400E9489E /* ZX8081.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ZX8081.cpp; path = Data/ZX8081.cpp; sourceTree = ""; }; + 4BA0F68D1EEA0E8400E9489E /* ZX8081.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ZX8081.hpp; path = Data/ZX8081.hpp; sourceTree = ""; }; 4BA22B051D8817CE0008C640 /* Disk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Disk.cpp; path = ../../StaticAnalyser/Commodore/Disk.cpp; sourceTree = ""; }; 4BA22B061D8817CE0008C640 /* Disk.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Disk.hpp; path = ../../StaticAnalyser/Commodore/Disk.hpp; sourceTree = ""; }; 4BA61EAE1D91515900B3C876 /* NSData+StdVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+StdVector.h"; sourceTree = ""; }; @@ -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 = ""; @@ -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 */, diff --git a/StaticAnalyser/ZX8081/StaticAnalyser.cpp b/StaticAnalyser/ZX8081/StaticAnalyser.cpp index 840f30d5f..2f5251e47 100644 --- a/StaticAnalyser/ZX8081/StaticAnalyser.cpp +++ b/StaticAnalyser/ZX8081/StaticAnalyser.cpp @@ -13,12 +13,12 @@ #include "../../Storage/Tape/Parsers/ZX8081.hpp" -static std::vector GetFiles(const std::shared_ptr &tape) { - std::vector files; +static std::vector GetFiles(const std::shared_ptr &tape) { + std::vector files; Storage::Tape::ZX8081::Parser parser; while(!tape->is_at_end()) { - std::shared_ptr next_file = parser.get_next_file(tape); + std::shared_ptr 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 &destination) { if(!tapes.empty()) { - std::vector files = GetFiles(tapes.front()); + std::vector files = GetFiles(tapes.front()); if(!files.empty()) { // TODO: check files for machine type, memory size. StaticAnalyser::Target target; diff --git a/Storage/Data/ZX8081.cpp b/Storage/Data/ZX8081.cpp new file mode 100644 index 000000000..0ce3d7151 --- /dev/null +++ b/Storage/Data/ZX8081.cpp @@ -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::FileFromData(const std::vector &data) { + return nullptr; +} diff --git a/Storage/Data/ZX8081.hpp b/Storage/Data/ZX8081.hpp new file mode 100644 index 000000000..88a5b5237 --- /dev/null +++ b/Storage/Data/ZX8081.hpp @@ -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 +#include +#include + +namespace Storage { +namespace Data { +namespace ZX8081 { + +struct File { + std::vector data; + std::string name; + bool isZX81; +}; + +std::shared_ptr FileFromData(const std::vector &data); + +} +} +} + +#endif /* ZX8081_hpp */ diff --git a/Storage/Tape/Parsers/ZX8081.cpp b/Storage/Tape/Parsers/ZX8081.cpp index f49661f9c..1f4ab5ce2 100644 --- a/Storage/Tape/Parsers/ZX8081.cpp +++ b/Storage/Tape/Parsers/ZX8081.cpp @@ -91,7 +91,7 @@ int Parser::get_next_byte(const std::shared_ptr &tape) { return result; } -std::shared_ptr Parser::get_next_file_data(const std::shared_ptr &tape) { +std::shared_ptr> Parser::get_next_file_data(const std::shared_ptr &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 Parser::get_next_file_data(const std::shared_ptris_at_end()) return nullptr; return_symbol(symbol); - std::shared_ptr result(new File); + std::shared_ptr> result(new std::vector); 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 Parser::get_next_file(const std::shared_ptr &tape) { - std::shared_ptr file = get_next_file_data(tape); - if(!file) return file; - - // TODO: is this ZX80? ZX81? Sensible at all? - - return file; +std::shared_ptr Parser::get_next_file(const std::shared_ptr &tape) { + std::shared_ptr> file_data = get_next_file_data(tape); + if(!file_data) return nullptr; + return Storage::Data::ZX8081::FileFromData(*file_data); } diff --git a/Storage/Tape/Parsers/ZX8081.hpp b/Storage/Tape/Parsers/ZX8081.hpp index b308dddcb..a6fb3f2e9 100644 --- a/Storage/Tape/Parsers/ZX8081.hpp +++ b/Storage/Tape/Parsers/ZX8081.hpp @@ -10,6 +10,9 @@ #define Storage_Tape_Parsers_ZX8081_hpp #include "TapeParser.hpp" + +#include "../../Data/ZX8081.hpp" + #include #include #include @@ -18,12 +21,6 @@ namespace Storage { namespace Tape { namespace ZX8081 { -struct File { - std::vector data; - std::string name; - bool isZX81; -}; - enum class WaveType { Pulse, Gap, LongGap, Unrecognised }; @@ -46,7 +43,7 @@ class Parser: public Storage::Tape::Parser { attempts to parse those as a valid ZX80 or ZX81 file. If no file is found, returns nullptr. */ - std::shared_ptr get_next_file(const std::shared_ptr &tape); + std::shared_ptr get_next_file(const std::shared_ptr &tape); private: bool pulse_was_high_; @@ -54,7 +51,7 @@ class Parser: public Storage::Tape::Parser { void process_pulse(Storage::Tape::Tape::Pulse pulse); void inspect_waves(const std::vector &waves); - std::shared_ptr get_next_file_data(const std::shared_ptr &tape); + std::shared_ptr> get_next_file_data(const std::shared_ptr &tape); }; }