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
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef Storage_Tape_Parsers_Oric_hpp
|
|
|
|
#define Storage_Tape_Parsers_Oric_hpp
|
|
|
|
|
|
|
|
#include "TapeParser.hpp"
|
|
|
|
|
|
|
|
namespace Storage {
|
|
|
|
namespace Tape {
|
|
|
|
namespace Oric {
|
|
|
|
|
|
|
|
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:
|
2017-07-15 23:07:35 +00:00
|
|
|
void process_pulse(const Storage::Tape::Tape::Pulse &pulse);
|
2016-11-07 00:22:09 +00:00
|
|
|
void inspect_waves(const std::vector<WaveType> &waves);
|
|
|
|
|
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
|
|
|
|
|
|
|
struct Pattern
|
|
|
|
{
|
|
|
|
WaveType type;
|
|
|
|
int count;
|
|
|
|
};
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* Oric_hpp */
|