1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-27 01:31:42 +00:00

Merge pull request #252 from TomHarte/Casts

Begins this project's conversion to functional-style casts.
This commit is contained in:
Thomas Harte 2017-10-03 22:05:22 -04:00 committed by GitHub
commit c39759333a
27 changed files with 93 additions and 93 deletions

View File

@ -720,7 +720,7 @@ void WD1770::posit_event(int new_event_type) {
case 0xfd: case 0xfe:
// clock is 0xc7 = 1010 0000 0010 1010 = 0xa022
write_raw_short(
(uint16_t)(
static_cast<uint16_t>(
0xa022 |
((data_ & 0x80) << 7) |
((data_ & 0x40) << 6) |

View File

@ -49,11 +49,11 @@ void MOS6522Base::do_phase2() {
registers_.timer[1] --;
if(registers_.next_timer[0] >= 0) {
registers_.timer[0] = (uint16_t)registers_.next_timer[0];
registers_.timer[0] = static_cast<uint16_t>(registers_.next_timer[0]);
registers_.next_timer[0] = -1;
}
if(registers_.next_timer[1] >= 0) {
registers_.timer[1] = (uint16_t)registers_.next_timer[1];
registers_.timer[1] = static_cast<uint16_t>(registers_.next_timer[1]);
registers_.next_timer[1] = -1;
}
}

View File

@ -35,7 +35,7 @@ template <typename T> void MOS6522<T>::set_register(int address, uint8_t value)
// Timer 1
case 0x6: case 0x4: registers_.timer_latch[0] = (registers_.timer_latch[0]&0xff00) | value; break;
case 0x5: case 0x7:
registers_.timer_latch[0] = (registers_.timer_latch[0]&0x00ff) | (uint16_t)(value << 8);
registers_.timer_latch[0] = (registers_.timer_latch[0]&0x00ff) | static_cast<uint16_t>(value << 8);
registers_.interrupt_flags &= ~InterruptFlag::Timer1;
if(address == 0x05) {
registers_.next_timer[0] = registers_.timer_latch[0];
@ -48,7 +48,7 @@ template <typename T> void MOS6522<T>::set_register(int address, uint8_t value)
case 0x8: registers_.timer_latch[1] = value; break;
case 0x9:
registers_.interrupt_flags &= ~InterruptFlag::Timer2;
registers_.next_timer[1] = registers_.timer_latch[1] | (uint16_t)(value << 8);
registers_.next_timer[1] = registers_.timer_latch[1] | static_cast<uint16_t>(value << 8);
timer_is_running_[1] = true;
reevaluate_interrupts();
break;

View File

@ -79,7 +79,7 @@ template <class T> class MOS6532 {
// Timer and interrupt control
case 0x04: case 0x06: {
uint8_t value = (uint8_t)(timer_.value >> timer_.activeShift);
uint8_t value = static_cast<uint8_t>(timer_.value >> timer_.activeShift);
timer_.interrupt_enabled = !!(address&0x08);
interrupt_status_ &= ~InterruptFlag::Timer;
evaluate_interrupts();

View File

@ -218,7 +218,7 @@ template <class T> class MOS6560 {
if(column_counter_&1) {
fetch_address = registers_.character_cell_start_address + (character_code_*(registers_.tall_characters ? 16 : 8)) + current_character_row_;
} else {
fetch_address = (uint16_t)(registers_.video_matrix_start_address + video_matrix_address_counter_);
fetch_address = static_cast<uint16_t>(registers_.video_matrix_start_address + video_matrix_address_counter_);
video_matrix_address_counter_++;
if(
(current_character_row_ == 15) ||
@ -345,7 +345,7 @@ template <class T> class MOS6560 {
case 0x2:
registers_.number_of_columns = value & 0x7f;
registers_.video_matrix_start_address = (uint16_t)((registers_.video_matrix_start_address & 0x3c00) | ((value & 0x80) << 2));
registers_.video_matrix_start_address = static_cast<uint16_t>((registers_.video_matrix_start_address & 0x3c00) | ((value & 0x80) << 2));
break;
case 0x3:
@ -354,8 +354,8 @@ template <class T> class MOS6560 {
break;
case 0x5:
registers_.character_cell_start_address = (uint16_t)((value & 0x0f) << 10);
registers_.video_matrix_start_address = (uint16_t)((registers_.video_matrix_start_address & 0x0200) | ((value & 0xf0) << 6));
registers_.character_cell_start_address = static_cast<uint16_t>((value & 0x0f) << 10);
registers_.video_matrix_start_address = static_cast<uint16_t>((registers_.video_matrix_start_address & 0x0200) | ((value & 0xf0) << 6));
break;
case 0xa:
@ -399,7 +399,7 @@ template <class T> class MOS6560 {
int current_line = (full_frame_counter_ + timing_.line_counter_increment_offset) / timing_.cycles_per_line;
switch(address) {
default: return registers_.direct_values[address];
case 0x03: return (uint8_t)(current_line << 7) | (registers_.direct_values[3] & 0x7f);
case 0x03: return static_cast<uint8_t>(current_line << 7) | (registers_.direct_values[3] & 0x7f);
case 0x04: return (current_line >> 1) & 0xff;
}
}

View File

@ -240,7 +240,7 @@ template <class T> class CRTC6845 {
inline void do_end_of_frame() {
line_counter_ = 0;
line_is_visible_ = true;
line_address_ = (uint16_t)((registers_[12] << 8) | registers_[13]);
line_address_ = static_cast<uint16_t>((registers_[12] << 8) | registers_[13]);
bus_state_.refresh_address = line_address_;
}

View File

@ -775,7 +775,7 @@ void i8272::posit_event(int event_type) {
// If a drive was found, return its results. Otherwise return a single 0x80.
if(found_drive != -1) {
drives_[found_drive].phase = Drive::NotSeeking;
status_[0] = (uint8_t)found_drive;
status_[0] = static_cast<uint8_t>(found_drive);
main_status_ &= ~(1 << found_drive);
SetSeekEnd();

View File

@ -160,7 +160,7 @@ void AY38910::evaluate_output_volume() {
#undef channel_volume
// Mix additively.
output_volume_ = (int16_t)(
output_volume_ = static_cast<int16_t>(
volumes_[volumes[0]] * channel_levels[0] +
volumes_[volumes[1]] * channel_levels[1] +
volumes_[volumes[2]] * channel_levels[2]
@ -186,7 +186,7 @@ void AY38910::set_register_value(uint8_t value) {
int channel = selected_register >> 1;
if(selected_register & 1)
tone_periods_[channel] = (tone_periods_[channel] & 0xff) | (uint16_t)((value&0xf) << 8);
tone_periods_[channel] = (tone_periods_[channel] & 0xff) | static_cast<uint16_t>((value&0xf) << 8);
else
tone_periods_[channel] = (tone_periods_[channel] & ~0xff) | value;
}

View File

@ -224,7 +224,7 @@ class CRTCBusHandler {
// MA13 MA12 RA2 RA1 RA0 MA9 MA8 MA7 MA6 MA5 MA4 MA3 MA2 MA1 MA0 CCLK
// ... so form the real access address.
uint16_t address =
(uint16_t)(
static_cast<uint16_t>(
((state.refresh_address & 0x3ff) << 1) |
((state.row_address & 0x7) << 11) |
((state.refresh_address & 0x3000) << 2)
@ -374,16 +374,16 @@ class CRTCBusHandler {
void establish_palette_hits() {
for(int c = 0; c < 256; c++) {
mode0_palette_hits_[Mode0Colour0(c)].push_back((uint8_t)c);
mode0_palette_hits_[Mode0Colour1(c)].push_back((uint8_t)c);
mode0_palette_hits_[Mode0Colour0(c)].push_back(static_cast<uint8_t>(c));
mode0_palette_hits_[Mode0Colour1(c)].push_back(static_cast<uint8_t>(c));
mode1_palette_hits_[Mode1Colour0(c)].push_back((uint8_t)c);
mode1_palette_hits_[Mode1Colour1(c)].push_back((uint8_t)c);
mode1_palette_hits_[Mode1Colour2(c)].push_back((uint8_t)c);
mode1_palette_hits_[Mode1Colour3(c)].push_back((uint8_t)c);
mode1_palette_hits_[Mode1Colour0(c)].push_back(static_cast<uint8_t>(c));
mode1_palette_hits_[Mode1Colour1(c)].push_back(static_cast<uint8_t>(c));
mode1_palette_hits_[Mode1Colour2(c)].push_back(static_cast<uint8_t>(c));
mode1_palette_hits_[Mode1Colour3(c)].push_back(static_cast<uint8_t>(c));
mode3_palette_hits_[Mode3Colour0(c)].push_back((uint8_t)c);
mode3_palette_hits_[Mode3Colour1(c)].push_back((uint8_t)c);
mode3_palette_hits_[Mode3Colour0(c)].push_back(static_cast<uint8_t>(c));
mode3_palette_hits_[Mode3Colour1(c)].push_back(static_cast<uint8_t>(c));
}
}

View File

@ -39,7 +39,7 @@ class Pitfall2: public BusExtender {
if(isReadOperation(operation)) {
*value = random_number_generator_;
}
random_number_generator_ = (uint8_t)(
random_number_generator_ = static_cast<uint8_t>(
(random_number_generator_ << 1) |
(~( (random_number_generator_ >> 7) ^
(random_number_generator_ >> 5) ^

View File

@ -37,7 +37,7 @@ TIA::TIA(bool create_crt) :
}
for(int c = 0; c < 256; c++) {
reverse_table[c] = (uint8_t)(
reverse_table[c] = static_cast<uint8_t>(
((c & 0x01) << 7) | ((c & 0x02) << 5) | ((c & 0x04) << 3) | ((c & 0x08) << 1) |
((c & 0x10) >> 1) | ((c & 0x20) >> 3) | ((c & 0x40) >> 5) | ((c & 0x80) >> 7)
);
@ -74,17 +74,17 @@ TIA::TIA(bool create_crt) :
colour_mask_by_mode_collision_flags_[(int)ColourMode::Standard][c] =
colour_mask_by_mode_collision_flags_[(int)ColourMode::ScoreLeft][c] =
colour_mask_by_mode_collision_flags_[(int)ColourMode::ScoreRight][c] =
colour_mask_by_mode_collision_flags_[(int)ColourMode::OnTop][c] = (uint8_t)ColourIndex::Background;
colour_mask_by_mode_collision_flags_[(int)ColourMode::OnTop][c] = static_cast<uint8_t>(ColourIndex::Background);
// test 1 for standard priority: if there is a playfield or ball pixel, plot that colour
if(has_playfield || has_ball) {
colour_mask_by_mode_collision_flags_[(int)ColourMode::Standard][c] = (uint8_t)ColourIndex::PlayfieldBall;
colour_mask_by_mode_collision_flags_[(int)ColourMode::Standard][c] = static_cast<uint8_t>(ColourIndex::PlayfieldBall);
}
// test 1 for score mode: if there is a ball pixel, plot that colour
if(has_ball) {
colour_mask_by_mode_collision_flags_[(int)ColourMode::ScoreLeft][c] =
colour_mask_by_mode_collision_flags_[(int)ColourMode::ScoreRight][c] = (uint8_t)ColourIndex::PlayfieldBall;
colour_mask_by_mode_collision_flags_[(int)ColourMode::ScoreRight][c] = static_cast<uint8_t>(ColourIndex::PlayfieldBall);
}
// test 1 for on-top mode, test 2 for everbody else: if there is a player 1 or missile 1 pixel, plot that colour
@ -92,12 +92,12 @@ TIA::TIA(bool create_crt) :
colour_mask_by_mode_collision_flags_[(int)ColourMode::Standard][c] =
colour_mask_by_mode_collision_flags_[(int)ColourMode::ScoreLeft][c] =
colour_mask_by_mode_collision_flags_[(int)ColourMode::ScoreRight][c] =
colour_mask_by_mode_collision_flags_[(int)ColourMode::OnTop][c] = (uint8_t)ColourIndex::PlayerMissile1;
colour_mask_by_mode_collision_flags_[(int)ColourMode::OnTop][c] = static_cast<uint8_t>(ColourIndex::PlayerMissile1);
}
// in the right-hand side of score mode, the playfield has the same priority as player 1
if(has_playfield) {
colour_mask_by_mode_collision_flags_[(int)ColourMode::ScoreRight][c] = (uint8_t)ColourIndex::PlayerMissile1;
colour_mask_by_mode_collision_flags_[(int)ColourMode::ScoreRight][c] = static_cast<uint8_t>(ColourIndex::PlayerMissile1);
}
// next test for everybody: if there is a player 0 or missile 0 pixel, plot that colour instead
@ -105,17 +105,17 @@ TIA::TIA(bool create_crt) :
colour_mask_by_mode_collision_flags_[(int)ColourMode::Standard][c] =
colour_mask_by_mode_collision_flags_[(int)ColourMode::ScoreLeft][c] =
colour_mask_by_mode_collision_flags_[(int)ColourMode::ScoreRight][c] =
colour_mask_by_mode_collision_flags_[(int)ColourMode::OnTop][c] = (uint8_t)ColourIndex::PlayerMissile0;
colour_mask_by_mode_collision_flags_[(int)ColourMode::OnTop][c] = static_cast<uint8_t>(ColourIndex::PlayerMissile0);
}
// if this is the left-hand side of score mode, the playfield has the same priority as player 0
if(has_playfield) {
colour_mask_by_mode_collision_flags_[(int)ColourMode::ScoreLeft][c] = (uint8_t)ColourIndex::PlayerMissile0;
colour_mask_by_mode_collision_flags_[(int)ColourMode::ScoreLeft][c] = static_cast<uint8_t>(ColourIndex::PlayerMissile0);
}
// a final test for 'on top' priority mode: if the playfield or ball are visible, prefer that colour to all others
if(has_playfield || has_ball) {
colour_mask_by_mode_collision_flags_[(int)ColourMode::OnTop][c] = (uint8_t)ColourIndex::PlayfieldBall;
colour_mask_by_mode_collision_flags_[(int)ColourMode::OnTop][c] = static_cast<uint8_t>(ColourIndex::PlayfieldBall);
}
}
}
@ -210,16 +210,16 @@ void TIA::set_playfield(uint16_t offset, uint8_t value) {
assert(offset >= 0 && offset < 3);
switch(offset) {
case 0:
background_[1] = (background_[1] & 0x0ffff) | ((uint32_t)reverse_table[value & 0xf0] << 16);
background_[0] = (background_[0] & 0xffff0) | (uint32_t)(value >> 4);
background_[1] = (background_[1] & 0x0ffff) | (static_cast<uint32_t>(reverse_table[value & 0xf0]) << 16);
background_[0] = (background_[0] & 0xffff0) | static_cast<uint32_t>(value >> 4);
break;
case 1:
background_[1] = (background_[1] & 0xf00ff) | ((uint32_t)value << 8);
background_[0] = (background_[0] & 0xff00f) | ((uint32_t)reverse_table[value] << 4);
background_[1] = (background_[1] & 0xf00ff) | (static_cast<uint32_t>(value) << 8);
background_[0] = (background_[0] & 0xff00f) | (static_cast<uint32_t>(reverse_table[value]) << 4);
break;
case 2:
background_[1] = (background_[1] & 0xfff00) | reverse_table[value];
background_[0] = (background_[0] & 0x00fff) | ((uint32_t)value << 12);
background_[0] = (background_[0] & 0x00fff) | (static_cast<uint32_t>(value) << 12);
break;
}
}
@ -360,7 +360,7 @@ void TIA::clear_motion() {
}
uint8_t TIA::get_collision_flags(int offset) {
return (uint8_t)((collision_flags_ >> (offset << 1)) << 6) & 0xc0;
return static_cast<uint8_t>((collision_flags_ >> (offset << 1)) << 6) & 0xc0;
}
void TIA::clear_collision_flags() {
@ -401,11 +401,11 @@ void TIA::output_for_cycles(int number_of_cycles) {
int latent_start = output_cursor + 4;
int latent_end = horizontal_counter_ + 4;
draw_playfield(latent_start, latent_end);
draw_object<Player>(player_[0], (uint8_t)CollisionType::Player0, output_cursor, horizontal_counter_);
draw_object<Player>(player_[1], (uint8_t)CollisionType::Player1, output_cursor, horizontal_counter_);
draw_missile(missile_[0], player_[0], (uint8_t)CollisionType::Missile0, output_cursor, horizontal_counter_);
draw_missile(missile_[1], player_[1], (uint8_t)CollisionType::Missile1, output_cursor, horizontal_counter_);
draw_object<Ball>(ball_, (uint8_t)CollisionType::Ball, output_cursor, horizontal_counter_);
draw_object<Player>(player_[0], static_cast<uint8_t>(CollisionType::Player0), output_cursor, horizontal_counter_);
draw_object<Player>(player_[1], static_cast<uint8_t>(CollisionType::Player1), output_cursor, horizontal_counter_);
draw_missile(missile_[0], player_[0], static_cast<uint8_t>(CollisionType::Missile0), output_cursor, horizontal_counter_);
draw_missile(missile_[1], player_[1], static_cast<uint8_t>(CollisionType::Missile1), output_cursor, horizontal_counter_);
draw_object<Ball>(ball_, static_cast<uint8_t>(CollisionType::Ball), output_cursor, horizontal_counter_);
// convert to television signals

View File

@ -19,7 +19,7 @@ void Memory::Fuzz(uint8_t *buffer, size_t size) {
}
for(size_t c = 0; c < size; c++) {
buffer[c] = (uint8_t)(std::rand() >> shift);
buffer[c] = static_cast<uint8_t>(std::rand() >> shift);
}
}

View File

@ -83,7 +83,7 @@ Typer::~Typer() {
#pragma mark - Character mapper
uint16_t *CharacterMapper::table_lookup_sequence_for_character(KeySequence *sequences, size_t length, char character) {
size_t ucharacter = (size_t)((unsigned char)character);
size_t ucharacter = static_cast<size_t>((unsigned char)character);
if(ucharacter > (length / sizeof(KeySequence))) return nullptr;
if(sequences[ucharacter][0] == NotMapped) return nullptr;
return sequences[ucharacter];

View File

@ -24,7 +24,7 @@ G64::G64(const char *file_name) :
if(version != 0) throw ErrorUnknownVersion;
// get the number of tracks and track size
number_of_tracks_ = (uint8_t)fgetc(file_);
number_of_tracks_ = static_cast<uint8_t>(fgetc(file_));
maximum_track_size_ = fgetc16le();
}

View File

@ -32,13 +32,13 @@ std::shared_ptr<Track> MFMSectorDump::get_track_at_position(unsigned int head, u
fread(sectors, 1, sizeof(sectors), file_);
}
return track_for_sectors(sectors, (uint8_t)position, (uint8_t)head, 0, sector_size_, is_double_density_);
return track_for_sectors(sectors, static_cast<uint8_t>(position), static_cast<uint8_t>(head), 0, sector_size_, is_double_density_);
}
void MFMSectorDump::set_track_at_position(unsigned int head, unsigned int position, const std::shared_ptr<Track> &track) {
uint8_t parsed_track[(128 << sector_size_)*sectors_per_track_];
// Assumption here: sector IDs will run from 0.
decode_sectors(*track, parsed_track, 0, (uint8_t)(sectors_per_track_-1), sector_size_, is_double_density_);
decode_sectors(*track, parsed_track, 0, static_cast<uint8_t>(sectors_per_track_-1), sector_size_, is_double_density_);
long file_offset = get_file_offset_for_position(head, position);

View File

@ -63,7 +63,7 @@ std::shared_ptr<Track> OricMFMDSK::get_track_at_position(unsigned int head, unsi
std::unique_ptr<Encodings::MFM::Encoder> encoder = Encodings::MFM::GetMFMEncoder(segment.data);
bool did_sync = false;
while(track_offset < 6250) {
uint8_t next_byte = (uint8_t)fgetc(file_);
uint8_t next_byte = static_cast<uint8_t>(fgetc(file_));
track_offset++;
switch(next_byte) {
@ -75,7 +75,7 @@ std::shared_ptr<Track> OricMFMDSK::get_track_at_position(unsigned int head, unsi
case 0xfe:
for(int byte = 0; byte < 6; byte++) {
last_header[byte] = (uint8_t)fgetc(file_);
last_header[byte] = static_cast<uint8_t>(fgetc(file_));
encoder->add_byte(last_header[byte]);
track_offset++;
if(track_offset == 6250) break;
@ -84,7 +84,7 @@ std::shared_ptr<Track> OricMFMDSK::get_track_at_position(unsigned int head, unsi
case 0xfb:
for(int byte = 0; byte < (128 << last_header[3]) + 2; byte++) {
encoder->add_byte((uint8_t)fgetc(file_));
encoder->add_byte(static_cast<uint8_t>(fgetc(file_)));
track_offset++;
if(track_offset == 6250) break;
}

View File

@ -66,9 +66,9 @@ void Storage::Encodings::CommodoreGCR::encode_block(uint8_t *destination, uint8_
encoding_for_byte(source[3]),
};
destination[0] = (uint8_t)(encoded_bytes[0] >> 2);
destination[1] = (uint8_t)((encoded_bytes[0] << 6) | (encoded_bytes[1] >> 4));
destination[2] = (uint8_t)((encoded_bytes[1] << 4) | (encoded_bytes[2] >> 6));
destination[3] = (uint8_t)((encoded_bytes[2] << 2) | (encoded_bytes[3] >> 8));
destination[4] = (uint8_t)(encoded_bytes[3]);
destination[0] = static_cast<uint8_t>(encoded_bytes[0] >> 2);
destination[1] = static_cast<uint8_t>((encoded_bytes[0] << 6) | (encoded_bytes[1] >> 4));
destination[2] = static_cast<uint8_t>((encoded_bytes[1] << 4) | (encoded_bytes[2] >> 6));
destination[3] = static_cast<uint8_t>((encoded_bytes[2] << 2) | (encoded_bytes[3] >> 8));
destination[4] = static_cast<uint8_t>(encoded_bytes[3]);
}

View File

@ -108,7 +108,7 @@ void Shifter::add_input_bit(int value) {
}
uint8_t Shifter::get_byte() const {
return (uint8_t)(
return static_cast<uint8_t>(
((shift_register_ & 0x0001) >> 0) |
((shift_register_ & 0x0004) >> 1) |
((shift_register_ & 0x0010) >> 2) |

View File

@ -26,7 +26,7 @@ std::unique_ptr<Storage::Disk::CPM::Catalogue> Storage::Disk::CPM::GetCatalogue(
if(catalogue_allocation_bitmap & 0x8000) {
size_t size_read = 0;
do {
Storage::Encodings::MFM::Sector *sector_contents = parser.get_sector(0, (uint8_t)track, (uint8_t)(parameters.first_sector + sector));
Storage::Encodings::MFM::Sector *sector_contents = parser.get_sector(0, static_cast<uint8_t>(track), static_cast<uint8_t>(parameters.first_sector + sector));
if(!sector_contents) {
return nullptr;
}
@ -134,7 +134,7 @@ std::unique_ptr<Storage::Disk::CPM::Catalogue> Storage::Disk::CPM::GetCatalogue(
track = first_sector / parameters.sectors_per_track;
for(int s = 0; s < sectors_per_block && record < entry->number_of_records; s++) {
Storage::Encodings::MFM::Sector *sector_contents = parser.get_sector(0, (uint8_t)track, (uint8_t)(parameters.first_sector + sector));
Storage::Encodings::MFM::Sector *sector_contents = parser.get_sector(0, static_cast<uint8_t>(track), static_cast<uint8_t>(parameters.first_sector + sector));
if(!sector_contents) break;
sector++;
if(sector == parameters.sectors_per_track) {

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_];

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;

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)
{

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);
}

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_;

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;
}

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);
}
/*!

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;
}