mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-25 16:31:42 +00:00
58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
//
|
|
// ZX8081.hpp
|
|
// Clock Signal
|
|
//
|
|
// Created by Thomas Harte on 07/06/2017.
|
|
// Copyright 2017 Thomas Harte. All rights reserved.
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#include "TapeParser.hpp"
|
|
|
|
#include "../../Data/ZX8081.hpp"
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <cstdint>
|
|
|
|
namespace Storage::Tape::ZX8081 {
|
|
|
|
enum class WaveType {
|
|
Pulse, Gap, LongGap, Unrecognised
|
|
};
|
|
|
|
enum class SymbolType {
|
|
One, Zero, FileGap, Unrecognised
|
|
};
|
|
|
|
class Parser: public Storage::Tape::PulseClassificationParser<WaveType, SymbolType> {
|
|
public:
|
|
Parser();
|
|
|
|
/*!
|
|
Reads and combines the next eight bits. Returns -1 if any errors are encountered.
|
|
*/
|
|
int get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &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<Storage::Data::ZX8081::File> get_next_file(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
|
|
|
private:
|
|
bool pulse_was_high_;
|
|
Time pulse_time_;
|
|
void post_pulse();
|
|
|
|
void process_pulse(const Storage::Tape::Tape::Pulse &pulse) override;
|
|
void mark_end() override;
|
|
void inspect_waves(const std::vector<WaveType> &waves) override;
|
|
|
|
std::shared_ptr<std::vector<uint8_t>> get_next_file_data(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
|
};
|
|
|
|
}
|