mirror of
https://github.com/TomHarte/CLK.git
synced 2026-04-19 19:16:34 +00:00
Further remove type info from function naming.
This commit is contained in:
@@ -32,8 +32,8 @@ CPCDSK::CPCDSK(const std::string &file_name) :
|
||||
|
||||
// Don't really care about about the creator; skip.
|
||||
file.seek(0x30, SEEK_SET);
|
||||
head_position_count_ = file.get8();
|
||||
head_count_ = file.get8();
|
||||
head_position_count_ = file.get();
|
||||
head_count_ = file.get();
|
||||
|
||||
// Used only for non-extended disks.
|
||||
long size_of_a_track = 0;
|
||||
@@ -45,7 +45,7 @@ CPCDSK::CPCDSK(const std::string &file_name) :
|
||||
// Skip two unused bytes and grab the track size table.
|
||||
file.seek(2, SEEK_CUR);
|
||||
for(int c = 0; c < head_position_count_ * head_count_; c++) {
|
||||
track_sizes.push_back(size_t(file.get8()) << 8);
|
||||
track_sizes.push_back(size_t(file.get()) << 8);
|
||||
}
|
||||
} else {
|
||||
size_of_a_track = file.get_le<uint16_t>();
|
||||
@@ -61,19 +61,19 @@ CPCDSK::CPCDSK(const std::string &file_name) :
|
||||
Track *track = tracks_.back().get();
|
||||
|
||||
// Track and side are stored, being a byte each.
|
||||
track->track = file.get8();
|
||||
track->side = file.get8();
|
||||
track->track = file.get();
|
||||
track->side = file.get();
|
||||
|
||||
// If this is an extended disk image then John Elliott's extension provides some greater
|
||||
// data rate and encoding context. Otherwise the next two bytes have no defined meaning.
|
||||
if(is_extended_) {
|
||||
switch(file.get8()) {
|
||||
switch(file.get()) {
|
||||
default: track->data_rate = Track::DataRate::Unknown; break;
|
||||
case 1: track->data_rate = Track::DataRate::SingleOrDoubleDensity; break;
|
||||
case 2: track->data_rate = Track::DataRate::HighDensity; break;
|
||||
case 3: track->data_rate = Track::DataRate::ExtendedDensity; break;
|
||||
}
|
||||
switch(file.get8()) {
|
||||
switch(file.get()) {
|
||||
default: track->data_encoding = Track::DataEncoding::Unknown; break;
|
||||
case 1: track->data_encoding = Track::DataEncoding::FM; break;
|
||||
case 2: track->data_encoding = Track::Track::DataEncoding::MFM; break;
|
||||
@@ -86,10 +86,10 @@ CPCDSK::CPCDSK(const std::string &file_name) :
|
||||
|
||||
// Sector size, number of sectors, gap 3 length and the filler byte are then common
|
||||
// between both variants of DSK.
|
||||
track->sector_length = file.get8();
|
||||
std::size_t number_of_sectors = file.get8();
|
||||
track->gap3_length = file.get8();
|
||||
track->filler_byte = file.get8();
|
||||
track->sector_length = file.get();
|
||||
std::size_t number_of_sectors = file.get();
|
||||
track->gap3_length = file.get();
|
||||
track->filler_byte = file.get();
|
||||
|
||||
// Sector information begins immediately after the track information table.
|
||||
while(number_of_sectors--) {
|
||||
@@ -98,12 +98,12 @@ CPCDSK::CPCDSK(const std::string &file_name) :
|
||||
|
||||
// Track, side, sector, size and two FDC8272-esque status bytes are stored
|
||||
// per sector, in both regular and extended DSK files.
|
||||
sector.address.track = file.get8();
|
||||
sector.address.side = file.get8();
|
||||
sector.address.sector = file.get8();
|
||||
sector.size = file.get8();
|
||||
sector.fdc_status1 = file.get8();
|
||||
sector.fdc_status2 = file.get8();
|
||||
sector.address.track = file.get();
|
||||
sector.address.side = file.get();
|
||||
sector.address.sector = file.get();
|
||||
sector.size = file.get();
|
||||
sector.fdc_status1 = file.get();
|
||||
sector.fdc_status2 = file.get();
|
||||
|
||||
if(sector.fdc_status2 & 0x20) {
|
||||
// The CRC failed in the data field.
|
||||
@@ -279,19 +279,19 @@ void CPCDSK::set_tracks(const std::map<::Storage::Disk::Track::Address, std::uni
|
||||
Storage::FileHolder output(file_name_, Storage::FileHolder::FileMode::Rewrite);
|
||||
output.write(reinterpret_cast<const uint8_t *>("EXTENDED CPC DSK File\r\nDisk-Info\r\n"), 34);
|
||||
output.write(reinterpret_cast<const uint8_t *>("Clock Signal "), 14);
|
||||
output.put8(uint8_t(head_position_count_));
|
||||
output.put8(uint8_t(head_count_));
|
||||
output.put(uint8_t(head_position_count_));
|
||||
output.put(uint8_t(head_count_));
|
||||
output.putn(2, 0);
|
||||
|
||||
// Output size table.
|
||||
for(std::size_t index = 0; index < size_t(head_position_count_ * head_count_); ++index) {
|
||||
if(index >= tracks_.size()) {
|
||||
output.put8(0);
|
||||
output.put(0);
|
||||
continue;
|
||||
}
|
||||
Track *track = tracks_[index].get();
|
||||
if(!track) {
|
||||
output.put8(0);
|
||||
output.put(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ void CPCDSK::set_tracks(const std::map<::Storage::Disk::Track::Address, std::uni
|
||||
|
||||
// Round upward and output.
|
||||
track_size += (256 - (track_size & 255)) & 255;
|
||||
output.put8(uint8_t(track_size >> 8));
|
||||
output.put(uint8_t(track_size >> 8));
|
||||
}
|
||||
|
||||
// Advance to offset 256.
|
||||
@@ -320,46 +320,46 @@ void CPCDSK::set_tracks(const std::map<::Storage::Disk::Track::Address, std::uni
|
||||
// Output track header.
|
||||
output.write(reinterpret_cast<const uint8_t *>("Track-Info\r\n"), 13);
|
||||
output.putn(3, 0);
|
||||
output.put8(track->track);
|
||||
output.put8(track->side);
|
||||
output.put(track->track);
|
||||
output.put(track->side);
|
||||
switch (track->data_rate) {
|
||||
default:
|
||||
output.put8(0);
|
||||
output.put(0);
|
||||
break;
|
||||
case Track::DataRate::SingleOrDoubleDensity:
|
||||
output.put8(1);
|
||||
output.put(1);
|
||||
break;
|
||||
case Track::DataRate::HighDensity:
|
||||
output.put8(2);
|
||||
output.put(2);
|
||||
break;
|
||||
case Track::DataRate::ExtendedDensity:
|
||||
output.put8(3);
|
||||
output.put(3);
|
||||
break;
|
||||
}
|
||||
switch (track->data_encoding) {
|
||||
default:
|
||||
output.put8(0);
|
||||
output.put(0);
|
||||
break;
|
||||
case Track::DataEncoding::FM:
|
||||
output.put8(1);
|
||||
output.put(1);
|
||||
break;
|
||||
case Track::DataEncoding::MFM:
|
||||
output.put8(2);
|
||||
output.put(2);
|
||||
break;
|
||||
}
|
||||
output.put8(track->sector_length);
|
||||
output.put8(uint8_t(track->sectors.size()));
|
||||
output.put8(track->gap3_length);
|
||||
output.put8(track->filler_byte);
|
||||
output.put(track->sector_length);
|
||||
output.put(uint8_t(track->sectors.size()));
|
||||
output.put(track->gap3_length);
|
||||
output.put(track->filler_byte);
|
||||
|
||||
// Output sector information list.
|
||||
for(auto §or: track->sectors) {
|
||||
output.put8(sector.address.track);
|
||||
output.put8(sector.address.side);
|
||||
output.put8(sector.address.sector);
|
||||
output.put8(sector.size);
|
||||
output.put8(sector.fdc_status1);
|
||||
output.put8(sector.fdc_status2);
|
||||
output.put(sector.address.track);
|
||||
output.put(sector.address.side);
|
||||
output.put(sector.address.sector);
|
||||
output.put(sector.size);
|
||||
output.put(sector.fdc_status1);
|
||||
output.put(sector.fdc_status2);
|
||||
|
||||
std::size_t data_size = 0;
|
||||
for(auto &sample: sector.samples) {
|
||||
|
||||
@@ -36,12 +36,12 @@ DMK::DMK(const std::string &file_name) :
|
||||
file_(file_name) {
|
||||
// Determine whether this DMK represents a read-only disk (whether intentionally,
|
||||
// or by virtue of filesystem placement).
|
||||
uint8_t read_only_byte = file_.get8();
|
||||
uint8_t read_only_byte = file_.get();
|
||||
if(read_only_byte != 0x00 && read_only_byte != 0xff) throw Error::InvalidFormat;
|
||||
is_read_only_ = (read_only_byte == 0xff) || file_.get_is_known_read_only();
|
||||
|
||||
// Read track count and size.
|
||||
head_position_count_ = int(file_.get8());
|
||||
head_position_count_ = int(file_.get());
|
||||
track_length_ = long(file_.get_le<uint16_t>());
|
||||
|
||||
// Track length must be at least 0x80, as that's the size of the IDAM
|
||||
@@ -49,7 +49,7 @@ DMK::DMK(const std::string &file_name) :
|
||||
if(track_length_ < 0x80) throw Error::InvalidFormat;
|
||||
|
||||
// Read the file flags and apply them.
|
||||
uint8_t flags = file_.get8();
|
||||
uint8_t flags = file_.get();
|
||||
head_count_ = 2 - ((flags & 0x10) >> 4);
|
||||
head_position_count_ /= head_count_;
|
||||
is_purely_single_density_ = !!(flags & 0x40);
|
||||
|
||||
@@ -22,11 +22,11 @@ G64::G64(const std::string &file_name) :
|
||||
if(!file_.check_signature("GCR-1541")) throw Error::InvalidFormat;
|
||||
|
||||
// check the version number
|
||||
int version = file_.get8();
|
||||
int version = file_.get();
|
||||
if(version != 0) throw Error::UnknownVersion;
|
||||
|
||||
// get the number of tracks and track size
|
||||
number_of_tracks_ = file_.get8();
|
||||
number_of_tracks_ = file_.get();
|
||||
maximum_track_size_ = file_.get_le<uint16_t>();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ HFE::HFE(const std::string &file_name) :
|
||||
file_(file_name) {
|
||||
if(!file_.check_signature("HXCPICFE")) throw Error::InvalidFormat;
|
||||
|
||||
if(file_.get8()) throw Error::UnknownVersion;
|
||||
track_count_ = file_.get8();
|
||||
head_count_ = file_.get8();
|
||||
if(file_.get()) throw Error::UnknownVersion;
|
||||
track_count_ = file_.get();
|
||||
head_count_ = file_.get();
|
||||
|
||||
file_.seek(7, SEEK_CUR);
|
||||
track_list_offset_ = long(file_.get_le<uint16_t>()) << 9;
|
||||
|
||||
@@ -26,7 +26,7 @@ IMD::IMD(const std::string &file_name) : file_(file_name) {
|
||||
}
|
||||
|
||||
// Skip rest of ASCII.
|
||||
while(file_.get8() != 0x1a);
|
||||
while(file_.get() != 0x1a);
|
||||
|
||||
// Build track map.
|
||||
while(true) {
|
||||
@@ -36,10 +36,10 @@ IMD::IMD(const std::string &file_name) : file_(file_name) {
|
||||
file_.seek(1, SEEK_CUR);
|
||||
|
||||
// Grab relevant fields.
|
||||
const uint8_t cylinder = file_.get8();
|
||||
const uint8_t head = file_.get8();
|
||||
const uint8_t sector_count = file_.get8();
|
||||
const uint8_t sector_size = file_.get8();
|
||||
const uint8_t cylinder = file_.get();
|
||||
const uint8_t head = file_.get();
|
||||
const uint8_t sector_count = file_.get();
|
||||
const uint8_t sector_size = file_.get();
|
||||
if(file_.eof()) {
|
||||
break;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ IMD::IMD(const std::string &file_name) : file_(file_name) {
|
||||
|
||||
// Skip sectors.
|
||||
for(int c = 0; c < sector_count; c++) {
|
||||
const uint8_t type = file_.get8();
|
||||
const uint8_t type = file_.get();
|
||||
switch(type) {
|
||||
case 0x00: break; // Sector couldn't be read.
|
||||
|
||||
@@ -111,11 +111,11 @@ std::unique_ptr<Track> IMD::track_at_position(const Track::Address address) cons
|
||||
// Seek to track, parse fully this time.
|
||||
file_.seek(location->second, SEEK_SET);
|
||||
|
||||
const uint8_t mode = file_.get8();
|
||||
const uint8_t cylinder = file_.get8();
|
||||
const uint8_t head = file_.get8();
|
||||
const uint8_t sector_count = file_.get8();
|
||||
const uint8_t sector_size = file_.get8();
|
||||
const uint8_t mode = file_.get();
|
||||
const uint8_t cylinder = file_.get();
|
||||
const uint8_t head = file_.get();
|
||||
const uint8_t sector_count = file_.get();
|
||||
const uint8_t sector_size = file_.get();
|
||||
|
||||
const std::vector<uint8_t> sector_ids = file_.read(sector_count);
|
||||
const std::vector<uint8_t> cylinders = (head & 0x80) ? file_.read(sector_count) : std::vector<uint8_t>{};
|
||||
@@ -135,7 +135,7 @@ std::unique_ptr<Track> IMD::track_at_position(const Track::Address address) cons
|
||||
sector.size = sector_size;
|
||||
|
||||
const auto byte_size = size_t(128 << sector_size);
|
||||
uint8_t type = file_.get8();
|
||||
uint8_t type = file_.get();
|
||||
|
||||
// Type 0: sector was present, but couldn't be read.
|
||||
// Since body CRC errors are a separate item, just don't include a body at all.
|
||||
@@ -152,7 +152,7 @@ std::unique_ptr<Track> IMD::track_at_position(const Track::Address address) cons
|
||||
sector.is_deleted = type & 2;
|
||||
sector.has_data_crc_error = type & 4;
|
||||
if(type & 1) {
|
||||
sector.samples.emplace_back(byte_size, file_.get8());
|
||||
sector.samples.emplace_back(byte_size, file_.get());
|
||||
} else {
|
||||
sector.samples.push_back(file_.read(byte_size));
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ constexpr uint32_t block(const char (& src)[5]) {
|
||||
);
|
||||
}
|
||||
|
||||
size_t block_size(Storage::FileHolder &file, uint8_t header) {
|
||||
size_t block_size(Storage::FileHolder &file, const uint8_t header) {
|
||||
uint8_t size_width = header >> 5;
|
||||
size_t length = 0;
|
||||
while(size_width--) {
|
||||
length = (length << 8) | file.get8();
|
||||
length = (length << 8) | file.get();
|
||||
}
|
||||
return length;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ IPF::IPF(const std::string &file_name) : file_(file_name) {
|
||||
|
||||
platform_type_ = 0;
|
||||
for(int c = 0; c < 4; c++) {
|
||||
const uint8_t platform = file_.get8();
|
||||
const uint8_t platform = file_.get();
|
||||
switch(platform) {
|
||||
default: break;
|
||||
case 1: platform_type_ |= TargetPlatform::Amiga; break;
|
||||
@@ -248,7 +248,7 @@ std::unique_ptr<Track> IPF::track_at_position(const Track::Address address) cons
|
||||
if(block.gap_offset) {
|
||||
file_.seek(description.file_offset + block.gap_offset, SEEK_SET);
|
||||
while(true) {
|
||||
const uint8_t gap_header = file_.get8();
|
||||
const uint8_t gap_header = file_.get();
|
||||
if(!gap_header) break;
|
||||
|
||||
// Decompose the header and read the length.
|
||||
@@ -278,7 +278,7 @@ std::unique_ptr<Track> IPF::track_at_position(const Track::Address address) cons
|
||||
if(block.data_offset) {
|
||||
file_.seek(description.file_offset + block.data_offset, SEEK_SET);
|
||||
while(true) {
|
||||
const uint8_t data_header = file_.get8();
|
||||
const uint8_t data_header = file_.get();
|
||||
if(!data_header) break;
|
||||
|
||||
// Decompose the header and read the length.
|
||||
@@ -408,7 +408,7 @@ void IPF::add_unencoded_data(std::vector<Storage::Disk::PCMSegment> &track, Time
|
||||
|
||||
auto encoder = Storage::Encodings::MFM::GetMFMEncoder(segment.data);
|
||||
for(size_t c = 0; c < num_bits; c += 8) {
|
||||
encoder->add_byte(file_.get8());
|
||||
encoder->add_byte(file_.get());
|
||||
}
|
||||
|
||||
assert(segment.data.size() <= (byte_length * 16));
|
||||
@@ -423,7 +423,7 @@ void IPF::add_raw_data(std::vector<Storage::Disk::PCMSegment> &track, Time bit_l
|
||||
segment.data.reserve(num_bits_ceiling);
|
||||
|
||||
for(size_t bit = 0; bit < num_bits; bit += 8) {
|
||||
const uint8_t next = file_.get8();
|
||||
const uint8_t next = file_.get();
|
||||
segment.data.push_back(next & 0x80);
|
||||
segment.data.push_back(next & 0x40);
|
||||
segment.data.push_back(next & 0x20);
|
||||
|
||||
@@ -41,7 +41,7 @@ MSA::MSA(const std::string &file_name) :
|
||||
track.reserve(sectors_per_track_ * 512);
|
||||
uint16_t pointer = 0;
|
||||
while(pointer < data_length) {
|
||||
const auto byte = file_.get8();
|
||||
const auto byte = file_.get();
|
||||
|
||||
// Compression scheme: if the byte E5 is encountered, an RLE run follows.
|
||||
// An RLE run is encoded as the byte to repeat plus a 16-bit repeat count.
|
||||
@@ -54,7 +54,7 @@ MSA::MSA(const std::string &file_name) :
|
||||
pointer += 4;
|
||||
if(pointer > data_length) break;
|
||||
|
||||
const auto value = file_.get8();
|
||||
const auto value = file_.get();
|
||||
auto count = file_.get_be<uint16_t>();
|
||||
while(count--) {
|
||||
track.push_back(value);
|
||||
|
||||
@@ -45,9 +45,9 @@ MacintoshIMG::MacintoshIMG(const std::string &file_name) :
|
||||
//
|
||||
// Luckily, both 0x00 and 0x4c are invalid string length for the proper
|
||||
// DiskCopy 4.2 format, so there's no ambiguity here.
|
||||
const auto name_length = file_.get8();
|
||||
const auto name_length = file_.get();
|
||||
if(name_length == 0x4c || !name_length) {
|
||||
uint32_t magic_word = file_.get8();
|
||||
uint32_t magic_word = file_.get();
|
||||
if(!((name_length == 0x4c && magic_word == 0x4b) || (name_length == 0x00 && magic_word == 0x00)))
|
||||
throw Error::InvalidFormat;
|
||||
|
||||
@@ -77,7 +77,7 @@ MacintoshIMG::MacintoshIMG(const std::string &file_name) :
|
||||
throw Error::InvalidFormat;
|
||||
|
||||
// Check that this is a comprehensible disk encoding.
|
||||
const auto encoding = file_.get8();
|
||||
const auto encoding = file_.get();
|
||||
switch(encoding) {
|
||||
default: throw Error::InvalidFormat;
|
||||
|
||||
@@ -86,7 +86,7 @@ MacintoshIMG::MacintoshIMG(const std::string &file_name) :
|
||||
case 2: encoding_ = Encoding::MFM720; break;
|
||||
case 3: encoding_ = Encoding::MFM1440; break;
|
||||
}
|
||||
format_ = file_.get8();
|
||||
format_ = file_.get();
|
||||
|
||||
// Check the magic number.
|
||||
const auto magic_number = file_.get_be<uint16_t>();
|
||||
|
||||
@@ -36,7 +36,7 @@ NIB::NIB(const std::string &file_name) :
|
||||
// A real NIB should have every single top bit set. Yes, 1/8th of the
|
||||
// file size is a complete waste. But it provides a hook for validation.
|
||||
while(true) {
|
||||
uint8_t next = file_.get8();
|
||||
uint8_t next = file_.get();
|
||||
if(file_.eof()) break;
|
||||
if(!(next & 0x80)) throw Error::InvalidFormat;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ std::unique_ptr<Track> OricMFMDSK::track_at_position(const Track::Address addres
|
||||
std::unique_ptr<Encodings::MFM::Encoder> encoder = Encodings::MFM::GetMFMEncoder(segment.data);
|
||||
bool did_sync = false;
|
||||
while(track_offset < 6250) {
|
||||
uint8_t next_byte = file_.get8();
|
||||
uint8_t next_byte = file_.get();
|
||||
track_offset++;
|
||||
|
||||
switch(next_byte) {
|
||||
@@ -75,7 +75,7 @@ std::unique_ptr<Track> OricMFMDSK::track_at_position(const Track::Address addres
|
||||
|
||||
case 0xfe:
|
||||
for(int byte = 0; byte < 6; byte++) {
|
||||
last_header[byte] = file_.get8();
|
||||
last_header[byte] = file_.get();
|
||||
encoder->add_byte(last_header[byte]);
|
||||
++track_offset;
|
||||
if(track_offset == 6250) break;
|
||||
@@ -84,7 +84,7 @@ std::unique_ptr<Track> OricMFMDSK::track_at_position(const Track::Address addres
|
||||
|
||||
case 0xfb:
|
||||
for(int byte = 0; byte < (128 << last_header[3]) + 2; byte++) {
|
||||
encoder->add_byte(file_.get8());
|
||||
encoder->add_byte(file_.get());
|
||||
++track_offset;
|
||||
// Special exception: don't interrupt a sector body if it seems to
|
||||
// be about to run over the end of the track. It seems like BD-500
|
||||
|
||||
@@ -399,7 +399,7 @@ STX::STX(const std::string &file_name) : file_(file_name) {
|
||||
|
||||
// Skip the track count, test for a new-style encoding, skip a reserved area.
|
||||
file_.seek(1, SEEK_CUR);
|
||||
is_new_format_ = file_.get8() == 2;
|
||||
is_new_format_ = file_.get() == 2;
|
||||
file_.seek(4, SEEK_CUR);
|
||||
|
||||
// Set all tracks absent.
|
||||
@@ -428,7 +428,7 @@ STX::STX(const std::string &file_name) : file_(file_name) {
|
||||
// Skip fields other than track position, then fill in table position and advance.
|
||||
file_.seek(10, SEEK_CUR);
|
||||
|
||||
const uint8_t track_position = file_.get8();
|
||||
const uint8_t track_position = file_.get();
|
||||
offset_by_track_[track_position] = offset;
|
||||
|
||||
// Update the maximum surface dimensions.
|
||||
@@ -484,7 +484,7 @@ std::unique_ptr<Track> STX::track_at_position(const Track::Address address) cons
|
||||
sectors.back().bit_position = file_.get_le<uint16_t>();
|
||||
sectors.back().data_duration = file_.get_le<uint16_t>();
|
||||
file_.read(sectors.back().address);
|
||||
sectors.back().status = file_.get8();
|
||||
sectors.back().status = file_.get();
|
||||
file_.seek(1, SEEK_CUR);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,10 +66,10 @@ WOZ::WOZ(const std::string &file_name) :
|
||||
|
||||
switch(chunk_id) {
|
||||
case chunk("INFO"): {
|
||||
const uint8_t version = file_.get8();
|
||||
const uint8_t version = file_.get();
|
||||
if(version > 2) break;
|
||||
is_3_5_disk_ = file_.get8() == 2;
|
||||
is_read_only_ = file_.get8() == 1;
|
||||
is_3_5_disk_ = file_.get() == 2;
|
||||
is_read_only_ = file_.get() == 1;
|
||||
/*
|
||||
Ignored:
|
||||
1 byte: Synchronized; 1 = Cross track sync was used during imaging.
|
||||
|
||||
@@ -41,16 +41,16 @@ FileHolder::FileHolder(const std::string &file_name, FileMode ideal_mode)
|
||||
if(!file_) throw Error::CantOpen;
|
||||
}
|
||||
|
||||
uint8_t FileHolder::get8() {
|
||||
uint8_t FileHolder::get() {
|
||||
return uint8_t(std::fgetc(file_));
|
||||
}
|
||||
|
||||
void FileHolder::put8(uint8_t value) {
|
||||
void FileHolder::put(uint8_t value) {
|
||||
std::fputc(value, file_);
|
||||
}
|
||||
|
||||
void FileHolder::putn(std::size_t repeats, uint8_t value) {
|
||||
while(repeats--) put8(value);
|
||||
while(repeats--) put(value);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> FileHolder::read(std::size_t size) {
|
||||
|
||||
+15
-11
@@ -48,59 +48,63 @@ public:
|
||||
FileHolder(const std::string &file_name, FileMode ideal_mode = FileMode::ReadWrite);
|
||||
|
||||
/*!
|
||||
Writes @c value using successive @c put8s, in little endian order.
|
||||
Writes @c value using successive @c puts, in little endian order.
|
||||
Optionally limits itself to only @c size bytes.
|
||||
*/
|
||||
template <typename IntT, size_t size = sizeof(IntT)>
|
||||
void put_le(IntT value) {
|
||||
for(size_t c = 0; c < size; c++) {
|
||||
put8(uint8_t(value));
|
||||
put(uint8_t(value));
|
||||
value >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Writes @c value using successive @c put8s, in big endian order.
|
||||
Writes @c value using successive @c puts, in big endian order.
|
||||
Optionally limits itself to only @c size bytes.
|
||||
*/
|
||||
template <typename IntT, size_t size = sizeof(IntT)>
|
||||
void put_be(IntT value) {
|
||||
auto shift = size * 8;
|
||||
while(shift) {
|
||||
shift -= 8;
|
||||
put8((value >> shift)&0xff);
|
||||
put((value >> shift)&0xff);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Writes @c value using successive @c put8s, in little endian order.
|
||||
Reads a value of type @c IntT using successive @c gets, in little endian order.
|
||||
Optionally limits itself to only @c size bytes.
|
||||
*/
|
||||
template <typename IntT, size_t size = sizeof(IntT)>
|
||||
IntT get_le() {
|
||||
IntT result{};
|
||||
for(size_t c = 0; c < size; c++) {
|
||||
result >>= 8;
|
||||
result |= IntT(get8() << ((size - 1) * 8));
|
||||
result |= IntT(get() << ((size - 1) * 8));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
Writes @c value using successive @c put8s, in big endian order.
|
||||
Reads a value of type @c IntT using successive @c gets, in big endian order.
|
||||
Optionally limits itself to only @c size bytes.
|
||||
*/
|
||||
template <typename IntT, size_t size = sizeof(IntT)>
|
||||
IntT get_be() {
|
||||
IntT result{};
|
||||
for(size_t c = 0; c < size; c++) {
|
||||
result <<= 8;
|
||||
result |= get8();
|
||||
result |= get();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*! Reads a single byte from @c file. */
|
||||
uint8_t get8();
|
||||
uint8_t get();
|
||||
|
||||
/*! Writes a single byte from @c file. */
|
||||
void put8(uint8_t value);
|
||||
void put(uint8_t value);
|
||||
|
||||
/*! Writes @c value a total of @c repeats times. */
|
||||
void putn(std::size_t repeats, uint8_t value);
|
||||
@@ -140,7 +144,7 @@ public:
|
||||
template <int max_bits, bool lsb_first>
|
||||
Numeric::BitStream<max_bits, lsb_first> bitstream() {
|
||||
return Numeric::BitStream<max_bits, lsb_first>([&] {
|
||||
return get8();
|
||||
return get();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ std::unique_ptr<Analyser::Static::Target> SNA::load(const std::string &file_name
|
||||
// Comments below: [offset] [contents]
|
||||
|
||||
// 00 I
|
||||
const uint8_t i = file.get8();
|
||||
const uint8_t i = file.get();
|
||||
|
||||
// 01 HL'; 03 DE'; 05 BC'; 07 AF'
|
||||
state->z80.registers.hl_dash = file.get_le<uint16_t>();
|
||||
@@ -50,21 +50,21 @@ std::unique_ptr<Analyser::Static::Target> SNA::load(const std::string &file_name
|
||||
state->z80.registers.ix = file.get_le<uint16_t>();
|
||||
|
||||
// 13 IFF2 (in bit 2)
|
||||
const uint8_t iff = file.get8();
|
||||
const uint8_t iff = file.get();
|
||||
state->z80.registers.iff1 = state->z80.registers.iff2 = iff & 4;
|
||||
|
||||
// 14 R
|
||||
const uint8_t r = file.get8();
|
||||
const uint8_t r = file.get();
|
||||
state->z80.registers.ir = uint16_t((i << 8) | r);
|
||||
|
||||
// 15 AF; 17 SP; 19 interrupt mode
|
||||
state->z80.registers.flags = file.get8();
|
||||
state->z80.registers.a = file.get8();
|
||||
state->z80.registers.flags = file.get();
|
||||
state->z80.registers.a = file.get();
|
||||
state->z80.registers.stack_pointer = file.get_le<uint16_t>();
|
||||
state->z80.registers.interrupt_mode = file.get8();
|
||||
state->z80.registers.interrupt_mode = file.get();
|
||||
|
||||
// 1A border colour
|
||||
state->video.border_colour = file.get8();
|
||||
state->video.border_colour = file.get();
|
||||
|
||||
// 1B– 48kb RAM contents
|
||||
state->ram = file.read(48*1024);
|
||||
|
||||
+19
-19
@@ -40,14 +40,14 @@ std::unique_ptr<Analyser::Static::Target> SZX::load(const std::string &file_name
|
||||
if(!file.check_signature("ZXST")) {
|
||||
return nullptr;
|
||||
}
|
||||
const uint8_t major_version = file.get8();
|
||||
[[maybe_unused]] const uint8_t minor_version = file.get8();
|
||||
const uint8_t major_version = file.get();
|
||||
[[maybe_unused]] const uint8_t minor_version = file.get();
|
||||
if(major_version > 1) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Check for a supported machine type.
|
||||
const uint8_t machine_type = file.get8();
|
||||
const uint8_t machine_type = file.get();
|
||||
switch(machine_type) {
|
||||
default: return nullptr;
|
||||
|
||||
@@ -68,7 +68,7 @@ std::unique_ptr<Analyser::Static::Target> SZX::load(const std::string &file_name
|
||||
break;
|
||||
}
|
||||
|
||||
const uint8_t file_flags = file.get8();
|
||||
const uint8_t file_flags = file.get();
|
||||
[[maybe_unused]] const bool uses_late_timings = file_flags & 1;
|
||||
|
||||
// Now parse all included blocks.
|
||||
@@ -85,8 +85,8 @@ std::unique_ptr<Analyser::Static::Target> SZX::load(const std::string &file_name
|
||||
|
||||
// ZXSTZ80REGS
|
||||
case block("Z80R"): {
|
||||
state->z80.registers.flags = file.get8();
|
||||
state->z80.registers.a = file.get8();
|
||||
state->z80.registers.flags = file.get();
|
||||
state->z80.registers.a = file.get();
|
||||
|
||||
state->z80.registers.bc = file.get_le<uint16_t>();
|
||||
state->z80.registers.de = file.get_le<uint16_t>();
|
||||
@@ -102,22 +102,22 @@ std::unique_ptr<Analyser::Static::Target> SZX::load(const std::string &file_name
|
||||
state->z80.registers.stack_pointer = file.get_le<uint16_t>();
|
||||
state->z80.registers.program_counter = file.get_le<uint16_t>();
|
||||
|
||||
const uint8_t i = file.get8();
|
||||
const uint8_t r = file.get8();
|
||||
const uint8_t i = file.get();
|
||||
const uint8_t r = file.get();
|
||||
state->z80.registers.ir = uint16_t((i << 8) | r);
|
||||
|
||||
state->z80.registers.iff1 = file.get8();
|
||||
state->z80.registers.iff2 = file.get8();
|
||||
state->z80.registers.interrupt_mode = file.get8();
|
||||
state->z80.registers.iff1 = file.get();
|
||||
state->z80.registers.iff2 = file.get();
|
||||
state->z80.registers.interrupt_mode = file.get();
|
||||
|
||||
state->video.half_cycles_since_interrupt = int(file.get_le<uint32_t>()) * 2;
|
||||
|
||||
// SZX includes a count of remaining cycles that interrupt should be asserted for
|
||||
// because it supports hardware that might cause an interrupt other than the display.
|
||||
// This emulator doesn't, so this field can be ignored.
|
||||
[[maybe_unused]] uint8_t remaining_interrupt_cycles = file.get8();
|
||||
[[maybe_unused]] uint8_t remaining_interrupt_cycles = file.get();
|
||||
|
||||
const uint8_t flags = file.get8();
|
||||
const uint8_t flags = file.get();
|
||||
state->z80.execution_state.is_halted = flags & 2;
|
||||
// TODO: bit 0 indicates that the last instruction was an EI, or an invalid
|
||||
// DD or FD. I assume I'm supposed to use that to conclude an interrupt
|
||||
@@ -131,16 +131,16 @@ std::unique_ptr<Analyser::Static::Target> SZX::load(const std::string &file_name
|
||||
case block("AY\0\0"): {
|
||||
// This applies to 48kb machines with AY boxes only. This emulator
|
||||
// doesn't currently support those.
|
||||
[[maybe_unused]] const uint8_t interface_type = file.get8();
|
||||
[[maybe_unused]] const uint8_t interface_type = file.get();
|
||||
|
||||
state->ay.selected_register = file.get8();
|
||||
state->ay.selected_register = file.get();
|
||||
file.read(state->ay.registers, 16);
|
||||
} break;
|
||||
|
||||
// ZXSTRAMPAGE
|
||||
case block("RAMP"): {
|
||||
const uint16_t flags = file.get_le<uint16_t>();
|
||||
const uint8_t page = file.get8();
|
||||
const uint8_t page = file.get();
|
||||
|
||||
std::vector<uint8_t> contents;
|
||||
if(flags & 1) {
|
||||
@@ -182,9 +182,9 @@ std::unique_ptr<Analyser::Static::Target> SZX::load(const std::string &file_name
|
||||
|
||||
// ZXSTSPECREGS
|
||||
case block("SPCR"): {
|
||||
state->video.border_colour = file.get8();
|
||||
state->last_7ffd = file.get8();
|
||||
state->last_1ffd = file.get8();
|
||||
state->video.border_colour = file.get();
|
||||
state->last_7ffd = file.get();
|
||||
state->last_1ffd = file.get();
|
||||
|
||||
// TODO: use last write to FE, at least.
|
||||
} break;
|
||||
|
||||
+17
-17
@@ -26,7 +26,7 @@ std::vector<uint8_t> read_memory(Storage::FileHolder &file, size_t size, bool is
|
||||
size_t cursor = 0;
|
||||
|
||||
while(cursor != size) {
|
||||
const uint8_t next = file.get8();
|
||||
const uint8_t next = file.get();
|
||||
|
||||
// If the next byte definitely doesn't, or can't,
|
||||
// start an ED ED sequence then just take it.
|
||||
@@ -38,7 +38,7 @@ std::vector<uint8_t> read_memory(Storage::FileHolder &file, size_t size, bool is
|
||||
|
||||
// Grab the next byte. If it's not ED then write
|
||||
// both and continue.
|
||||
const uint8_t after = file.get8();
|
||||
const uint8_t after = file.get();
|
||||
if(after != 0xed) {
|
||||
result[cursor] = next;
|
||||
result[cursor+1] = after;
|
||||
@@ -47,8 +47,8 @@ std::vector<uint8_t> read_memory(Storage::FileHolder &file, size_t size, bool is
|
||||
}
|
||||
|
||||
// An ED ED has begun, so grab the RLE sequence.
|
||||
const uint8_t count = file.get8();
|
||||
const uint8_t value = file.get8();
|
||||
const uint8_t count = file.get();
|
||||
const uint8_t value = file.get();
|
||||
|
||||
memset(&result[cursor], value, count);
|
||||
cursor += count;
|
||||
@@ -69,8 +69,8 @@ std::unique_ptr<Analyser::Static::Target> Z80::load(const std::string &file_name
|
||||
result->state = std::unique_ptr<Reflection::Struct>(state);
|
||||
|
||||
// Read version 1 header.
|
||||
state->z80.registers.a = file.get8();
|
||||
state->z80.registers.flags = file.get8();
|
||||
state->z80.registers.a = file.get();
|
||||
state->z80.registers.flags = file.get();
|
||||
state->z80.registers.bc = file.get_le<uint16_t>();
|
||||
state->z80.registers.hl = file.get_le<uint16_t>();
|
||||
state->z80.registers.program_counter = file.get_le<uint16_t>();
|
||||
@@ -80,7 +80,7 @@ std::unique_ptr<Analyser::Static::Target> Z80::load(const std::string &file_name
|
||||
// Bit 7 of R is stored separately; likely this relates to an
|
||||
// optimisation in the Z80 emulator that for some reason was
|
||||
// exported into its file format.
|
||||
const uint8_t raw_misc = file.get8();
|
||||
const uint8_t raw_misc = file.get();
|
||||
const uint8_t misc = (raw_misc == 0xff) ? 1 : raw_misc;
|
||||
state->z80.registers.ir = uint16_t((state->z80.registers.ir & ~0x80) | ((misc&1) << 7));
|
||||
|
||||
@@ -91,8 +91,8 @@ std::unique_ptr<Analyser::Static::Target> Z80::load(const std::string &file_name
|
||||
state->z80.registers.af_dash = file.get_be<uint16_t>(); // Stored A' then F'.
|
||||
state->z80.registers.iy = file.get_le<uint16_t>();
|
||||
state->z80.registers.ix = file.get_le<uint16_t>();
|
||||
state->z80.registers.iff1 = bool(file.get8());
|
||||
state->z80.registers.iff2 = bool(file.get8());
|
||||
state->z80.registers.iff1 = bool(file.get());
|
||||
state->z80.registers.iff2 = bool(file.get());
|
||||
|
||||
// Ignored from the next byte:
|
||||
//
|
||||
@@ -100,7 +100,7 @@ std::unique_ptr<Analyser::Static::Target> Z80::load(const std::string &file_name
|
||||
// bit 3 = 1 => double interrupt frequency (?)
|
||||
// bit 4–5 => video synchronisation (to do with emulation hackery?)
|
||||
// bit 6–7 => joystick type
|
||||
state->z80.registers.interrupt_mode = file.get8() & 3;
|
||||
state->z80.registers.interrupt_mode = file.get() & 3;
|
||||
|
||||
// If the program counter is non-0 then this is a version 1 snapshot,
|
||||
// which means it's definitely a 48k image.
|
||||
@@ -117,7 +117,7 @@ std::unique_ptr<Analyser::Static::Target> Z80::load(const std::string &file_name
|
||||
}
|
||||
|
||||
state->z80.registers.program_counter = file.get_le<uint16_t>();
|
||||
const uint8_t model = file.get8();
|
||||
const uint8_t model = file.get();
|
||||
switch(model) {
|
||||
default: return nullptr;
|
||||
case 0: result->model = Target::Model::FortyEightK; break;
|
||||
@@ -128,10 +128,10 @@ std::unique_ptr<Analyser::Static::Target> Z80::load(const std::string &file_name
|
||||
case 13: result->model = Target::Model::Plus2a; break;
|
||||
}
|
||||
|
||||
state->last_7ffd = file.get8();
|
||||
state->last_7ffd = file.get();
|
||||
|
||||
file.seek(1, SEEK_CUR);
|
||||
if(file.get8() & 0x80) {
|
||||
if(file.get() & 0x80) {
|
||||
// The 'hardware modify' bit, which inexplicably does this:
|
||||
switch(result->model) {
|
||||
default: break;
|
||||
@@ -141,13 +141,13 @@ std::unique_ptr<Analyser::Static::Target> Z80::load(const std::string &file_name
|
||||
}
|
||||
}
|
||||
|
||||
state->ay.selected_register = file.get8();
|
||||
state->ay.selected_register = file.get();
|
||||
file.read(state->ay.registers, 16);
|
||||
|
||||
if(bonus_header_size != 23) {
|
||||
// More Z80, the emulator, lack of encapsulation to deal with here.
|
||||
const auto low_t_state = file.get_le<uint16_t>();
|
||||
const uint16_t high_t_state = file.get8();
|
||||
const uint16_t high_t_state = file.get();
|
||||
switch(result->model) {
|
||||
case Target::Model::SixteenK:
|
||||
case Target::Model::FortyEightK:
|
||||
@@ -169,7 +169,7 @@ std::unique_ptr<Analyser::Static::Target> Z80::load(const std::string &file_name
|
||||
file.seek(3, SEEK_CUR);
|
||||
|
||||
if(bonus_header_size == 55) {
|
||||
state->last_1ffd = file.get8();
|
||||
state->last_1ffd = file.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ std::unique_ptr<Analyser::Static::Target> Z80::load(const std::string &file_name
|
||||
|
||||
while(true) {
|
||||
const auto block_size = file.get_le<uint16_t>();
|
||||
const uint8_t page = file.get8();
|
||||
const uint8_t page = file.get();
|
||||
const auto location = file.tell();
|
||||
if(file.eof()) break;
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ CSW::CSW(const std::string &file_name) {
|
||||
}
|
||||
|
||||
// Check terminating byte.
|
||||
if(file.get8() != 0x1a) throw ErrorNotCSW;
|
||||
if(file.get() != 0x1a) throw ErrorNotCSW;
|
||||
|
||||
// Get version file number.
|
||||
const uint8_t major_version = file.get8();
|
||||
const uint8_t minor_version = file.get8();
|
||||
const uint8_t major_version = file.get();
|
||||
const uint8_t minor_version = file.get();
|
||||
|
||||
// Reject if this is an unknown version.
|
||||
if(major_version > 2 || !major_version || minor_version > 1) throw ErrorNotCSW;
|
||||
@@ -38,23 +38,23 @@ CSW::CSW(const std::string &file_name) {
|
||||
if(major_version == 1) {
|
||||
pulse_.length.clock_rate = file.get_le<uint16_t>();
|
||||
|
||||
if(file.get8() != 1) throw ErrorNotCSW;
|
||||
if(file.get() != 1) throw ErrorNotCSW;
|
||||
compression_type = CompressionType::RLE;
|
||||
|
||||
pulse_.type = (file.get8() & 1) ? Pulse::High : Pulse::Low;
|
||||
pulse_.type = (file.get() & 1) ? Pulse::High : Pulse::Low;
|
||||
|
||||
file.seek(0x20, SEEK_SET);
|
||||
} else {
|
||||
pulse_.length.clock_rate = file.get_le<uint32_t>();
|
||||
file.seek(4, SEEK_CUR); // Skip number of waves.
|
||||
switch(file.get8()) {
|
||||
switch(file.get()) {
|
||||
case 1: compression_type = CompressionType::RLE; break;
|
||||
case 2: compression_type = CompressionType::ZRLE; break;
|
||||
default: throw ErrorNotCSW;
|
||||
}
|
||||
|
||||
pulse_.type = (file.get8() & 1) ? Pulse::High : Pulse::Low;
|
||||
const uint8_t extension_length = file.get8();
|
||||
pulse_.type = (file.get() & 1) ? Pulse::High : Pulse::Low;
|
||||
const uint8_t extension_length = file.get();
|
||||
|
||||
if(file.stats().st_size < 0x34 + extension_length) throw ErrorNotCSW;
|
||||
file.seek(0x34 + extension_length, SEEK_SET);
|
||||
|
||||
@@ -24,7 +24,7 @@ CommodoreTAP::CommodoreTAP(const std::string &file_name) : file_name_(file_name)
|
||||
// const FileType type = is_c16 ? FileType::C16 : FileType::C64;
|
||||
|
||||
// Get and check the file version.
|
||||
const uint8_t version = file.get8();
|
||||
const uint8_t version = file.get();
|
||||
if(version > 2) {
|
||||
throw ErrorNotCommodoreTAP;
|
||||
}
|
||||
@@ -32,8 +32,8 @@ CommodoreTAP::CommodoreTAP(const std::string &file_name) : file_name_(file_name)
|
||||
half_waves_ = version >= 2;
|
||||
|
||||
// Read clock rate-implying bytes.
|
||||
platform_ = Platform(file.get8());
|
||||
const VideoStandard video = VideoStandard(file.get8());
|
||||
platform_ = Platform(file.get());
|
||||
const VideoStandard video = VideoStandard(file.get());
|
||||
file.seek(1, SEEK_CUR);
|
||||
|
||||
const bool double_clock = platform_ != Platform::C16 || !half_waves_; // TODO: is the platform check correct?
|
||||
@@ -85,7 +85,7 @@ Storage::Tape::Pulse CommodoreTAP::Serialiser::next_pulse() {
|
||||
|
||||
const auto read_next_length = [&]() -> bool {
|
||||
uint32_t next_length;
|
||||
const uint8_t next_byte = file_.get8();
|
||||
const uint8_t next_byte = file_.get();
|
||||
if(!updated_layout_ || next_byte > 0) {
|
||||
next_length = uint32_t(next_byte) << 3;
|
||||
} else {
|
||||
|
||||
@@ -17,7 +17,7 @@ OricTAP::OricTAP(const std::string &file_name) : file_name_(file_name) {
|
||||
|
||||
// Check for a sequence of at least three 0x16s followed by a 0x24.
|
||||
while(true) {
|
||||
const uint8_t next = file.get8();
|
||||
const uint8_t next = file.get();
|
||||
if(next != 0x16 && next != 0x24) {
|
||||
throw ErrorNotOricTAP;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ Pulse OricTAP::Serialiser::next_pulse() {
|
||||
phase_counter_++;
|
||||
if(phase_counter_ == 259) { // 256 artificial bytes plus the three in the file = 259
|
||||
while(1) {
|
||||
if(file_.get8() != 0x16) break;
|
||||
if(file_.get() != 0x16) break;
|
||||
}
|
||||
next_phase_ = Header;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ Pulse OricTAP::Serialiser::next_pulse() {
|
||||
// [6, 7]: start address of data
|
||||
// 8: "unused" (on the Oric 1)
|
||||
// [9...]: filename, up to NULL byte
|
||||
next_byte = file_.get8();
|
||||
next_byte = file_.get();
|
||||
|
||||
if(phase_counter_ == 4) data_end_address_ = uint16_t(next_byte << 8);
|
||||
if(phase_counter_ == 5) data_end_address_ |= next_byte;
|
||||
@@ -101,7 +101,7 @@ Pulse OricTAP::Serialiser::next_pulse() {
|
||||
break;
|
||||
|
||||
case Data:
|
||||
next_byte = file_.get8();
|
||||
next_byte = file_.get();
|
||||
phase_counter_++;
|
||||
if(phase_counter_ >= (data_end_address_ - data_start_address_)+1) {
|
||||
if(next_byte == 0x16) {
|
||||
|
||||
@@ -26,11 +26,11 @@ TZX::TZX(const std::string &file_name) : file_name_(file_name) {
|
||||
|
||||
// Check for signature followed by a 0x1a
|
||||
if(!file.check_signature("ZXTape!")) throw ErrorNotTZX;
|
||||
if(file.get8() != 0x1a) throw ErrorNotTZX;
|
||||
if(file.get() != 0x1a) throw ErrorNotTZX;
|
||||
|
||||
// Get version number
|
||||
const uint8_t major_version = file.get8();
|
||||
const uint8_t minor_version = file.get8();
|
||||
const uint8_t major_version = file.get();
|
||||
const uint8_t minor_version = file.get();
|
||||
|
||||
// Reject if an incompatible version
|
||||
if(major_version != 1 || minor_version > 21) throw ErrorNotTZX;
|
||||
@@ -58,7 +58,7 @@ void TZX::Serialiser::reset() {
|
||||
|
||||
void TZX::Serialiser::push_next_pulses() {
|
||||
while(empty()) {
|
||||
const uint8_t chunk_id = file_.get8();
|
||||
const uint8_t chunk_id = file_.get();
|
||||
if(file_.eof()) {
|
||||
set_is_at_end(true);
|
||||
return;
|
||||
@@ -111,7 +111,7 @@ void TZX::Serialiser::get_csw_recording_block() {
|
||||
const auto block_length = file_.get_le<uint32_t>();
|
||||
const auto pause_after_block = file_.get_le<uint16_t>();
|
||||
const auto sampling_rate = file_.get_le<uint32_t, 3>();
|
||||
const auto compression_type = file_.get8();
|
||||
const auto compression_type = file_.get();
|
||||
const auto number_of_compressed_pulses = file_.get_le<uint32_t>();
|
||||
|
||||
std::vector<uint8_t> raw_block = file_.read(block_length - 10);
|
||||
@@ -139,12 +139,12 @@ void TZX::Serialiser::get_generalised_data_block() {
|
||||
const auto pause_after_block = file_.get_le<uint16_t>();
|
||||
|
||||
const auto total_pilot_symbols = file_.get_le<uint32_t>();
|
||||
const uint8_t maximum_pulses_per_pilot_symbol = file_.get8();
|
||||
const uint8_t symbols_in_pilot_table = file_.get8();
|
||||
const uint8_t maximum_pulses_per_pilot_symbol = file_.get();
|
||||
const uint8_t symbols_in_pilot_table = file_.get();
|
||||
|
||||
const auto total_data_symbols = file_.get_le<uint32_t>();
|
||||
const uint8_t maximum_pulses_per_data_symbol = file_.get8();
|
||||
const uint8_t symbols_in_data_table = file_.get8();
|
||||
const uint8_t maximum_pulses_per_data_symbol = file_.get();
|
||||
const uint8_t symbols_in_data_table = file_.get();
|
||||
|
||||
get_generalised_segment(total_pilot_symbols, maximum_pulses_per_pilot_symbol, symbols_in_pilot_table, false);
|
||||
get_generalised_segment(total_data_symbols, maximum_pulses_per_data_symbol, symbols_in_data_table, true);
|
||||
@@ -170,7 +170,7 @@ void TZX::Serialiser::get_generalised_segment(
|
||||
std::vector<Symbol> symbol_table;
|
||||
for(int c = 0; c < number_of_symbols; c++) {
|
||||
Symbol symbol;
|
||||
symbol.flags = file_.get8();
|
||||
symbol.flags = file_.get();
|
||||
for(int ic = 0; ic < max_pulses_per_symbol; ic++) {
|
||||
symbol.pulse_lengths.push_back(file_.get_le<uint16_t>());
|
||||
}
|
||||
@@ -192,7 +192,7 @@ void TZX::Serialiser::get_generalised_segment(
|
||||
symbol_value = stream.next(bits);
|
||||
count = 1;
|
||||
} else {
|
||||
symbol_value = file_.get8();
|
||||
symbol_value = file_.get();
|
||||
count = file_.get_le<uint16_t>();
|
||||
}
|
||||
if(symbol_value > number_of_symbols) {
|
||||
@@ -231,7 +231,7 @@ void TZX::Serialiser::get_standard_speed_data_block() {
|
||||
data_block.data.data_length = file_.get_le<uint16_t>();
|
||||
if(!data_block.data.data_length) return;
|
||||
|
||||
const uint8_t first_byte = file_.get8();
|
||||
const uint8_t first_byte = file_.get();
|
||||
data_block.length_of_pilot_tone = (first_byte < 128) ? 8063 : 3223;
|
||||
file_.seek(-1, SEEK_CUR);
|
||||
|
||||
@@ -246,7 +246,7 @@ void TZX::Serialiser::get_turbo_speed_data_block() {
|
||||
data_block.data.length_of_zero_bit_pulse = file_.get_le<uint16_t>();
|
||||
data_block.data.length_of_one_bit_pulse = file_.get_le<uint16_t>();
|
||||
data_block.length_of_pilot_tone = file_.get_le<uint16_t>();
|
||||
data_block.data.number_of_bits_in_final_byte = file_.get8();
|
||||
data_block.data.number_of_bits_in_final_byte = file_.get();
|
||||
data_block.data.pause_after_block = file_.get_le<uint16_t>();
|
||||
data_block.data.data_length = file_.get_le<uint32_t, 3>();
|
||||
|
||||
@@ -267,7 +267,7 @@ void TZX::Serialiser::get_data_block(const DataBlock &data_block) {
|
||||
void TZX::Serialiser::get_data(const Data &data) {
|
||||
// Output data.
|
||||
for(decltype(data.data_length) c = 0; c < data.data_length; c++) {
|
||||
uint8_t next_byte = file_.get8();
|
||||
uint8_t next_byte = file_.get();
|
||||
|
||||
auto bits = (c != data.data_length-1) ? 8 : data.number_of_bits_in_final_byte;
|
||||
while(bits--) {
|
||||
@@ -294,7 +294,7 @@ void TZX::Serialiser::get_pure_data_block() {
|
||||
Data data;
|
||||
data.length_of_zero_bit_pulse = file_.get_le<uint16_t>();
|
||||
data.length_of_one_bit_pulse = file_.get_le<uint16_t>();
|
||||
data.number_of_bits_in_final_byte = file_.get8();
|
||||
data.number_of_bits_in_final_byte = file_.get();
|
||||
data.pause_after_block = file_.get_le<uint16_t>();
|
||||
data.data_length = file_.get_le<uint32_t, 3>();
|
||||
|
||||
@@ -304,7 +304,7 @@ void TZX::Serialiser::get_pure_data_block() {
|
||||
void TZX::Serialiser::get_direct_recording_block() {
|
||||
const Storage::Time length_per_sample(unsigned(file_.get_le<uint16_t>()), StandardTZXClock);
|
||||
const auto pause_after_block = file_.get_le<uint16_t>();
|
||||
uint8_t used_bits_in_final_byte = file_.get8();
|
||||
uint8_t used_bits_in_final_byte = file_.get();
|
||||
const auto length_of_data = file_.get_le<uint32_t, 3>();
|
||||
|
||||
if(used_bits_in_final_byte < 1) used_bits_in_final_byte = 1;
|
||||
@@ -314,7 +314,7 @@ void TZX::Serialiser::get_direct_recording_block() {
|
||||
unsigned int bits_at_level = 0;
|
||||
uint8_t level = 0;
|
||||
for(std::size_t bit = 0; bit < (length_of_data - 1) * 8 + used_bits_in_final_byte; ++bit) {
|
||||
if(!(bit&7)) byte = file_.get8();
|
||||
if(!(bit&7)) byte = file_.get();
|
||||
if(!bit) level = byte&0x80;
|
||||
|
||||
if((byte&0x80) != level) {
|
||||
@@ -332,7 +332,7 @@ void TZX::Serialiser::get_direct_recording_block() {
|
||||
}
|
||||
|
||||
void TZX::Serialiser::get_pulse_sequence() {
|
||||
uint8_t number_of_pulses = file_.get8();
|
||||
uint8_t number_of_pulses = file_.get();
|
||||
while(number_of_pulses--) {
|
||||
post_pulse(file_.get_le<uint16_t>());
|
||||
}
|
||||
@@ -349,7 +349,7 @@ void TZX::Serialiser::get_pause() {
|
||||
|
||||
void TZX::Serialiser::get_set_signal_level() {
|
||||
file_.seek(4, SEEK_CUR);
|
||||
const uint8_t level = file_.get8();
|
||||
const uint8_t level = file_.get();
|
||||
current_level_ = !!level;
|
||||
}
|
||||
|
||||
@@ -362,12 +362,12 @@ void TZX::Serialiser::get_kansas_city_block() {
|
||||
uint16_t pulse_durations[2];
|
||||
pulse_durations[0] = file_.get_le<uint16_t>();
|
||||
pulse_durations[1] = file_.get_le<uint16_t>();
|
||||
const uint8_t packed_pulse_counts = file_.get8();
|
||||
const uint8_t packed_pulse_counts = file_.get();
|
||||
const unsigned int pulse_counts[2] = {
|
||||
unsigned((((packed_pulse_counts >> 4) - 1) & 15) + 1),
|
||||
unsigned((((packed_pulse_counts & 15) - 1) & 15) + 1)
|
||||
};
|
||||
const uint8_t padding_flags = file_.get8();
|
||||
const uint8_t padding_flags = file_.get();
|
||||
|
||||
const unsigned int number_of_leading_pulses = ((padding_flags >> 6)&3) * pulse_counts[(padding_flags >> 5) & 1];
|
||||
const unsigned int leading_pulse_length = pulse_durations[(padding_flags >> 5) & 1];
|
||||
@@ -384,7 +384,7 @@ void TZX::Serialiser::get_kansas_city_block() {
|
||||
while(block_length--) {
|
||||
post_pulses(number_of_leading_pulses, leading_pulse_length);
|
||||
|
||||
uint8_t new_byte = file_.get8();
|
||||
uint8_t new_byte = file_.get();
|
||||
int bits = 8;
|
||||
if(padding_flags & 1) {
|
||||
// Output MSB first.
|
||||
@@ -437,7 +437,7 @@ void TZX::Serialiser::post_pulse(const Storage::Time &time) {
|
||||
// MARK: - Flow control; currently ignored
|
||||
|
||||
void TZX::Serialiser::ignore_group_start() {
|
||||
const uint8_t length = file_.get8();
|
||||
const uint8_t length = file_.get();
|
||||
file_.seek(length, SEEK_CUR);
|
||||
}
|
||||
|
||||
@@ -483,13 +483,13 @@ void TZX::Serialiser::ignore_custom_info_block() {
|
||||
// MARK: - Messaging
|
||||
|
||||
void TZX::Serialiser::ignore_text_description() {
|
||||
const uint8_t length = file_.get8();
|
||||
const uint8_t length = file_.get();
|
||||
file_.seek(length, SEEK_CUR);
|
||||
}
|
||||
|
||||
void TZX::Serialiser::ignore_message_block() {
|
||||
const uint8_t time_for_display = file_.get8();
|
||||
const uint8_t length = file_.get8();
|
||||
const uint8_t time_for_display = file_.get();
|
||||
const uint8_t length = file_.get();
|
||||
file_.seek(length, SEEK_CUR);
|
||||
(void)time_for_display;
|
||||
}
|
||||
@@ -501,7 +501,7 @@ void TZX::Serialiser::ignore_archive_info() {
|
||||
|
||||
void TZX::Serialiser::get_hardware_type() {
|
||||
// TODO: pick a way to retain and communicate this.
|
||||
const uint8_t number_of_machines = file_.get8();
|
||||
const uint8_t number_of_machines = file_.get();
|
||||
file_.seek(number_of_machines * 3, SEEK_CUR);
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ void PRG::Serialiser::get_next_output_token() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
output_byte_ = file_.get8();
|
||||
output_byte_ = file_.get();
|
||||
if(file_.eof()) {
|
||||
output_byte_ = check_digit_;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ Pulse ZXSpectrumTAP::Serialiser::next_pulse() {
|
||||
read_next_block();
|
||||
}
|
||||
} else {
|
||||
data_byte_ = file_.get8();
|
||||
data_byte_ = file_.get();
|
||||
}
|
||||
}
|
||||
} break;
|
||||
@@ -122,7 +122,7 @@ void ZXSpectrumTAP::Serialiser::read_next_block() {
|
||||
phase_ = Phase::Gap;
|
||||
} else {
|
||||
block_length_ = file_.get_le<uint16_t>();
|
||||
data_byte_ = block_type_ = file_.get8();
|
||||
data_byte_ = block_type_ = file_.get();
|
||||
phase_ = Phase::PilotTone;
|
||||
}
|
||||
distance_into_phase_ = 0;
|
||||
|
||||
Reference in New Issue
Block a user