46 constexpr
byte CAS_HEADER [ 8] = { 0x1F,0xA6,0xDE,0xBA,0xCC,0x13,0x7D,0x74 };
47 constexpr
byte ASCII_HEADER [10] = { 0xEA,0xEA,0xEA,0xEA,0xEA,0xEA,0xEA,0xEA,0xEA,0xEA };
48 constexpr
byte BINARY_HEADER[10] = { 0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0,0xD0 };
49 constexpr
byte BASIC_HEADER [10] = { 0xD3,0xD3,0xD3,0xD3,0xD3,0xD3,0xD3,0xD3,0xD3,0xD3 };
55 convert(
filename, filePool, cliComm);
61 unsigned pos = zero.getTicksTill(time);
62 return pos < output.size() ? output[pos] * 256 : 0;
68 clk += unsigned(output.size());
79 size_t nbSamples = output.size();
81 for (
auto i :
xrange(num)) {
97 void CasImage::write0()
99 append(output, {127, 127, -127, -127});
101 void CasImage::write1()
103 append(output, {127, -127, 127, -127});
107 void CasImage::writeHeader(
unsigned s)
109 repeat(s, [&] { write1(); });
113 void CasImage::writeSilence(
unsigned s)
115 output.insert(
end(output), s, 0);
119 void CasImage::writeByte(
byte b)
124 for (
auto i :
xrange(8)) {
140 while ((pos + 8) <= buf.
size()) {
145 if (buf[pos] == 0x1A) {
150 while (pos < buf.
size()) {
151 writeByte(buf[pos++]);
156 void CasImage::convert(
const Filename&
filename, FilePool& filePool, CliComm& cliComm)
159 auto buf = file.mmap();
162 bool issueWarning =
false;
163 bool headerFound =
false;
164 bool firstFile =
true;
166 while ((pos + 8) <= buf.
size()) {
175 if ((pos + 10) <= buf.
size()) {
194 eof = writeData(buf, pos);
195 }
while (!eof && ((pos + 8) <= buf.
size()));
222 throw MSXException(
filename.getOriginal(),
": not a valid CAS image");
225 cliComm.printWarning(
"Skipped unhandled data in ",
unsigned getFrequency() const override
CasImage(const Filename &fileName, FilePool &filePool, CliComm &cliComm)
int16_t getSampleAt(EmuTime::param time) override
void fillBuffer(unsigned pos, float **bufs, unsigned num) const override
EmuTime getEndTime() const override
float getAmplificationFactorImpl() const override
void setSha1Sum(const Sha1Sum &sha1sum)
void setFirstFileType(FileType type)
Represents a clock with a fixed frequency.
constexpr EmuTime::param getTime() const
Gets the time at which the last clock tick occurred.
This class represents a filename.
constexpr index_type size() const noexcept
This file implemented 3 utility functions:
constexpr unsigned BAUDRATE
constexpr byte BASIC_HEADER[10]
constexpr unsigned SHORT_SILENCE
constexpr byte ASCII_HEADER[10]
constexpr unsigned LONG_SILENCE
constexpr byte BINARY_HEADER[10]
constexpr unsigned OUTPUT_FREQUENCY
constexpr const char *const filename
constexpr byte CAS_HEADER[8]
constexpr unsigned AUDIO_OVERSAMPLE
constexpr unsigned SHORT_HEADER
constexpr unsigned LONG_HEADER
constexpr void repeat(T n, Op op)
Repeat the given operation 'op' 'n' times.
constexpr auto xrange(T e)
constexpr auto end(const zstring_view &x)