2016-11-07 00:22:09 +00:00
|
|
|
//
|
|
|
|
// Oric.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 06/11/2016.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2016 Thomas Harte. All rights reserved.
|
2016-11-07 00:22:09 +00:00
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2016-11-07 00:22:09 +00:00
|
|
|
|
|
|
|
#include "TapeParser.hpp"
|
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace Storage::Tape::Oric {
|
2016-11-07 00:22:09 +00:00
|
|
|
|
|
|
|
enum class WaveType {
|
2018-05-13 19:46:14 +00:00
|
|
|
Short, // i.e. 416 microseconds
|
|
|
|
Medium, // i.e. 624 microseconds
|
|
|
|
Long, // i.e. 832 microseconds
|
2016-11-09 11:37:10 +00:00
|
|
|
Unrecognised
|
2016-11-07 00:22:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class SymbolType {
|
2016-11-07 02:31:10 +00:00
|
|
|
One, Zero, FoundFast, FoundSlow
|
2016-11-07 00:22:09 +00:00
|
|
|
};
|
|
|
|
|
2017-07-15 23:07:35 +00:00
|
|
|
class Parser: public Storage::Tape::PulseClassificationParser<WaveType, SymbolType> {
|
2016-11-07 00:22:09 +00:00
|
|
|
public:
|
|
|
|
int get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &tape, bool use_fast_encoding);
|
2016-11-07 02:31:10 +00:00
|
|
|
bool sync_and_get_encoding_speed(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
2016-11-07 00:22:09 +00:00
|
|
|
|
|
|
|
private:
|
2021-03-07 20:56:58 +00:00
|
|
|
void process_pulse(const Storage::Tape::Tape::Pulse &pulse) override;
|
|
|
|
void inspect_waves(const std::vector<WaveType> &waves) override;
|
2016-11-07 00:22:09 +00:00
|
|
|
|
2016-11-07 02:31:10 +00:00
|
|
|
enum DetectionMode {
|
|
|
|
FastData,
|
|
|
|
SlowData,
|
2016-11-08 01:17:06 +00:00
|
|
|
FastZero,
|
|
|
|
SlowZero,
|
2016-11-07 02:31:10 +00:00
|
|
|
Sync
|
2016-12-03 17:05:19 +00:00
|
|
|
} detection_mode_;
|
|
|
|
bool wave_was_high_;
|
|
|
|
float cycle_length_;
|
2016-11-07 02:31:10 +00:00
|
|
|
|
2021-03-08 01:49:40 +00:00
|
|
|
struct Pattern {
|
2016-11-07 02:31:10 +00:00
|
|
|
WaveType type;
|
2020-05-30 23:31:17 +00:00
|
|
|
int count = 0;
|
2016-11-07 02:31:10 +00:00
|
|
|
};
|
2019-12-22 05:00:23 +00:00
|
|
|
std::size_t pattern_matching_depth(const std::vector<WaveType> &waves, const Pattern *pattern);
|
2016-11-07 00:22:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|