1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-04-22 09:37:21 +00:00

Reduce redundant types.

This commit is contained in:
Thomas Harte 2025-02-19 00:09:57 -05:00
parent 79671890c5
commit 6aff0b74cd
12 changed files with 58 additions and 58 deletions

View File

@ -34,17 +34,17 @@ Disk2MG::DiskOrMassStorageDevice Disk2MG::open(const std::string &file_name) {
const auto creator = file.read(4);
// Grab the header size, version number and image format.
const uint16_t header_size = file.get_le<uint16_t>();
const uint16_t version = file.get_le<uint16_t>();
const uint32_t format = file.get_le<uint32_t>();
const uint32_t flags = file.get_le<uint32_t>();
const auto header_size = file.get_le<uint16_t>();
const auto version = file.get_le<uint16_t>();
const auto format = file.get_le<uint32_t>();
const auto flags = file.get_le<uint32_t>();
// Skip the number of ProDOS blocks; this is surely implicit from the data size?
file.seek(4, SEEK_CUR);
// Get the offset and size of the disk image data.
const uint32_t data_start = file.get_le<uint32_t>();
uint32_t data_size = file.get_le<uint32_t>();
const auto data_start = file.get_le<uint32_t>();
auto data_size = file.get_le<uint32_t>();
// Correct for the Sweet 16 emulator, which writes broken 2MGs.
if(!data_size && !memcmp(creator.data(), "WOOF", 4)) {

View File

@ -57,7 +57,7 @@ DMK::DMK(const std::string &file_name) :
// Skip to the end of the header and check that this is
// "in the emulator's native format".
file_.seek(0xc, SEEK_SET);
uint32_t format = file_.get_le<uint32_t>();
const auto format = file_.get_le<uint32_t>();
if(format) throw Error::InvalidFormat;
}

View File

@ -24,7 +24,7 @@ FAT12::FAT12(const std::string &file_name) :
file_.seek(11, SEEK_SET);
sector_size_ = file_.get_le<uint16_t>();
file_.seek(19, SEEK_SET);
const uint16_t total_sectors = file_.get_le<uint16_t>();
const auto total_sectors = file_.get_le<uint16_t>();
file_.seek(24, SEEK_SET);
sector_count_ = file_.get_le<uint16_t>();
head_count_ = file_.get_le<uint16_t>();

View File

@ -41,7 +41,7 @@ std::unique_ptr<Track> G64::track_at_position(Track::Address address) {
file_.seek(long((address.position.as_half() * 4) + 0xc), SEEK_SET);
// read the track offset
const uint32_t track_offset = file_.get_le<uint32_t>();
const auto track_offset = file_.get_le<uint32_t>();
// if the track offset is zero, this track doesn't exist, so...
if(!track_offset) return nullptr;
@ -50,7 +50,7 @@ std::unique_ptr<Track> G64::track_at_position(Track::Address address) {
file_.seek(long(track_offset), SEEK_SET);
// get the real track length
const uint16_t track_length = file_.get_le<uint16_t>();
const auto track_length = file_.get_le<uint16_t>();
// grab the byte contents of this track
const std::vector<uint8_t> track_contents = file_.read(track_length);
@ -59,7 +59,7 @@ std::unique_ptr<Track> G64::track_at_position(Track::Address address) {
file_.seek(long((address.position.as_half() * 4) + 0x15c), SEEK_SET);
// read the speed zone offsrt
const uint32_t speed_zone_offset = file_.get_le<uint32_t>();
const auto speed_zone_offset = file_.get_le<uint32_t>();
// if the speed zone is not constant, create a track based on the whole table; otherwise create one that's constant
if(speed_zone_offset > 3) {

View File

@ -45,8 +45,8 @@ uint16_t HFE::seek_track(Track::Address address) {
// based on an assumption of two heads.
file_.seek(track_list_offset_ + address.position.as_int() * 4, SEEK_SET);
long track_offset = long(file_.get_le<uint16_t>()) << 9; // Track offset, in units of 512 bytes.
uint16_t track_length = file_.get_le<uint16_t>(); // Track length, in bytes, containing both the front and back track.
long track_offset = long(file_.get_le<uint16_t>()) << 9; // Track offset, in units of 512 bytes.
const auto track_length = file_.get_le<uint16_t>(); // Track length, in bytes, containing both the front and back track.
file_.seek(track_offset, SEEK_SET);
if(address.head) file_.seek(256, SEEK_CUR);

View File

@ -43,9 +43,9 @@ IPF::IPF(const std::string &file_name) : file_(file_name) {
// plus the other fields that'll be necessary to convert them into flux on demand later.
while(true) {
const auto start_of_block = file_.tell();
const uint32_t type = file_.get_be<uint32_t>();
uint32_t length = file_.get_be<uint32_t>(); // Can't be const because of the dumb encoding of DATA blocks.
[[maybe_unused]] const uint32_t crc = file_.get_be<uint32_t>();
const auto type = file_.get_be<uint32_t>();
auto length = file_.get_be<uint32_t>(); // Can't be const because of the dumb encoding of DATA blocks.
[[maybe_unused]] const auto crc = file_.get_be<uint32_t>();
if(file_.eof()) break;
// Sanity check: the first thing in a file should be the CAPS record.
@ -71,7 +71,7 @@ IPF::IPF(const std::string &file_name) : file_(file_name) {
// aren't that interesting.
// Make sure this is a floppy disk.
const uint32_t media_type = file_.get_be<uint32_t>();
const auto media_type = file_.get_be<uint32_t>();
if(media_type != 1) {
throw Error::InvalidFormat;
}
@ -117,8 +117,8 @@ IPF::IPF(const std::string &file_name) : file_(file_name) {
case block("IMGE"): {
// Get track location.
const uint32_t track = file_.get_be<uint32_t>();
const uint32_t side = file_.get_be<uint32_t>();
const auto track = file_.get_be<uint32_t>();
const auto side = file_.get_be<uint32_t>();
const Track::Address address{int(side), HeadPosition(int(track))};
// Hence generate a TrackDescription.
@ -147,7 +147,7 @@ IPF::IPF(const std::string &file_name) : file_(file_name) {
// For some reason the authors decided to introduce another primary key,
// in addition to that which naturally exists of (track, side). So set up
// a mapping from the one to the other.
const uint32_t data_key = file_.get_be<uint32_t>();
const auto data_key = file_.get_be<uint32_t>();
tracks_by_data_key.emplace(data_key, address);
} break;
@ -160,7 +160,7 @@ IPF::IPF(const std::string &file_name) : file_(file_name) {
// position for this track.
//
// Assumed here: DATA records will come after corresponding IMGE records.
const uint32_t data_key = file_.get_be<uint32_t>();
const auto data_key = file_.get_be<uint32_t>();
const auto pair = tracks_by_data_key.find(data_key);
if(pair == tracks_by_data_key.end()) {
break;
@ -231,7 +231,7 @@ std::unique_ptr<Track> IPF::track_at_position([[maybe_unused]] Track::Address ad
}
block.is_mfm = file_.get_be<uint32_t>() == 1;
const uint32_t flags = file_.get_be<uint32_t>();
const auto flags = file_.get_be<uint32_t>();
block.has_forward_gap = flags & 1;
block.has_backwards_gap = flags & 2;
block.data_unit_is_bits = flags & 4;

View File

@ -422,7 +422,7 @@ STX::STX(const std::string &file_name) : file_(file_name) {
head_count_ = 1;
while(true) {
const long offset = file_.tell();
const uint32_t size = file_.get_le<uint32_t>();
const auto size = file_.get_le<uint32_t>();
if(file_.eof()) break;
// Skip fields other than track position, then fill in table position and advance.
@ -460,9 +460,9 @@ std::unique_ptr<Track> STX::track_at_position(Track::Address address) {
file_.seek(offset_by_track_[track_index] + 4, SEEK_SET);
// Grab the track description.
const uint32_t fuzzy_size = file_.get_le<uint32_t>();
const uint16_t sector_count = file_.get_le<uint16_t>();
const uint16_t flags = file_.get_le<uint16_t>();
const auto fuzzy_size = file_.get_le<uint32_t>();
const auto sector_count = file_.get_le<uint16_t>();
const auto flags = file_.get_le<uint16_t>();
const size_t track_length = file_.get_le<uint16_t>();
file_.seek(2, SEEK_CUR); // Skip track type; despite being named, it's apparently unused.
@ -520,10 +520,10 @@ std::unique_ptr<Track> STX::track_at_position(Track::Address address) {
// bit
if(flags & 0x80) {
first_sync = file_.get_le<uint16_t>();
const uint16_t image_size = file_.get_le<uint16_t>();
const auto image_size = file_.get_le<uint16_t>();
track_data = file_.read(image_size);
} else {
const uint16_t image_size = file_.get_le<uint16_t>();
const auto image_size = file_.get_le<uint16_t>();
track_data = file_.read(image_size);
}
}

View File

@ -41,7 +41,7 @@ WOZ::WOZ(const std::string &file_name) :
type_ = isWoz2 ? Type::WOZ2 : Type::WOZ1;
// Get the file's CRC32.
const uint32_t crc = file_.get_le<uint32_t>();
const auto crc = file_.get_le<uint32_t>();
// Get the collection of all data that contributes to the CRC.
post_crc_contents_ = file_.read(size_t(file_.stats().st_size - 12));
@ -58,8 +58,8 @@ WOZ::WOZ(const std::string &file_name) :
// Parse all chunks up front.
bool has_tmap = false;
while(true) {
const uint32_t chunk_id = file_.get_le<uint32_t>();
const uint32_t chunk_size = file_.get_le<uint32_t>();
const auto chunk_id = file_.get_le<uint32_t>();
const auto chunk_size = file_.get_le<uint32_t>();
if(file_.eof()) break;
long end_of_chunk = file_.tell() + long(chunk_size);
@ -173,7 +173,7 @@ std::unique_ptr<Track> WOZ::track_at_position(Track::Address address) {
default:
case Type::WOZ2: {
// In WOZ 2 an extra level of indirection allows for variable track sizes.
const uint16_t starting_block = file_.get_le<uint16_t>();
const auto starting_block = file_.get_le<uint16_t>();
file_.seek(2, SEEK_CUR); // Skip the block count; the amount of data to read is implied by the number of bits.
number_of_bits = file_.get_le<uint32_t>();

View File

@ -73,8 +73,8 @@ std::unique_ptr<Analyser::Static::Target> SZX::load(const std::string &file_name
// Now parse all included blocks.
while(true) {
const uint32_t blockID = file.get_le<uint32_t>();
const uint32_t size = file.get_le<uint32_t>();
const auto blockID = file.get_le<uint32_t>();
const auto size = file.get_le<uint32_t>();
if(file.eof()) break;
const auto location = file.tell();

View File

@ -111,7 +111,7 @@ std::unique_ptr<Analyser::Static::Target> Z80::load(const std::string &file_name
}
// This was a version 1 or 2 snapshot, so keep going...
const uint16_t bonus_header_size = file.get_le<uint16_t>();
const auto bonus_header_size = file.get_le<uint16_t>();
if(bonus_header_size != 23 && bonus_header_size != 54 && bonus_header_size != 55) {
return nullptr;
}
@ -146,7 +146,7 @@ std::unique_ptr<Analyser::Static::Target> Z80::load(const std::string &file_name
if(bonus_header_size != 23) {
// More Z80, the emulator, lack of encapsulation to deal with here.
const uint16_t low_t_state = file.get_le<uint16_t>();
const auto low_t_state = file.get_le<uint16_t>();
const uint16_t high_t_state = file.get8();
switch(result->model) {
case Target::Model::SixteenK:
@ -181,7 +181,7 @@ std::unique_ptr<Analyser::Static::Target> Z80::load(const std::string &file_name
}
while(true) {
const uint16_t block_size = file.get_le<uint16_t>();
const auto block_size = file.get_le<uint16_t>();
const uint8_t page = file.get8();
const auto location = file.tell();
if(file.eof()) break;

View File

@ -114,7 +114,7 @@ CAS::CAS(const std::string &file_name) {
} else {
// Raw data appears now. Grab its length and keep going.
file.seek(header_position + 8, SEEK_SET);
const uint16_t length = file.get_le<uint16_t>();
const auto length = file.get_le<uint16_t>();
file.seek(header_position + 8, SEEK_SET);
chunks_.emplace_back(false, false, file.read(size_t(length) + 2));
@ -136,8 +136,8 @@ CAS::CAS(const std::string &file_name) {
// Get the start and end addresses in order to figure out how much data
// is here.
file.seek(header_position + 8, SEEK_SET);
const uint16_t start_address = file.get_le<uint16_t>();
const uint16_t end_address = file.get_le<uint16_t>();
const auto start_address = file.get_le<uint16_t>();
const auto end_address = file.get_le<uint16_t>();
file.seek(header_position + 8, SEEK_SET);
const auto length = end_address - start_address + 1;
@ -152,7 +152,7 @@ CAS::CAS(const std::string &file_name) {
file.seek(header_position + 8, SEEK_SET);
uint16_t address = 0x8001; // the BASIC start address.
while(true) {
const uint16_t next_line_address = file.get_le<uint16_t>();
const auto next_line_address = file.get_le<uint16_t>();
if(!next_line_address || file.eof()) break;
file.seek(next_line_address - address - 2, SEEK_CUR);
address = next_line_address;

View File

@ -134,15 +134,15 @@ void TZX::Serialiser::get_csw_recording_block() {
}
void TZX::Serialiser::get_generalised_data_block() {
const uint32_t block_length = file_.get_le<uint32_t>();
const auto block_length = file_.get_le<uint32_t>();
const long endpoint = file_.tell() + long(block_length);
const uint16_t pause_after_block = file_.get_le<uint16_t>();
const auto pause_after_block = file_.get_le<uint16_t>();
const uint32_t total_pilot_symbols = file_.get_le<uint32_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 uint32_t total_data_symbols = file_.get_le<uint32_t>();
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();
@ -284,8 +284,8 @@ void TZX::Serialiser::get_data(const Data &data) {
}
void TZX::Serialiser::get_pure_tone_data_block() {
const uint16_t length_of_pulse = file_.get_le<uint16_t>();
const uint16_t nunber_of_pulses = file_.get_le<uint16_t>();
const auto length_of_pulse = file_.get_le<uint16_t>();
const auto nunber_of_pulses = file_.get_le<uint16_t>();
post_pulses(nunber_of_pulses, length_of_pulse);
}
@ -339,7 +339,7 @@ void TZX::Serialiser::get_pulse_sequence() {
}
void TZX::Serialiser::get_pause() {
const uint16_t duration = file_.get_le<uint16_t>();
const auto duration = file_.get_le<uint16_t>();
if(!duration) {
// TODO (maybe): post a 'pause the tape' suggestion
} else {
@ -354,11 +354,11 @@ void TZX::Serialiser::get_set_signal_level() {
}
void TZX::Serialiser::get_kansas_city_block() {
uint32_t block_length = file_.get_le<uint32_t>();
auto block_length = file_.get_le<uint32_t>();
const uint16_t pause_after_block = file_.get_le<uint16_t>();
const uint16_t pilot_pulse_duration = file_.get_le<uint16_t>();
const uint16_t pilot_length = file_.get_le<uint16_t>();
const auto pause_after_block = file_.get_le<uint16_t>();
const auto pilot_pulse_duration = file_.get_le<uint16_t>();
const auto pilot_length = file_.get_le<uint16_t>();
uint16_t pulse_durations[2];
pulse_durations[0] = file_.get_le<uint16_t>();
pulse_durations[1] = file_.get_le<uint16_t>();
@ -445,12 +445,12 @@ void TZX::Serialiser::ignore_group_end() {
}
void TZX::Serialiser::ignore_jump_to_block() {
const uint16_t target = file_.get_le<uint16_t>();
const auto target = file_.get_le<uint16_t>();
(void)target;
}
void TZX::Serialiser::ignore_loop_start() {
const uint16_t number_of_repetitions = file_.get_le<uint16_t>();
const auto number_of_repetitions = file_.get_le<uint16_t>();
(void)number_of_repetitions;
}
@ -458,7 +458,7 @@ void TZX::Serialiser::ignore_loop_end() {
}
void TZX::Serialiser::ignore_call_sequence() {
const uint16_t number_of_entries = file_.get_le<uint16_t>();
const auto number_of_entries = file_.get_le<uint16_t>();
file_.seek(number_of_entries * sizeof(uint16_t), SEEK_CUR);
}
@ -466,7 +466,7 @@ void TZX::Serialiser::ignore_return_from_sequence() {
}
void TZX::Serialiser::ignore_select_block() {
const uint16_t length_of_block = file_.get_le<uint16_t>();
const auto length_of_block = file_.get_le<uint16_t>();
file_.seek(length_of_block, SEEK_CUR);
}
@ -476,7 +476,7 @@ void TZX::Serialiser::ignore_stop_tape_if_in_48kb_mode() {
void TZX::Serialiser::ignore_custom_info_block() {
file_.seek(0x10, SEEK_CUR);
const uint32_t length = file_.get_le<uint32_t>();
const auto length = file_.get_le<uint32_t>();
file_.seek(length, SEEK_CUR);
}
@ -495,7 +495,7 @@ void TZX::Serialiser::ignore_message_block() {
}
void TZX::Serialiser::ignore_archive_info() {
const uint16_t length = file_.get_le<uint16_t>();
const auto length = file_.get_le<uint16_t>();
file_.seek(length, SEEK_CUR);
}