1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-26 19:17:52 +00:00

Begins this project's conversion to functional-style casts.

This commit is contained in:
Thomas Harte
2017-10-03 22:04:15 -04:00
parent ea5023ac26
commit edb9fd301c
27 changed files with 93 additions and 93 deletions
+4 -4
View File
@@ -25,8 +25,8 @@ CSW::CSW(const char *file_name) :
if(fgetc(file_) != 0x1a) throw ErrorNotCSW;
// Get version file number.
uint8_t major_version = (uint8_t)fgetc(file_);
uint8_t minor_version = (uint8_t)fgetc(file_);
uint8_t major_version = static_cast<uint8_t>(fgetc(file_));
uint8_t minor_version = static_cast<uint8_t>(fgetc(file_));
// Reject if this is an unknown version.
if(major_version > 2 || !major_version || minor_version > 1) throw ErrorNotCSW;
@@ -52,7 +52,7 @@ CSW::CSW(const char *file_name) :
}
pulse_.type = (fgetc(file_) & 1) ? Pulse::High : Pulse::Low;
uint8_t extension_length = (uint8_t)fgetc(file_);
uint8_t extension_length = static_cast<uint8_t>(fgetc(file_));
if(file_stats_.st_size < 0x34 + extension_length) throw ErrorNotCSW;
fseek(file_, 0x34 + extension_length, SEEK_SET);
@@ -84,7 +84,7 @@ CSW::CSW(const char *file_name) :
uint8_t CSW::get_next_byte() {
switch(compression_type_) {
case RLE: return (uint8_t)fgetc(file_);
case RLE: return static_cast<uint8_t>(fgetc(file_));
case ZRLE: {
if(source_data_pointer_ == source_data_.size()) return 0xff;
uint8_t result = source_data_[source_data_pointer_];
+1 -1
View File
@@ -64,7 +64,7 @@ Storage::Tape::Tape::Pulse CommodoreTAP::virtual_get_next_pulse()
if(current_pulse_.type == Pulse::High)
{
uint32_t next_length;
uint8_t next_byte = (uint8_t)fgetc(file_);
uint8_t next_byte = static_cast<uint8_t>(fgetc(file_));
if(!updated_layout_ || next_byte > 0)
{
next_length = (uint32_t)next_byte << 3;
+2 -2
View File
@@ -69,7 +69,7 @@ Tape::Pulse OricTAP::virtual_get_next_pulse()
// [6, 7]: start address of data
// 8: "unused" (on the Oric 1)
// [9...]: filename, up to NULL byte
next_byte = (uint8_t)fgetc(file_);
next_byte = static_cast<uint8_t>(fgetc(file_));
if(phase_counter_ == 4) data_end_address_ = (uint16_t)(next_byte << 8);
if(phase_counter_ == 5) data_end_address_ |= next_byte;
@@ -96,7 +96,7 @@ Tape::Pulse OricTAP::virtual_get_next_pulse()
break;
case Data:
next_byte = (uint8_t)fgetc(file_);
next_byte = static_cast<uint8_t>(fgetc(file_));
phase_counter_++;
if(phase_counter_ >= (data_end_address_ - data_start_address_)+1)
{
+19 -19
View File
@@ -27,8 +27,8 @@ TZX::TZX(const char *file_name) :
if(fgetc(file_) != 0x1a) throw ErrorNotTZX;
// Get version number
uint8_t major_version = (uint8_t)fgetc(file_);
uint8_t minor_version = (uint8_t)fgetc(file_);
uint8_t major_version = static_cast<uint8_t>(fgetc(file_));
uint8_t minor_version = static_cast<uint8_t>(fgetc(file_));
// Reject if an incompatible version
if(major_version != 1 || minor_version > 20) throw ErrorNotTZX;
@@ -50,7 +50,7 @@ void TZX::virtual_reset() {
void TZX::get_next_pulses() {
while(empty()) {
uint8_t chunk_id = (uint8_t)fgetc(file_);
uint8_t chunk_id = static_cast<uint8_t>(fgetc(file_));
if(feof(file_)) {
set_is_at_end(true);
return;
@@ -95,12 +95,12 @@ void TZX::get_generalised_data_block() {
uint16_t pause_after_block = fgetc16le();
uint32_t total_pilot_symbols = fgetc32le();
uint8_t maximum_pulses_per_pilot_symbol = (uint8_t)fgetc(file_);
uint8_t symbols_in_pilot_table = (uint8_t)fgetc(file_);
uint8_t maximum_pulses_per_pilot_symbol = static_cast<uint8_t>(fgetc(file_));
uint8_t symbols_in_pilot_table = static_cast<uint8_t>(fgetc(file_));
uint32_t total_data_symbols = fgetc32le();
uint8_t maximum_pulses_per_data_symbol = (uint8_t)fgetc(file_);
uint8_t symbols_in_data_table = (uint8_t)fgetc(file_);
uint8_t maximum_pulses_per_data_symbol = static_cast<uint8_t>(fgetc(file_));
uint8_t symbols_in_data_table = static_cast<uint8_t>(fgetc(file_));
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);
@@ -121,7 +121,7 @@ void TZX::get_generalised_segment(uint32_t output_symbols, uint8_t max_pulses_pe
std::vector<Symbol> symbol_table;
for(int c = 0; c < number_of_symbols; c++) {
Symbol symbol;
symbol.flags = (uint8_t)fgetc(file_);
symbol.flags = static_cast<uint8_t>(fgetc(file_));
for(int ic = 0; ic < max_pulses_per_symbol; ic++) {
symbol.pulse_lengths.push_back(fgetc16le());
}
@@ -143,7 +143,7 @@ void TZX::get_generalised_segment(uint32_t output_symbols, uint8_t max_pulses_pe
symbol_value = stream.get_bits(bits);
count = 1;
} else {
symbol_value = (uint8_t)fgetc(file_);
symbol_value = static_cast<uint8_t>(fgetc(file_));
count = fgetc16le();
}
if(symbol_value > number_of_symbols) {
@@ -182,7 +182,7 @@ void TZX::get_standard_speed_data_block() {
data_block.data.data_length = fgetc16le();
if(!data_block.data.data_length) return;
uint8_t first_byte = (uint8_t)fgetc(file_);
uint8_t first_byte = static_cast<uint8_t>(fgetc(file_));
data_block.length_of_pilot_tone = (first_byte < 128) ? 8063 : 3223;
ungetc(first_byte, file_);
@@ -197,7 +197,7 @@ void TZX::get_turbo_speed_data_block() {
data_block.data.length_of_zero_bit_pulse = fgetc16le();
data_block.data.length_of_one_bit_pulse = fgetc16le();
data_block.length_of_pilot_tone = fgetc16le();
data_block.data.number_of_bits_in_final_byte = (uint8_t)fgetc(file_);
data_block.data.number_of_bits_in_final_byte = static_cast<uint8_t>(fgetc(file_));
data_block.data.pause_after_block = fgetc16le();
data_block.data.data_length = fgetc16le();
data_block.data.data_length |= (long)(fgetc(file_) << 16);
@@ -221,7 +221,7 @@ void TZX::get_data_block(const DataBlock &data_block) {
void TZX::get_data(const Data &data) {
// Output data.
for(unsigned int c = 0; c < data.data_length; c++) {
uint8_t next_byte = (uint8_t)fgetc(file_);
uint8_t next_byte = static_cast<uint8_t>(fgetc(file_));
unsigned int bits = (c != data.data_length-1) ? 8 : data.number_of_bits_in_final_byte;
while(bits--) {
@@ -248,7 +248,7 @@ void TZX::get_pure_data_block() {
Data data;
data.length_of_zero_bit_pulse = fgetc16le();
data.length_of_one_bit_pulse = fgetc16le();
data.number_of_bits_in_final_byte = (uint8_t)fgetc(file_);
data.number_of_bits_in_final_byte = static_cast<uint8_t>(fgetc(file_));
data.pause_after_block = fgetc16le();
data.data_length = fgetc16le();
data.data_length |= (long)(fgetc(file_) << 16);
@@ -257,7 +257,7 @@ void TZX::get_pure_data_block() {
}
void TZX::get_pulse_sequence() {
uint8_t number_of_pulses = (uint8_t)fgetc(file_);
uint8_t number_of_pulses = static_cast<uint8_t>(fgetc(file_));
while(number_of_pulses--) {
post_pulse(fgetc16le());
}
@@ -297,7 +297,7 @@ void TZX::post_pulse(const Storage::Time &time) {
void TZX::ignore_group_start() {
printf("Ignoring TZX group\n");
uint8_t length = (uint8_t)fgetc(file_);
uint8_t length = static_cast<uint8_t>(fgetc(file_));
fseek(file_, length, SEEK_CUR);
}
@@ -336,21 +336,21 @@ void TZX::ignore_select_block() {
#pragma mark - Messaging
void TZX::ignore_text_description() {
uint8_t length = (uint8_t)fgetc(file_);
uint8_t length = static_cast<uint8_t>(fgetc(file_));
fseek(file_, length, SEEK_CUR);
printf("Ignoring TZX text description\n");
}
void TZX::ignore_message_block() {
__unused uint8_t time_for_display = (uint8_t)fgetc(file_);
uint8_t length = (uint8_t)fgetc(file_);
__unused uint8_t time_for_display = static_cast<uint8_t>(fgetc(file_));
uint8_t length = static_cast<uint8_t>(fgetc(file_));
fseek(file_, length, SEEK_CUR);
printf("Ignoring TZX message\n");
}
void TZX::get_hardware_type() {
// TODO: pick a way to retain and communicate this.
uint8_t number_of_machines = (uint8_t)fgetc(file_);
uint8_t number_of_machines = static_cast<uint8_t>(fgetc(file_));
fseek(file_, number_of_machines * 3, SEEK_CUR);
printf("Ignoring TZX hardware types (%d)\n", number_of_machines);
}
+2 -2
View File
@@ -172,7 +172,7 @@ void PRG::get_next_output_token()
// the first nine bytes are countdown; the high bit is set if this is a header
if(byte_offset < countdown_bytes)
{
output_byte_ = (uint8_t)(countdown_bytes - byte_offset) | copy_mask_;
output_byte_ = static_cast<uint8_t>(countdown_bytes - byte_offset) | copy_mask_;
}
else
{
@@ -207,7 +207,7 @@ void PRG::get_next_output_token()
}
else
{
output_byte_ = (uint8_t)fgetc(file_);
output_byte_ = static_cast<uint8_t>(fgetc(file_));
if(feof(file_))
{
output_byte_ = check_digit_;
+1 -1
View File
@@ -37,7 +37,7 @@ int Parser::get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &tape) {
set_error_flag();
return -1;
}
crc_.add((uint8_t)value);
crc_.add(static_cast<uint8_t>(value));
return value;
}
+2 -2
View File
@@ -243,8 +243,8 @@ uint8_t Parser::get_next_byte_contents(const std::shared_ptr<Storage::Tape::Tape
if((check&1) == (byte_plus_parity >> 8))
set_error_flag();
add_parity_byte((uint8_t)byte_plus_parity);
return (uint8_t)byte_plus_parity;
add_parity_byte(static_cast<uint8_t>(byte_plus_parity));
return static_cast<uint8_t>(byte_plus_parity);
}
/*!
+1 -1
View File
@@ -125,7 +125,7 @@ std::shared_ptr<std::vector<uint8_t>> Parser::get_next_file_data(const std::shar
while(!is_at_end(tape)) {
byte = get_next_byte(tape);
if(byte == -1) return result;
result->push_back((uint8_t)byte);
result->push_back(static_cast<uint8_t>(byte));
}
return result;
}