2017-06-07 14:12:13 +00:00
|
|
|
//
|
|
|
|
// ZX8081.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 07/06/2017.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2017 Thomas Harte. All rights reserved.
|
2017-06-07 14:12:13 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef Storage_Tape_Parsers_ZX8081_hpp
|
|
|
|
#define Storage_Tape_Parsers_ZX8081_hpp
|
|
|
|
|
|
|
|
#include "TapeParser.hpp"
|
2017-06-08 23:09:51 +00:00
|
|
|
|
|
|
|
#include "../../Data/ZX8081.hpp"
|
|
|
|
|
2017-06-07 14:12:13 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <cstdint>
|
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace Storage::Tape::ZX8081 {
|
2017-06-07 14:12:13 +00:00
|
|
|
|
|
|
|
enum class WaveType {
|
2017-06-07 21:27:05 +00:00
|
|
|
Pulse, Gap, LongGap, Unrecognised
|
2017-06-07 14:12:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class SymbolType {
|
2017-06-07 21:27:05 +00:00
|
|
|
One, Zero, FileGap, Unrecognised
|
2017-06-07 14:12:13 +00:00
|
|
|
};
|
|
|
|
|
2017-07-15 23:07:35 +00:00
|
|
|
class Parser: public Storage::Tape::PulseClassificationParser<WaveType, SymbolType> {
|
2017-06-07 14:12:13 +00:00
|
|
|
public:
|
|
|
|
Parser();
|
|
|
|
|
|
|
|
/*!
|
2017-06-07 21:27:05 +00:00
|
|
|
Reads and combines the next eight bits. Returns -1 if any errors are encountered.
|
2017-06-07 14:12:13 +00:00
|
|
|
*/
|
2017-06-07 21:27:05 +00:00
|
|
|
int get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
2017-06-07 14:12:13 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
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.
|
|
|
|
*/
|
2017-06-08 23:09:51 +00:00
|
|
|
std::shared_ptr<Storage::Data::ZX8081::File> get_next_file(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
2017-06-07 14:12:13 +00:00
|
|
|
|
|
|
|
private:
|
2017-06-07 21:27:05 +00:00
|
|
|
bool pulse_was_high_;
|
|
|
|
Time pulse_time_;
|
2017-06-09 01:33:35 +00:00
|
|
|
void post_pulse();
|
|
|
|
|
2021-03-07 20:56:58 +00:00
|
|
|
void process_pulse(const Storage::Tape::Tape::Pulse &pulse) override;
|
|
|
|
void mark_end() override;
|
|
|
|
void inspect_waves(const std::vector<WaveType> &waves) override;
|
2017-06-07 21:27:05 +00:00
|
|
|
|
2017-06-08 23:09:51 +00:00
|
|
|
std::shared_ptr<std::vector<uint8_t>> get_next_file_data(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
2017-06-07 14:12:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* ZX8081_hpp */
|