1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00
CLK/Storage/Tape/Formats/CAS.hpp
Thomas Harte b4bfcd4279 Switches to an attempt to break the .CAS into files ahead of time.
Hopefully the better to insert appropriate lengths of header and gap.
2017-12-23 18:41:50 -05:00

76 lines
1.4 KiB
C++

//
// CAS.hpp
// Clock Signal
//
// Created by Thomas Harte on 25/11/2017.
// Copyright © 2017 Thomas Harte. All rights reserved.
//
#ifndef CAS_hpp
#define CAS_hpp
#include "../Tape.hpp"
#include "../../FileHolder.hpp"
#include <cstdint>
#include <vector>
namespace Storage {
namespace Tape {
/*!
Provides a @c Tape containing a CAS tape image, which is an MSX byte stream.
*/
class CAS: public Tape {
public:
/*!
Constructs a @c CAS containing content from the file with name @c file_name.
@throws ErrorNotCAS if this file could not be opened and recognised as a valid CAS file.
*/
CAS(const char *file_name);
enum {
ErrorNotCAS
};
// implemented to satisfy @c Tape
bool is_at_end();
private:
void virtual_reset();
Pulse virtual_get_next_pulse();
// Helper for populating the file list, below.
void get_next(Storage::FileHolder &file, uint8_t (&buffer)[8], std::size_t quantity);
// Storage for the array of files to transcribe into audio.
enum class Block {
BSAVE,
CSAVE,
ASCII
};
struct File {
Block type;
std::vector<std::vector<std::uint8_t>> chunks;
};
std::vector<File> files_;
// Tracker for active state within the file list.
std::size_t file_pointer_ = 0;
std::size_t chunk_pointer_ = 0;
enum class Phase {
Header,
Bytes,
Gap,
EndOfFile
} phase_ = Phase::Header;
std::size_t distance_into_phase_ = 0;
std::size_t distance_into_bit_ = 0;
};
}
}
#endif /* CAS_hpp */