2017-07-11 01:43:58 +00:00
|
|
|
//
|
|
|
|
// CSW.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 10/07/2017.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2017 Thomas Harte. All rights reserved.
|
2017-07-11 01:43:58 +00:00
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2017-07-11 01:43:58 +00:00
|
|
|
|
|
|
|
#include "../Tape.hpp"
|
|
|
|
|
2018-04-06 21:42:24 +00:00
|
|
|
#include <string>
|
2017-07-13 01:23:59 +00:00
|
|
|
#include <vector>
|
2018-04-06 21:42:24 +00:00
|
|
|
#include <zlib.h>
|
2017-07-12 02:41:10 +00:00
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace Storage::Tape {
|
2017-07-11 01:43:58 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Provides a @c Tape containing a CSW tape image, which is a compressed 1-bit sampling.
|
|
|
|
*/
|
2017-11-03 02:32:00 +00:00
|
|
|
class CSW: public Tape {
|
2024-12-02 02:44:14 +00:00
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
Constructs a @c CSW containing content from the file with name @c file_name.
|
2017-07-11 01:43:58 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
@throws ErrorNotCSW if this file could not be opened and recognised as a valid CSW file.
|
|
|
|
*/
|
|
|
|
CSW(const std::string &file_name);
|
2017-07-11 01:43:58 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
enum class CompressionType {
|
|
|
|
RLE,
|
|
|
|
ZRLE
|
|
|
|
};
|
2018-02-23 02:28:12 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
/*!
|
|
|
|
Constructs a @c CSW containing content as specified. Does not throw.
|
|
|
|
*/
|
|
|
|
CSW(const std::vector<uint8_t> &&data, CompressionType compression_type, bool initial_level, uint32_t sampling_rate);
|
2018-02-23 02:28:12 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
enum {
|
|
|
|
ErrorNotCSW
|
|
|
|
};
|
2017-07-11 01:43:58 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
// implemented to satisfy @c Tape
|
|
|
|
bool is_at_end();
|
2017-07-11 01:43:58 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
private:
|
|
|
|
void virtual_reset();
|
|
|
|
Pulse virtual_get_next_pulse();
|
2017-07-12 02:41:10 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
Pulse pulse_;
|
|
|
|
CompressionType compression_type_;
|
2017-07-13 01:23:59 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
uint8_t get_next_byte();
|
|
|
|
uint32_t get_next_int32le();
|
|
|
|
void invert_pulse();
|
2017-07-13 01:23:59 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
std::vector<uint8_t> source_data_;
|
|
|
|
std::size_t source_data_pointer_;
|
2017-07-11 01:43:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|