2017-07-11 01:43:58 +00:00
|
|
|
//
|
|
|
|
// CSW.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 10/07/2017.
|
|
|
|
// Copyright © 2017 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef CSW_hpp
|
|
|
|
#define CSW_hpp
|
|
|
|
|
|
|
|
#include "../Tape.hpp"
|
|
|
|
#include "../../FileHolder.hpp"
|
|
|
|
|
2017-07-12 02:41:10 +00:00
|
|
|
#include <zlib.h>
|
2017-07-13 01:23:59 +00:00
|
|
|
#include <vector>
|
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.
|
|
|
|
*/
|
|
|
|
CSW(const char *file_name);
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ErrorNotCSW
|
|
|
|
};
|
|
|
|
|
|
|
|
// implemented to satisfy @c Tape
|
|
|
|
bool is_at_end();
|
|
|
|
|
|
|
|
private:
|
2017-11-03 02:32:00 +00:00
|
|
|
Storage::FileHolder file_;
|
|
|
|
|
2017-07-11 01:43:58 +00:00
|
|
|
void virtual_reset();
|
|
|
|
Pulse virtual_get_next_pulse();
|
2017-07-12 02:41:10 +00:00
|
|
|
|
|
|
|
Pulse pulse_;
|
2017-11-12 21:42:53 +00:00
|
|
|
enum class CompressionType {
|
2017-07-12 02:41:10 +00:00
|
|
|
RLE,
|
|
|
|
ZRLE
|
|
|
|
} 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-13 01:23:59 +00:00
|
|
|
|
|
|
|
long rle_start_;
|
2017-07-11 01:43:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CSW_hpp */
|