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
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef CSW_hpp
|
|
|
|
#define CSW_hpp
|
|
|
|
|
|
|
|
#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
|
|
|
|
2017-07-11 01:43:58 +00:00
|
|
|
namespace Storage {
|
|
|
|
namespace Tape {
|
|
|
|
|
|
|
|
/*!
|
|
|
|
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 {
|
2017-07-11 01:43:58 +00:00
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
Constructs a @c CSW containing content from the file with name @c file_name.
|
|
|
|
|
|
|
|
@throws ErrorNotCSW if this file could not be opened and recognised as a valid CSW file.
|
|
|
|
*/
|
2018-04-06 21:42:24 +00:00
|
|
|
CSW(const std::string &file_name);
|
2017-07-11 01:43:58 +00:00
|
|
|
|
2018-02-23 02:28:12 +00:00
|
|
|
enum class CompressionType {
|
|
|
|
RLE,
|
|
|
|
ZRLE
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
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);
|
|
|
|
|
2017-07-11 01:43:58 +00:00
|
|
|
enum {
|
|
|
|
ErrorNotCSW
|
|
|
|
};
|
|
|
|
|
|
|
|
// implemented to satisfy @c Tape
|
|
|
|
bool is_at_end();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void virtual_reset();
|
|
|
|
Pulse virtual_get_next_pulse();
|
2017-07-12 02:41:10 +00:00
|
|
|
|
|
|
|
Pulse pulse_;
|
2018-02-23 02:28:12 +00:00
|
|
|
CompressionType compression_type_;
|
2017-07-13 01:23:59 +00:00
|
|
|
|
|
|
|
uint8_t get_next_byte();
|
2017-07-14 00:57:27 +00:00
|
|
|
uint32_t get_next_int32le();
|
2017-07-13 01:23:59 +00:00
|
|
|
void invert_pulse();
|
|
|
|
|
|
|
|
std::vector<uint8_t> source_data_;
|
2017-11-11 20:28:40 +00:00
|
|
|
std::size_t source_data_pointer_;
|
2017-07-11 01:43:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CSW_hpp */
|