1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-13 15:31:05 +00:00
CLK/Storage/Tape/Parsers/Acorn.hpp

66 lines
1.4 KiB
C++
Raw Normal View History

//
// Acorn.hpp
// Clock Signal
//
// Created by Thomas Harte on 06/11/2016.
// Copyright 2016 Thomas Harte. All rights reserved.
//
#pragma once
#include "TapeParser.hpp"
2020-01-20 04:14:35 +00:00
#include "../../../Numeric/CRC.hpp"
2017-09-23 02:39:23 +00:00
#include "../../Disk/DPLL/DigitalPhaseLockedLoop.hpp"
2023-05-10 21:02:18 +00:00
namespace Storage::Tape::Acorn {
class Shifter {
public:
Shifter();
void process_pulse(const Storage::Tape::Tape::Pulse &);
struct Delegate {
virtual void acorn_shifter_output_bit(int value) = 0;
};
void set_delegate(Delegate *delegate) {
delegate_ = delegate;
}
void digital_phase_locked_loop_output_bit(int value);
private:
Storage::DigitalPhaseLockedLoop<Shifter, 15> pll_;
bool was_high_;
unsigned int input_pattern_;
Delegate *delegate_;
};
enum class SymbolType {
One, Zero
};
2023-05-16 20:40:09 +00:00
class Parser: public Storage::Tape::Parser<SymbolType>, public Shifter::Delegate {
public:
Parser();
int get_next_bit(const std::shared_ptr<Storage::Tape::Tape> &);
int get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &);
unsigned int get_next_short(const std::shared_ptr<Storage::Tape::Tape> &);
unsigned int get_next_word(const std::shared_ptr<Storage::Tape::Tape> &);
void reset_crc();
uint16_t get_crc() const;
private:
void acorn_shifter_output_bit(int value) override;
void process_pulse(const Storage::Tape::Tape::Pulse &) override;
bool did_update_shifter(int new_value, int length);
CRC::Generator<uint16_t, 0x0000, 0x0000, false, false> crc_;
Shifter shifter_;
};
}