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> {
|
2024-12-02 02:44:14 +00:00
|
|
|
public:
|
|
|
|
int get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &tape, bool use_fast_encoding);
|
|
|
|
bool sync_and_get_encoding_speed(const std::shared_ptr<Storage::Tape::Tape> &tape);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void process_pulse(const Storage::Tape::Tape::Pulse &pulse) override;
|
|
|
|
void inspect_waves(const std::vector<WaveType> &waves) override;
|
|
|
|
|
|
|
|
enum DetectionMode {
|
|
|
|
FastData,
|
|
|
|
SlowData,
|
|
|
|
FastZero,
|
|
|
|
SlowZero,
|
|
|
|
Sync
|
|
|
|
} detection_mode_;
|
|
|
|
bool wave_was_high_;
|
|
|
|
float cycle_length_;
|
|
|
|
|
|
|
|
struct Pattern {
|
|
|
|
WaveType type;
|
|
|
|
int count = 0;
|
|
|
|
};
|
|
|
|
std::size_t pattern_matching_depth(const std::vector<WaveType> &waves, const Pattern *pattern);
|
2016-11-07 00:22:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|