From 60300851eaf8ac4d5b695649a600b665e0e62e9e Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 7 Jun 2017 10:12:13 -0400 Subject: [PATCH] Started sketching out a tape parser for ZX80 and '81 files. I think this'll help me to verify whether the .O input is working. --- .../Clock Signal.xcodeproj/project.pbxproj | 6 ++ Storage/Tape/Parsers/ZX8081.cpp | 9 +++ Storage/Tape/Parsers/ZX8081.hpp | 62 +++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 Storage/Tape/Parsers/ZX8081.cpp create mode 100644 Storage/Tape/Parsers/ZX8081.hpp diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 40fbb609e..c4d64e492 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -384,6 +384,7 @@ 4BBF99141C8FBA6F0075DAFB /* TextureBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBF99081C8FBA6F0075DAFB /* TextureBuilder.cpp */; }; 4BBF99151C8FBA6F0075DAFB /* CRTOpenGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBF990A1C8FBA6F0075DAFB /* CRTOpenGL.cpp */; }; 4BBF99181C8FBA6F0075DAFB /* TextureTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBF99121C8FBA6F0075DAFB /* TextureTarget.cpp */; }; + 4BBFBB6C1EE8401E00C01E7A /* ZX8081.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBFBB6A1EE8401E00C01E7A /* ZX8081.cpp */; }; 4BC3B74F1CD194CC00F86E85 /* Shader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC3B74D1CD194CC00F86E85 /* Shader.cpp */; }; 4BC3B7521CD1956900F86E85 /* OutputShader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC3B7501CD1956900F86E85 /* OutputShader.cpp */; }; 4BC5E4921D7ED365008CF980 /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC5E4901D7ED365008CF980 /* StaticAnalyser.cpp */; }; @@ -922,6 +923,8 @@ 4BBF99121C8FBA6F0075DAFB /* TextureTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureTarget.cpp; sourceTree = ""; }; 4BBF99131C8FBA6F0075DAFB /* TextureTarget.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TextureTarget.hpp; sourceTree = ""; }; 4BBF99191C8FC2750075DAFB /* CRTTypes.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CRTTypes.hpp; sourceTree = ""; }; + 4BBFBB6A1EE8401E00C01E7A /* ZX8081.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ZX8081.cpp; path = Parsers/ZX8081.cpp; sourceTree = ""; }; + 4BBFBB6B1EE8401E00C01E7A /* ZX8081.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ZX8081.hpp; path = Parsers/ZX8081.hpp; sourceTree = ""; }; 4BC3B74D1CD194CC00F86E85 /* Shader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Shader.cpp; sourceTree = ""; }; 4BC3B74E1CD194CC00F86E85 /* Shader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Shader.hpp; sourceTree = ""; }; 4BC3B7501CD1956900F86E85 /* OutputShader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OutputShader.cpp; sourceTree = ""; }; @@ -1415,6 +1418,8 @@ 4B8805F31DCFD22A003085B1 /* Commodore.hpp */, 4B8805F91DCFF807003085B1 /* Oric.cpp */, 4B8805FA1DCFF807003085B1 /* Oric.hpp */, + 4BBFBB6A1EE8401E00C01E7A /* ZX8081.cpp */, + 4BBFBB6B1EE8401E00C01E7A /* ZX8081.hpp */, ); name = Parsers; sourceTree = ""; @@ -2627,6 +2632,7 @@ 4BCA6CC81D9DD9F000C2D7B2 /* CommodoreROM.cpp in Sources */, 4BA22B071D8817CE0008C640 /* Disk.cpp in Sources */, 4BEA52661DF3472B007E74F2 /* Speaker.cpp in Sources */, + 4BBFBB6C1EE8401E00C01E7A /* ZX8081.cpp in Sources */, 4BC3B7521CD1956900F86E85 /* OutputShader.cpp in Sources */, 4B4C83701D4F623200CD541F /* D64.cpp in Sources */, 4B5073071DDD3B9400C48FBD /* ArrayBuilder.cpp in Sources */, diff --git a/Storage/Tape/Parsers/ZX8081.cpp b/Storage/Tape/Parsers/ZX8081.cpp new file mode 100644 index 000000000..f202ec249 --- /dev/null +++ b/Storage/Tape/Parsers/ZX8081.cpp @@ -0,0 +1,9 @@ +// +// ZX8081.cpp +// Clock Signal +// +// Created by Thomas Harte on 07/06/2017. +// Copyright © 2017 Thomas Harte. All rights reserved. +// + +#include "ZX8081.hpp" diff --git a/Storage/Tape/Parsers/ZX8081.hpp b/Storage/Tape/Parsers/ZX8081.hpp new file mode 100644 index 000000000..4826851e5 --- /dev/null +++ b/Storage/Tape/Parsers/ZX8081.hpp @@ -0,0 +1,62 @@ +// +// ZX8081.hpp +// Clock Signal +// +// Created by Thomas Harte on 07/06/2017. +// Copyright © 2017 Thomas Harte. All rights reserved. +// + +#ifndef Storage_Tape_Parsers_ZX8081_hpp +#define Storage_Tape_Parsers_ZX8081_hpp + +#include "TapeParser.hpp" +#include +#include +#include + +namespace Storage { +namespace Tape { +namespace ZX8081 { + +struct File { + std::vector data; + std::string name; + bool isZX81; +}; + +enum class WaveType { + Pulse, Gap, LongGap +}; + +enum class SymbolType { + One, Zero, Gap +}; + +class Parser: public Storage::Tape::Parser { + public: + Parser(); + + /*! + Reads and combines the next eight bits. + */ + uint8_t get_next_byte(const std::shared_ptr &tape); + + /*! + Waits for a long gap, reads all the bytes between that and the next long gap, then + attempts to parse those as a valid ZX80 or ZX81 file. If no file is found, + returns nullptr. + */ + std::shared_ptr get_next_file(); + + private: + /*! + Proceeds beyond the current or next gap then counts pulses until the gap afterwards, and returns the resulting bit. + */ + uint8_t get_next_bit(const std::shared_ptr &tape); +}; + +} +} +} + +#endif /* ZX8081_hpp */