1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Performed the initial wiring to announce that this application supports TZX files and to route them to the ZX80/81 static analyser. The TZX class itself does not yet do much beyond basic validation. I think it'll be easiest if it follows in UEF's footsteps in queuing up pulses ahead of time, so some factoring out is now required.

This commit is contained in:
Thomas Harte 2017-07-16 21:33:11 -04:00
parent 7b5f93510b
commit 238348c885
6 changed files with 123 additions and 1 deletions

View File

@ -53,6 +53,7 @@
4B3BA0D11D318B44005DD7A7 /* TestMachine6502.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B3BA0CD1D318B44005DD7A7 /* TestMachine6502.mm */; };
4B3BF5B01F146265005B6C36 /* CSW.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B3BF5AE1F146264005B6C36 /* CSW.cpp */; };
4B3F1B461E0388D200DB26EE /* PCMPatchedTrack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B3F1B441E0388D200DB26EE /* PCMPatchedTrack.cpp */; };
4B448E811F1C45A00009ABD6 /* TZX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B448E7F1F1C45A00009ABD6 /* TZX.cpp */; };
4B44EBF51DC987AF00A7820C /* AllSuiteA.bin in Resources */ = {isa = PBXBuildFile; fileRef = 4B44EBF41DC987AE00A7820C /* AllSuiteA.bin */; };
4B44EBF71DC9883B00A7820C /* 6502_functional_test.bin in Resources */ = {isa = PBXBuildFile; fileRef = 4B44EBF61DC9883B00A7820C /* 6502_functional_test.bin */; };
4B44EBF91DC9898E00A7820C /* BCDTEST_beeb in Resources */ = {isa = PBXBuildFile; fileRef = 4B44EBF81DC9898E00A7820C /* BCDTEST_beeb */; };
@ -544,6 +545,8 @@
4B3BF5AF1F146264005B6C36 /* CSW.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CSW.hpp; sourceTree = "<group>"; };
4B3F1B441E0388D200DB26EE /* PCMPatchedTrack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PCMPatchedTrack.cpp; sourceTree = "<group>"; };
4B3F1B451E0388D200DB26EE /* PCMPatchedTrack.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PCMPatchedTrack.hpp; sourceTree = "<group>"; };
4B448E7F1F1C45A00009ABD6 /* TZX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TZX.cpp; sourceTree = "<group>"; };
4B448E801F1C45A00009ABD6 /* TZX.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TZX.hpp; sourceTree = "<group>"; };
4B44EBF41DC987AE00A7820C /* AllSuiteA.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = AllSuiteA.bin; path = AllSuiteA/AllSuiteA.bin; sourceTree = "<group>"; };
4B44EBF61DC9883B00A7820C /* 6502_functional_test.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = 6502_functional_test.bin; path = "Klaus Dormann/6502_functional_test.bin"; sourceTree = "<group>"; };
4B44EBF81DC9898E00A7820C /* BCDTEST_beeb */ = {isa = PBXFileReference; lastKnownFileType = file; name = BCDTEST_beeb; path = BCDTest/BCDTEST_beeb; sourceTree = "<group>"; };
@ -1402,12 +1405,14 @@
4B59199A1DAC6C46005BB85C /* OricTAP.cpp */,
4B2BFC5D1D613E0200BA3AA9 /* TapePRG.cpp */,
4B69FB421C4D941400B5F0AA /* TapeUEF.cpp */,
4B448E7F1F1C45A00009ABD6 /* TZX.cpp */,
4B1497861EE4A1DA00CE2596 /* ZX80O81P.cpp */,
4BC91B821D1F160E00884B76 /* CommodoreTAP.hpp */,
4B3BF5AF1F146264005B6C36 /* CSW.hpp */,
4B59199B1DAC6C46005BB85C /* OricTAP.hpp */,
4B2BFC5E1D613E0200BA3AA9 /* TapePRG.hpp */,
4B69FB431C4D941400B5F0AA /* TapeUEF.hpp */,
4B448E801F1C45A00009ABD6 /* TZX.hpp */,
4B1497871EE4A1DA00CE2596 /* ZX80O81P.hpp */,
4B69FB451C4D950F00B5F0AA /* libz.tbd */,
);
@ -2605,6 +2610,7 @@
4B7913CC1DFCD80E00175A82 /* Video.cpp in Sources */,
4B2A53A11D117D36003C6002 /* CSAtari2600.mm in Sources */,
4BF829661D8F732B001BAE39 /* Disk.cpp in Sources */,
4B448E811F1C45A00009ABD6 /* TZX.cpp in Sources */,
4BEA52631DF339D7007E74F2 /* Speaker.cpp in Sources */,
4BC5E4921D7ED365008CF980 /* StaticAnalyser.cpp in Sources */,
4BC830D11D6E7C690000A26F /* Tape.cpp in Sources */,

View File

@ -212,6 +212,20 @@
<key>NSDocumentClass</key>
<string>$(PRODUCT_MODULE_NAME).MachineDocument</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>tzx</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>cassette</string>
<key>CFBundleTypeName</key>
<string>Tape Image</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>NSDocumentClass</key>
<string>$(PRODUCT_MODULE_NAME).MachineDocument</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>

View File

@ -34,6 +34,7 @@
#include "../Storage/Tape/Formats/OricTAP.hpp"
#include "../Storage/Tape/Formats/TapePRG.hpp"
#include "../Storage/Tape/Formats/TapeUEF.hpp"
#include "../Storage/Tape/Formats/TZX.hpp"
#include "../Storage/Tape/Formats/ZX80O81P.hpp"
typedef int TargetPlatformType;
@ -124,6 +125,7 @@ std::list<Target> StaticAnalyser::GetTargets(const char *file_name)
Format("ssd", disks, Disk::SSD, TargetPlatform::Acorn) // SSD
Format("tap", tapes, Tape::CommodoreTAP, TargetPlatform::Commodore) // TAP (Commodore)
Format("tap", tapes, Tape::OricTAP, TargetPlatform::Oric) // TAP (Oric)
Format("tzx", tapes, Tape::TZX, TargetPlatform::ZX8081) // TZX
Format("uef", tapes, Tape::UEF, TargetPlatform::Acorn) // UEF (tape)
#undef Format

View File

@ -18,7 +18,7 @@ CSW::CSW(const char *file_name) :
// Check signature.
char identifier[22];
char signature[] = "Compressed Square Wave";
fread(identifier, 1, 22, file_);
fread(identifier, 1, strlen(signature), file_);
if(memcmp(identifier, signature, strlen(signature))) throw ErrorNotCSW;
// Check terminating byte.

View File

@ -0,0 +1,49 @@
//
// TZX.cpp
// Clock Signal
//
// Created by Thomas Harte on 16/07/2017.
// Copyright © 2017 Thomas Harte. All rights reserved.
//
#include "TZX.hpp"
using namespace Storage::Tape;
TZX::TZX(const char *file_name) :
Storage::FileHolder(file_name),
is_high_(false),
is_at_end_(false),
pulse_pointer_(0) {
// Check for signature followed by a 0x1a
char identifier[7];
char signature[] = "ZXTape!";
fread(identifier, 1, strlen(signature), file_);
if(memcmp(identifier, signature, strlen(signature))) throw ErrorNotTZX;
if(fgetc(file_) != 0x1a) throw ErrorNotTZX;
// Get version number
uint8_t major_version = (uint8_t)fgetc(file_);
uint8_t minor_version = (uint8_t)fgetc(file_);
// Reject if an incompatible version
if(major_version != 1 || minor_version > 20) throw ErrorNotTZX;
// seed initial block contents
parse_next_chunk();
}
bool TZX::is_at_end() {
return true;
}
Tape::Pulse TZX::virtual_get_next_pulse() {
return Tape::Pulse();
}
void TZX::virtual_reset() {
}
void TZX::parse_next_chunk() {
}

View File

@ -0,0 +1,51 @@
//
// TZX.hpp
// Clock Signal
//
// Created by Thomas Harte on 16/07/2017.
// Copyright © 2017 Thomas Harte. All rights reserved.
//
#ifndef TZX_hpp
#define TZX_hpp
#include "../Tape.hpp"
#include "../../FileHolder.hpp"
namespace Storage {
namespace Tape {
/*!
Provides a @c Tape containing a CSW tape image, which is a compressed 1-bit sampling.
*/
class TZX: public Tape, public Storage::FileHolder {
public:
/*!
Constructs a @c TZX containing content from the file with name @c file_name.
@throws ErrorNotTZX if this file could not be opened and recognised as a valid TZX file.
*/
TZX(const char *file_name);
enum {
ErrorNotTZX
};
// implemented to satisfy @c Tape
bool is_at_end();
private:
Pulse virtual_get_next_pulse();
void virtual_reset();
// std::vector<Pulse> queued_pulses_;
size_t pulse_pointer_;
bool is_at_end_;
bool is_high_;
void parse_next_chunk();
};
}
}
#endif /* TZX_hpp */