1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-01 06:41:36 +00:00

Further doubles down on construction syntax for type conversions.

This commit is contained in:
Thomas Harte 2020-05-09 23:00:39 -04:00
parent 3729bddb2a
commit 25996ce180
114 changed files with 737 additions and 737 deletions

View File

@ -11,7 +11,7 @@
using namespace Analyser::Dynamic;
float ConfidenceCounter::get_confidence() {
return static_cast<float>(hits_) / static_cast<float>(hits_ + misses_);
return float(hits_) / float(hits_ + misses_);
}
void ConfidenceCounter::add_hit() {

View File

@ -34,7 +34,7 @@ float MultiSpeaker::get_ideal_clock_rate_in_range(float minimum, float maximum)
ideal += speaker->get_ideal_clock_rate_in_range(minimum, maximum);
}
return ideal / static_cast<float>(speakers_.size());
return ideal / float(speakers_.size());
}
void MultiSpeaker::set_computed_output_rate(float cycles_per_second, int buffer_size, bool stereo) {

View File

@ -48,18 +48,18 @@ std::unique_ptr<Catalogue> Analyser::Static::Acorn::GetDFSCatalogue(const std::s
char name[10];
snprintf(name, 10, "%c.%.7s", names->samples[0][file_offset + 7] & 0x7f, &names->samples[0][file_offset]);
new_file.name = name;
new_file.load_address = (uint32_t)(details->samples[0][file_offset] | (details->samples[0][file_offset+1] << 8) | ((details->samples[0][file_offset+6]&0x0c) << 14));
new_file.execution_address = (uint32_t)(details->samples[0][file_offset+2] | (details->samples[0][file_offset+3] << 8) | ((details->samples[0][file_offset+6]&0xc0) << 10));
new_file.is_protected = !!(names->samples[0][file_offset + 7] & 0x80);
new_file.load_address = uint32_t(details->samples[0][file_offset] | (details->samples[0][file_offset+1] << 8) | ((details->samples[0][file_offset+6]&0x0c) << 14));
new_file.execution_address = uint32_t(details->samples[0][file_offset+2] | (details->samples[0][file_offset+3] << 8) | ((details->samples[0][file_offset+6]&0xc0) << 10));
new_file.is_protected = names->samples[0][file_offset + 7] & 0x80;
long data_length = static_cast<long>(details->samples[0][file_offset+4] | (details->samples[0][file_offset+5] << 8) | ((details->samples[0][file_offset+6]&0x30) << 12));
long data_length = long(details->samples[0][file_offset+4] | (details->samples[0][file_offset+5] << 8) | ((details->samples[0][file_offset+6]&0x30) << 12));
int start_sector = details->samples[0][file_offset+7] | ((details->samples[0][file_offset+6]&0x03) << 8);
new_file.data.reserve(static_cast<std::size_t>(data_length));
new_file.data.reserve(size_t(data_length));
if(start_sector < 2) continue;
while(data_length > 0) {
uint8_t sector = static_cast<uint8_t>(start_sector % 10);
uint8_t track = static_cast<uint8_t>(start_sector / 10);
uint8_t sector = uint8_t(start_sector % 10);
uint8_t track = uint8_t(start_sector / 10);
start_sector++;
Storage::Encodings::MFM::Sector *next_sector = parser.get_sector(0, track, sector);

View File

@ -41,7 +41,7 @@ static std::unique_ptr<File::Chunk> GetNextChunk(const std::shared_ptr<Storage::
char name[11];
std::size_t name_ptr = 0;
while(!tape->is_at_end() && name_ptr < sizeof(name)) {
name[name_ptr] = (char)parser.get_next_byte(tape);
name[name_ptr] = char(parser.get_next_byte(tape));
if(!name[name_ptr]) break;
name_ptr++;
}
@ -49,16 +49,16 @@ static std::unique_ptr<File::Chunk> GetNextChunk(const std::shared_ptr<Storage::
new_chunk->name = name;
// addresses
new_chunk->load_address = (uint32_t)parser.get_next_word(tape);
new_chunk->execution_address = (uint32_t)parser.get_next_word(tape);
new_chunk->block_number = static_cast<uint16_t>(parser.get_next_short(tape));
new_chunk->block_length = static_cast<uint16_t>(parser.get_next_short(tape));
new_chunk->block_flag = static_cast<uint8_t>(parser.get_next_byte(tape));
new_chunk->next_address = (uint32_t)parser.get_next_word(tape);
new_chunk->load_address = uint32_t(parser.get_next_word(tape));
new_chunk->execution_address = uint32_t(parser.get_next_word(tape));
new_chunk->block_number = uint16_t(parser.get_next_short(tape));
new_chunk->block_length = uint16_t(parser.get_next_short(tape));
new_chunk->block_flag = uint8_t(parser.get_next_byte(tape));
new_chunk->next_address = uint32_t(parser.get_next_word(tape));
uint16_t calculated_header_crc = parser.get_crc();
uint16_t stored_header_crc = static_cast<uint16_t>(parser.get_next_short(tape));
stored_header_crc = static_cast<uint16_t>((stored_header_crc >> 8) | (stored_header_crc << 8));
uint16_t stored_header_crc = uint16_t(parser.get_next_short(tape));
stored_header_crc = uint16_t((stored_header_crc >> 8) | (stored_header_crc << 8));
new_chunk->header_crc_matched = stored_header_crc == calculated_header_crc;
if(!new_chunk->header_crc_matched) return nullptr;
@ -66,13 +66,13 @@ static std::unique_ptr<File::Chunk> GetNextChunk(const std::shared_ptr<Storage::
parser.reset_crc();
new_chunk->data.reserve(new_chunk->block_length);
for(int c = 0; c < new_chunk->block_length; c++) {
new_chunk->data.push_back(static_cast<uint8_t>(parser.get_next_byte(tape)));
new_chunk->data.push_back(uint8_t(parser.get_next_byte(tape)));
}
if(new_chunk->block_length && !(new_chunk->block_flag&0x40)) {
uint16_t calculated_data_crc = parser.get_crc();
uint16_t stored_data_crc = static_cast<uint16_t>(parser.get_next_short(tape));
stored_data_crc = static_cast<uint16_t>((stored_data_crc >> 8) | (stored_data_crc << 8));
uint16_t stored_data_crc = uint16_t(parser.get_next_short(tape));
stored_data_crc = uint16_t((stored_data_crc >> 8) | (stored_data_crc << 8));
new_chunk->data_crc_matched = stored_data_crc == calculated_data_crc;
} else {
new_chunk->data_crc_matched = true;

View File

@ -19,15 +19,15 @@ static void DeterminePagingFor2kCartridge(Target &target, const Storage::Cartrid
// if this is a 2kb cartridge then it's definitely either unpaged or a CommaVid
uint16_t entry_address, break_address;
entry_address = (static_cast<uint16_t>(segment.data[0x7fc] | (segment.data[0x7fd] << 8))) & 0x1fff;
break_address = (static_cast<uint16_t>(segment.data[0x7fe] | (segment.data[0x7ff] << 8))) & 0x1fff;
entry_address = uint16_t(segment.data[0x7fc] | (segment.data[0x7fd] << 8)) & 0x1fff;
break_address = uint16_t(segment.data[0x7fe] | (segment.data[0x7ff] << 8)) & 0x1fff;
// a CommaVid start address needs to be outside of its RAM
if(entry_address < 0x1800 || break_address < 0x1800) return;
std::function<std::size_t(uint16_t address)> high_location_mapper = [](uint16_t address) {
address &= 0x1fff;
return static_cast<std::size_t>(address - 0x1800);
return size_t(address - 0x1800);
};
Analyser::Static::MOS6502::Disassembly high_location_disassembly =
Analyser::Static::MOS6502::Disassemble(segment.data, high_location_mapper, {entry_address, break_address});
@ -125,12 +125,12 @@ static void DeterminePagingForCartridge(Target &target, const Storage::Cartridge
uint16_t entry_address, break_address;
entry_address = static_cast<uint16_t>(segment.data[segment.data.size() - 4] | (segment.data[segment.data.size() - 3] << 8));
break_address = static_cast<uint16_t>(segment.data[segment.data.size() - 2] | (segment.data[segment.data.size() - 1] << 8));
entry_address = uint16_t(segment.data[segment.data.size() - 4] | (segment.data[segment.data.size() - 3] << 8));
break_address = uint16_t(segment.data[segment.data.size() - 2] | (segment.data[segment.data.size() - 1] << 8));
std::function<std::size_t(uint16_t address)> address_mapper = [](uint16_t address) {
if(!(address & 0x1000)) return static_cast<std::size_t>(-1);
return static_cast<std::size_t>(address & 0xfff);
if(!(address & 0x1000)) return size_t(-1);
return size_t(address & 0xfff);
};
std::vector<uint8_t> final_4k(segment.data.end() - 4096, segment.data.end());

View File

@ -22,7 +22,7 @@ static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>>
// the two bytes that will be first must be 0xaa and 0x55, either way around
auto *start = &segment.data[0];
if((data_size & static_cast<std::size_t>(~8191)) > 32768) {
if((data_size & size_t(~8191)) > 32768) {
start = &segment.data[segment.data.size() - 16384];
}
if(start[0] != 0xaa && start[0] != 0x55 && start[1] != 0xaa && start[1] != 0x55) continue;

View File

@ -38,7 +38,7 @@ class CommodoreGCRParser: public Storage::Disk::Controller {
@returns a sector if one was found; @c nullptr otherwise.
*/
std::shared_ptr<Sector> get_sector(uint8_t track, uint8_t sector) {
int difference = static_cast<int>(track) - static_cast<int>(track_);
int difference = int(track) - int(track_);
track_ = track;
if(difference) {
@ -71,7 +71,7 @@ class CommodoreGCRParser: public Storage::Disk::Controller {
std::shared_ptr<Sector> sector_cache_[65536];
void process_input_bit(int value) {
shift_register_ = ((shift_register_ << 1) | static_cast<unsigned int>(value)) & 0x3ff;
shift_register_ = ((shift_register_ << 1) | unsigned(value)) & 0x3ff;
bit_count_++;
}
@ -112,15 +112,15 @@ class CommodoreGCRParser: public Storage::Disk::Controller {
}
std::shared_ptr<Sector> get_sector(uint8_t sector) {
uint16_t sector_address = static_cast<uint16_t>((track_ << 8) | sector);
const uint16_t sector_address = uint16_t((track_ << 8) | sector);
if(sector_cache_[sector_address]) return sector_cache_[sector_address];
std::shared_ptr<Sector> first_sector = get_next_sector();
const std::shared_ptr<Sector> first_sector = get_next_sector();
if(!first_sector) return first_sector;
if(first_sector->sector == sector) return first_sector;
while(1) {
std::shared_ptr<Sector> next_sector = get_next_sector();
const std::shared_ptr<Sector> next_sector = get_next_sector();
if(next_sector->sector == first_sector->sector) return nullptr;
if(next_sector->sector == sector) return next_sector;
}
@ -138,12 +138,12 @@ class CommodoreGCRParser: public Storage::Disk::Controller {
}
// get sector details, skip if this looks malformed
uint8_t checksum = static_cast<uint8_t>(get_next_byte());
sector->sector = static_cast<uint8_t>(get_next_byte());
sector->track = static_cast<uint8_t>(get_next_byte());
uint8_t checksum = uint8_t(get_next_byte());
sector->sector = uint8_t(get_next_byte());
sector->track = uint8_t(get_next_byte());
uint8_t disk_id[2];
disk_id[0] = static_cast<uint8_t>(get_next_byte());
disk_id[1] = static_cast<uint8_t>(get_next_byte());
disk_id[0] = uint8_t(get_next_byte());
disk_id[1] = uint8_t(get_next_byte());
if(checksum != (sector->sector ^ sector->track ^ disk_id[0] ^ disk_id[1])) continue;
// look for the following data
@ -154,12 +154,12 @@ class CommodoreGCRParser: public Storage::Disk::Controller {
checksum = 0;
for(std::size_t c = 0; c < 256; c++) {
sector->data[c] = static_cast<uint8_t>(get_next_byte());
sector->data[c] = uint8_t(get_next_byte());
checksum ^= sector->data[c];
}
if(checksum == get_next_byte()) {
uint16_t sector_address = static_cast<uint16_t>((sector->track << 8) | sector->sector);
uint16_t sector_address = uint16_t((sector->track << 8) | sector->sector);
sector_cache_[sector_address] = sector;
return sector;
}
@ -192,7 +192,7 @@ std::vector<File> Analyser::Static::Commodore::GetFiles(const std::shared_ptr<St
}
// parse directory
std::size_t header_pointer = static_cast<std::size_t>(-32);
std::size_t header_pointer = size_t(-32);
while(header_pointer+32+31 < directory.size()) {
header_pointer += 32;
@ -216,7 +216,7 @@ std::vector<File> Analyser::Static::Commodore::GetFiles(const std::shared_ptr<St
}
new_file.name = Storage::Data::Commodore::petscii_from_bytes(&new_file.raw_name[0], 16, false);
std::size_t number_of_sectors = static_cast<std::size_t>(directory[header_pointer + 0x1e]) + (static_cast<std::size_t>(directory[header_pointer + 0x1f]) << 8);
std::size_t number_of_sectors = size_t(directory[header_pointer + 0x1e]) + (size_t(directory[header_pointer + 0x1f]) << 8);
new_file.data.reserve((number_of_sectors - 1) * 254 + 252);
bool is_first_sector = true;
@ -227,7 +227,7 @@ std::vector<File> Analyser::Static::Commodore::GetFiles(const std::shared_ptr<St
next_track = sector->data[0];
next_sector = sector->data[1];
if(is_first_sector) new_file.starting_address = static_cast<uint16_t>(sector->data[2]) | static_cast<uint16_t>(sector->data[3] << 8);
if(is_first_sector) new_file.starting_address = uint16_t(sector->data[2]) | uint16_t(sector->data[3] << 8);
if(next_track)
new_file.data.insert(new_file.data.end(), sector->data.begin() + (is_first_sector ? 4 : 2), sector->data.end());
else

View File

@ -23,7 +23,7 @@ bool Analyser::Static::Commodore::File::is_basic() {
// ... null-terminated code ...
// (with a next line address of 0000 indicating end of program)
while(1) {
if(static_cast<size_t>(line_address - starting_address) >= data.size() + 2) break;
if(size_t(line_address - starting_address) >= data.size() + 2) break;
uint16_t next_line_address = data[line_address - starting_address];
next_line_address |= data[line_address - starting_address + 1] << 8;
@ -33,13 +33,13 @@ bool Analyser::Static::Commodore::File::is_basic() {
}
if(next_line_address < line_address + 5) break;
if(static_cast<size_t>(line_address - starting_address) >= data.size() + 5) break;
if(size_t(line_address - starting_address) >= data.size() + 5) break;
uint16_t next_line_number = data[line_address - starting_address + 2];
next_line_number |= data[line_address - starting_address + 3] << 8;
if(next_line_number <= line_number) break;
line_number = static_cast<uint16_t>(next_line_number);
line_number = uint16_t(next_line_number);
line_address = next_line_address;
}

View File

@ -250,7 +250,7 @@ static void AddToDisassembly(PartialDisassembly &disassembly, const std::vector<
if(low_operand_address >= memory.size() || high_operand_address >= memory.size()) return;
address += 2;
instruction.operand = memory[low_operand_address] | static_cast<uint16_t>(memory[high_operand_address] << 8);
instruction.operand = memory[low_operand_address] | uint16_t(memory[high_operand_address] << 8);
}
break;
}
@ -302,7 +302,7 @@ static void AddToDisassembly(PartialDisassembly &disassembly, const std::vector<
return;
}
if(instruction.addressing_mode == Instruction::Relative) {
uint16_t destination = static_cast<uint16_t>(address + (int8_t)instruction.operand);
uint16_t destination = uint16_t(address + int8_t(instruction.operand));
disassembly.remaining_entry_points.push_back(destination);
}
}

View File

@ -21,7 +21,7 @@ namespace Disassembler {
*/
template <typename T> std::function<std::size_t(T)> OffsetMapper(T start_address) {
return [start_address](T argument) {
return static_cast<std::size_t>(argument - start_address);
return size_t(argument - start_address);
};
}

View File

@ -33,7 +33,7 @@ class Accessor {
uint16_t word() {
uint8_t low = byte();
uint8_t high = byte();
return static_cast<uint16_t>(low | (high << 8));
return uint16_t(low | (high << 8));
}
bool overrun() {
@ -562,7 +562,7 @@ struct Z80Disassembler {
int access_type =
((instruction.source == Instruction::Location::Operand_Indirect) ? 1 : 0) |
((instruction.destination == Instruction::Location::Operand_Indirect) ? 2 : 0);
uint16_t address = static_cast<uint16_t>(instruction.operand);
uint16_t address = uint16_t(instruction.operand);
bool is_internal = address_mapper(address) < memory.size();
switch(access_type) {
default: break;
@ -594,7 +594,7 @@ struct Z80Disassembler {
instruction.operation == Instruction::Operation::JR ||
instruction.operation == Instruction::Operation::CALL ||
instruction.operation == Instruction::Operation::RST) {
disassembly.remaining_entry_points.push_back(static_cast<uint16_t>(instruction.operand));
disassembly.remaining_entry_points.push_back(uint16_t(instruction.operand));
}
// This is it if: an unconditional RET, RETI, RETN, JP or JR is found.

View File

@ -27,7 +27,7 @@ static std::unique_ptr<Analyser::Static::Target> CartridgeTarget(
std::vector<Storage::Cartridge::Cartridge::Segment> output_segments;
if(segment.data.size() & 0x1fff) {
std::vector<uint8_t> truncated_data;
std::vector<uint8_t>::difference_type truncated_size = static_cast<std::vector<uint8_t>::difference_type>(segment.data.size()) & ~0x1fff;
std::vector<uint8_t>::difference_type truncated_size = std::vector<uint8_t>::difference_type(segment.data.size()) & ~0x1fff;
truncated_data.insert(truncated_data.begin(), segment.data.begin(), segment.data.begin() + truncated_size);
output_segments.emplace_back(start_address, truncated_data);
} else {
@ -96,7 +96,7 @@ static Analyser::Static::TargetList CartridgeTargetsFrom(
// Reject cartridge if the ROM header wasn't found.
if(!found_start) continue;
uint16_t init_address = static_cast<uint16_t>(segment.data[2] | (segment.data[3] << 8));
uint16_t init_address = uint16_t(segment.data[2] | (segment.data[3] << 8));
// TODO: check for a rational init address?
// If this ROM is less than 48kb in size then it's an ordinary ROM. Just emplace it and move on.
@ -146,7 +146,7 @@ static Analyser::Static::TargetList CartridgeTargetsFrom(
// ) &&
// ((next_iterator->second.operand >> 13) != (0x4000 >> 13))
// ) {
// const uint16_t address = static_cast<uint16_t>(next_iterator->second.operand);
// const uint16_t address = uint16_t(next_iterator->second.operand);
// switch(iterator->second.operand) {
// case 0x6000:
// if(address >= 0x6000 && address < 0x8000) {
@ -207,13 +207,13 @@ static Analyser::Static::TargetList CartridgeTargetsFrom(
if( instruction_pair.second.operation == Instruction::Operation::LD &&
instruction_pair.second.destination == Instruction::Location::Operand_Indirect &&
instruction_pair.second.source == Instruction::Location::A) {
address_counts[static_cast<uint16_t>(instruction_pair.second.operand)]++;
address_counts[uint16_t(instruction_pair.second.operand)]++;
}
}
// Weight confidences by number of observed hits.
float total_hits =
static_cast<float>(
float(
address_counts[0x6000] + address_counts[0x6800] +
address_counts[0x7000] + address_counts[0x7800] +
address_counts[0x77ff] + address_counts[0x8000] +
@ -225,35 +225,35 @@ static Analyser::Static::TargetList CartridgeTargetsFrom(
segment,
start_address,
Analyser::Static::MSX::Cartridge::ASCII8kb,
static_cast<float>( address_counts[0x6000] +
address_counts[0x6800] +
address_counts[0x7000] +
address_counts[0x7800]) / total_hits));
float( address_counts[0x6000] +
address_counts[0x6800] +
address_counts[0x7000] +
address_counts[0x7800]) / total_hits));
targets.push_back(CartridgeTarget(
segment,
start_address,
Analyser::Static::MSX::Cartridge::ASCII16kb,
static_cast<float>( address_counts[0x6000] +
address_counts[0x7000] +
address_counts[0x77ff]) / total_hits));
float( address_counts[0x6000] +
address_counts[0x7000] +
address_counts[0x77ff]) / total_hits));
if(!is_ascii) {
targets.push_back(CartridgeTarget(
segment,
start_address,
Analyser::Static::MSX::Cartridge::Konami,
static_cast<float>( address_counts[0x6000] +
address_counts[0x8000] +
address_counts[0xa000]) / total_hits));
float( address_counts[0x6000] +
address_counts[0x8000] +
address_counts[0xa000]) / total_hits));
}
if(!is_ascii) {
targets.push_back(CartridgeTarget(
segment,
start_address,
Analyser::Static::MSX::Cartridge::KonamiWithSCC,
static_cast<float>( address_counts[0x5000] +
address_counts[0x7000] +
address_counts[0x9000] +
address_counts[0xb000]) / total_hits));
float( address_counts[0x5000] +
address_counts[0x7000] +
address_counts[0x9000] +
address_counts[0xb000]) / total_hits));
}
}

View File

@ -44,7 +44,7 @@ std::vector<File> Analyser::Static::MSX::GetFiles(const std::shared_ptr<Storage:
for(std::size_t c = 0; c < sizeof(header); ++c) {
int next_byte = Parser::get_byte(*file_speed, tape_player);
if(next_byte == -1) break;
header[c] = static_cast<uint8_t>(next_byte);
header[c] = uint8_t(next_byte);
}
bool bytes_are_same = true;
@ -67,7 +67,7 @@ std::vector<File> Analyser::Static::MSX::GetFiles(const std::shared_ptr<Storage:
// Read file name.
char name[7];
for(std::size_t c = 1; c < 6; ++c)
name[c] = static_cast<char>(Parser::get_byte(*file_speed, tape_player));
name[c] = char(Parser::get_byte(*file_speed, tape_player));
name[6] = '\0';
file.name = name;
@ -82,7 +82,7 @@ std::vector<File> Analyser::Static::MSX::GetFiles(const std::shared_ptr<Storage:
int byte = Parser::get_byte(*file_speed, tape_player);
if(byte == -1) break;
contains_end_of_file |= (byte == 0x1a);
file.data.push_back(static_cast<uint8_t>(byte));
file.data.push_back(uint8_t(byte));
}
if(c != -1) break;
if(contains_end_of_file) {
@ -105,13 +105,13 @@ std::vector<File> Analyser::Static::MSX::GetFiles(const std::shared_ptr<Storage:
for(c = 0; c < sizeof(locations); ++c) {
int byte = Parser::get_byte(*file_speed, tape_player);
if(byte == -1) break;
locations[c] = static_cast<uint8_t>(byte);
locations[c] = uint8_t(byte);
}
if(c != sizeof(locations)) continue;
file.starting_address = static_cast<uint16_t>(locations[0] | (locations[1] << 8));
end_address = static_cast<uint16_t>(locations[2] | (locations[3] << 8));
file.entry_address = static_cast<uint16_t>(locations[4] | (locations[5] << 8));
file.starting_address = uint16_t(locations[0] | (locations[1] << 8));
end_address = uint16_t(locations[2] | (locations[3] << 8));
file.entry_address = uint16_t(locations[4] | (locations[5] << 8));
if(end_address < file.starting_address) continue;
@ -119,7 +119,7 @@ std::vector<File> Analyser::Static::MSX::GetFiles(const std::shared_ptr<Storage:
while(length--) {
int byte = Parser::get_byte(*file_speed, tape_player);
if(byte == -1) continue;
file.data.push_back(static_cast<uint8_t>(byte));
file.data.push_back(uint8_t(byte));
}
files.push_back(std::move(file));
@ -135,10 +135,10 @@ std::vector<File> Analyser::Static::MSX::GetFiles(const std::shared_ptr<Storage:
next_address_buffer[1] = Parser::get_byte(*file_speed, tape_player);
if(next_address_buffer[0] == -1 || next_address_buffer[1] == -1) break;
file.data.push_back(static_cast<uint8_t>(next_address_buffer[0]));
file.data.push_back(static_cast<uint8_t>(next_address_buffer[1]));
file.data.push_back(uint8_t(next_address_buffer[0]));
file.data.push_back(uint8_t(next_address_buffer[1]));
uint16_t next_address = static_cast<uint16_t>(next_address_buffer[0] | (next_address_buffer[1] << 8));
uint16_t next_address = uint16_t(next_address_buffer[0] | (next_address_buffer[1] << 8));
if(!next_address) {
files.push_back(std::move(file));
break;
@ -155,7 +155,7 @@ std::vector<File> Analyser::Static::MSX::GetFiles(const std::shared_ptr<Storage:
found_error = true;
break;
}
file.data.push_back(static_cast<uint8_t>(byte));
file.data.push_back(uint8_t(byte));
}
if(found_error) break;
}

View File

@ -49,10 +49,10 @@ std::vector<File> Analyser::Static::Oric::GetFiles(const std::shared_ptr<Storage
}
// read end and start addresses
new_file.ending_address = static_cast<uint16_t>(parser.get_next_byte(tape, is_fast) << 8);
new_file.ending_address |= static_cast<uint16_t>(parser.get_next_byte(tape, is_fast));
new_file.starting_address = static_cast<uint16_t>(parser.get_next_byte(tape, is_fast) << 8);
new_file.starting_address |= static_cast<uint16_t>(parser.get_next_byte(tape, is_fast));
new_file.ending_address = uint16_t(parser.get_next_byte(tape, is_fast) << 8);
new_file.ending_address |= uint16_t(parser.get_next_byte(tape, is_fast));
new_file.starting_address = uint16_t(parser.get_next_byte(tape, is_fast) << 8);
new_file.starting_address |= uint16_t(parser.get_next_byte(tape, is_fast));
// skip an empty byte
parser.get_next_byte(tape, is_fast);
@ -61,7 +61,7 @@ std::vector<File> Analyser::Static::Oric::GetFiles(const std::shared_ptr<Storage
char file_name[17];
int name_pos = 0;
while(name_pos < 16) {
file_name[name_pos] = (char)parser.get_next_byte(tape, is_fast);
file_name[name_pos] = char(parser.get_next_byte(tape, is_fast));
if(!file_name[name_pos]) break;
name_pos++;
}
@ -72,7 +72,7 @@ std::vector<File> Analyser::Static::Oric::GetFiles(const std::shared_ptr<Storage
std::size_t body_length = new_file.ending_address - new_file.starting_address + 1;
new_file.data.reserve(body_length);
for(std::size_t c = 0; c < body_length; c++) {
new_file.data.push_back(static_cast<uint8_t>(parser.get_next_byte(tape, is_fast)));
new_file.data.push_back(uint8_t(parser.get_next_byte(tape, is_fast)));
}
// only one validation check: was there enough tape?

View File

@ -69,7 +69,7 @@ template <typename T> void MOS6522<T>::write(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) | static_cast<uint16_t>(value << 8);
registers_.timer_latch[0] = (registers_.timer_latch[0]&0x00ff) | uint16_t(value << 8);
registers_.interrupt_flags &= ~InterruptFlag::Timer1;
if(address == 0x05) {
registers_.next_timer[0] = registers_.timer_latch[0];
@ -82,7 +82,7 @@ template <typename T> void MOS6522<T>::write(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] | static_cast<uint16_t>(value << 8);
registers_.next_timer[1] = registers_.timer_latch[1] | uint16_t(value << 8);
timer_is_running_[1] = true;
reevaluate_interrupts();
break;
@ -281,11 +281,11 @@ template <typename T> void MOS6522<T>::do_phase2() {
registers_.timer[1] --;
if(registers_.next_timer[0] >= 0) {
registers_.timer[0] = static_cast<uint16_t>(registers_.next_timer[0]);
registers_.timer[0] = uint16_t(registers_.next_timer[0]);
registers_.next_timer[0] = -1;
}
if(registers_.next_timer[1] >= 0) {
registers_.timer[1] = static_cast<uint16_t>(registers_.next_timer[1]);
registers_.timer[1] = uint16_t(registers_.next_timer[1]);
registers_.next_timer[1] = -1;
}

View File

@ -51,7 +51,7 @@ template <class T> class MOS6532 {
case 0x04: case 0x05: case 0x06: case 0x07:
if(address & 0x10) {
timer_.writtenShift = timer_.activeShift = (decodedAddress - 0x04) * 3 + (decodedAddress / 0x07); // i.e. 0, 3, 6, 10
timer_.value = (static_cast<unsigned int>(value) << timer_.activeShift) ;
timer_.value = (unsigned(value) << timer_.activeShift) ;
timer_.interrupt_enabled = !!(address&0x08);
interrupt_status_ &= ~InterruptFlag::Timer;
evaluate_interrupts();
@ -79,7 +79,7 @@ template <class T> class MOS6532 {
// Timer and interrupt control
case 0x04: case 0x06: {
uint8_t value = static_cast<uint8_t>(timer_.value >> timer_.activeShift);
uint8_t value = uint8_t(timer_.value >> timer_.activeShift);
timer_.interrupt_enabled = !!(address&0x08);
interrupt_status_ &= ~InterruptFlag::Timer;
evaluate_interrupts();
@ -107,7 +107,7 @@ template <class T> class MOS6532 {
}
inline void run_for(const Cycles cycles) {
unsigned int number_of_cycles = static_cast<unsigned int>(cycles.as_integral());
unsigned int number_of_cycles = unsigned(cycles.as_integral());
// permit counting _to_ zero; counting _through_ zero initiates the other behaviour
if(timer_.value >= number_of_cycles) {
@ -122,7 +122,7 @@ template <class T> class MOS6532 {
}
MOS6532() {
timer_.value = static_cast<unsigned int>((rand() & 0xff) << 10);
timer_.value = unsigned((rand() & 0xff) << 10);
}
inline void set_port_did_change(int port) {

View File

@ -98,7 +98,7 @@ static uint8_t noise_pattern[] = {
#define shift(r) shift_registers_[r] = (shift_registers_[r] << 1) | (((shift_registers_[r]^0x80)&control_registers_[r]) >> 7)
#define increment(r) shift_registers_[r] = (shift_registers_[r]+1)%8191
#define update(r, m, up) counters_[r]++; if((counters_[r] >> m) == 0x80) { up(r); counters_[r] = static_cast<unsigned int>(control_registers_[r]&0x7f) << m; }
#define update(r, m, up) counters_[r]++; if((counters_[r] >> m) == 0x80) { up(r); counters_[r] = unsigned(control_registers_[r]&0x7f) << m; }
// Note on slightly askew test: as far as I can make out, if the value in the register is 0x7f then what's supposed to happen
// is that the 0x7f is loaded, on the next clocked cycle the Vic spots a 0x7f, pumps the output, reloads, etc. No increment
// ever occurs. It's conditional. I don't really want two conditionals if I can avoid it so I'm incrementing regardless and
@ -114,7 +114,7 @@ void AudioGenerator::get_samples(std::size_t number_of_samples, int16_t *target)
// this sums the output of all three sounds channels plus a DC offset for volume;
// TODO: what's the real ratio of this stuff?
target[c] = static_cast<int16_t>(
target[c] = int16_t(
(shift_registers_[0]&1) +
(shift_registers_[1]&1) +
(shift_registers_[2]&1) +
@ -133,7 +133,7 @@ void AudioGenerator::skip_samples(std::size_t number_of_samples) {
}
void AudioGenerator::set_sample_volume_range(std::int16_t range) {
range_multiplier_ = static_cast<int16_t>(range / 64);
range_multiplier_ = int16_t(range / 64);
}
#undef shift

View File

@ -81,7 +81,7 @@ template <class BusHandler> class MOS6560 {
}
void set_clock_rate(double clock_rate) {
speaker_.set_input_rate(static_cast<float>(clock_rate / 4.0));
speaker_.set_input_rate(float(clock_rate / 4.0));
}
void set_scan_target(Outputs::Display::ScanTarget *scan_target) { crt_.set_scan_target(scan_target); }
@ -235,7 +235,7 @@ template <class BusHandler> 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 = static_cast<uint16_t>(registers_.video_matrix_start_address + video_matrix_address_counter_);
fetch_address = uint16_t(registers_.video_matrix_start_address + video_matrix_address_counter_);
video_matrix_address_counter_++;
if(
(current_character_row_ == 15) ||
@ -371,7 +371,7 @@ template <class BusHandler> class MOS6560 {
case 0x2:
registers_.number_of_columns = value & 0x7f;
registers_.video_matrix_start_address = static_cast<uint16_t>((registers_.video_matrix_start_address & 0x3c00) | ((value & 0x80) << 2));
registers_.video_matrix_start_address = uint16_t((registers_.video_matrix_start_address & 0x3c00) | ((value & 0x80) << 2));
break;
case 0x3:
@ -380,8 +380,8 @@ template <class BusHandler> class MOS6560 {
break;
case 0x5:
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));
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));
break;
case 0xa:

View File

@ -167,8 +167,8 @@ template <class T> class CRTC6845 {
private:
inline void perform_bus_cycle_phase1() {
// Skew theory of operation: keep a history of the last three states, and apply whichever is selected.
character_is_visible_shifter_ = (character_is_visible_shifter_ << 1) | static_cast<unsigned int>(character_is_visible_);
bus_state_.display_enable = (static_cast<int>(character_is_visible_shifter_) & display_skew_mask_) && line_is_visible_;
character_is_visible_shifter_ = (character_is_visible_shifter_ << 1) | unsigned(character_is_visible_);
bus_state_.display_enable = (int(character_is_visible_shifter_) & display_skew_mask_) && line_is_visible_;
bus_handler_.perform_bus_cycle_phase1(bus_state_);
}
@ -240,7 +240,7 @@ template <class T> class CRTC6845 {
inline void do_end_of_frame() {
line_counter_ = 0;
line_is_visible_ = true;
line_address_ = static_cast<uint16_t>((registers_[12] << 8) | registers_[13]);
line_address_ = uint16_t((registers_[12] << 8) | registers_[13]);
bus_state_.refresh_address = line_address_;
}

View File

@ -79,7 +79,7 @@ namespace {
i8272::i8272(BusHandler &bus_handler, Cycles clock_rate) :
Storage::Disk::MFMController(clock_rate),
bus_handler_(bus_handler) {
posit_event(static_cast<int>(Event8272::CommandByte));
posit_event(int(Event8272::CommandByte));
}
ClockingHint::Preference i8272::preferred_clocking() const {
@ -97,7 +97,7 @@ void i8272::run_for(Cycles cycles) {
if(delay_time_ > 0) {
if(cycles.as_integral() >= delay_time_) {
delay_time_ = 0;
posit_event(static_cast<int>(Event8272::Timer));
posit_event(int(Event8272::Timer));
} else {
delay_time_ -= cycles.as_integral();
}
@ -114,7 +114,7 @@ void i8272::run_for(Cycles cycles) {
while(steps--) {
// Perform a step.
int direction = (drives_[c].target_head_position < drives_[c].head_position) ? -1 : 1;
LOG("Target " << PADDEC(0) << drives_[c].target_head_position << " versus believed " << static_cast<int>(drives_[c].head_position));
LOG("Target " << PADDEC(0) << drives_[c].target_head_position << " versus believed " << int(drives_[c].head_position));
select_drive(c);
get_drive().step(Storage::Disk::HeadPosition(direction));
if(drives_[c].target_head_position >= 0) drives_[c].head_position += direction;
@ -156,7 +156,7 @@ void i8272::run_for(Cycles cycles) {
// check for busy plus ready disabled
if(is_executing_ && !get_drive().get_is_ready()) {
posit_event(static_cast<int>(Event8272::NoLongerReady));
posit_event(int(Event8272::NoLongerReady));
}
is_sleeping_ = !delay_time_ && !drives_seeking_ && !head_timers_running_;
@ -177,7 +177,7 @@ void i8272::write(int address, uint8_t value) {
} else {
// accumulate latest byte in the command byte sequence
command_.push_back(value);
posit_event(static_cast<int>(Event8272::CommandByte));
posit_event(int(Event8272::CommandByte));
}
}
@ -186,7 +186,7 @@ uint8_t i8272::read(int address) {
if(result_stack_.empty()) return 0xff;
uint8_t result = result_stack_.back();
result_stack_.pop_back();
if(result_stack_.empty()) posit_event(static_cast<int>(Event8272::ResultEmpty));
if(result_stack_.empty()) posit_event(int(Event8272::ResultEmpty));
return result;
} else {
@ -198,16 +198,16 @@ uint8_t i8272::read(int address) {
#define END_SECTION() }
#define MS_TO_CYCLES(x) x * 8000
#define WAIT_FOR_EVENT(mask) resume_point_ = __LINE__; interesting_event_mask_ = static_cast<int>(mask); return; case __LINE__:
#define WAIT_FOR_TIME(ms) resume_point_ = __LINE__; interesting_event_mask_ = static_cast<int>(Event8272::Timer); delay_time_ = MS_TO_CYCLES(ms); is_sleeping_ = false; update_clocking_observer(); case __LINE__: if(delay_time_) return;
#define WAIT_FOR_EVENT(mask) resume_point_ = __LINE__; interesting_event_mask_ = int(mask); return; case __LINE__:
#define WAIT_FOR_TIME(ms) resume_point_ = __LINE__; interesting_event_mask_ = int(Event8272::Timer); delay_time_ = MS_TO_CYCLES(ms); is_sleeping_ = false; update_clocking_observer(); case __LINE__: if(delay_time_) return;
#define PASTE(x, y) x##y
#define CONCAT(x, y) PASTE(x, y)
#define FIND_HEADER() \
set_data_mode(DataMode::Scanning); \
CONCAT(find_header, __LINE__): WAIT_FOR_EVENT(static_cast<int>(Event::Token) | static_cast<int>(Event::IndexHole)); \
if(event_type == static_cast<int>(Event::IndexHole)) { index_hole_limit_--; } \
CONCAT(find_header, __LINE__): WAIT_FOR_EVENT(int(Event::Token) | int(Event::IndexHole)); \
if(event_type == int(Event::IndexHole)) { index_hole_limit_--; } \
else if(get_latest_token().type == Token::ID) goto CONCAT(header_found, __LINE__); \
\
if(index_hole_limit_) goto CONCAT(find_header, __LINE__); \
@ -215,8 +215,8 @@ uint8_t i8272::read(int address) {
#define FIND_DATA() \
set_data_mode(DataMode::Scanning); \
CONCAT(find_data, __LINE__): WAIT_FOR_EVENT(static_cast<int>(Event::Token) | static_cast<int>(Event::IndexHole)); \
if(event_type == static_cast<int>(Event::Token)) { \
CONCAT(find_data, __LINE__): WAIT_FOR_EVENT(int(Event::Token) | int(Event::IndexHole)); \
if(event_type == int(Event::Token)) { \
if(get_latest_token().type == Token::Byte || get_latest_token().type == Token::Sync) goto CONCAT(find_data, __LINE__); \
}
@ -264,8 +264,8 @@ uint8_t i8272::read(int address) {
}
void i8272::posit_event(int event_type) {
if(event_type == static_cast<int>(Event::IndexHole)) index_hole_count_++;
if(event_type == static_cast<int>(Event8272::NoLongerReady)) {
if(event_type == int(Event::IndexHole)) index_hole_count_++;
if(event_type == int(Event8272::NoLongerReady)) {
SetNotReady();
goto abort;
}
@ -425,12 +425,12 @@ void i8272::posit_event(int event_type) {
// Performs the read data or read deleted data command.
read_data:
LOG(PADHEX(2) << "Read [deleted] data ["
<< static_cast<int>(command_[2]) << " "
<< static_cast<int>(command_[3]) << " "
<< static_cast<int>(command_[4]) << " "
<< static_cast<int>(command_[5]) << " ... "
<< static_cast<int>(command_[6]) << " "
<< static_cast<int>(command_[8]) << "]");
<< int(command_[2]) << " "
<< int(command_[3]) << " "
<< int(command_[4]) << " "
<< int(command_[5]) << " ... "
<< int(command_[6]) << " "
<< int(command_[8]) << "]");
read_next_data:
goto read_write_find_header;
@ -439,7 +439,7 @@ void i8272::posit_event(int event_type) {
read_data_found_header:
FIND_DATA();
ClearControlMark();
if(event_type == static_cast<int>(Event::Token)) {
if(event_type == int(Event::Token)) {
if(get_latest_token().type != Token::Data && get_latest_token().type != Token::DeletedData) {
// Something other than a data mark came next, impliedly an ID or index mark.
SetMissingAddressMark();
@ -470,24 +470,24 @@ void i8272::posit_event(int event_type) {
//
// TODO: consider DTL.
read_data_get_byte:
WAIT_FOR_EVENT(static_cast<int>(Event::Token) | static_cast<int>(Event::IndexHole));
if(event_type == static_cast<int>(Event::Token)) {
WAIT_FOR_EVENT(int(Event::Token) | int(Event::IndexHole));
if(event_type == int(Event::Token)) {
result_stack_.push_back(get_latest_token().byte_value);
distance_into_section_++;
SetDataRequest();
SetDataDirectionToProcessor();
WAIT_FOR_EVENT(static_cast<int>(Event8272::ResultEmpty) | static_cast<int>(Event::Token) | static_cast<int>(Event::IndexHole));
WAIT_FOR_EVENT(int(Event8272::ResultEmpty) | int(Event::Token) | int(Event::IndexHole));
}
switch(event_type) {
case static_cast<int>(Event8272::ResultEmpty): // The caller read the byte in time; proceed as normal.
case int(Event8272::ResultEmpty): // The caller read the byte in time; proceed as normal.
ResetDataRequest();
if(distance_into_section_ < (128 << size_)) goto read_data_get_byte;
break;
case static_cast<int>(Event::Token): // The caller hasn't read the old byte yet and a new one has arrived
case int(Event::Token): // The caller hasn't read the old byte yet and a new one has arrived
SetOverrun();
goto abort;
break;
case static_cast<int>(Event::IndexHole):
case int(Event::IndexHole):
SetEndOfCylinder();
goto abort;
break;
@ -515,12 +515,12 @@ void i8272::posit_event(int event_type) {
write_data:
LOG(PADHEX(2) << "Write [deleted] data ["
<< static_cast<int>(command_[2]) << " "
<< static_cast<int>(command_[3]) << " "
<< static_cast<int>(command_[4]) << " "
<< static_cast<int>(command_[5]) << " ... "
<< static_cast<int>(command_[6]) << " "
<< static_cast<int>(command_[8]) << "]");
<< int(command_[2]) << " "
<< int(command_[3]) << " "
<< int(command_[4]) << " "
<< int(command_[5]) << " ... "
<< int(command_[6]) << " "
<< int(command_[8]) << "]");
if(get_drive().get_is_read_only()) {
SetNotWriteable();
@ -571,7 +571,7 @@ void i8272::posit_event(int event_type) {
// Performs the read ID command.
read_id:
// Establishes the drive and head being addressed, and whether in double density mode.
LOG(PADHEX(2) << "Read ID [" << static_cast<int>(command_[0]) << " " << static_cast<int>(command_[1]) << "]");
LOG(PADHEX(2) << "Read ID [" << int(command_[0]) << " " << int(command_[1]) << "]");
// Sets a maximum index hole limit of 2 then waits either until it finds a header mark or sees too many index holes.
// If a header mark is found, reads in the following bytes that produce a header. Otherwise branches to data not found.
@ -594,10 +594,10 @@ void i8272::posit_event(int event_type) {
// Performs read track.
read_track:
LOG(PADHEX(2) << "Read track ["
<< static_cast<int>(command_[2]) << " "
<< static_cast<int>(command_[3]) << " "
<< static_cast<int>(command_[4]) << " "
<< static_cast<int>(command_[5]) << "]");
<< int(command_[2]) << " "
<< int(command_[3]) << " "
<< int(command_[4]) << " "
<< int(command_[5]) << "]");
// Wait for the index hole.
WAIT_FOR_EVENT(Event::IndexHole);
@ -627,7 +627,7 @@ void i8272::posit_event(int event_type) {
distance_into_section_++;
SetDataRequest();
// TODO: other possible exit conditions; find a way to merge with the read_data version of this.
WAIT_FOR_EVENT(static_cast<int>(Event8272::ResultEmpty));
WAIT_FOR_EVENT(int(Event8272::ResultEmpty));
ResetDataRequest();
if(distance_into_section_ < (128 << header_[2])) goto read_track_get_byte;
@ -664,13 +664,13 @@ void i8272::posit_event(int event_type) {
expects_input_ = true;
distance_into_section_ = 0;
format_track_write_header:
WAIT_FOR_EVENT(static_cast<int>(Event::DataWritten) | static_cast<int>(Event::IndexHole));
WAIT_FOR_EVENT(int(Event::DataWritten) | int(Event::IndexHole));
switch(event_type) {
case static_cast<int>(Event::IndexHole):
case int(Event::IndexHole):
SetOverrun();
goto abort;
break;
case static_cast<int>(Event::DataWritten):
case int(Event::DataWritten):
header_[distance_into_section_] = input_;
write_byte(input_);
has_input_ = false;
@ -683,10 +683,10 @@ void i8272::posit_event(int event_type) {
}
LOG(PADHEX(2) << "W:"
<< static_cast<int>(header_[0]) << " "
<< static_cast<int>(header_[1]) << " "
<< static_cast<int>(header_[2]) << " "
<< static_cast<int>(header_[3]) << ", "
<< int(header_[0]) << " "
<< int(header_[1]) << " "
<< int(header_[2]) << " "
<< int(header_[3]) << ", "
<< get_crc_generator().get_value());
write_crc();
@ -706,8 +706,8 @@ void i8272::posit_event(int event_type) {
// Otherwise, pad out to the index hole.
format_track_pad:
write_byte(get_is_double_density() ? 0x4e : 0xff);
WAIT_FOR_EVENT(static_cast<int>(Event::DataWritten) | static_cast<int>(Event::IndexHole));
if(event_type != static_cast<int>(Event::IndexHole)) goto format_track_pad;
WAIT_FOR_EVENT(int(Event::DataWritten) | int(Event::IndexHole));
if(event_type != int(Event::IndexHole)) goto format_track_pad;
end_writing();
@ -758,7 +758,7 @@ void i8272::posit_event(int event_type) {
// up in run_for understands to mean 'keep going until track 0 is active').
if(command_.size() > 2) {
drives_[drive].target_head_position = command_[2];
LOG(PADHEX(2) << "Seek to " << static_cast<int>(command_[2]));
LOG(PADHEX(2) << "Seek to " << int(command_[2]));
} else {
drives_[drive].target_head_position = -1;
drives_[drive].head_position = 0;
@ -789,7 +789,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] = static_cast<uint8_t>(found_drive);
status_[0] = uint8_t(found_drive);
main_status_ &= ~(1 << found_drive);
SetSeekEnd();
@ -819,7 +819,7 @@ void i8272::posit_event(int event_type) {
int drive = command_[1] & 3;
select_drive(drive);
result_stack_= {
static_cast<uint8_t>(
uint8_t(
(command_[1] & 7) | // drive and head number
0x08 | // single sided
(get_drive().get_is_track_zero() ? 0x10 : 0x00) |
@ -853,9 +853,9 @@ void i8272::posit_event(int event_type) {
// Posts whatever is in result_stack_ as a result phase. Be aware that it is a stack, so the
// last thing in it will be returned first.
post_result:
LOGNBR(PADHEX(2) << "Result to " << static_cast<int>(command_[0] & 0x1f) << ", main " << static_cast<int>(main_status_) << "; ");
LOGNBR(PADHEX(2) << "Result to " << int(command_[0] & 0x1f) << ", main " << int(main_status_) << "; ");
for(std::size_t c = 0; c < result_stack_.size(); c++) {
LOGNBR(" " << static_cast<int>(result_stack_[result_stack_.size() - 1 - c]));
LOGNBR(" " << int(result_stack_[result_stack_.size() - 1 - c]));
}
LOGNBR(std::endl);

View File

@ -68,7 +68,7 @@ class i8272 : public Storage::Disk::MFMController {
NoLongerReady = (1 << 6)
};
void posit_event(int type) final;
int interesting_event_mask_ = static_cast<int>(Event8272::CommandByte);
int interesting_event_mask_ = int(Event8272::CommandByte);
int resume_point_ = 0;
bool is_access_command_ = false;

View File

@ -33,7 +33,7 @@ struct ReverseTable {
ReverseTable() {
for(int c = 0; c < 256; ++c) {
map[c] = static_cast<uint8_t>(
map[c] = uint8_t(
((c & 0x80) >> 7) |
((c & 0x40) >> 5) |
((c & 0x20) >> 3) |
@ -144,7 +144,7 @@ void Base::LineBuffer::reset_sprite_collection() {
void Base::posit_sprite(LineBuffer &buffer, int sprite_number, int sprite_position, int screen_row) {
if(!(status_ & StatusSpriteOverflow)) {
status_ = static_cast<uint8_t>((status_ & ~0x1f) | (sprite_number & 0x1f));
status_ = uint8_t((status_ & ~0x1f) | (sprite_number & 0x1f));
}
if(buffer.sprites_stopped)
return;
@ -531,7 +531,7 @@ void TMS9918::write(int address, uint8_t value) {
// The RAM pointer is always set on a second write, regardless of
// whether the caller is intending to enqueue a VDP operation.
ram_pointer_ = (ram_pointer_ & 0x00ff) | static_cast<uint16_t>(value << 8);
ram_pointer_ = (ram_pointer_ & 0x00ff) | uint16_t(value << 8);
write_phase_ = false;
if(value & 0x80) {
@ -665,7 +665,7 @@ uint8_t TMS9918::get_current_line() {
}
}
return static_cast<uint8_t>(source_row);
return uint8_t(source_row);
}
uint8_t TMS9918::get_latched_horizontal_counter() {

View File

@ -352,9 +352,9 @@ class Base {
if(master_system_.cram_is_selected) {
// Adjust the palette.
master_system_.colour_ram[ram_pointer_ & 0x1f] = palette_pack(
static_cast<uint8_t>(((read_ahead_buffer_ >> 0) & 3) * 255 / 3),
static_cast<uint8_t>(((read_ahead_buffer_ >> 2) & 3) * 255 / 3),
static_cast<uint8_t>(((read_ahead_buffer_ >> 4) & 3) * 255 / 3)
uint8_t(((read_ahead_buffer_ >> 0) & 3) * 255 / 3),
uint8_t(((read_ahead_buffer_ >> 2) & 3) * 255 / 3),
uint8_t(((read_ahead_buffer_ >> 4) & 3) * 255 / 3)
);
// Schedule a CRAM dot; this is scheduled for wherever it should appear
@ -518,7 +518,7 @@ class Base {
fetch_columns_4(location+12, column+4);
LineBuffer &line_buffer = line_buffers_[write_pointer_.row];
const size_t row_base = pattern_name_address_ & (0x3c00 | static_cast<size_t>(write_pointer_.row >> 3) * 40);
const size_t row_base = pattern_name_address_ & (0x3c00 | size_t(write_pointer_.row >> 3) * 40);
const size_t row_offset = pattern_generator_table_address_ & (0x3800 | (write_pointer_.row & 7));
switch(start) {
@ -731,7 +731,7 @@ class Base {
const size_t scrolled_column = (column - horizontal_offset) & 0x1f;\
const size_t address = row_info.pattern_address_base + (scrolled_column << 1); \
line_buffer.names[column].flags = ram_[address+1]; \
line_buffer.names[column].offset = static_cast<size_t>( \
line_buffer.names[column].offset = size_t( \
(((line_buffer.names[column].flags&1) << 8) | ram_[address]) << 5 \
) + row_info.sub_row[(line_buffer.names[column].flags&4) >> 2]; \
}
@ -785,7 +785,7 @@ class Base {
};
const RowInfo scrolled_row_info = {
(pattern_name_address & size_t(((scrolled_row & ~7) << 3) | 0x3800)) - pattern_name_offset,
{static_cast<size_t>((scrolled_row & 7) << 2), 28 ^ static_cast<size_t>((scrolled_row & 7) << 2)}
{size_t((scrolled_row & 7) << 2), 28 ^ size_t((scrolled_row & 7) << 2)}
};
RowInfo row_info;
if(master_system_.vertical_scroll_lock) {

View File

@ -85,13 +85,13 @@ void DiskII::run_for(const Cycles cycles) {
--flux_duration_;
if(!flux_duration_) inputs_ |= input_flux;
}
state_ = state_machine_[static_cast<std::size_t>(address)];
state_ = state_machine_[size_t(address)];
switch(state_ & 0xf) {
default: shift_register_ = 0; break; // clear
case 0x8: break; // nop
default: shift_register_ = 0; break; // clear
case 0x8: break; // nop
case 0x9: shift_register_ = static_cast<uint8_t>(shift_register_ << 1); break; // shift left, bringing in a zero
case 0xd: shift_register_ = static_cast<uint8_t>((shift_register_ << 1) | 1); break; // shift left, bringing in a one
case 0x9: shift_register_ = uint8_t(shift_register_ << 1); break; // shift left, bringing in a zero
case 0xd: shift_register_ = uint8_t((shift_register_ << 1) | 1); break; // shift left, bringing in a one
case 0xa: // shift right, bringing in write protected status
shift_register_ = (shift_register_ >> 1) | (is_write_protected() ? 0x80 : 0x00);
@ -105,7 +105,7 @@ void DiskII::run_for(const Cycles cycles) {
return;
}
break;
case 0xb: shift_register_ = data_input_; break; // load data register from data bus
case 0xb: shift_register_ = data_input_; break; // load data register from data bus
}
// Currently writing?

View File

@ -87,13 +87,13 @@ void SCC::write(uint16_t address, uint8_t value) {
void SCC::evaluate_output_volume() {
transient_output_level_ =
static_cast<int16_t>(
int16_t(
((
(channel_enable_ & 0x01) ? static_cast<int8_t>(waves_[0].samples[channels_[0].offset]) * channels_[0].amplitude : 0 +
(channel_enable_ & 0x02) ? static_cast<int8_t>(waves_[1].samples[channels_[1].offset]) * channels_[1].amplitude : 0 +
(channel_enable_ & 0x04) ? static_cast<int8_t>(waves_[2].samples[channels_[2].offset]) * channels_[2].amplitude : 0 +
(channel_enable_ & 0x08) ? static_cast<int8_t>(waves_[3].samples[channels_[3].offset]) * channels_[3].amplitude : 0 +
(channel_enable_ & 0x10) ? static_cast<int8_t>(waves_[3].samples[channels_[4].offset]) * channels_[4].amplitude : 0
(channel_enable_ & 0x01) ? int8_t(waves_[0].samples[channels_[0].offset]) * channels_[0].amplitude : 0 +
(channel_enable_ & 0x02) ? int8_t(waves_[1].samples[channels_[1].offset]) * channels_[1].amplitude : 0 +
(channel_enable_ & 0x04) ? int8_t(waves_[2].samples[channels_[2].offset]) * channels_[2].amplitude : 0 +
(channel_enable_ & 0x08) ? int8_t(waves_[3].samples[channels_[3].offset]) * channels_[3].amplitude : 0 +
(channel_enable_ & 0x10) ? int8_t(waves_[3].samples[channels_[4].offset]) * channels_[4].amplitude : 0
) * master_volume_) / (255*15*5)
// Five channels, each with 8-bit samples and 4-bit volumes implies a natural range of 0 to 255*15*5.
);

View File

@ -39,9 +39,9 @@ SN76489::SN76489(Personality personality, Concurrency::DeferringAsyncTaskQueue &
void SN76489::set_sample_volume_range(std::int16_t range) {
// Build a volume table.
double multiplier = pow(10.0, -0.1);
double volume = static_cast<float>(range) / 4.0f; // As there are four channels.
double volume = float(range) / 4.0f; // As there are four channels.
for(int c = 0; c < 16; ++c) {
volumes_[c] = (int)round(volume);
volumes_[c] = int(round(volume));
volume *= multiplier;
}
volumes_[15] = 0;
@ -65,7 +65,7 @@ void SN76489::write(uint8_t value) {
if(value & 0x80) {
channels_[channel].divider = (channels_[channel].divider & ~0xf) | (value & 0xf);
} else {
channels_[channel].divider = static_cast<uint16_t>((channels_[channel].divider & 0xf) | ((value & 0x3f) << 4));
channels_[channel].divider = uint16_t((channels_[channel].divider & 0xf) | ((value & 0x3f) << 4));
}
} else {
// writes to the noise register always reset the shifter
@ -77,7 +77,7 @@ void SN76489::write(uint8_t value) {
noise_mode_ = shifter_is_16bit_ ? Periodic16 : Periodic15;
}
channels_[3].divider = static_cast<uint16_t>(0x10 << (value & 3));
channels_[3].divider = uint16_t(0x10 << (value & 3));
// Special case: if these bits are both set, the noise channel should track channel 2,
// which is marked with a divider of 0xffff.
if(channels_[3].divider == 0x80) channels_[3].divider = 0xffff;
@ -91,7 +91,7 @@ bool SN76489::is_zero_level() const {
}
void SN76489::evaluate_output_volume() {
output_volume_ = static_cast<int16_t>(
output_volume_ = int16_t(
channels_[0].level * volumes_[channels_[0].volume] +
channels_[1].level * volumes_[channels_[1].volume] +
channels_[2].level * volumes_[channels_[2].volume] +

View File

@ -89,7 +89,7 @@ void Line::reset_writing() {
events_.clear();
}
bool Line::read() {
bool Line::read() const {
return level_;
}
@ -136,5 +136,5 @@ void Line::update_delegate(bool level) {
Cycles::IntType Line::minimum_write_cycles_for_read_delegate_bit() {
if(!read_delegate_) return 0;
return 1 + (read_delegate_bit_length_ * static_cast<unsigned int>(clock_rate_.as_integral())).get<int>();
return 1 + (read_delegate_bit_length_ * unsigned(clock_rate_.as_integral())).get<int>();
}

View File

@ -59,7 +59,7 @@ class Line {
void reset_writing();
/// @returns The instantaneous level of this line.
bool read();
bool read() const;
struct ReadDelegate {
virtual bool serial_line_did_produce_bit(Line *line, int bit) = 0;

View File

@ -161,11 +161,11 @@ class ConcreteJoystick: public Joystick {
const bool is_digital_axis = input.is_digital_axis();
const bool is_analogue_axis = input.is_analogue_axis();
if(is_digital_axis || is_analogue_axis) {
const size_t required_size = static_cast<size_t>(input.info.control.index+1);
const size_t required_size = size_t(input.info.control.index+1);
if(stick_types_.size() < required_size) {
stick_types_.resize(required_size);
}
stick_types_[static_cast<size_t>(input.info.control.index)] = is_digital_axis ? StickType::Digital : StickType::Analogue;
stick_types_[size_t(input.info.control.index)] = is_digital_axis ? StickType::Digital : StickType::Analogue;
}
}
}

View File

@ -20,7 +20,7 @@ Keyboard::Keyboard(const std::set<Key> &observed_keys, const std::set<Key> &esse
observed_keys_(observed_keys), essential_modifiers_(essential_modifiers), is_exclusive_(false) {}
bool Keyboard::set_key_pressed(Key key, char value, bool is_pressed) {
std::size_t key_offset = static_cast<std::size_t>(key);
std::size_t key_offset = size_t(key);
if(key_offset >= key_states_.size()) {
key_states_.resize(key_offset+1, false);
}
@ -44,7 +44,7 @@ void Keyboard::set_delegate(Delegate *delegate) {
}
bool Keyboard::get_key_state(Key key) {
std::size_t key_offset = static_cast<std::size_t>(key);
std::size_t key_offset = size_t(key);
if(key_offset >= key_states_.size()) return false;
return key_states_[key_offset];
}

View File

@ -331,7 +331,7 @@ template <Analyser::Static::AppleII::Target::Model model> class ConcreteMachine:
// The speaker, however, should think it is clocked at half the master clock, per a general
// decision to sample it at seven times the CPU clock (plus stretches).
speaker_.set_input_rate(static_cast<float>(master_clock / (2.0 * static_cast<float>(audio_divider))));
speaker_.set_input_rate(float(master_clock / (2.0 * float(audio_divider))));
// Apply a 6Khz low-pass filter. This was picked by ear and by an attempt to understand the
// Apple II schematic but, well, I don't claim much insight on the latter. This is definitely
@ -387,7 +387,7 @@ template <Analyser::Static::AppleII::Target::Model model> class ConcreteMachine:
rom_ = std::move(*roms[1]);
if(rom_.size() > rom_size) {
rom_.erase(rom_.begin(), rom_.end() - static_cast<off_t>(rom_size));
rom_.erase(rom_.begin(), rom_.end() - off_t(rom_size));
}
video_.set_character_rom(*roms[0]);
@ -735,7 +735,7 @@ template <Analyser::Static::AppleII::Target::Model model> class ConcreteMachine:
// If the selected card is a just-in-time card, update the just-in-time cards,
// and then message it specifically.
const bool is_read = isReadOperation(operation);
Apple::II::Card *const target = cards_[static_cast<size_t>(card_number)].get();
Apple::II::Card *const target = cards_[size_t(card_number)].get();
if(target && !is_every_cycle_card(target)) {
update_just_in_time_cards();
target->perform_bus_operation(select, is_read, address, value);
@ -835,10 +835,10 @@ template <Analyser::Static::AppleII::Target::Model model> class ConcreteMachine:
}
// Prior to the IIe, the keyboard could produce uppercase only.
if(!is_iie()) value = static_cast<char>(toupper(value));
if(!is_iie()) value = char(toupper(value));
if(is_pressed) {
keyboard_input_ = static_cast<uint8_t>(value | 0x80);
keyboard_input_ = uint8_t(value | 0x80);
key_is_down_ = true;
} else {
if((keyboard_input_ & 0x7f) == value) {

View File

@ -41,7 +41,7 @@ void DiskIICard::perform_bus_operation(Select select, bool is_read, uint16_t add
const int disk_value = diskii_.read_address(address);
if(is_read) {
if(disk_value != diskii_.DidNotLoad)
*value = static_cast<uint8_t>(disk_value);
*value = uint8_t(disk_value);
}
} break;
case Device:

View File

@ -174,7 +174,7 @@ void VideoBase::output_text(uint8_t *target, const uint8_t *const source, size_t
for(size_t c = 0; c < length; ++c) {
const int character = source[c] & character_zones[source[c] >> 6].address_mask;
const uint8_t xor_mask = character_zones[source[c] >> 6].xor_mask;
const std::size_t character_address = static_cast<std::size_t>(character << 3) + pixel_row;
const std::size_t character_address = size_t(character << 3) + pixel_row;
const uint8_t character_pattern = character_rom_[character_address] ^ xor_mask;
// The character ROM is output MSB to LSB rather than LSB to MSB.
@ -193,19 +193,19 @@ void VideoBase::output_text(uint8_t *target, const uint8_t *const source, size_t
void VideoBase::output_double_text(uint8_t *target, const uint8_t *const source, const uint8_t *const auxiliary_source, size_t length, size_t pixel_row) const {
for(size_t c = 0; c < length; ++c) {
const std::size_t character_addresses[2] = {
static_cast<std::size_t>(
size_t(
(auxiliary_source[c] & character_zones[auxiliary_source[c] >> 6].address_mask) << 3
) + pixel_row,
static_cast<std::size_t>(
size_t(
(source[c] & character_zones[source[c] >> 6].address_mask) << 3
) + pixel_row
};
const uint8_t character_patterns[2] = {
static_cast<uint8_t>(
uint8_t(
character_rom_[character_addresses[0]] ^ character_zones[auxiliary_source[c] >> 6].xor_mask
),
static_cast<uint8_t>(
uint8_t(
character_rom_[character_addresses[1]] ^ character_zones[source[c] >> 6].xor_mask
)
};
@ -235,7 +235,7 @@ void VideoBase::output_low_resolution(uint8_t *target, const uint8_t *const sour
for(size_t c = 0; c < length; ++c) {
// Low-resolution graphics mode shifts the colour code on a loop, but has to account for whether this
// 14-sample output window is starting at the beginning of a colour cycle or halfway through.
if((column + static_cast<int>(c))&1) {
if((column + int(c))&1) {
target[0] = target[4] = target[8] = target[12] = (source[c] >> row_shift) & 4;
target[1] = target[5] = target[9] = target[13] = (source[c] >> row_shift) & 8;
target[2] = target[6] = target[10] = (source[c] >> row_shift) & 1;
@ -269,7 +269,7 @@ void VideoBase::output_fat_low_resolution(uint8_t *target, const uint8_t *const
void VideoBase::output_double_low_resolution(uint8_t *target, const uint8_t *const source, const uint8_t *const auxiliary_source, size_t length, int column, int row) const {
const int row_shift = row&4;
for(size_t c = 0; c < length; ++c) {
if((column + static_cast<int>(c))&1) {
if((column + int(c))&1) {
target[0] = target[4] = (auxiliary_source[c] >> row_shift) & 2;
target[1] = target[5] = (auxiliary_source[c] >> row_shift) & 4;
target[2] = target[6] = (auxiliary_source[c] >> row_shift) & 8;

View File

@ -164,7 +164,7 @@ class VideoBase {
// State affecting logical state.
int row_ = 0, column_ = 0, flash_ = 0;
uint8_t flash_mask() {
return static_cast<uint8_t>((flash_ / flash_length) * 0xff);
return uint8_t((flash_ / flash_length) * 0xff);
}
// Enumerates all Apple II and IIe display modes.
@ -178,7 +178,7 @@ class VideoBase {
FatLowRes
};
bool is_text_mode(GraphicsMode m) { return m <= GraphicsMode::DoubleText; }
bool is_double_mode(GraphicsMode m) { return !!(static_cast<int>(m)&1); }
bool is_double_mode(GraphicsMode m) { return !!(int(m)&1); }
// Various soft-switch values.
bool alternative_character_set_ = false, set_alternative_character_set_ = false;
@ -309,7 +309,7 @@ template <class BusHandler, bool is_iie> class Video: public VideoBase {
}
// Calculate the address and return the value.
uint16_t read_address = static_cast<uint16_t>(get_row_address(mapped_row) + mapped_column - 25);
uint16_t read_address = uint16_t(get_row_address(mapped_row) + mapped_column - 25);
uint8_t value, aux_value;
bus_handler_.perform_read(read_address, 1, &value, &aux_value);
return value;
@ -378,7 +378,7 @@ template <class BusHandler, bool is_iie> class Video: public VideoBase {
// 40 columns of rows prior to 192.
if(row_ < 192 && column_ < 40) {
const int character_row = row_ >> 3;
const uint16_t row_address = static_cast<uint16_t>((character_row >> 3) * 40 + ((character_row&7) << 7));
const uint16_t row_address = uint16_t((character_row >> 3) * 40 + ((character_row&7) << 7));
// Grab the memory contents that'll be needed momentarily.
const int fetch_end = std::min(40, ending_column);
@ -390,21 +390,21 @@ template <class BusHandler, bool is_iie> class Video: public VideoBase {
case GraphicsMode::LowRes:
case GraphicsMode::FatLowRes:
case GraphicsMode::DoubleLowRes: {
const uint16_t text_address = static_cast<uint16_t>(((video_page()+1) * 0x400) + row_address);
fetch_address = static_cast<uint16_t>(text_address + column_);
const uint16_t text_address = uint16_t(((video_page()+1) * 0x400) + row_address);
fetch_address = uint16_t(text_address + column_);
} break;
case GraphicsMode::HighRes:
case GraphicsMode::DoubleHighRes:
fetch_address = static_cast<uint16_t>(((video_page()+1) * 0x2000) + row_address + ((row_&7) << 10) + column_);
fetch_address = uint16_t(((video_page()+1) * 0x2000) + row_address + ((row_&7) << 10) + column_);
break;
}
bus_handler_.perform_read(
fetch_address,
static_cast<size_t>(fetch_end - column_),
&base_stream_[static_cast<size_t>(column_)],
&auxiliary_stream_[static_cast<size_t>(column_)]);
size_t(fetch_end - column_),
&base_stream_[size_t(column_)],
&auxiliary_stream_[size_t(column_)]);
}
if(row_ < 192) {
@ -439,25 +439,25 @@ template <class BusHandler, bool is_iie> class Video: public VideoBase {
case GraphicsMode::Text:
output_text(
&pixel_pointer_[pixel_start * 14 + 7],
&base_stream_[static_cast<size_t>(pixel_start)],
static_cast<size_t>(pixel_end - pixel_start),
static_cast<size_t>(pixel_row));
&base_stream_[size_t(pixel_start)],
size_t(pixel_end - pixel_start),
size_t(pixel_row));
break;
case GraphicsMode::DoubleText:
output_double_text(
&pixel_pointer_[pixel_start * 14],
&base_stream_[static_cast<size_t>(pixel_start)],
&auxiliary_stream_[static_cast<size_t>(pixel_start)],
static_cast<size_t>(pixel_end - pixel_start),
static_cast<size_t>(pixel_row));
&base_stream_[size_t(pixel_start)],
&auxiliary_stream_[size_t(pixel_start)],
size_t(pixel_end - pixel_start),
size_t(pixel_row));
break;
case GraphicsMode::LowRes:
output_low_resolution(
&pixel_pointer_[pixel_start * 14 + 7],
&base_stream_[static_cast<size_t>(pixel_start)],
static_cast<size_t>(pixel_end - pixel_start),
&base_stream_[size_t(pixel_start)],
size_t(pixel_end - pixel_start),
pixel_start,
pixel_row);
break;
@ -465,8 +465,8 @@ template <class BusHandler, bool is_iie> class Video: public VideoBase {
case GraphicsMode::FatLowRes:
output_fat_low_resolution(
&pixel_pointer_[pixel_start * 14 + 7],
&base_stream_[static_cast<size_t>(pixel_start)],
static_cast<size_t>(pixel_end - pixel_start),
&base_stream_[size_t(pixel_start)],
size_t(pixel_end - pixel_start),
pixel_start,
pixel_row);
break;
@ -474,9 +474,9 @@ template <class BusHandler, bool is_iie> class Video: public VideoBase {
case GraphicsMode::DoubleLowRes:
output_double_low_resolution(
&pixel_pointer_[pixel_start * 14],
&base_stream_[static_cast<size_t>(pixel_start)],
&auxiliary_stream_[static_cast<size_t>(pixel_start)],
static_cast<size_t>(pixel_end - pixel_start),
&base_stream_[size_t(pixel_start)],
&auxiliary_stream_[size_t(pixel_start)],
size_t(pixel_end - pixel_start),
pixel_start,
pixel_row);
break;
@ -484,16 +484,16 @@ template <class BusHandler, bool is_iie> class Video: public VideoBase {
case GraphicsMode::HighRes:
output_high_resolution(
&pixel_pointer_[pixel_start * 14 + 7],
&base_stream_[static_cast<size_t>(pixel_start)],
static_cast<size_t>(pixel_end - pixel_start));
&base_stream_[size_t(pixel_start)],
size_t(pixel_end - pixel_start));
break;
case GraphicsMode::DoubleHighRes:
output_double_high_resolution(
&pixel_pointer_[pixel_start * 14],
&base_stream_[static_cast<size_t>(pixel_start)],
&auxiliary_stream_[static_cast<size_t>(pixel_start)],
static_cast<size_t>(pixel_end - pixel_start));
&base_stream_[size_t(pixel_start)],
&auxiliary_stream_[size_t(pixel_start)],
size_t(pixel_end - pixel_start));
break;
default: break;
@ -596,12 +596,12 @@ template <class BusHandler, bool is_iie> class Video: public VideoBase {
uint16_t get_row_address(int row) {
const int character_row = row >> 3;
const int pixel_row = row & 7;
const uint16_t row_address = static_cast<uint16_t>((character_row >> 3) * 40 + ((character_row&7) << 7));
const uint16_t row_address = uint16_t((character_row >> 3) * 40 + ((character_row&7) << 7));
const GraphicsMode pixel_mode = graphics_mode(row);
return ((pixel_mode == GraphicsMode::HighRes) || (pixel_mode == GraphicsMode::DoubleHighRes)) ?
static_cast<uint16_t>(((video_page()+1) * 0x2000) + row_address + ((pixel_row&7) << 10)) :
static_cast<uint16_t>(((video_page()+1) * 0x400) + row_address);
uint16_t(((video_page()+1) * 0x2000) + row_address + ((pixel_row&7) << 10)) :
uint16_t(((video_page()+1) * 0x400) + row_address);
}
BusHandler &bus_handler_;

View File

@ -156,7 +156,7 @@ class ConcreteMachine:
// to satisfy CRTMachine::Machine
void set_scan_target(Outputs::Display::ScanTarget *scan_target) final {
bus_->speaker_.set_input_rate(static_cast<float>(get_clock_rate() / static_cast<double>(CPUTicksPerAudioTick)));
bus_->speaker_.set_input_rate(float(get_clock_rate() / double(CPUTicksPerAudioTick)));
bus_->tia_.set_crt_delegate(&frequency_mismatch_warner_);
bus_->tia_.set_scan_target(scan_target);
}

View File

@ -35,7 +35,7 @@ class Pitfall2: public BusExtender {
if(isReadOperation(operation)) {
*value = random_number_generator_;
}
random_number_generator_ = static_cast<uint8_t>(
random_number_generator_ = uint8_t(
(random_number_generator_ << 1) |
(~( (random_number_generator_ >> 7) ^
(random_number_generator_ >> 5) ^
@ -69,7 +69,7 @@ class Pitfall2: public BusExtender {
mask_[address & 7] = 0x00;
break;
case 0x1058: case 0x1059: case 0x105a: case 0x105b: case 0x105c: case 0x105d: case 0x105e: case 0x105f:
featcher_address_[address & 7] = (featcher_address_[address & 7] & 0x00ff) | static_cast<uint16_t>(*value << 8);
featcher_address_[address & 7] = (featcher_address_[address & 7] & 0x00ff) | uint16_t(*value << 8);
break;
case 0x1070: case 0x1071: case 0x1072: case 0x1073: case 0x1074: case 0x1075: case 0x1076: case 0x1077:
random_number_generator_ = 0;

View File

@ -28,19 +28,19 @@ TIA::TIA():
set_output_mode(OutputMode::NTSC);
for(int c = 0; c < 256; c++) {
reverse_table[c] = static_cast<uint8_t>(
reverse_table[c] = 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)
);
}
for(int c = 0; c < 64; c++) {
bool has_playfield = c & static_cast<int>(CollisionType::Playfield);
bool has_ball = c & static_cast<int>(CollisionType::Ball);
bool has_player0 = c & static_cast<int>(CollisionType::Player0);
bool has_player1 = c & static_cast<int>(CollisionType::Player1);
bool has_missile0 = c & static_cast<int>(CollisionType::Missile0);
bool has_missile1 = c & static_cast<int>(CollisionType::Missile1);
bool has_playfield = c & int(CollisionType::Playfield);
bool has_ball = c & int(CollisionType::Ball);
bool has_player0 = c & int(CollisionType::Player0);
bool has_player1 = c & int(CollisionType::Player1);
bool has_missile0 = c & int(CollisionType::Missile0);
bool has_missile1 = c & int(CollisionType::Missile1);
uint8_t collision_registers[8];
collision_registers[0] = ((has_missile0 && has_player1) ? 0x80 : 0x00) | ((has_missile0 && has_player0) ? 0x40 : 0x00);
@ -62,51 +62,51 @@ TIA::TIA():
(collision_registers[7] << 8);
// all priority modes show the background if nothing else is present
colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::Standard)][c] =
colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::ScoreLeft)][c] =
colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::ScoreRight)][c] =
colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::OnTop)][c] = static_cast<uint8_t>(ColourIndex::Background);
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);
// 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_[static_cast<int>(ColourMode::Standard)][c] = static_cast<uint8_t>(ColourIndex::PlayfieldBall);
colour_mask_by_mode_collision_flags_[int(ColourMode::Standard)][c] = 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_[static_cast<int>(ColourMode::ScoreLeft)][c] =
colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::ScoreRight)][c] = static_cast<uint8_t>(ColourIndex::PlayfieldBall);
colour_mask_by_mode_collision_flags_[int(ColourMode::ScoreLeft)][c] =
colour_mask_by_mode_collision_flags_[int(ColourMode::ScoreRight)][c] = 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
if(has_player1 || has_missile1) {
colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::Standard)][c] =
colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::ScoreLeft)][c] =
colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::ScoreRight)][c] =
colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::OnTop)][c] = static_cast<uint8_t>(ColourIndex::PlayerMissile1);
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);
}
// 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_[static_cast<int>(ColourMode::ScoreRight)][c] = static_cast<uint8_t>(ColourIndex::PlayerMissile1);
colour_mask_by_mode_collision_flags_[int(ColourMode::ScoreRight)][c] = uint8_t(ColourIndex::PlayerMissile1);
}
// next test for everybody: if there is a player 0 or missile 0 pixel, plot that colour instead
if(has_player0 || has_missile0) {
colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::Standard)][c] =
colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::ScoreLeft)][c] =
colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::ScoreRight)][c] =
colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::OnTop)][c] = static_cast<uint8_t>(ColourIndex::PlayerMissile0);
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);
}
// 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_[static_cast<int>(ColourMode::ScoreLeft)][c] = static_cast<uint8_t>(ColourIndex::PlayerMissile0);
colour_mask_by_mode_collision_flags_[int(ColourMode::ScoreLeft)][c] = 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_[static_cast<int>(ColourMode::OnTop)][c] = static_cast<uint8_t>(ColourIndex::PlayfieldBall);
colour_mask_by_mode_collision_flags_[int(ColourMode::OnTop)][c] = uint8_t(ColourIndex::PlayfieldBall);
}
}
}
@ -224,16 +224,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) | (static_cast<uint32_t>(reverse_table[value & 0xf0]) << 16);
background_[0] = (background_[0] & 0xffff0) | static_cast<uint32_t>(value >> 4);
background_[1] = (background_[1] & 0x0ffff) | (uint32_t(reverse_table[value & 0xf0]) << 16);
background_[0] = (background_[0] & 0xffff0) | uint32_t(value >> 4);
break;
case 1:
background_[1] = (background_[1] & 0xf00ff) | (static_cast<uint32_t>(value) << 8);
background_[0] = (background_[0] & 0xff00f) | (static_cast<uint32_t>(reverse_table[value]) << 4);
background_[1] = (background_[1] & 0xf00ff) | (uint32_t(value) << 8);
background_[0] = (background_[0] & 0xff00f) | (uint32_t(reverse_table[value]) << 4);
break;
case 2:
background_[1] = (background_[1] & 0xfff00) | reverse_table[value];
background_[0] = (background_[0] & 0x00fff) | (static_cast<uint32_t>(value) << 12);
background_[0] = (background_[0] & 0x00fff) | (uint32_t(value) << 12);
break;
}
}
@ -374,7 +374,7 @@ void TIA::clear_motion() {
}
uint8_t TIA::get_collision_flags(int offset) {
return static_cast<uint8_t>((collision_flags_ >> (offset << 1)) << 6) & 0xc0;
return uint8_t((collision_flags_ >> (offset << 1)) << 6) & 0xc0;
}
void TIA::clear_collision_flags() {
@ -414,11 +414,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], 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_);
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_);
// convert to television signals
@ -505,18 +505,18 @@ void TIA::output_pixels(int start, int end) {
if(playfield_priority_ == PlayfieldPriority::Score) {
while(start < end && start < first_pixel_cycle + 80) {
uint8_t buffer_value = collision_buffer_[start - first_pixel_cycle];
pixel_target_[target_position] = colour_palette_[colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::ScoreLeft)][buffer_value]].luminance_phase;
pixel_target_[target_position] = colour_palette_[colour_mask_by_mode_collision_flags_[int(ColourMode::ScoreLeft)][buffer_value]].luminance_phase;
start++;
target_position++;
}
while(start < end) {
uint8_t buffer_value = collision_buffer_[start - first_pixel_cycle];
pixel_target_[target_position] = colour_palette_[colour_mask_by_mode_collision_flags_[static_cast<int>(ColourMode::ScoreRight)][buffer_value]].luminance_phase;
pixel_target_[target_position] = colour_palette_[colour_mask_by_mode_collision_flags_[int(ColourMode::ScoreRight)][buffer_value]].luminance_phase;
start++;
target_position++;
}
} else {
int table_index = static_cast<int>((playfield_priority_ == PlayfieldPriority::Standard) ? ColourMode::Standard : ColourMode::OnTop);
int table_index = int((playfield_priority_ == PlayfieldPriority::Standard) ? ColourMode::Standard : ColourMode::OnTop);
while(start < end) {
uint8_t buffer_value = collision_buffer_[start - first_pixel_cycle];
pixel_target_[target_position] = colour_palette_[colour_mask_by_mode_collision_flags_[table_index][buffer_value]].luminance_phase;

View File

@ -122,7 +122,7 @@ class ConcreteMachine:
ay_(GI::AY38910::Personality::AY38910, audio_queue_),
mixer_(sn76489_, ay_),
speaker_(mixer_) {
speaker_.set_input_rate(3579545.0f / static_cast<float>(sn76489_divider));
speaker_.set_input_rate(3579545.0f / float(sn76489_divider));
set_clock_rate(3579545);
joysticks_.emplace_back(new Joystick);
joysticks_.emplace_back(new Joystick);
@ -143,7 +143,7 @@ class ConcreteMachine:
if(cartridge_.size() >= 32768)
cartridge_address_limit_ = 0xffff;
else
cartridge_address_limit_ = static_cast<uint16_t>(0x8000 + cartridge_.size() - 1);
cartridge_address_limit_ = uint16_t(0x8000 + cartridge_.size() - 1);
if(cartridge_.size() > 32768) {
// Ensure the cartrige is a multiple of 16kb in size, as that won't
@ -381,7 +381,7 @@ class ConcreteMachine:
private:
inline void page_megacart(uint16_t address) {
const std::size_t selected_start = (static_cast<std::size_t>(address&63) << 14) % cartridge_.size();
const std::size_t selected_start = (size_t(address&63) << 14) % cartridge_.size();
cartridge_pages_[1] = &cartridge_[selected_start];
}
inline void update_audio() {

View File

@ -139,7 +139,7 @@ void MachineBase::process_input_bit(int value) {
}
bit_window_offset_++;
if(bit_window_offset_ == 8) {
drive_VIA_port_handler_.set_data_input(static_cast<uint8_t>(shift_register_));
drive_VIA_port_handler_.set_data_input(uint8_t(shift_register_));
bit_window_offset_ = 0;
if(drive_VIA_port_handler_.get_should_set_overflow()) {
m6502_.set_overflow_line(true);
@ -158,7 +158,7 @@ void MachineBase::drive_via_did_step_head(void *driveVIA, int direction) {
}
void MachineBase::drive_via_did_set_data_density(void *driveVIA, int density) {
set_expected_bit_length(Storage::Encodings::CommodoreGCR::length_of_a_bit_in_time_zone(static_cast<unsigned int>(density)));
set_expected_bit_length(Storage::Encodings::CommodoreGCR::length_of_a_bit_in_time_zone(unsigned(density)));
}
// MARK: - SerialPortVIA
@ -177,7 +177,7 @@ void SerialPortVIA::set_port_output(MOS::MOS6522::Port port, uint8_t value, uint
attention_acknowledge_level_ = !(value&0x10);
data_level_output_ = (value&0x02);
serialPort->set_output(::Commodore::Serial::Line::Clock, static_cast<::Commodore::Serial::LineLevel>(!(value&0x08)));
serialPort->set_output(::Commodore::Serial::Line::Clock, ::Commodore::Serial::LineLevel(!(value&0x08)));
update_data_line();
}
}
@ -206,7 +206,7 @@ void SerialPortVIA::update_data_line() {
if(serialPort) {
// "ATN (Attention) is an input on pin 3 of P2 and P3 that is sensed at PB7 and CA1 of UC3 after being inverted by UA1"
serialPort->set_output(::Commodore::Serial::Line::Data,
static_cast<::Commodore::Serial::LineLevel>(!data_level_output_ && (attention_level_input_ != attention_acknowledge_level_)));
::Commodore::Serial::LineLevel(!data_level_output_ && (attention_level_input_ != attention_acknowledge_level_)));
}
}
@ -281,7 +281,7 @@ void DriveVIA::set_activity_observer(Activity::Observer *observer) {
void SerialPort::set_input(::Commodore::Serial::Line line, ::Commodore::Serial::LineLevel level) {
std::shared_ptr<SerialPortVIA> serialPortVIA = serial_port_VIA_.lock();
if(serialPortVIA) serialPortVIA->set_serial_line_state(line, static_cast<bool>(level));
if(serialPortVIA) serialPortVIA->set_serial_line_state(line, bool(level));
}
void SerialPort::set_serial_port_via(const std::shared_ptr<SerialPortVIA> &serialPortVIA) {

View File

@ -31,12 +31,12 @@ void ::Commodore::Serial::AttachPortAndBus(std::shared_ptr<Port> port, std::shar
void Bus::add_port(std::shared_ptr<Port> port) {
ports_.push_back(port);
for(int line = static_cast<int>(ServiceRequest); line <= static_cast<int>(Reset); line++) {
for(int line = int(ServiceRequest); line <= int(Reset); line++) {
// the addition of a new device may change the line output...
set_line_output_did_change(static_cast<Line>(line));
set_line_output_did_change(Line(line));
// ... but the new device will need to be told the current state regardless
port->set_input(static_cast<Line>(line), line_levels_[line]);
port->set_input(Line(line), line_levels_[line]);
}
}
@ -46,7 +46,7 @@ void Bus::set_line_output_did_change(Line line) {
for(std::weak_ptr<Port> port : ports_) {
std::shared_ptr<Port> locked_port = port.lock();
if(locked_port) {
new_line_level = (LineLevel)(static_cast<bool>(new_line_level) & static_cast<bool>(locked_port->get_output(line)));
new_line_level = (LineLevel)(bool(new_line_level) & bool(locked_port->get_output(line)));
}
}

View File

@ -206,7 +206,7 @@ class SerialPort : public ::Commodore::Serial::Port {
/// Receives an input change from the base serial port class, and communicates it to the user-port VIA.
void set_input(::Commodore::Serial::Line line, ::Commodore::Serial::LineLevel level) {
std::shared_ptr<UserPortVIA> userPortVIA = user_port_via_.lock();
if(userPortVIA) userPortVIA->set_serial_line_state(line, static_cast<bool>(level));
if(userPortVIA) userPortVIA->set_serial_line_state(line, bool(level));
}
/// Sets the user-port VIA with which this serial port communicates.
@ -425,19 +425,19 @@ class ConcreteMachine:
for(auto addr = video_range.start; addr < video_range.end; addr += 0x400) {
auto destination_address = (addr & 0x1fff) | (((addr & 0x8000) >> 2) ^ 0x2000);
if(processor_read_memory_map_[addr >> 10]) {
write_to_map(mos6560_bus_handler_.video_memory_map, &ram_[addr], static_cast<uint16_t>(destination_address), 0x400);
write_to_map(mos6560_bus_handler_.video_memory_map, &ram_[addr], uint16_t(destination_address), 0x400);
}
}
}
mos6560_bus_handler_.colour_memory = colour_ram_;
// install the BASIC ROM
write_to_map(processor_read_memory_map_, basic_rom_.data(), 0xc000, static_cast<uint16_t>(basic_rom_.size()));
write_to_map(processor_read_memory_map_, basic_rom_.data(), 0xc000, uint16_t(basic_rom_.size()));
// install the system ROM
write_to_map(processor_read_memory_map_, character_rom_.data(), 0x8000, static_cast<uint16_t>(character_rom_.size()));
write_to_map(mos6560_bus_handler_.video_memory_map, character_rom_.data(), 0x0000, static_cast<uint16_t>(character_rom_.size()));
write_to_map(processor_read_memory_map_, kernel_rom_.data(), 0xe000, static_cast<uint16_t>(kernel_rom_.size()));
write_to_map(processor_read_memory_map_, character_rom_.data(), 0x8000, uint16_t(character_rom_.size()));
write_to_map(mos6560_bus_handler_.video_memory_map, character_rom_.data(), 0x0000, uint16_t(character_rom_.size()));
write_to_map(processor_read_memory_map_, kernel_rom_.data(), 0xe000, uint16_t(kernel_rom_.size()));
// The insert_media occurs last, so if there's a conflict between cartridges and RAM,
// the cartridge wins.
@ -459,7 +459,7 @@ class ConcreteMachine:
if(!media.cartridges.empty()) {
rom_address_ = 0xa000;
std::vector<uint8_t> rom_image = media.cartridges.front()->get_segments().front().data;
rom_length_ = static_cast<uint16_t>(rom_image.size());
rom_length_ = uint16_t(rom_image.size());
rom_ = rom_image;
rom_.resize(0x2000);
@ -533,7 +533,7 @@ class ConcreteMachine:
const uint64_t tape_position = tape_->get_tape()->get_offset();
if(header) {
// serialise to wherever b2:b3 points
const uint16_t tape_buffer_pointer = static_cast<uint16_t>(ram_[0xb2]) | static_cast<uint16_t>(ram_[0xb3] << 8);
const uint16_t tape_buffer_pointer = uint16_t(ram_[0xb2]) | uint16_t(ram_[0xb3] << 8);
header->serialise(&ram_[tape_buffer_pointer], 0x8000 - tape_buffer_pointer);
hold_tape_ = true;
LOG("Vic-20: Found header");
@ -550,15 +550,15 @@ class ConcreteMachine:
*value = 0x0c; // i.e. NOP abs, to swallow the entire JSR
} else if(address == 0xf90b) {
uint8_t x = static_cast<uint8_t>(m6502_.get_value_of_register(CPU::MOS6502::Register::X));
uint8_t x = uint8_t(m6502_.get_value_of_register(CPU::MOS6502::Register::X));
if(x == 0xe) {
Storage::Tape::Commodore::Parser parser;
const uint64_t tape_position = tape_->get_tape()->get_offset();
const std::unique_ptr<Storage::Tape::Commodore::Data> data = parser.get_next_data(tape_->get_tape());
if(data) {
uint16_t start_address, end_address;
start_address = static_cast<uint16_t>(ram_[0xc1] | (ram_[0xc2] << 8));
end_address = static_cast<uint16_t>(ram_[0xae] | (ram_[0xaf] << 8));
start_address = uint16_t(ram_[0xc1] | (ram_[0xc2] << 8));
end_address = uint16_t(ram_[0xae] | (ram_[0xaf] << 8));
// perform a via-processor_write_memory_map_ memcpy
uint8_t *data_ptr = data->data.data();
@ -573,8 +573,8 @@ class ConcreteMachine:
// set tape status, carry and flag
ram_[0x90] |= 0x40;
uint8_t flags = static_cast<uint8_t>(m6502_.get_value_of_register(CPU::MOS6502::Register::Flags));
flags &= ~static_cast<uint8_t>((CPU::MOS6502::Flag::Carry | CPU::MOS6502::Flag::Interrupt));
uint8_t flags = uint8_t(m6502_.get_value_of_register(CPU::MOS6502::Register::Flags));
flags &= ~uint8_t((CPU::MOS6502::Flag::Carry | CPU::MOS6502::Flag::Interrupt));
m6502_.set_value_of_register(CPU::MOS6502::Register::Flags, flags);
// to ensure that execution proceeds to 0xfccf, pretend a NOP was here and

View File

@ -161,8 +161,8 @@ class ConcreteMachine:
ROM slot = ROM::Slot12;
for(std::shared_ptr<Storage::Cartridge::Cartridge> cartridge : media.cartridges) {
const ROM first_slot_tried = slot;
while(rom_inserted_[static_cast<int>(slot)]) {
slot = static_cast<ROM>((static_cast<int>(slot) + 1) & 15);
while(rom_inserted_[int(slot)]) {
slot = ROM((int(slot) + 1) & 15);
if(slot == first_slot_tried) return false;
}
set_rom(slot, cartridge->get_segments().front().data, false);
@ -313,7 +313,7 @@ class ConcreteMachine:
// allow the PC read to return an RTS.
)
) {
uint8_t service_call = static_cast<uint8_t>(m6502_.get_value_of_register(CPU::MOS6502::Register::X));
uint8_t service_call = uint8_t(m6502_.get_value_of_register(CPU::MOS6502::Register::X));
if(address == 0xf0a8) {
if(!ram_[0x247] && service_call == 14) {
tape_.set_delegate(nullptr);
@ -354,7 +354,7 @@ class ConcreteMachine:
}
}
if(basic_is_active_) {
*value &= roms_[static_cast<int>(ROM::BASIC)][address & 16383];
*value &= roms_[int(ROM::BASIC)][address & 16383];
}
} else if(rom_write_masks_[active_rom_]) {
roms_[active_rom_][address & 16383] = *value;
@ -388,7 +388,7 @@ class ConcreteMachine:
}
}
return Cycles(static_cast<int>(cycles));
return Cycles(int(cycles));
}
forceinline void flush() {
@ -503,8 +503,8 @@ class ConcreteMachine:
case ROM::OS: target = os_; break;
default:
target = roms_[static_cast<int>(slot)];
rom_write_masks_[static_cast<int>(slot)] = is_writeable;
target = roms_[int(slot)];
rom_write_masks_[int(slot)] = is_writeable;
break;
}
@ -516,8 +516,8 @@ class ConcreteMachine:
rom_ptr += size_to_copy;
}
if(static_cast<int>(slot) < 16)
rom_inserted_[static_cast<int>(slot)] = true;
if(int(slot) < 16)
rom_inserted_[int(slot)] = true;
}
// MARK: - Work deferral updates.
@ -566,7 +566,7 @@ class ConcreteMachine:
std::vector<uint8_t> dfs_, adfs1_, adfs2_;
// Paging
int active_rom_ = static_cast<int>(ROM::Slot0);
int active_rom_ = int(ROM::Slot0);
bool keyboard_is_active_ = false;
bool basic_is_active_ = false;

View File

@ -16,13 +16,13 @@ SoundGenerator::SoundGenerator(Concurrency::DeferringAsyncTaskQueue &audio_queue
audio_queue_(audio_queue) {}
void SoundGenerator::set_sample_volume_range(std::int16_t range) {
volume_ = static_cast<unsigned int>(range / 2);
volume_ = unsigned(range / 2);
}
void SoundGenerator::get_samples(std::size_t number_of_samples, int16_t *target) {
if(is_enabled_) {
while(number_of_samples--) {
*target = static_cast<int16_t>((counter_ / (divider_+1)) * volume_);
*target = int16_t((counter_ / (divider_+1)) * volume_);
target++;
counter_ = (counter_ + 1) % ((divider_+1) * 2);
}

View File

@ -15,7 +15,7 @@ Tape::Tape() : TapePlayer(2000000) {
}
void Tape::push_tape_bit(uint16_t bit) {
data_register_ = static_cast<uint16_t>((data_register_ >> 1) | (bit << 10));
data_register_ = uint16_t((data_register_ >> 1) | (bit << 10));
if(input_.minimum_bits_until_full) input_.minimum_bits_until_full--;
if(input_.minimum_bits_until_full == 8) interrupt_status_ &= ~Interrupt::ReceiveDataFull;
@ -57,12 +57,12 @@ void Tape::set_counter(uint8_t value) {
}
void Tape::set_data_register(uint8_t value) {
data_register_ = static_cast<uint16_t>((value << 2) | 1);
data_register_ = uint16_t((value << 2) | 1);
output_.bits_remaining_until_empty = 9;
}
uint8_t Tape::get_data_register() {
return static_cast<uint8_t>(data_register_ >> 2);
return uint8_t(data_register_ >> 2);
}
void Tape::process_input_pulse(const Storage::Tape::Tape::Pulse &pulse) {
@ -70,7 +70,7 @@ void Tape::process_input_pulse(const Storage::Tape::Tape::Pulse &pulse) {
}
void Tape::acorn_shifter_output_bit(int value) {
push_tape_bit(static_cast<uint16_t>(value));
push_tape_bit(uint16_t(value));
}
void Tape::run_for(const Cycles cycles) {
@ -80,7 +80,7 @@ void Tape::run_for(const Cycles cycles) {
TapePlayer::run_for(cycles);
}
} else {
output_.cycles_into_pulse += static_cast<unsigned int>(cycles.as_integral());
output_.cycles_into_pulse += unsigned(cycles.as_integral());
while(output_.cycles_into_pulse > 1664) { // 1664 = the closest you can get to 1200 baud if you're looking for something
output_.cycles_into_pulse -= 1664; // that divides the 125,000Hz clock that the sound divider runs off.
push_tape_bit(1);

View File

@ -261,11 +261,11 @@ void VideoOutput::run_for(const Cycles cycles) {
void VideoOutput::write(int address, uint8_t value) {
switch(address & 0xf) {
case 0x02:
start_screen_address_ = (start_screen_address_ & 0xfe00) | static_cast<uint16_t>((value & 0xe0) << 1);
start_screen_address_ = (start_screen_address_ & 0xfe00) | uint16_t((value & 0xe0) << 1);
if(!start_screen_address_) start_screen_address_ |= 0x8000;
break;
case 0x03:
start_screen_address_ = (start_screen_address_ & 0x01ff) | static_cast<uint16_t>((value & 0x3f) << 9);
start_screen_address_ = (start_screen_address_ & 0x01ff) | uint16_t((value & 0x3f) << 9);
if(!start_screen_address_) start_screen_address_ |= 0x8000;
break;
case 0x07: {
@ -420,9 +420,9 @@ unsigned int VideoOutput::get_cycles_until_next_ram_availability(int from_time)
}
// Mode 3 ends after 250 lines, not the usual 256.
if(implied_row < 8 && current_line < 250) result += static_cast<unsigned int>(80 - current_column);
if(implied_row < 8 && current_line < 250) result += unsigned(80 - current_column);
}
else result += static_cast<unsigned int>(80 - current_column);
else result += unsigned(80 - current_column);
}
}
return result;

View File

@ -54,7 +54,7 @@ void DiskROM::run_for(HalfCycles half_cycles) {
// needs an 8Mhz clock, so scale up. 8000000/7159090 simplifies to
// 800000/715909.
controller_cycles_ += 800000 * half_cycles.as_integral();
WD::WD1770::run_for(Cycles(static_cast<int>(controller_cycles_ / 715909)));
WD::WD1770::run_for(Cycles(int(controller_cycles_ / 715909)));
controller_cycles_ %= 715909;
}

View File

@ -315,7 +315,7 @@ class ConcreteMachine:
if(!media.cartridges.empty()) {
const auto &segment = media.cartridges.front()->get_segments().front();
memory_slots_[1].source = segment.data;
map(1, 0, static_cast<uint16_t>(segment.start_address), std::min(segment.data.size(), 65536 - segment.start_address));
map(1, 0, uint16_t(segment.start_address), std::min(segment.data.size(), 65536 - segment.start_address));
auto msx_cartridge = dynamic_cast<Analyser::Static::MSX::Cartridge *>(media.cartridges.front().get());
if(msx_cartridge) {
@ -376,7 +376,7 @@ class ConcreteMachine:
void map(int slot, std::size_t source_address, uint16_t destination_address, std::size_t length) final {
assert(!(destination_address & 8191));
assert(!(length & 8191));
assert(static_cast<std::size_t>(destination_address) + length <= 65536);
assert(size_t(destination_address) + length <= 65536);
for(std::size_t c = 0; c < (length >> 13); ++c) {
if(memory_slots_[slot].wrapping_strategy == ROMSlotHandler::WrappingStrategy::Repeat) source_address %= memory_slots_[slot].source.size();
@ -391,7 +391,7 @@ class ConcreteMachine:
void unmap(int slot, uint16_t destination_address, std::size_t length) final {
assert(!(destination_address & 8191));
assert(!(length & 8191));
assert(static_cast<std::size_t>(destination_address) + length <= 65536);
assert(size_t(destination_address) + length <= 65536);
for(std::size_t c = 0; c < (length >> 13); ++c) {
memory_slots_[slot].read_pointers[(destination_address >> 13) + c] = nullptr;
@ -473,7 +473,7 @@ class ConcreteMachine:
// If a byte was found, return it with carry unset. Otherwise set carry to
// indicate error.
if(next_byte >= 0) {
z80_.set_value_of_register(CPU::Z80::Register::A, static_cast<uint16_t>(next_byte));
z80_.set_value_of_register(CPU::Z80::Register::A, uint16_t(next_byte));
z80_.set_value_of_register(CPU::Z80::Register::Flags, 0);
} else {
z80_.set_value_of_register(CPU::Z80::Register::Flags, 1);
@ -523,9 +523,9 @@ class ConcreteMachine:
case 0xa2:
update_audio();
ay_.set_control_lines(static_cast<GI::AY38910::ControlLines>(GI::AY38910::BC2 | GI::AY38910::BC1));
ay_.set_control_lines(GI::AY38910::ControlLines(GI::AY38910::BC2 | GI::AY38910::BC1));
*cycle.value = ay_.get_data_output();
ay_.set_control_lines(static_cast<GI::AY38910::ControlLines>(0));
ay_.set_control_lines(GI::AY38910::ControlLines(0));
break;
case 0xa8: case 0xa9:
@ -550,9 +550,9 @@ class ConcreteMachine:
case 0xa0: case 0xa1:
update_audio();
ay_.set_control_lines(static_cast<GI::AY38910::ControlLines>(GI::AY38910::BDIR | GI::AY38910::BC2 | ((port == 0xa0) ? GI::AY38910::BC1 : 0)));
ay_.set_control_lines(GI::AY38910::ControlLines(GI::AY38910::BDIR | GI::AY38910::BC2 | ((port == 0xa0) ? GI::AY38910::BC1 : 0)));
ay_.set_data_input(*cycle.value);
ay_.set_control_lines(static_cast<GI::AY38910::ControlLines>(0));
ay_.set_control_lines(GI::AY38910::ControlLines(0));
break;
case 0xa8: case 0xa9:
@ -588,16 +588,16 @@ class ConcreteMachine:
while(characters_written < input_text_.size()) {
const int next_write_address = (write_address + 1) % buffer_size;
if(next_write_address == read_address) break;
ram_[write_address + buffer_start] = static_cast<uint8_t>(input_text_[characters_written]);
ram_[write_address + buffer_start] = uint8_t(input_text_[characters_written]);
++characters_written;
write_address = next_write_address;
}
input_text_.erase(input_text_.begin(), input_text_.begin() + static_cast<std::string::difference_type>(characters_written));
input_text_.erase(input_text_.begin(), input_text_.begin() + std::string::difference_type(characters_written));
// Map the write address back into absolute terms and write it out again as PUTPNT.
write_address += buffer_start;
ram_[0xf3f8] = static_cast<uint8_t>(write_address);
ram_[0xf3f9] = static_cast<uint8_t>(write_address >> 8);
ram_[0xf3f8] = uint8_t(write_address);
ram_[0xf3f9] = uint8_t(write_address >> 8);
}
break;

View File

@ -105,7 +105,7 @@ class ConcreteMachine:
keyboard_({Inputs::Keyboard::Key::Enter, Inputs::Keyboard::Key::Escape}, {}) {
// Pick the clock rate based on the region.
const double clock_rate = target.region == Target::Region::Europe ? 3546893.0 : 3579540.0;
speaker_.set_input_rate(static_cast<float>(clock_rate / audio_divider));
speaker_.set_input_rate(float(clock_rate / audio_divider));
set_clock_rate(clock_rate);
// Instantiate the joysticks.
@ -277,7 +277,7 @@ class ConcreteMachine:
} else {
Joystick *const joypad1 = static_cast<Joystick *>(joysticks_[0].get());
Joystick *const joypad2 = static_cast<Joystick *>(joysticks_[1].get());
*cycle.value = static_cast<uint8_t>(joypad1->get_state() | (joypad2->get_state() << 6));
*cycle.value = uint8_t(joypad1->get_state() | (joypad2->get_state() << 6));
}
} break;
case 0xc1: {
@ -449,7 +449,7 @@ class ConcreteMachine:
// Quick not on TH inputs here: if either is setup as an output, then the
// currently output level is returned. Otherwise they're fixed at 1.
return
static_cast<uint8_t>(
uint8_t(
((io_port_control_ & 0x02) << 5) | ((io_port_control_&0x20) << 1) |
((io_port_control_ & 0x08) << 4) | (io_port_control_&0x80)
);
@ -537,7 +537,7 @@ class ConcreteMachine:
map(
read_pointers_,
cartridge_.data() + start_addr,
std::min(static_cast<size_t>(0x4000), cartridge_.size() - start_addr),
std::min(size_t(0x4000), cartridge_.size() - start_addr),
c * 0x4000);
}

View File

@ -123,7 +123,7 @@ class TapePlayer: public Storage::Tape::BinaryTapePlayer {
@returns The next byte from the tape.
*/
uint8_t get_next_byte(bool use_fast_encoding) {
return static_cast<uint8_t>(parser_.get_next_byte(get_tape(), use_fast_encoding));
return uint8_t(parser_.get_next_byte(get_tape(), use_fast_encoding));
}
private:
@ -475,7 +475,7 @@ template <Analyser::Static::Oric::Target::DiskInterface disk_interface> class Co
} else {
flush_diskii();
const int disk_value = diskii_.read_address(address);
if(isReadOperation(operation) && disk_value != diskii_.DidNotLoad) *value = static_cast<uint8_t>(disk_value);
if(isReadOperation(operation) && disk_value != diskii_.DidNotLoad) *value = uint8_t(disk_value);
}
break;
}

View File

@ -105,7 +105,7 @@ void VideoOutput::set_colour_rom(const std::vector<uint8_t> &rom) {
// uint32_t test_value = 0x0001;
// if(*reinterpret_cast<uint8_t *>(&test_value) != 0x01) {
// for(std::size_t c = 0; c < 8; c++) {
// colour_forms_[c] = static_cast<uint16_t>((colour_forms_[c] >> 8) | (colour_forms_[c] << 8));
// colour_forms_[c] = uint16_t((colour_forms_[c] >> 8) | (colour_forms_[c] << 8));
// }
// }
}

View File

@ -30,7 +30,7 @@ class TimedMachine {
virtual void run_for(Time::Seconds duration) {
const double cycles = (duration * clock_rate_ * speed_multiplier_) + clock_conversion_error_;
clock_conversion_error_ = std::fmod(cycles, 1.0);
run_for(Cycles(static_cast<int>(cycles)));
run_for(Cycles(int(cycles)));
}
/*!

View File

@ -11,7 +11,7 @@
#include <cstdlib>
void Memory::Fuzz(uint8_t *buffer, std::size_t size) {
unsigned int divider = (static_cast<unsigned int>(RAND_MAX) + 1) / 256;
unsigned int divider = (unsigned(RAND_MAX) + 1) / 256;
unsigned int shift = 1, value = 1;
while(value < divider) {
value <<= 1;
@ -19,7 +19,7 @@ void Memory::Fuzz(uint8_t *buffer, std::size_t size) {
}
for(std::size_t c = 0; c < size; c++) {
buffer[c] = static_cast<uint8_t>(std::rand() >> shift);
buffer[c] = uint8_t(std::rand() >> shift);
}
}

View File

@ -34,7 +34,7 @@ StringSerialiser::StringSerialiser(const std::string &source, bool use_linefeed_
uint8_t StringSerialiser::head() {
if(input_string_pointer_ == input_string_.size())
return '\0';
return static_cast<uint8_t>(input_string_[input_string_pointer_]);
return uint8_t(input_string_[input_string_pointer_]);
}
bool StringSerialiser::advance() {

View File

@ -135,7 +135,7 @@ bool Typer::type_next_character() {
// MARK: - Character mapper
uint16_t *CharacterMapper::table_lookup_sequence_for_character(KeySequence *sequences, std::size_t length, char character) {
std::size_t ucharacter = static_cast<std::size_t>((unsigned char)character);
std::size_t ucharacter = size_t((unsigned char)character);
if(ucharacter >= (length / sizeof(KeySequence))) return nullptr;
if(sequences[ucharacter][0] == MachineTypes::MappedKeyboardMachine::KeyNotMapped) return nullptr;
return sequences[ucharacter];

View File

@ -49,7 +49,7 @@ void Video::flush(bool next_sync) {
if(line_data_) {
// If there is output data queued, output it either if it's being interrupted by
// sync, or if we're past its end anyway. Otherwise let it be.
int data_length = static_cast<int>(line_data_pointer_ - line_data_);
int data_length = int(line_data_pointer_ - line_data_);
if(data_length < int(time_since_update_.as_integral()) || next_sync) {
auto output_length = std::min(data_length, int(time_since_update_.as_integral()));
crt_.output_data(output_length);

View File

@ -66,7 +66,7 @@ template<bool is_zx81> class ConcreteMachine:
ay_(GI::AY38910::Personality::AY38910, audio_queue_),
speaker_(ay_) {
set_clock_rate(ZX8081ClockRate);
speaker_.set_input_rate(static_cast<float>(ZX8081ClockRate) / 2.0f);
speaker_.set_input_rate(float(ZX8081ClockRate) / 2.0f);
clear_all_keys();
const bool use_zx81_rom = target.is_ZX81 || target.ZX80_uses_ZX81_ROM;
@ -95,7 +95,7 @@ template<bool is_zx81> class ConcreteMachine:
automatic_tape_motor_start_address_ = 0x0206;
automatic_tape_motor_end_address_ = 0x024d;
}
rom_mask_ = static_cast<uint16_t>(rom_.size() - 1);
rom_mask_ = uint16_t(rom_.size() - 1);
switch(target.memory_model) {
case Analyser::Static::ZX8081::Target::MemoryModel::Unexpanded:
@ -230,7 +230,7 @@ template<bool is_zx81> class ConcreteMachine:
z80_.set_interrupt_line(false);
}
if(has_latched_video_byte_) {
std::size_t char_address = static_cast<std::size_t>((address & 0xfe00) | ((latched_video_byte_ & 0x3f) << 3) | line_counter_);
std::size_t char_address = size_t((address & 0xfe00) | ((latched_video_byte_ & 0x3f) << 3) | line_counter_);
const uint8_t mask = (latched_video_byte_ & 0x80) ? 0x00 : 0xff;
if(char_address < ram_base_) {
latched_video_byte_ = rom_[char_address & rom_mask_] ^ mask;
@ -250,7 +250,7 @@ template<bool is_zx81> class ConcreteMachine:
const int next_byte = parser_.get_next_byte(tape_player_.get_tape());
if(next_byte != -1) {
const uint16_t hl = z80_.get_value_of_register(CPU::Z80::Register::HL);
ram_[hl & ram_mask_] = static_cast<uint8_t>(next_byte);
ram_[hl & ram_mask_] = uint8_t(next_byte);
*cycle.value = 0x00;
z80_.set_value_of_register(CPU::Z80::Register::ProgramCounter, tape_return_address_ - 1);

View File

@ -189,7 +189,7 @@ struct SpeakerDelegate: public Outputs::Speaker::Speaker::Delegate {
std::lock_guard<std::mutex> lock_guard(audio_buffer_mutex_);
// SDL buffer length is in bytes, so there's no need to adjust for stereo/mono in here.
const std::size_t sample_length = static_cast<std::size_t>(len) / sizeof(int16_t);
const std::size_t sample_length = size_t(len) / sizeof(int16_t);
const std::size_t copy_length = std::min(sample_length, audio_buffer_.size());
int16_t *const target = static_cast<int16_t *>(static_cast<void *>(stream));
@ -977,7 +977,7 @@ int main(int argc, char *argv[]) {
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &target_framebuffer);
scan_target.set_target_framebuffer(target_framebuffer);
SDL_GetWindowSize(window, &window_width, &window_height);
if(activity_observer) activity_observer->set_aspect_ratio(static_cast<float>(window_width) / static_cast<float>(window_height));
if(activity_observer) activity_observer->set_aspect_ratio(float(window_width) / float(window_height));
} break;
default: break;
@ -1211,8 +1211,8 @@ int main(int argc, char *argv[]) {
// unless the user seems to be using a hat.
// SDL will return a value in the range [-32768, 32767], so map from that to [0, 1.0]
if(!joysticks[c].hat_values()) {
const float x_axis = static_cast<float>(SDL_JoystickGetAxis(joysticks[c].get(), 0) + 32768) / 65535.0f;
const float y_axis = static_cast<float>(SDL_JoystickGetAxis(joysticks[c].get(), 1) + 32768) / 65535.0f;
const float x_axis = float(SDL_JoystickGetAxis(joysticks[c].get(), 0) + 32768) / 65535.0f;
const float y_axis = float(SDL_JoystickGetAxis(joysticks[c].get(), 1) + 32768) / 65535.0f;
machine_joysticks[target]->set_input(Inputs::Joystick::Input(Inputs::Joystick::Input::Type::Horizontal), x_axis);
machine_joysticks[target]->set_input(Inputs::Joystick::Input(Inputs::Joystick::Input::Type::Vertical), y_axis);
}

View File

@ -130,7 +130,7 @@ void CRT::set_new_display_type(int cycles_per_line, Outputs::Display::Type displ
void CRT::set_composite_function_type(CompositeSourceType type, float offset_of_first_sample) {
if(type == DiscreteFourSamplesPerCycle) {
colour_burst_phase_adjustment_ = static_cast<uint8_t>(offset_of_first_sample * 256.0f) & 63;
colour_burst_phase_adjustment_ = uint8_t(offset_of_first_sample * 256.0f) & 63;
} else {
colour_burst_phase_adjustment_ = 0xff;
}
@ -417,12 +417,12 @@ void CRT::output_colour_burst(int number_of_cycles, uint8_t phase, uint8_t ampli
void CRT::output_default_colour_burst(int number_of_cycles, uint8_t amplitude) {
// TODO: avoid applying a rounding error here?
output_colour_burst(number_of_cycles, static_cast<uint8_t>((phase_numerator_ * 256) / phase_denominator_), amplitude);
output_colour_burst(number_of_cycles, uint8_t((phase_numerator_ * 256) / phase_denominator_), amplitude);
}
void CRT::set_immediate_default_phase(float phase) {
phase = fmodf(phase, 1.0f);
phase_numerator_ = static_cast<int>(phase * static_cast<float>(phase_denominator_));
phase_numerator_ = int(phase * float(phase_denominator_));
}
void CRT::output_data(int number_of_cycles, size_t number_of_samples) {
@ -453,11 +453,11 @@ Outputs::Display::Rect CRT::get_rect_for_area(int first_line_after_sync, int num
const int horizontal_retrace_period = horizontal_period - horizontal_scan_period;
// make sure that the requested range is visible
if(static_cast<int>(first_cycle_after_sync) < horizontal_retrace_period) first_cycle_after_sync = static_cast<int>(horizontal_retrace_period);
if(static_cast<int>(first_cycle_after_sync + number_of_cycles) > horizontal_scan_period) number_of_cycles = static_cast<int>(horizontal_scan_period - static_cast<int>(first_cycle_after_sync));
if(int(first_cycle_after_sync) < horizontal_retrace_period) first_cycle_after_sync = int(horizontal_retrace_period);
if(int(first_cycle_after_sync + number_of_cycles) > horizontal_scan_period) number_of_cycles = int(horizontal_scan_period - int(first_cycle_after_sync));
float start_x = static_cast<float>(static_cast<int>(first_cycle_after_sync) - horizontal_retrace_period) / static_cast<float>(horizontal_scan_period);
float width = static_cast<float>(number_of_cycles) / static_cast<float>(horizontal_scan_period);
float start_x = float(int(first_cycle_after_sync) - horizontal_retrace_period) / float(horizontal_scan_period);
float width = float(number_of_cycles) / float(horizontal_scan_period);
// determine prima facie y extent
const int vertical_period = vertical_flywheel_->get_standard_period();
@ -465,13 +465,13 @@ Outputs::Display::Rect CRT::get_rect_for_area(int first_line_after_sync, int num
const int vertical_retrace_period = vertical_period - vertical_scan_period;
// make sure that the requested range is visible
// if(static_cast<int>(first_line_after_sync) * horizontal_period < vertical_retrace_period)
// if(int(first_line_after_sync) * horizontal_period < vertical_retrace_period)
// first_line_after_sync = (vertical_retrace_period + horizontal_period - 1) / horizontal_period;
// if((first_line_after_sync + number_of_lines) * horizontal_period > vertical_scan_period)
// number_of_lines = static_cast<int>(horizontal_scan_period - static_cast<int>(first_cycle_after_sync));
// number_of_lines = int(horizontal_scan_period - int(first_cycle_after_sync));
float start_y = static_cast<float>((static_cast<int>(first_line_after_sync) * horizontal_period) - vertical_retrace_period) / static_cast<float>(vertical_scan_period);
float height = static_cast<float>(static_cast<int>(number_of_lines) * horizontal_period) / vertical_scan_period;
float start_y = float((int(first_line_after_sync) * horizontal_period) - vertical_retrace_period) / float(vertical_scan_period);
float height = float(int(number_of_lines) * horizontal_period) / vertical_scan_period;
// adjust to ensure aspect ratio is correct
const float adjusted_aspect_ratio = (3.0f*aspect_ratio / 4.0f);

View File

@ -228,7 +228,7 @@ template <typename SampleSource> class LowpassSpeaker: public Speaker {
uint64_t(filter_parameters.output_cycles_per_second));
filter_ = std::make_unique<SignalProcessing::FIRFilter>(
static_cast<unsigned int>(number_of_taps),
unsigned(number_of_taps),
filter_parameters.input_cycles_per_second,
0.0,
high_pass_frequency,

View File

@ -29,12 +29,12 @@ uint16_t ProcessorBase::get_value_of_register(Register r) const {
void ProcessorBase::set_value_of_register(Register r, uint16_t value) {
switch (r) {
case Register::ProgramCounter: pc_.full = value; break;
case Register::StackPointer: s_ = static_cast<uint8_t>(value); break;
case Register::Flags: set_flags(static_cast<uint8_t>(value)); break;
case Register::A: a_ = static_cast<uint8_t>(value); break;
case Register::X: x_ = static_cast<uint8_t>(value); break;
case Register::Y: y_ = static_cast<uint8_t>(value); break;
case Register::ProgramCounter: pc_.full = value; break;
case Register::StackPointer: s_ = uint8_t(value); break;
case Register::Flags: set_flags(uint8_t(value)); break;
case Register::A: a_ = uint8_t(value); break;
case Register::X: x_ = uint8_t(value); break;
case Register::Y: y_ = uint8_t(value); break;
default: break;
}
}

View File

@ -16,12 +16,12 @@ AllRAMProcessor::AllRAMProcessor(std::size_t memory_size) :
timestamp_(0) {}
void AllRAMProcessor::set_data_at_address(uint16_t startAddress, std::size_t length, const uint8_t *data) {
std::size_t endAddress = std::min(startAddress + length, static_cast<std::size_t>(65536));
std::size_t endAddress = std::min(startAddress + length, size_t(65536));
std::memcpy(&memory_[startAddress], data, endAddress - startAddress);
}
void AllRAMProcessor::get_data_at_address(uint16_t startAddress, std::size_t length, uint8_t *data) {
std::size_t endAddress = std::min(startAddress + length, static_cast<std::size_t>(65536));
std::size_t endAddress = std::min(startAddress + length, size_t(65536));
std::memcpy(data, &memory_[startAddress], endAddress - startAddress);
}

View File

@ -22,7 +22,7 @@ uint16_t ProcessorBase::get_value_of_register(Register r) {
case Register::A: return a_;
case Register::Flags: return get_flags();
case Register::AF: return static_cast<uint16_t>((a_ << 8) | get_flags());
case Register::AF: return uint16_t((a_ << 8) | get_flags());
case Register::B: return bc_.halves.high;
case Register::C: return bc_.halves.low;
case Register::BC: return bc_.full;
@ -59,7 +59,7 @@ uint16_t ProcessorBase::get_value_of_register(Register r) {
case Register::IFF1: return iff1_ ? 1 : 0;
case Register::IFF2: return iff2_ ? 1 : 0;
case Register::IM: return static_cast<uint16_t>(interrupt_mode_);
case Register::IM: return uint16_t(interrupt_mode_);
case Register::MemPtr: return memptr_.full;
@ -72,43 +72,43 @@ void ProcessorBase::set_value_of_register(Register r, uint16_t value) {
case Register::ProgramCounter: pc_.full = value; break;
case Register::StackPointer: sp_.full = value; break;
case Register::A: a_ = static_cast<uint8_t>(value); break;
case Register::AF: a_ = static_cast<uint8_t>(value >> 8); // deliberate fallthrough...
case Register::Flags: set_flags(static_cast<uint8_t>(value)); break;
case Register::A: a_ = uint8_t(value); break;
case Register::AF: a_ = uint8_t(value >> 8); // deliberate fallthrough...
case Register::Flags: set_flags(uint8_t(value)); break;
case Register::B: bc_.halves.high = static_cast<uint8_t>(value); break;
case Register::C: bc_.halves.low = static_cast<uint8_t>(value); break;
case Register::BC: bc_.full = value; break;
case Register::D: de_.halves.high = static_cast<uint8_t>(value); break;
case Register::E: de_.halves.low = static_cast<uint8_t>(value); break;
case Register::DE: de_.full = value; break;
case Register::H: hl_.halves.high = static_cast<uint8_t>(value); break;
case Register::L: hl_.halves.low = static_cast<uint8_t>(value); break;
case Register::HL: hl_.full = value; break;
case Register::B: bc_.halves.high = uint8_t(value); break;
case Register::C: bc_.halves.low = uint8_t(value); break;
case Register::BC: bc_.full = value; break;
case Register::D: de_.halves.high = uint8_t(value); break;
case Register::E: de_.halves.low = uint8_t(value); break;
case Register::DE: de_.full = value; break;
case Register::H: hl_.halves.high = uint8_t(value); break;
case Register::L: hl_.halves.low = uint8_t(value); break;
case Register::HL: hl_.full = value; break;
case Register::ADash: afDash_.halves.high = static_cast<uint8_t>(value); break;
case Register::FlagsDash: afDash_.halves.low = static_cast<uint8_t>(value); break;
case Register::AFDash: afDash_.full = value; break;
case Register::BDash: bcDash_.halves.high = static_cast<uint8_t>(value); break;
case Register::CDash: bcDash_.halves.low = static_cast<uint8_t>(value); break;
case Register::BCDash: bcDash_.full = value; break;
case Register::DDash: deDash_.halves.high = static_cast<uint8_t>(value); break;
case Register::EDash: deDash_.halves.low = static_cast<uint8_t>(value); break;
case Register::DEDash: deDash_.full = value; break;
case Register::HDash: hlDash_.halves.high = static_cast<uint8_t>(value); break;
case Register::LDash: hlDash_.halves.low = static_cast<uint8_t>(value); break;
case Register::HLDash: hlDash_.full = value; break;
case Register::ADash: afDash_.halves.high = uint8_t(value); break;
case Register::FlagsDash: afDash_.halves.low = uint8_t(value); break;
case Register::AFDash: afDash_.full = value; break;
case Register::BDash: bcDash_.halves.high = uint8_t(value); break;
case Register::CDash: bcDash_.halves.low = uint8_t(value); break;
case Register::BCDash: bcDash_.full = value; break;
case Register::DDash: deDash_.halves.high = uint8_t(value); break;
case Register::EDash: deDash_.halves.low = uint8_t(value); break;
case Register::DEDash: deDash_.full = value; break;
case Register::HDash: hlDash_.halves.high = uint8_t(value); break;
case Register::LDash: hlDash_.halves.low = uint8_t(value); break;
case Register::HLDash: hlDash_.full = value; break;
case Register::IXh: ix_.halves.high = static_cast<uint8_t>(value); break;
case Register::IXl: ix_.halves.low = static_cast<uint8_t>(value); break;
case Register::IX: ix_.full = value; break;
case Register::IYh: iy_.halves.high = static_cast<uint8_t>(value); break;
case Register::IYl: iy_.halves.low = static_cast<uint8_t>(value); break;
case Register::IY: iy_.full = value; break;
case Register::IXh: ix_.halves.high = uint8_t(value); break;
case Register::IXl: ix_.halves.low = uint8_t(value); break;
case Register::IX: ix_.full = value; break;
case Register::IYh: iy_.halves.high = uint8_t(value); break;
case Register::IYl: iy_.halves.low = uint8_t(value); break;
case Register::IY: iy_.full = value; break;
case Register::R: ir_.halves.low = static_cast<uint8_t>(value); break;
case Register::I: ir_.halves.high = static_cast<uint8_t>(value); break;
case Register::Refresh: ir_.full = value; break;
case Register::R: ir_.halves.low = uint8_t(value); break;
case Register::I: ir_.halves.high = uint8_t(value); break;
case Register::Refresh: ir_.full = value; break;
case Register::IFF1: iff1_ = !!value; break;
case Register::IFF2: iff2_ = !!value; break;

View File

@ -61,7 +61,7 @@ template < class T,
flag_adjustment_history_ |= 1;
#define set_parity(v) \
parity_overflow_result_ = static_cast<uint8_t>(v^1);\
parity_overflow_result_ = uint8_t(v^1);\
parity_overflow_result_ ^= parity_overflow_result_ >> 4;\
parity_overflow_result_ ^= parity_overflow_result_ << 2;\
parity_overflow_result_ ^= parity_overflow_result_ >> 1;
@ -91,13 +91,13 @@ template < class T,
case MicroOp::DecodeOperation:
refresh_addr_ = ir_;
ir_.halves.low = (ir_.halves.low & 0x80) | ((ir_.halves.low + current_instruction_page_->r_step) & 0x7f);
pc_.full += pc_increment_ & static_cast<uint16_t>(halt_mask_);
pc_.full += pc_increment_ & uint16_t(halt_mask_);
scheduled_program_counter_ = current_instruction_page_->instructions[operation_ & halt_mask_];
flag_adjustment_history_ <<= 1;
break;
case MicroOp::DecodeOperationNoRChange:
refresh_addr_ = ir_;
pc_.full += pc_increment_ & static_cast<uint16_t>(halt_mask_);
pc_.full += pc_increment_ & uint16_t(halt_mask_);
scheduled_program_counter_ = current_instruction_page_->instructions[operation_ & halt_mask_];
break;
@ -153,7 +153,7 @@ template < class T,
break;
case MicroOp::CCF:
half_carry_result_ = static_cast<uint8_t>(carry_result_ << 4);
half_carry_result_ = uint8_t(carry_result_ << 4);
carry_result_ ^= Flag::Carry;
subtract_flag_ = 0;
if(flag_adjustment_history_&2) {
@ -192,12 +192,12 @@ template < class T,
// MARK: - 8-bit arithmetic
#define set_arithmetic_flags(sub, b53) \
sign_result_ = zero_result_ = static_cast<uint8_t>(result); \
carry_result_ = static_cast<uint8_t>(result >> 8); \
half_carry_result_ = static_cast<uint8_t>(half_result); \
parity_overflow_result_ = static_cast<uint8_t>(overflow >> 5); \
sign_result_ = zero_result_ = uint8_t(result); \
carry_result_ = uint8_t(result >> 8); \
half_carry_result_ = uint8_t(half_result); \
parity_overflow_result_ = uint8_t(overflow >> 5); \
subtract_flag_ = sub; \
bit53_result_ = static_cast<uint8_t>(b53); \
bit53_result_ = uint8_t(b53); \
set_did_compute_flags();
case MicroOp::CP8: {
@ -222,7 +222,7 @@ template < class T,
// different and the result is different again
const int overflow = (value^a_) & (result^a_);
a_ = static_cast<uint8_t>(result);
a_ = uint8_t(result);
set_arithmetic_flags(Flag::Subtract, result);
} break;
@ -235,7 +235,7 @@ template < class T,
// different and the result is different again
const int overflow = (value^a_) & (result^a_);
a_ = static_cast<uint8_t>(result);
a_ = uint8_t(result);
set_arithmetic_flags(Flag::Subtract, result);
} break;
@ -248,7 +248,7 @@ template < class T,
// the same and the result is different
const int overflow = ~(value^a_) & (result^a_);
a_ = static_cast<uint8_t>(result);
a_ = uint8_t(result);
set_arithmetic_flags(0, result);
} break;
@ -261,7 +261,7 @@ template < class T,
// the same and the result is different
const int overflow = ~(value^a_) & (result^a_);
a_ = static_cast<uint8_t>(result);
a_ = uint8_t(result);
set_arithmetic_flags(0, result);
} break;
@ -272,12 +272,12 @@ template < class T,
const int result = -a_;
const int halfResult = -(a_&0xf);
a_ = static_cast<uint8_t>(result);
a_ = uint8_t(result);
bit53_result_ = sign_result_ = zero_result_ = a_;
parity_overflow_result_ = overflow ? Flag::Overflow : 0;
subtract_flag_ = Flag::Subtract;
carry_result_ = static_cast<uint8_t>(result >> 8);
half_carry_result_ = static_cast<uint8_t>(halfResult);
carry_result_ = uint8_t(result >> 8);
half_carry_result_ = uint8_t(halfResult);
set_did_compute_flags();
} break;
@ -290,12 +290,12 @@ template < class T,
const int overflow = (value ^ result) & ~value;
const int half_result = (value&0xf) + 1;
*static_cast<uint8_t *>(operation->source) = static_cast<uint8_t>(result);
*static_cast<uint8_t *>(operation->source) = uint8_t(result);
// sign, zero and 5 & 3 are set directly from the result
bit53_result_ = sign_result_ = zero_result_ = static_cast<uint8_t>(result);
half_carry_result_ = static_cast<uint8_t>(half_result);
parity_overflow_result_ = static_cast<uint8_t>(overflow >> 5);
bit53_result_ = sign_result_ = zero_result_ = uint8_t(result);
half_carry_result_ = uint8_t(half_result);
parity_overflow_result_ = uint8_t(overflow >> 5);
subtract_flag_ = 0;
set_did_compute_flags();
} break;
@ -309,12 +309,12 @@ template < class T,
const int overflow = (value ^ result) & value;
const int half_result = (value&0xf) - 1;
*static_cast<uint8_t *>(operation->source) = static_cast<uint8_t>(result);
*static_cast<uint8_t *>(operation->source) = uint8_t(result);
// sign, zero and 5 & 3 are set directly from the result
bit53_result_ = sign_result_ = zero_result_ = static_cast<uint8_t>(result);
half_carry_result_ = static_cast<uint8_t>(half_result);
parity_overflow_result_ = static_cast<uint8_t>(overflow >> 5);
bit53_result_ = sign_result_ = zero_result_ = uint8_t(result);
half_carry_result_ = uint8_t(half_result);
parity_overflow_result_ = uint8_t(overflow >> 5);
subtract_flag_ = Flag::Subtract;
set_did_compute_flags();
} break;
@ -371,13 +371,13 @@ template < class T,
const int result = sourceValue + destinationValue;
const int halfResult = (sourceValue&0xfff) + (destinationValue&0xfff);
bit53_result_ = static_cast<uint8_t>(result >> 8);
carry_result_ = static_cast<uint8_t>(result >> 16);
half_carry_result_ = static_cast<uint8_t>(halfResult >> 8);
bit53_result_ = uint8_t(result >> 8);
carry_result_ = uint8_t(result >> 16);
half_carry_result_ = uint8_t(halfResult >> 8);
subtract_flag_ = 0;
set_did_compute_flags();
*static_cast<uint16_t *>(operation->destination) = static_cast<uint16_t>(result);
*static_cast<uint16_t *>(operation->destination) = uint16_t(result);
memptr_.full++;
} break;
@ -391,15 +391,15 @@ template < class T,
const int overflow = (result ^ destinationValue) & ~(destinationValue ^ sourceValue);
bit53_result_ =
sign_result_ = static_cast<uint8_t>(result >> 8);
zero_result_ = static_cast<uint8_t>(result | sign_result_);
sign_result_ = uint8_t(result >> 8);
zero_result_ = uint8_t(result | sign_result_);
subtract_flag_ = 0;
carry_result_ = static_cast<uint8_t>(result >> 16);
half_carry_result_ = static_cast<uint8_t>(halfResult >> 8);
parity_overflow_result_ = static_cast<uint8_t>(overflow >> 13);
carry_result_ = uint8_t(result >> 16);
half_carry_result_ = uint8_t(halfResult >> 8);
parity_overflow_result_ = uint8_t(overflow >> 13);
set_did_compute_flags();
*static_cast<uint16_t *>(operation->destination) = static_cast<uint16_t>(result);
*static_cast<uint16_t *>(operation->destination) = uint16_t(result);
memptr_.full++;
} break;
@ -416,15 +416,15 @@ template < class T,
const int overflow = (result ^ destinationValue) & (sourceValue ^ destinationValue);
bit53_result_ =
sign_result_ = static_cast<uint8_t>(result >> 8);
zero_result_ = static_cast<uint8_t>(result | sign_result_);
sign_result_ = uint8_t(result >> 8);
zero_result_ = uint8_t(result | sign_result_);
subtract_flag_ = Flag::Subtract;
carry_result_ = static_cast<uint8_t>(result >> 16);
half_carry_result_ = static_cast<uint8_t>(halfResult >> 8);
parity_overflow_result_ = static_cast<uint8_t>(overflow >> 13);
carry_result_ = uint8_t(result >> 16);
half_carry_result_ = uint8_t(halfResult >> 8);
parity_overflow_result_ = uint8_t(overflow >> 13);
set_did_compute_flags();
*static_cast<uint16_t *>(operation->destination) = static_cast<uint16_t>(result);
*static_cast<uint16_t *>(operation->destination) = uint16_t(result);
memptr_.full++;
} break;
@ -490,7 +490,7 @@ template < class T,
de_.full += dir; \
hl_.full += dir; \
const uint8_t sum = a_ + temp8_; \
bit53_result_ = static_cast<uint8_t>((sum&0x8) | ((sum & 0x02) << 4)); \
bit53_result_ = uint8_t((sum&0x8) | ((sum & 0x02) << 4)); \
subtract_flag_ = 0; \
half_carry_result_ = 0; \
parity_overflow_result_ = bc_.full ? Flag::Parity : 0; \
@ -530,7 +530,7 @@ template < class T,
sign_result_ = zero_result_ = result; \
\
result -= (halfResult >> 4)&1; \
bit53_result_ = static_cast<uint8_t>((result&0x8) | ((result&0x2) << 4)); \
bit53_result_ = uint8_t((result&0x8) | ((result&0x2) << 4)); \
set_did_compute_flags();
case MicroOp::CPDR: {
@ -675,25 +675,25 @@ template < class T,
case MicroOp::RLA: {
const uint8_t new_carry = a_ >> 7;
a_ = static_cast<uint8_t>((a_ << 1) | (carry_result_ & Flag::Carry));
a_ = uint8_t((a_ << 1) | (carry_result_ & Flag::Carry));
set_rotate_flags();
} break;
case MicroOp::RRA: {
const uint8_t new_carry = a_ & 1;
a_ = static_cast<uint8_t>((a_ >> 1) | (carry_result_ << 7));
a_ = uint8_t((a_ >> 1) | (carry_result_ << 7));
set_rotate_flags();
} break;
case MicroOp::RLCA: {
const uint8_t new_carry = a_ >> 7;
a_ = static_cast<uint8_t>((a_ << 1) | new_carry);
a_ = uint8_t((a_ << 1) | new_carry);
set_rotate_flags();
} break;
case MicroOp::RRCA: {
const uint8_t new_carry = a_ & 1;
a_ = static_cast<uint8_t>((a_ >> 1) | (new_carry << 7));
a_ = uint8_t((a_ >> 1) | (new_carry << 7));
set_rotate_flags();
} break;
@ -708,51 +708,51 @@ template < class T,
case MicroOp::RLC:
carry_result_ = *static_cast<uint8_t *>(operation->source) >> 7;
*static_cast<uint8_t *>(operation->source) = static_cast<uint8_t>((*static_cast<uint8_t *>(operation->source) << 1) | carry_result_);
*static_cast<uint8_t *>(operation->source) = uint8_t((*static_cast<uint8_t *>(operation->source) << 1) | carry_result_);
set_shift_flags();
break;
case MicroOp::RRC:
carry_result_ = *static_cast<uint8_t *>(operation->source);
*static_cast<uint8_t *>(operation->source) = static_cast<uint8_t>((*static_cast<uint8_t *>(operation->source) >> 1) | (carry_result_ << 7));
*static_cast<uint8_t *>(operation->source) = uint8_t((*static_cast<uint8_t *>(operation->source) >> 1) | (carry_result_ << 7));
set_shift_flags();
break;
case MicroOp::RL: {
const uint8_t next_carry = *static_cast<uint8_t *>(operation->source) >> 7;
*static_cast<uint8_t *>(operation->source) = static_cast<uint8_t>((*static_cast<uint8_t *>(operation->source) << 1) | (carry_result_ & Flag::Carry));
*static_cast<uint8_t *>(operation->source) = uint8_t((*static_cast<uint8_t *>(operation->source) << 1) | (carry_result_ & Flag::Carry));
carry_result_ = next_carry;
set_shift_flags();
} break;
case MicroOp::RR: {
const uint8_t next_carry = *static_cast<uint8_t *>(operation->source);
*static_cast<uint8_t *>(operation->source) = static_cast<uint8_t>((*static_cast<uint8_t *>(operation->source) >> 1) | (carry_result_ << 7));
*static_cast<uint8_t *>(operation->source) = uint8_t((*static_cast<uint8_t *>(operation->source) >> 1) | (carry_result_ << 7));
carry_result_ = next_carry;
set_shift_flags();
} break;
case MicroOp::SLA:
carry_result_ = *static_cast<uint8_t *>(operation->source) >> 7;
*static_cast<uint8_t *>(operation->source) = static_cast<uint8_t>(*static_cast<uint8_t *>(operation->source) << 1);
*static_cast<uint8_t *>(operation->source) = uint8_t(*static_cast<uint8_t *>(operation->source) << 1);
set_shift_flags();
break;
case MicroOp::SRA:
carry_result_ = *static_cast<uint8_t *>(operation->source);
*static_cast<uint8_t *>(operation->source) = static_cast<uint8_t>((*static_cast<uint8_t *>(operation->source) >> 1) | (*static_cast<uint8_t *>(operation->source) & 0x80));
*static_cast<uint8_t *>(operation->source) = uint8_t((*static_cast<uint8_t *>(operation->source) >> 1) | (*static_cast<uint8_t *>(operation->source) & 0x80));
set_shift_flags();
break;
case MicroOp::SLL:
carry_result_ = *static_cast<uint8_t *>(operation->source) >> 7;
*static_cast<uint8_t *>(operation->source) = static_cast<uint8_t>(*static_cast<uint8_t *>(operation->source) << 1) | 1;
*static_cast<uint8_t *>(operation->source) = uint8_t(*static_cast<uint8_t *>(operation->source) << 1) | 1;
set_shift_flags();
break;
case MicroOp::SRL:
carry_result_ = *static_cast<uint8_t *>(operation->source);
*static_cast<uint8_t *>(operation->source) = static_cast<uint8_t>((*static_cast<uint8_t *>(operation->source) >> 1));
*static_cast<uint8_t *>(operation->source) = uint8_t((*static_cast<uint8_t *>(operation->source) >> 1));
set_shift_flags();
break;
@ -769,7 +769,7 @@ template < class T,
memptr_.full = hl_.full + 1;
const uint8_t low_nibble = a_ & 0xf;
a_ = (a_ & 0xf0) | (temp8_ & 0xf);
temp8_ = static_cast<uint8_t>((temp8_ >> 4) | (low_nibble << 4));
temp8_ = uint8_t((temp8_ >> 4) | (low_nibble << 4));
set_decimal_rotate_flags();
} break;
@ -777,7 +777,7 @@ template < class T,
memptr_.full = hl_.full + 1;
const uint8_t low_nibble = a_ & 0xf;
a_ = (a_ & 0xf0) | (temp8_ >> 4);
temp8_ = static_cast<uint8_t>((temp8_ << 4) | low_nibble);
temp8_ = uint8_t((temp8_ << 4) | low_nibble);
set_decimal_rotate_flags();
} break;
@ -880,11 +880,11 @@ template < class T,
break;
case MicroOp::CalculateIndexAddress:
memptr_.full = static_cast<uint16_t>(*static_cast<uint16_t *>(operation->source) + int8_t(temp8_));
memptr_.full = uint16_t(*static_cast<uint16_t *>(operation->source) + int8_t(temp8_));
break;
case MicroOp::SetAddrAMemptr:
memptr_.full = static_cast<uint16_t>(((*static_cast<uint16_t *>(operation->source) + 1)&0xff) + (a_ << 8));
memptr_.full = uint16_t(((*static_cast<uint16_t *>(operation->source) + 1)&0xff) + (a_ << 8));
break;
case MicroOp::IndexedPlaceHolder:

View File

@ -64,11 +64,11 @@ void FIRFilter::coefficients_for_idealised_filter_response(short *filter_coeffic
/* work out the right hand side of the filter coefficients */
std::size_t Np = (number_of_taps - 1) / 2;
float I0 = ino(a);
float Np_squared = static_cast<float>(Np * Np);
float Np_squared = float(Np * Np);
for(unsigned int i = 0; i <= Np; ++i) {
filter_coefficients_float[Np + i] =
A[i] *
ino(a * sqrtf(1.0f - (static_cast<float>(i * i) / Np_squared) )) /
ino(a * sqrtf(1.0f - (float(i * i) / Np_squared) )) /
I0;
}
@ -86,14 +86,14 @@ void FIRFilter::coefficients_for_idealised_filter_response(short *filter_coeffic
/* we'll also need integer versions, potentially */
float coefficientMultiplier = 1.0f / coefficientTotal;
for(std::size_t i = 0; i < number_of_taps; ++i) {
filter_coefficients[i] = static_cast<short>(filter_coefficients_float[i] * FixedMultiplier * coefficientMultiplier);
filter_coefficients[i] = short(filter_coefficients_float[i] * FixedMultiplier * coefficientMultiplier);
}
}
std::vector<float> FIRFilter::get_coefficients() const {
std::vector<float> coefficients;
for(const auto short_coefficient: filter_coefficients_) {
coefficients.push_back(static_cast<float>(short_coefficient) / FixedMultiplier);
coefficients.push_back(float(short_coefficient) / FixedMultiplier);
}
return coefficients;
}
@ -120,7 +120,7 @@ FIRFilter::FIRFilter(std::size_t number_of_taps, float input_sample_rate, float
std::vector<float> A(Np+1);
A[0] = 2.0f * (high_frequency - low_frequency) / input_sample_rate;
for(unsigned int i = 1; i <= Np; ++i) {
float i_pi = static_cast<float>(i) * static_cast<float>(M_PI);
float i_pi = float(i) * float(M_PI);
A[i] =
(
sinf(two_over_sample_rate * i_pi * high_frequency) -
@ -133,7 +133,7 @@ FIRFilter::FIRFilter(std::size_t number_of_taps, float input_sample_rate, float
FIRFilter::FIRFilter(const std::vector<float> &coefficients) {
for(const auto coefficient: coefficients) {
filter_coefficients_.push_back(static_cast<short>(coefficient * FixedMultiplier));
filter_coefficients_.push_back(short(coefficient * FixedMultiplier));
}
}

View File

@ -60,7 +60,7 @@ class FIRFilter {
for(std::size_t c = 0; c < filter_coefficients_.size(); ++c) {
outputValue += filter_coefficients_[c] * src[c * stride];
}
return static_cast<short>(outputValue >> FixedShift);
return short(outputValue >> FixedShift);
#endif
}

View File

@ -35,12 +35,12 @@ class Stepper {
of steps that should be taken at the @c output_rate.
*/
Stepper(uint64_t output_rate, uint64_t input_rate) :
accumulated_error_(-((int64_t)input_rate << 1)),
accumulated_error_(-(int64_t(input_rate) << 1)),
input_rate_(input_rate),
output_rate_(output_rate),
whole_step_(output_rate / input_rate),
adjustment_up_((int64_t)(output_rate % input_rate) << 1),
adjustment_down_((int64_t)input_rate << 1) {}
adjustment_up_(int64_t(output_rate % input_rate) << 1),
adjustment_down_(int64_t(input_rate) << 1) {}
/*!
Advances one step at the input rate.
@ -64,9 +64,9 @@ class Stepper {
*/
inline uint64_t step(uint64_t number_of_steps) {
uint64_t update = whole_step_ * number_of_steps;
accumulated_error_ += adjustment_up_ * (int64_t)number_of_steps;
accumulated_error_ += adjustment_up_ * int64_t(number_of_steps);
if(accumulated_error_ > 0) {
update += 1 + (uint64_t)(accumulated_error_ / adjustment_down_);
update += 1 + uint64_t(accumulated_error_ / adjustment_down_);
accumulated_error_ = (accumulated_error_ % adjustment_down_) - adjustment_down_;
}
return update;

View File

@ -8,5 +8,5 @@
#include "Cartridge.hpp"
const size_t Storage::Cartridge::Cartridge::Segment::UnknownAddress = static_cast<size_t>(-1);
const size_t Storage::Cartridge::Cartridge::Segment::UnknownAddress = size_t(-1);

View File

@ -21,9 +21,9 @@ BinaryDump::BinaryDump(const std::string &file_name) {
// grab contents
FILE *file = std::fopen(file_name.c_str(), "rb");
if(!file) throw ErrorNotAccessible;
std::size_t data_length = static_cast<std::size_t>(file_stats.st_size);
std::size_t data_length = size_t(file_stats.st_size);
std::vector<uint8_t> contents(data_length);
contents.resize(std::fread(&contents[0], 1, static_cast<std::size_t>(data_length), file));
contents.resize(std::fread(&contents[0], 1, size_t(data_length), file));
std::fclose(file);
// enshrine

View File

@ -29,15 +29,15 @@ PRG::PRG(const std::string &file_name) {
int loading_address = fgetc(file);
loading_address |= fgetc(file) << 8;
std::size_t data_length = static_cast<std::size_t>(file_stats.st_size) - 2;
std::size_t data_length = size_t(file_stats.st_size) - 2;
std::size_t padded_data_length = 1;
while(padded_data_length < data_length) padded_data_length <<= 1;
std::vector<uint8_t> contents(padded_data_length);
std::size_t length = std::fread(contents.data(), 1, static_cast<std::size_t>(data_length), file);
std::size_t length = std::fread(contents.data(), 1, size_t(data_length), file);
std::fclose(file);
// accept only files intended to load at 0xa000
if(loading_address != 0xa000 || length != static_cast<std::size_t>(data_length))
if(loading_address != 0xa000 || length != size_t(data_length))
throw ErrorNotROM;
// also accept only cartridges with the proper signature

View File

@ -11,7 +11,7 @@
void Storage::Data::BitReverse::reverse(std::vector<uint8_t> &vector) {
for(auto &byte : vector) {
byte =
static_cast<uint8_t>(
uint8_t(
((byte & 0x01) << 7) |
((byte & 0x02) << 5) |
((byte & 0x04) << 3) |

View File

@ -11,7 +11,7 @@
using namespace Storage::Data::ZX8081;
static uint16_t short_at(std::size_t address, const std::vector<uint8_t> &data) {
return static_cast<uint16_t>(data[address] | (data[address + 1] << 8));
return uint16_t(data[address] | (data[address + 1] << 8));
}
static std::shared_ptr<File> ZX80FileFromData(const std::vector<uint8_t> &data) {
@ -27,7 +27,7 @@ static std::shared_ptr<File> ZX80FileFromData(const std::vector<uint8_t> &data)
uint16_t display_address = short_at(0xc, data);
// check that the end of file is contained within the supplied data
if(static_cast<size_t>(end_of_file - 0x4000) > data.size()) return nullptr;
if(size_t(end_of_file - 0x4000) > data.size()) return nullptr;
// check for the proper ordering of buffers
if(vars > end_of_file) return nullptr;

View File

@ -18,11 +18,11 @@ MFMController::MFMController(Cycles clock_rate) :
}
void MFMController::process_index_hole() {
posit_event(static_cast<int>(Event::IndexHole));
posit_event(int(Event::IndexHole));
}
void MFMController::process_write_completed() {
posit_event(static_cast<int>(Event::DataWritten));
posit_event(int(Event::DataWritten));
}
void MFMController::set_is_double_density(bool is_double_density) {

View File

@ -20,8 +20,8 @@ using namespace Storage::Disk;
AcornADF::AcornADF(const std::string &file_name) : MFMSectorDump(file_name) {
// very loose validation: the file needs to be a multiple of 256 bytes
// and not ungainly large
if(file_.stats().st_size % static_cast<off_t>(128 << sector_size)) throw Error::InvalidFormat;
if(file_.stats().st_size < 7 * static_cast<off_t>(128 << sector_size)) throw Error::InvalidFormat;
if(file_.stats().st_size % off_t(128 << sector_size)) throw Error::InvalidFormat;
if(file_.stats().st_size < 7 * off_t(128 << sector_size)) throw Error::InvalidFormat;
// check that the initial directory's 'Hugo's are present
file_.seek(513, SEEK_SET);

View File

@ -26,7 +26,7 @@ AppleDSK::AppleDSK(const std::string &file_name) :
file_(file_name) {
if(file_.stats().st_size % (number_of_tracks*bytes_per_sector)) throw Error::InvalidFormat;
sectors_per_track_ = static_cast<int>(file_.stats().st_size / (number_of_tracks*bytes_per_sector));
sectors_per_track_ = int(file_.stats().st_size / (number_of_tracks*bytes_per_sector));
if(sectors_per_track_ != 13 && sectors_per_track_ != 16) throw Error::InvalidFormat;
// Check whether this is a Pro DOS disk by inspecting the filename.
@ -66,11 +66,11 @@ std::shared_ptr<Track> AppleDSK::get_track_at_position(Track::Address address) {
{
std::lock_guard<std::mutex> lock_guard(file_.get_file_access_mutex());
file_.seek(file_offset(address), SEEK_SET);
track_data = file_.read(static_cast<size_t>(bytes_per_sector * sectors_per_track_));
track_data = file_.read(size_t(bytes_per_sector * sectors_per_track_));
}
Storage::Disk::PCMSegment segment;
const uint8_t track = static_cast<uint8_t>(address.position.as_int());
const uint8_t track = uint8_t(address.position.as_int());
// In either case below, the code aims for exactly 50,000 bits per track.
if(sectors_per_track_ == 16) {
@ -104,7 +104,7 @@ void AppleDSK::set_tracks(const std::map<Track::Address, std::shared_ptr<Track>>
Storage::Disk::track_serialisation(*pair.second, Storage::Time(1, 50000)));
// Rearrange sectors into Apple DOS or Pro-DOS order.
std::vector<uint8_t> track_contents(static_cast<size_t>(bytes_per_sector * sectors_per_track_));
std::vector<uint8_t> track_contents(size_t(bytes_per_sector * sectors_per_track_));
for(const auto &sector_pair: sector_map) {
const size_t target_address = logical_sector_for_physical_sector(sector_pair.second.address.sector);
memcpy(&track_contents[target_address*256], sector_pair.second.data.data(), bytes_per_sector);

View File

@ -45,14 +45,14 @@ 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(static_cast<std::size_t>(file.get8()) << 8);
track_sizes.push_back(size_t(file.get8()) << 8);
}
} else {
size_of_a_track = file.get16le();
}
long file_offset = 0x100;
for(std::size_t c = 0; c < static_cast<std::size_t>(head_position_count_ * head_count_); c++) {
for(std::size_t c = 0; c < size_t(head_position_count_ * head_count_); c++) {
if(!is_extended_ || (track_sizes[c] > 0)) {
// Skip the introductory text, 'Track-Info\r\n' and its unused bytes.
file.seek(file_offset + 16, SEEK_SET);
@ -126,7 +126,7 @@ CPCDSK::CPCDSK(const std::string &file_name) :
}
// Figuring out the actual data size is a little more work...
std::size_t data_size = static_cast<std::size_t>(128 << sector.size);
std::size_t data_size = size_t(128 << sector.size);
std::size_t stored_data_size = data_size;
std::size_t number_of_samplings = 1;
@ -180,7 +180,7 @@ CPCDSK::CPCDSK(const std::string &file_name) :
// Advance to the beginning of the next track.
if(is_extended_)
file_offset += static_cast<long>(track_sizes[c]);
file_offset += long(track_sizes[c]);
else
file_offset += size_of_a_track;
}
@ -195,7 +195,7 @@ int CPCDSK::get_head_count() {
}
std::size_t CPCDSK::index_for_track(::Storage::Disk::Track::Address address) {
return static_cast<std::size_t>((address.position.as_int() * head_count_) + address.head);
return size_t((address.position.as_int() * head_count_) + address.head);
}
std::shared_ptr<Track> CPCDSK::get_track_at_position(::Storage::Disk::Track::Address address) {
@ -238,8 +238,8 @@ void CPCDSK::set_tracks(const std::map<::Storage::Disk::Track::Address, std::sha
Track *track = tracks_[chronological_track].get();
if(!track) {
track = new Track;
track->track = static_cast<uint8_t>(pair.first.position.as_int());
track->side = static_cast<uint8_t>(pair.first.head);
track->track = uint8_t(pair.first.position.as_int());
track->side = uint8_t(pair.first.head);
track->data_rate = Track::DataRate::SingleOrDoubleDensity;
track->data_encoding = Track::DataEncoding::MFM;
track->sector_length = 2;
@ -275,12 +275,12 @@ void CPCDSK::set_tracks(const std::map<::Storage::Disk::Track::Address, std::sha
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(static_cast<uint8_t>(head_position_count_));
output.put8(static_cast<uint8_t>(head_count_));
output.put8(uint8_t(head_position_count_));
output.put8(uint8_t(head_count_));
output.putn(2, 0);
// Output size table.
for(std::size_t index = 0; index < static_cast<std::size_t>(head_position_count_ * head_count_); ++index) {
for(std::size_t index = 0; index < size_t(head_position_count_ * head_count_); ++index) {
if(index >= tracks_.size()) {
output.put8(0);
continue;
@ -301,14 +301,14 @@ void CPCDSK::set_tracks(const std::map<::Storage::Disk::Track::Address, std::sha
// Round upward and output.
track_size += (256 - (track_size & 255)) & 255;
output.put8(static_cast<uint8_t>(track_size >> 8));
output.put8(uint8_t(track_size >> 8));
}
// Advance to offset 256.
output.putn(static_cast<std::size_t>(256 - output.tell()), 0);
output.putn(size_t(256 - output.tell()), 0);
// Output each track.
for(std::size_t index = 0; index < static_cast<std::size_t>(head_position_count_ * head_count_); ++index) {
for(std::size_t index = 0; index < size_t(head_position_count_ * head_count_); ++index) {
if(index >= tracks_.size()) continue;
Track *track = tracks_[index].get();
if(!track) continue;
@ -344,7 +344,7 @@ void CPCDSK::set_tracks(const std::map<::Storage::Disk::Track::Address, std::sha
break;
}
output.put8(track->sector_length);
output.put8(static_cast<uint8_t>(track->sectors.size()));
output.put8(uint8_t(track->sectors.size()));
output.put8(track->gap3_length);
output.put8(track->filler_byte);
@ -361,12 +361,12 @@ void CPCDSK::set_tracks(const std::map<::Storage::Disk::Track::Address, std::sha
for(auto &sample: sector.samples) {
data_size += sample.size();
}
output.put16le(static_cast<uint16_t>(data_size));
output.put16le(uint16_t(data_size));
}
// Move to next 256-byte boundary.
long distance = (256 - (output.tell()&255))&255;
output.putn(static_cast<std::size_t>(distance), 0);
output.putn(size_t(distance), 0);
// Output sector contents.
for(auto &sector: track->sectors) {
@ -377,7 +377,7 @@ void CPCDSK::set_tracks(const std::map<::Storage::Disk::Track::Address, std::sha
// Move to next 256-byte boundary.
distance = (256 - (output.tell()&255))&255;
output.putn(static_cast<std::size_t>(distance), 0);
output.putn(size_t(distance), 0);
}
}

View File

@ -31,7 +31,7 @@ D64::D64(const std::string &file_name) :
disk_id_ = 0;
for(const auto &character: file_name) {
disk_id_ ^= character;
disk_id_ = static_cast<uint16_t>((disk_id_ << 2) ^ (disk_id_ >> 13));
disk_id_ = uint16_t((disk_id_ << 2) ^ (disk_id_ >> 13));
}
}
@ -79,23 +79,23 @@ std::shared_ptr<Track> D64::get_track_at_position(Track::Address address) {
//
// = 349 GCR bytes per sector
std::size_t track_bytes = 349 * static_cast<std::size_t>(sectors_by_zone[zone]);
std::size_t track_bytes = 349 * size_t(sectors_by_zone[zone]);
std::vector<uint8_t> data(track_bytes);
for(int sector = 0; sector < sectors_by_zone[zone]; sector++) {
uint8_t *sector_data = &data[static_cast<size_t>(sector) * 349];
uint8_t *sector_data = &data[size_t(sector) * 349];
sector_data[0] = sector_data[1] = sector_data[2] = 0xff;
uint8_t sector_number = static_cast<uint8_t>(sector); // sectors count from 0
uint8_t track_number = static_cast<uint8_t>(address.position.as_int() + 1); // tracks count from 1
uint8_t checksum = static_cast<uint8_t>(sector_number ^ track_number ^ disk_id_ ^ (disk_id_ >> 8));
uint8_t sector_number = uint8_t(sector); // sectors count from 0
uint8_t track_number = uint8_t(address.position.as_int() + 1); // tracks count from 1
uint8_t checksum = uint8_t(sector_number ^ track_number ^ disk_id_ ^ (disk_id_ >> 8));
uint8_t header_start[4] = {
0x08, checksum, sector_number, track_number
};
Encodings::CommodoreGCR::encode_block(&sector_data[3], header_start);
uint8_t header_end[4] = {
static_cast<uint8_t>(disk_id_ & 0xff), static_cast<uint8_t>(disk_id_ >> 8), 0, 0
uint8_t(disk_id_ & 0xff), uint8_t(disk_id_ >> 8), 0, 0
};
Encodings::CommodoreGCR::encode_block(&sector_data[8], header_end);

View File

@ -41,8 +41,8 @@ DMK::DMK(const std::string &file_name) :
is_read_only_ = (read_only_byte == 0xff) || file_.get_is_known_read_only();
// Read track count and size.
head_position_count_ = static_cast<int>(file_.get8());
track_length_ = static_cast<long>(file_.get16le());
head_position_count_ = int(file_.get8());
track_length_ = long(file_.get16le());
// Track length must be at least 0x80, as that's the size of the IDAM
// table before track contents.
@ -93,7 +93,7 @@ std::shared_ptr<::Storage::Disk::Track> DMK::get_track_at_position(::Storage::Di
}
// Grab the rest of the track.
std::vector<uint8_t> track = file_.read(static_cast<std::size_t>(track_length_ - 0x80));
std::vector<uint8_t> track = file_.read(size_t(track_length_ - 0x80));
// Default to outputting double density unless the disk doesn't support it.
bool is_double_density = !is_purely_single_density_;
@ -104,7 +104,7 @@ std::shared_ptr<::Storage::Disk::Track> DMK::get_track_at_position(::Storage::Di
std::size_t idam_pointer = 0;
const std::size_t track_length = static_cast<std::size_t>(track_length_) - 0x80;
const std::size_t track_length = size_t(track_length_) - 0x80;
std::size_t track_pointer = 0;
while(track_pointer < track_length) {
// Determine bytes left until next IDAM.

View File

@ -40,7 +40,7 @@ std::shared_ptr<Track> G64::get_track_at_position(Track::Address address) {
std::shared_ptr<Track> resulting_track;
// seek to this track's entry in the track table
file_.seek(static_cast<long>((address.position.as_half() * 4) + 0xc), SEEK_SET);
file_.seek(long((address.position.as_half() * 4) + 0xc), SEEK_SET);
// read the track offset
const uint32_t track_offset = file_.get32le();
@ -49,7 +49,7 @@ std::shared_ptr<Track> G64::get_track_at_position(Track::Address address) {
if(!track_offset) return nullptr;
// seek to the track start
file_.seek(static_cast<long>(track_offset), SEEK_SET);
file_.seek(long(track_offset), SEEK_SET);
// get the real track length
const uint16_t track_length = file_.get16le();
@ -58,7 +58,7 @@ std::shared_ptr<Track> G64::get_track_at_position(Track::Address address) {
const std::vector<uint8_t> track_contents = file_.read(track_length);
// seek to this track's entry in the speed zone table
file_.seek(static_cast<long>((address.position.as_half() * 4) + 0x15c), SEEK_SET);
file_.seek(long((address.position.as_half() * 4) + 0x15c), SEEK_SET);
// read the speed zone offsrt
const uint32_t speed_zone_offset = file_.get32le();
@ -66,7 +66,7 @@ std::shared_ptr<Track> G64::get_track_at_position(Track::Address address) {
// 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) {
// seek to start of speed zone
file_.seek(static_cast<long>(speed_zone_offset), SEEK_SET);
file_.seek(long(speed_zone_offset), SEEK_SET);
// read the speed zone bytes
const uint16_t speed_zone_length = (track_length + 3) >> 2;
@ -79,7 +79,7 @@ std::shared_ptr<Track> G64::get_track_at_position(Track::Address address) {
unsigned int start_byte_in_current_speed = 0;
for(unsigned int byte = 0; byte < track_length; byte ++) {
unsigned int byte_speed = speed_zone_contents[byte >> 2] >> (6 - (byte&3)*2);
if(byte_speed != current_speed || byte == static_cast<uint16_t>(track_length-1)) {
if(byte_speed != current_speed || byte == uint16_t(track_length-1)) {
unsigned int number_of_bytes = byte - start_byte_in_current_speed;
PCMSegment segment(
@ -96,7 +96,7 @@ std::shared_ptr<Track> G64::get_track_at_position(Track::Address address) {
resulting_track = std::make_shared<PCMTrack>(std::move(segments));
} else {
PCMSegment segment(
Encodings::CommodoreGCR::length_of_a_bit_in_time_zone(static_cast<unsigned int>(speed_zone_offset)),
Encodings::CommodoreGCR::length_of_a_bit_in_time_zone(unsigned(speed_zone_offset)),
track_length * 8,
track_contents
);

View File

@ -23,7 +23,7 @@ HFE::HFE(const std::string &file_name) :
head_count_ = file_.get8();
file_.seek(7, SEEK_CUR);
track_list_offset_ = static_cast<long>(file_.get16le()) << 9;
track_list_offset_ = long(file_.get16le()) << 9;
}
HeadPosition HFE::get_maximum_head_position() {
@ -46,8 +46,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 = static_cast<long>(file_.get16le()) << 9; // Track offset, in units of 512 bytes.
uint16_t track_length = file_.get16le(); // Track length, in bytes, containing both the front and back track.
long track_offset = long(file_.get16le()) << 9; // Track offset, in units of 512 bytes.
uint16_t track_length = file_.get16le(); // 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);
@ -73,13 +73,13 @@ std::shared_ptr<Track> HFE::get_track_at_position(Track::Address address) {
uint16_t c = 0;
while(c < track_length) {
// Decide how many bytes of at most 256 to read, and read them.
uint16_t length = static_cast<uint16_t>(std::min(256, track_length - c));
uint16_t length = uint16_t(std::min(256, track_length - c));
std::vector<uint8_t> section = file_.read(length);
// Push those into the PCMSegment. In HFE the least-significant bit is
// serialised first. TODO: move this logic to PCMSegment.
for(uint16_t byte = 0; byte < length; ++byte) {
const size_t base = static_cast<size_t>(c + byte) << 3;
const size_t base = size_t(c + byte) << 3;
segment.data[base + 0] = !!(section[byte] & 0x01);
segment.data[base + 1] = !!(section[byte] & 0x02);
segment.data[base + 2] = !!(section[byte] & 0x04);
@ -110,14 +110,14 @@ void HFE::set_tracks(const std::map<Track::Address, std::shared_ptr<Track>> &tra
// Convert the segment into a byte encoding, LSB first.
std::vector<uint8_t> byte_segment = segment.byte_data(false);
uint16_t data_length = std::min(static_cast<uint16_t>(byte_segment.size()), track_length);
uint16_t data_length = std::min(uint16_t(byte_segment.size()), track_length);
lock_guard.lock();
seek_track(track.first);
uint16_t c = 0;
while(c < data_length) {
uint16_t length = static_cast<uint16_t>(std::min(256, data_length - c));
uint16_t length = uint16_t(std::min(256, data_length - c));
file_.write(&byte_segment[c], length);
c += length;
file_.seek(256, SEEK_CUR);

View File

@ -34,7 +34,7 @@ std::shared_ptr<Track> MFMSectorDump::get_track_at_position(Track::Address addre
file_.read(sectors, sizeof(sectors));
}
return track_for_sectors(sectors, sectors_per_track_, static_cast<uint8_t>(address.position.as_int()), static_cast<uint8_t>(address.head), first_sector_, sector_size_, is_double_density_);
return track_for_sectors(sectors, sectors_per_track_, uint8_t(address.position.as_int()), uint8_t(address.head), first_sector_, sector_size_, is_double_density_);
}
void MFMSectorDump::set_tracks(const std::map<Track::Address, std::shared_ptr<Track>> &tracks) {
@ -45,7 +45,7 @@ void MFMSectorDump::set_tracks(const std::map<Track::Address, std::shared_ptr<Tr
for(const auto &track : tracks) {
// Assumption here: sector IDs will run from 0.
decode_sectors(*track.second, parsed_track, first_sector_, first_sector_ + static_cast<uint8_t>(sectors_per_track_-1), sector_size_, is_double_density_);
decode_sectors(*track.second, parsed_track, first_sector_, first_sector_ + uint8_t(sectors_per_track_-1), sector_size_, is_double_density_);
const long file_offset = get_file_offset_for_position(track.first);
std::lock_guard<std::mutex> lock_guard(file_.get_file_access_mutex());

View File

@ -27,7 +27,7 @@ MSXDSK::MSXDSK(const std::string &file_name) :
// Throw if there would seemingly be an incomplete track.
if(file_size % track_size) throw Error::InvalidFormat;
track_count_ = static_cast<int>(file_size / track_size);
track_count_ = int(file_size / track_size);
head_count_ = 1;
// Throw if too large or too small or too large for single sided and

View File

@ -246,7 +246,7 @@ void MacintoshIMG::set_tracks(const std::map<Track::Address, std::shared_ptr<Tra
Storage::Disk::track_serialisation(*pair.second, Storage::Time(1, data_rate)));
// Rearrange sectors into ascending order.
std::vector<uint8_t> track_contents(static_cast<size_t>(524 * included_sectors.length));
std::vector<uint8_t> track_contents(size_t(524 * included_sectors.length));
for(const auto &sector_pair: sector_map) {
const size_t target_address = sector_pair.second.address.sector * 524;
if(target_address >= track_contents.size() || sector_pair.second.data.size() != 524) continue;

View File

@ -30,24 +30,24 @@ OricMFMDSK::OricMFMDSK(const std::string &file_name) :
}
HeadPosition OricMFMDSK::get_maximum_head_position() {
return HeadPosition(static_cast<int>(track_count_));
return HeadPosition(int(track_count_));
}
int OricMFMDSK::get_head_count() {
return static_cast<int>(head_count_);
return int(head_count_);
}
long OricMFMDSK::get_file_offset_for_position(Track::Address address) {
int seek_offset = 0;
switch(geometry_type_) {
case 1:
seek_offset = address.head * static_cast<int>(track_count_) + address.position.as_int();
seek_offset = address.head * int(track_count_) + address.position.as_int();
break;
case 2:
seek_offset = address.position.as_int() * static_cast<int>(track_count_ * head_count_) + address.head;
seek_offset = address.position.as_int() * int(track_count_ * head_count_) + address.head;
break;
}
return static_cast<long>(seek_offset) * 6400 + 256;
return long(seek_offset) * 6400 + 256;
}
std::shared_ptr<Track> OricMFMDSK::get_track_at_position(Track::Address address) {
@ -159,7 +159,7 @@ void OricMFMDSK::set_tracks(const std::map<Track::Address, std::shared_ptr<Track
std::lock_guard<std::mutex> lock_guard(file_.get_file_access_mutex());
file_.seek(file_offset, SEEK_SET);
std::size_t track_size = std::min(static_cast<std::size_t>(6400), parsed_track.size());
std::size_t track_size = std::min(size_t(6400), parsed_track.size());
file_.write(parsed_track.data(), track_size);
}
}

View File

@ -21,7 +21,7 @@ using namespace Storage::Disk;
std::shared_ptr<Track> Storage::Disk::track_for_sectors(const uint8_t *const source, int number_of_sectors, uint8_t track, uint8_t side, uint8_t first_sector, uint8_t size, bool is_double_density) {
std::vector<Storage::Encodings::MFM::Sector> sectors;
off_t byte_size = static_cast<off_t>(128 << size);
off_t byte_size = off_t(128 << size);
off_t source_pointer = 0;
for(int sector = 0; sector < number_of_sectors; sector++) {
sectors.emplace_back();
@ -51,7 +51,7 @@ void Storage::Disk::decode_sectors(Track &track, uint8_t *const destination, uin
Storage::Disk::track_serialisation(track, is_double_density ? Storage::Encodings::MFM::MFMBitLength : Storage::Encodings::MFM::FMBitLength),
is_double_density);
std::size_t byte_size = static_cast<std::size_t>(128 << sector_size);
std::size_t byte_size = size_t(128 << sector_size);
for(const auto &pair : sectors) {
if(pair.second.address.sector > last_sector) continue;
if(pair.second.address.sector < first_sector) continue;

View File

@ -20,7 +20,7 @@ WOZ::WOZ(const std::string &file_name) :
const char signature[8] = {
'W', 'O', 'Z', '1',
static_cast<char>(0xff), 0x0a, 0x0d, 0x0a
char(0xff), 0x0a, 0x0d, 0x0a
};
if(!file_.check_signature(signature, 8)) throw Error::InvalidFormat;
@ -28,7 +28,7 @@ WOZ::WOZ(const std::string &file_name) :
const uint32_t crc = file_.get32le();
// Get the collection of all data that contributes to the CRC.
post_crc_contents_ = file_.read(static_cast<std::size_t>(file_.stats().st_size - 12));
post_crc_contents_ = file_.read(size_t(file_.stats().st_size - 12));
// Test the CRC.
const uint32_t computed_crc = crc_generator.compute_crc(post_crc_contents_);
@ -46,7 +46,7 @@ WOZ::WOZ(const std::string &file_name) :
const uint32_t chunk_size = file_.get32le();
if(file_.eof()) break;
long end_of_chunk = file_.tell() + static_cast<long>(chunk_size);
long end_of_chunk = file_.tell() + long(chunk_size);
#define CK(str) (str[0] | (str[1] << 8) | (str[2] << 16) | (str[3] << 24))
switch(chunk_id) {
@ -118,7 +118,7 @@ std::shared_ptr<Track> WOZ::get_track_at_position(Track::Address address) {
// of bits that were used. Other information follows but is not intended for emulation.
track_contents = file_.read(6646);
file_.seek(2, SEEK_CUR);
number_of_bits = std::min(file_.get16le(), static_cast<uint16_t>(6646*8));
number_of_bits = std::min(file_.get16le(), uint16_t(6646*8));
}
return std::make_shared<PCMTrack>(PCMSegment(number_of_bits, track_contents));
@ -129,15 +129,15 @@ void WOZ::set_tracks(const std::map<Track::Address, std::shared_ptr<Track>> &tra
// Decode the track and store, patching into the post_crc_contents_.
auto segment = Storage::Disk::track_serialisation(*pair.second, Storage::Time(1, 50000));
auto offset = static_cast<std::size_t>(file_offset(pair.first) - 12);
auto offset = size_t(file_offset(pair.first) - 12);
std::vector<uint8_t> segment_bytes = segment.byte_data();
memcpy(&post_crc_contents_[offset - 12], segment_bytes.data(), segment_bytes.size());
// Write number of bytes and number of bits.
post_crc_contents_[offset + 6646] = static_cast<uint8_t>(segment.data.size() >> 3);
post_crc_contents_[offset + 6647] = static_cast<uint8_t>(segment.data.size() >> 11);
post_crc_contents_[offset + 6648] = static_cast<uint8_t>(segment.data.size());
post_crc_contents_[offset + 6649] = static_cast<uint8_t>(segment.data.size() >> 8);
post_crc_contents_[offset + 6646] = uint8_t(segment.data.size() >> 3);
post_crc_contents_[offset + 6647] = uint8_t(segment.data.size() >> 11);
post_crc_contents_[offset + 6648] = uint8_t(segment.data.size());
post_crc_contents_[offset + 6649] = uint8_t(segment.data.size() >> 8);
// Set no splice information now provided, since it's been lost if ever it was known.
post_crc_contents_[offset + 6650] = 0xff;

View File

@ -24,7 +24,7 @@ Drive::Drive(int input_clock_rate, int revolutions_per_minute, int number_of_hea
ready_type_(rdy_type) {
set_rotation_speed(revolutions_per_minute);
const auto seed = static_cast<std::default_random_engine::result_type>(std::chrono::system_clock::now().time_since_epoch().count());
const auto seed = std::default_random_engine::result_type(std::chrono::system_clock::now().time_since_epoch().count());
std::default_random_engine randomiser(seed);
// Get at least 64 bits of random information; rounding is likey to give this a slight bias.

View File

@ -36,7 +36,7 @@ Storage::Disk::PCMSegment sync(int length, int bit_size) {
Storage::Disk::PCMSegment segment;
// Reserve sufficient storage.
segment.data.reserve(static_cast<size_t>(length * bit_size));
segment.data.reserve(size_t(length * bit_size));
// Write patters of 0xff padded with 0s to the selected bit size.
while(length--) {
@ -75,8 +75,8 @@ Storage::Disk::PCMSegment AppleGCR::AppleII::header(uint8_t volume, uint8_t trac
data[2] = header_prologue[2];
#define WriteFM(index, value) \
data[index+0] = static_cast<uint8_t>(((value) >> 1) | 0xaa); \
data[index+1] = static_cast<uint8_t>((value) | 0xaa); \
data[index+0] = uint8_t(((value) >> 1) | 0xaa); \
data[index+1] = uint8_t((value) | 0xaa); \
WriteFM(3, volume);
WriteFM(5, track);
@ -141,19 +141,19 @@ Storage::Disk::PCMSegment AppleGCR::AppleII::six_and_two_data(const uint8_t *sou
const uint8_t bit_reverse[] = {0, 2, 1, 3};
for(std::size_t c = 0; c < 84; ++c) {
data[3 + c] =
static_cast<uint8_t>(
uint8_t(
bit_reverse[source[c]&3] |
(bit_reverse[source[c + 86]&3] << 2) |
(bit_reverse[source[c + 172]&3] << 4)
);
}
data[87] =
static_cast<uint8_t>(
uint8_t(
(bit_reverse[source[84]&3] << 0) |
(bit_reverse[source[170]&3] << 2)
);
data[88] =
static_cast<uint8_t>(
uint8_t(
(bit_reverse[source[85]&3] << 0) |
(bit_reverse[source[171]&3] << 2)
);

View File

@ -77,7 +77,7 @@ std::map<std::size_t, Sector> Storage::Encodings::AppleGCR::sectors_from_segment
int header_delay = 0;
bool is_five_and_three = false;
while(bit < segment.data.size() || pointer != scanning_sentinel || header_delay) {
shift_register = static_cast<uint_fast8_t>((shift_register << 1) | (segment.data[bit % segment.data.size()] ? 1 : 0));
shift_register = uint_fast8_t((shift_register << 1) | (segment.data[bit % segment.data.size()] ? 1 : 0));
++bit;
// Apple GCR parsing: bytes always have the top bit set.
@ -113,7 +113,7 @@ std::map<std::size_t, Sector> Storage::Encodings::AppleGCR::sectors_from_segment
new_sector = std::make_unique<Sector>();
new_sector->data.reserve(710);
} else {
sector_location = static_cast<std::size_t>(bit % segment.data.size());
sector_location = size_t(bit % segment.data.size());
header_delay = 200; // Allow up to 200 bytes to find the body, if the
// track split comes in between.
}
@ -211,7 +211,7 @@ std::map<std::size_t, Sector> Storage::Encodings::AppleGCR::sectors_from_segment
// Undo the 6 and 2 mapping.
const uint8_t bit_reverse[] = {0, 2, 1, 3};
#define unmap(byte, nibble, shift) \
sector->data[86 + byte] = static_cast<uint8_t>(\
sector->data[86 + byte] = uint8_t(\
(sector->data[86 + byte] << 2) | bit_reverse[(sector->data[nibble] >> shift)&3]);
for(std::size_t c = 0; c < 84; ++c) {

View File

@ -63,9 +63,9 @@ void Storage::Encodings::CommodoreGCR::encode_block(uint8_t *destination, uint8_
encoding_for_byte(source[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]);
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]);
}

View File

@ -30,7 +30,7 @@ class MFMEncoder: public Encoder {
void add_byte(uint8_t input, uint8_t fuzzy_mask = 0) final {
crc_generator_.add(input);
const uint16_t spread_value =
static_cast<uint16_t>(
uint16_t(
((input & 0x01) << 0) |
((input & 0x02) << 1) |
((input & 0x04) << 2) |
@ -40,11 +40,11 @@ class MFMEncoder: public Encoder {
((input & 0x40) << 6) |
((input & 0x80) << 7)
);
const uint16_t or_bits = static_cast<uint16_t>((spread_value << 1) | (spread_value >> 1) | (last_output_ << 15));
const uint16_t or_bits = uint16_t((spread_value << 1) | (spread_value >> 1) | (last_output_ << 15));
const uint16_t output = spread_value | ((~or_bits) & 0xaaaa);
const uint16_t spread_mask =
static_cast<uint16_t>(
uint16_t(
((fuzzy_mask & 0x01) << 0) |
((fuzzy_mask & 0x02) << 1) |
((fuzzy_mask & 0x04) << 2) |
@ -108,7 +108,7 @@ class FMEncoder: public Encoder {
void add_byte(uint8_t input, uint8_t fuzzy_mask = 0) final {
crc_generator_.add(input);
output_short(
static_cast<uint16_t>(
uint16_t(
((input & 0x01) << 0) |
((input & 0x02) << 1) |
((input & 0x04) << 2) |
@ -119,7 +119,7 @@ class FMEncoder: public Encoder {
((input & 0x80) << 7) |
0xaaaa
),
static_cast<uint16_t>(
uint16_t(
((fuzzy_mask & 0x01) << 0) |
((fuzzy_mask & 0x02) << 1) |
((fuzzy_mask & 0x04) << 2) |
@ -242,7 +242,7 @@ template<class T> std::shared_ptr<Storage::Disk::Track>
shifter.add_data_address_mark();
std::size_t c = 0;
std::size_t declared_length = static_cast<std::size_t>(128 << sector->size);
std::size_t declared_length = size_t(128 << sector->size);
if(sector->samples.size() > 1) {
// For each byte, mark as fuzzy any bits that differ. Which isn't exactly the
// same thing as obeying the multiple samples, as it discards the implied

View File

@ -59,7 +59,7 @@ std::map<std::size_t, Storage::Encodings::MFM::Sector> Storage::Encodings::MFM::
case 2: new_sector->address.sector = shifter.get_byte(); ++position; break;
case 3:
new_sector->size = shifter.get_byte();
size = static_cast<std::size_t>(128 << (new_sector->size&7));
size = size_t(128 << (new_sector->size&7));
++position;
is_reading = false;
shifter.set_should_obey_syncs(true);

View File

@ -24,7 +24,7 @@ void Shifter::set_should_obey_syncs(bool should_obey_syncs) {
}
void Shifter::add_input_bit(int value) {
shift_register_ = (shift_register_ << 1) | static_cast<unsigned int>(value);
shift_register_ = (shift_register_ << 1) | unsigned(value);
++bits_since_token_;
token_ = Token::None;

View File

@ -29,7 +29,7 @@ std::unique_ptr<Storage::Disk::CPM::Catalogue> Storage::Disk::CPM::GetCatalogue(
if(catalogue_allocation_bitmap & 0x8000) {
std::size_t size_read = 0;
do {
Storage::Encodings::MFM::Sector *sector_contents = parser.get_sector(0, static_cast<uint8_t>(track), static_cast<uint8_t>(parameters.first_sector + sector));
Storage::Encodings::MFM::Sector *sector_contents = parser.get_sector(0, uint8_t(track), uint8_t(parameters.first_sector + sector));
if(!sector_contents || sector_contents->samples.empty()) {
return nullptr;
}
@ -43,7 +43,7 @@ std::unique_ptr<Storage::Disk::CPM::Catalogue> Storage::Disk::CPM::GetCatalogue(
sector = 0;
track++;
}
} while(size_read < static_cast<std::size_t>(parameters.block_size));
} while(size_read < size_t(parameters.block_size));
}
catalogue_allocation_bitmap <<= 1;
@ -77,10 +77,10 @@ std::unique_ptr<Storage::Disk::CPM::Catalogue> Storage::Disk::CPM::GetCatalogue(
CatalogueEntry &entry = catalogue_entries.back();
entry.user_number = catalogue[c];
entry.name.insert(entry.name.begin(), &catalogue[c+1], &catalogue[c+9]);
for(std::size_t s = 0; s < 3; s++) entry.type.push_back((char)catalogue[c + s + 9] & 0x7f);
for(std::size_t s = 0; s < 3; s++) entry.type.push_back(char(catalogue[c + s + 9]) & 0x7f);
entry.read_only = catalogue[c + 9] & 0x80;
entry.system = catalogue[c + 10] & 0x80;
entry.extent = static_cast<std::size_t>(catalogue[c + 12] + (catalogue[c + 14] << 5));
entry.extent = size_t(catalogue[c + 12] + (catalogue[c + 14] << 5));
entry.number_of_records = catalogue[c + 15];
entry.catalogue_index = c;
}
@ -90,10 +90,10 @@ std::unique_ptr<Storage::Disk::CPM::Catalogue> Storage::Disk::CPM::GetCatalogue(
std::unique_ptr<Catalogue> result(new Catalogue);
bool has_long_allocation_units = (parameters.tracks * parameters.sectors_per_track * static_cast<int>(sector_size) / parameters.block_size) >= 256;
std::size_t bytes_per_catalogue_entry = (has_long_allocation_units ? 8 : 16) * static_cast<std::size_t>(parameters.block_size);
int sectors_per_block = parameters.block_size / static_cast<int>(sector_size);
int records_per_sector = static_cast<int>(sector_size) / 128;
bool has_long_allocation_units = (parameters.tracks * parameters.sectors_per_track * int(sector_size) / parameters.block_size) >= 256;
std::size_t bytes_per_catalogue_entry = (has_long_allocation_units ? 8 : 16) * size_t(parameters.block_size);
int sectors_per_block = parameters.block_size / int(sector_size);
int records_per_sector = int(sector_size) / 128;
auto entry = catalogue_entries.begin();
while(entry != catalogue_entries.end()) {
@ -114,7 +114,7 @@ std::unique_ptr<Storage::Disk::CPM::Catalogue> Storage::Disk::CPM::GetCatalogue(
new_file.system = entry->system;
// Create storage for data.
std::size_t required_size = final_entry->extent * bytes_per_catalogue_entry + static_cast<std::size_t>(final_entry->number_of_records) * 128;
std::size_t required_size = final_entry->extent * bytes_per_catalogue_entry + size_t(final_entry->number_of_records) * 128;
new_file.data.resize(required_size);
// Accumulate all data.
@ -138,7 +138,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 < number_of_records; s++) {
Storage::Encodings::MFM::Sector *sector_contents = parser.get_sector(0, static_cast<uint8_t>(track), static_cast<uint8_t>(parameters.first_sector + sector));
Storage::Encodings::MFM::Sector *sector_contents = parser.get_sector(0, uint8_t(track), uint8_t(parameters.first_sector + sector));
if(!sector_contents || sector_contents->samples.empty()) break;
sector++;
if(sector == parameters.sectors_per_track) {
@ -147,7 +147,7 @@ std::unique_ptr<Storage::Disk::CPM::Catalogue> Storage::Disk::CPM::GetCatalogue(
}
int records_to_copy = std::min(entry->number_of_records - record, records_per_sector);
std::memcpy(&new_file.data[entry->extent * bytes_per_catalogue_entry + static_cast<std::size_t>(record) * 128], sector_contents->samples[0].data(), static_cast<std::size_t>(records_to_copy) * 128);
std::memcpy(&new_file.data[entry->extent * bytes_per_catalogue_entry + size_t(record) * 128], sector_contents->samples[0].data(), size_t(records_to_copy) * 128);
record += records_to_copy;
}
}

View File

@ -60,12 +60,12 @@ void PCMSegment::rotate_right(size_t length) {
// the left, do the opposite.
std::vector<uint8_t> data_copy;
if(length > 0) {
data_copy.insert(data_copy.end(), data.end() - static_cast<off_t>(length), data.end());
data.erase(data.end() - static_cast<off_t>(length), data.end());
data_copy.insert(data_copy.end(), data.end() - off_t(length), data.end());
data.erase(data.end() - off_t(length), data.end());
data.insert(data.begin(), data_copy.begin(), data_copy.end());
} else {
data_copy.insert(data_copy.end(), data.begin(), data.begin() - static_cast<off_t>(length));
data.erase(data.begin(), data.begin() - static_cast<off_t>(length));
data_copy.insert(data_copy.end(), data.begin(), data.begin() - off_t(length));
data.erase(data.begin(), data.begin() - off_t(length));
data.insert(data.end(), data_copy.begin(), data_copy.end());
}
}
@ -106,7 +106,7 @@ Storage::Disk::Track::Event PCMSegmentEventSource::get_next_event() {
}
Storage::Time PCMSegmentEventSource::get_length() {
return segment_->length_of_a_bit * static_cast<unsigned int>(segment_->data.size());
return segment_->length_of_a_bit * unsigned(segment_->data.size());
}
Storage::Time PCMSegmentEventSource::seek_to(const Time &time_from_start) {
@ -136,7 +136,7 @@ Storage::Time PCMSegmentEventSource::seek_to(const Time &time_from_start) {
bit_pointer_ = 1 + (relative_time / segment_->length_of_a_bit).get<unsigned int>();
// map up to the correct amount of time
return half_bit_length + segment_->length_of_a_bit * static_cast<unsigned int>(bit_pointer_ - 1);
return half_bit_length + segment_->length_of_a_bit * unsigned(bit_pointer_ - 1);
}
const PCMSegment &PCMSegmentEventSource::segment() const {

View File

@ -145,7 +145,7 @@ struct PCMSegment {
/// @returns the total amount of time occupied by all the data stored in this segment.
Time length() const {
return length_of_a_bit * static_cast<unsigned int>(data.size());
return length_of_a_bit * unsigned(data.size());
}
};

View File

@ -17,18 +17,18 @@ PCMTrack::PCMTrack(const std::vector<PCMSegment> &segments) : PCMTrack() {
// sum total length of all segments
Time total_length;
for(const auto &segment : segments) {
total_length += segment.length_of_a_bit * static_cast<unsigned int>(segment.data.size());
total_length += segment.length_of_a_bit * unsigned(segment.data.size());
}
total_length.simplify();
// each segment is then some proportion of the total; for them all to sum to 1 they'll
// need to be adjusted to be
for(const auto &segment : segments) {
Time original_length_of_segment = segment.length_of_a_bit * static_cast<unsigned int>(segment.data.size());
Time original_length_of_segment = segment.length_of_a_bit * unsigned(segment.data.size());
Time proportion_of_whole = original_length_of_segment / total_length;
proportion_of_whole.simplify();
PCMSegment length_adjusted_segment = segment;
length_adjusted_segment.length_of_a_bit = proportion_of_whole / static_cast<unsigned int>(segment.data.size());
length_adjusted_segment.length_of_a_bit = proportion_of_whole / unsigned(segment.data.size());
length_adjusted_segment.length_of_a_bit.simplify();
segment_event_sources_.emplace_back(length_adjusted_segment);
}
@ -38,7 +38,7 @@ PCMTrack::PCMTrack(const PCMSegment &segment) : PCMTrack() {
// a single segment necessarily fills the track
PCMSegment length_adjusted_segment = segment;
length_adjusted_segment.length_of_a_bit.length = 1;
length_adjusted_segment.length_of_a_bit.clock_rate = static_cast<unsigned int>(segment.data.size());
length_adjusted_segment.length_of_a_bit.clock_rate = unsigned(segment.data.size());
segment_event_sources_.emplace_back(std::move(length_adjusted_segment));
}
@ -74,7 +74,7 @@ Track *PCMTrack::clone() const {
PCMTrack *PCMTrack::resampled_clone(size_t bits_per_track) {
// Create an empty track.
PCMTrack *const new_track = new PCMTrack(static_cast<unsigned int>(bits_per_track));
PCMTrack *const new_track = new PCMTrack(unsigned(bits_per_track));
// Plot all segments from this track onto the destination.
Time start_time;

View File

@ -45,7 +45,7 @@ Storage::Disk::PCMSegment Storage::Disk::track_serialisation(const Track &track,
Time extended_length = next_event.length * length_multiplier + time_error;
time_error.clock_rate = extended_length.clock_rate;
time_error.length = extended_length.length % extended_length.clock_rate;
pll.run_for(Cycles(static_cast<int>(extended_length.get<int64_t>())));
pll.run_for(Cycles(int(extended_length.get<int64_t>())));
if(next_event.type == Track::Event::IndexHole) break;
pll.add_pulse();

View File

@ -42,55 +42,55 @@ FileHolder::FileHolder(const std::string &file_name, FileMode ideal_mode)
}
uint32_t FileHolder::get32le() {
uint32_t result = static_cast<uint32_t>(std::fgetc(file_));
result |= static_cast<uint32_t>(std::fgetc(file_)) << 8;
result |= static_cast<uint32_t>(std::fgetc(file_)) << 16;
result |= static_cast<uint32_t>(std::fgetc(file_)) << 24;
uint32_t result = uint32_t(std::fgetc(file_));
result |= uint32_t(std::fgetc(file_)) << 8;
result |= uint32_t(std::fgetc(file_)) << 16;
result |= uint32_t(std::fgetc(file_)) << 24;
return result;
}
uint32_t FileHolder::get32be() {
uint32_t result = static_cast<uint32_t>(std::fgetc(file_)) << 24;
result |= static_cast<uint32_t>(std::fgetc(file_)) << 16;
result |= static_cast<uint32_t>(std::fgetc(file_)) << 8;
result |= static_cast<uint32_t>(std::fgetc(file_));
uint32_t result = uint32_t(std::fgetc(file_)) << 24;
result |= uint32_t(std::fgetc(file_)) << 16;
result |= uint32_t(std::fgetc(file_)) << 8;
result |= uint32_t(std::fgetc(file_));
return result;
}
uint32_t FileHolder::get24le() {
uint32_t result = static_cast<uint32_t>(std::fgetc(file_));
result |= static_cast<uint32_t>(std::fgetc(file_)) << 8;
result |= static_cast<uint32_t>(std::fgetc(file_)) << 16;
uint32_t result = uint32_t(std::fgetc(file_));
result |= uint32_t(std::fgetc(file_)) << 8;
result |= uint32_t(std::fgetc(file_)) << 16;
return result;
}
uint32_t FileHolder::get24be() {
uint32_t result = static_cast<uint32_t>(std::fgetc(file_)) << 16;
result |= static_cast<uint32_t>(std::fgetc(file_)) << 8;
result |= static_cast<uint32_t>(std::fgetc(file_));
uint32_t result = uint32_t(std::fgetc(file_)) << 16;
result |= uint32_t(std::fgetc(file_)) << 8;
result |= uint32_t(std::fgetc(file_));
return result;
}
uint16_t FileHolder::get16le() {
uint16_t result = static_cast<uint16_t>(std::fgetc(file_));
result |= static_cast<uint16_t>(static_cast<uint16_t>(std::fgetc(file_)) << 8);
uint16_t result = uint16_t(std::fgetc(file_));
result |= uint16_t(uint16_t(std::fgetc(file_)) << 8);
return result;
}
uint16_t FileHolder::get16be() {
uint16_t result = static_cast<uint16_t>(static_cast<uint16_t>(std::fgetc(file_)) << 8);
result |= static_cast<uint16_t>(std::fgetc(file_));
uint16_t result = uint16_t(uint16_t(std::fgetc(file_)) << 8);
result |= uint16_t(std::fgetc(file_));
return result;
}
uint8_t FileHolder::get8() {
return static_cast<uint8_t>(std::fgetc(file_));
return uint8_t(std::fgetc(file_));
}
void FileHolder::put16be(uint16_t value) {
@ -173,8 +173,8 @@ void FileHolder::ensure_is_at_least_length(long length) {
std::fseek(file_, 0, SEEK_END);
long bytes_to_write = length - ftell(file_);
if(bytes_to_write > 0) {
std::vector<uint8_t> empty(static_cast<std::size_t>(bytes_to_write), 0);
std::fwrite(empty.data(), sizeof(uint8_t), static_cast<std::size_t>(bytes_to_write), file_);
std::vector<uint8_t> empty(size_t(bytes_to_write), 0);
std::fwrite(empty.data(), sizeof(uint8_t), size_t(bytes_to_write), file_);
}
}

View File

@ -158,7 +158,7 @@ class FileHolder final {
uint8_t get_bits(int q) {
uint8_t result = 0;
while(q--) {
result = static_cast<uint8_t>((result << 1) | get_bit());
result = uint8_t((result << 1) | get_bit());
}
return result;
}
@ -179,7 +179,7 @@ class FileHolder final {
uint8_t get_bit() {
if(!bits_remaining_) {
bits_remaining_ = 8;
next_value_ = static_cast<uint8_t>(fgetc(file_));
next_value_ = uint8_t(fgetc(file_));
}
uint8_t bit;

View File

@ -24,9 +24,9 @@ struct Time {
unsigned int length, clock_rate;
Time() : length(0), clock_rate(1) {}
Time(unsigned int unsigned_int_value) : length(unsigned_int_value), clock_rate(1) {}
Time(int int_value) : Time(static_cast<unsigned int>(int_value)) {}
Time(int int_value) : Time(unsigned(int_value)) {}
Time(unsigned int length, unsigned int clock_rate) : length(length), clock_rate(clock_rate) {}
Time(int length, int clock_rate) : Time(static_cast<unsigned int>(length), static_cast<unsigned int>(clock_rate)) {}
Time(int length, int clock_rate) : Time(unsigned(length), unsigned(clock_rate)) {}
Time(uint64_t length, uint64_t clock_rate) {
install_result(length, clock_rate);
}
@ -48,27 +48,27 @@ struct Time {
@returns the floating point conversion of this @c Time. This will often be less precise.
*/
template <typename T> T get() const {
return static_cast<T>(length) / static_cast<T>(clock_rate);
return T(length) / T(clock_rate);
}
inline bool operator < (const Time &other) const {
return (uint64_t)other.clock_rate * (uint64_t)length < (uint64_t)clock_rate * (uint64_t)other.length;
return uint64_t(other.clock_rate) * uint64_t(length) < uint64_t(clock_rate) * uint64_t(other.length);
}
inline bool operator <= (const Time &other) const {
return (uint64_t)other.clock_rate * (uint64_t)length <= (uint64_t)clock_rate * (uint64_t)other.length;
return uint64_t(other.clock_rate) * uint64_t(length) <= uint64_t(clock_rate) * uint64_t(other.length);
}
inline bool operator > (const Time &other) const {
return (uint64_t)other.clock_rate * (uint64_t)length > (uint64_t)clock_rate * (uint64_t)other.length;
return uint64_t(other.clock_rate) * uint64_t(length) > uint64_t(clock_rate) * uint64_t(other.length);
}
inline bool operator >= (const Time &other) const {
return (uint64_t)other.clock_rate * (uint64_t)length >= (uint64_t)clock_rate * (uint64_t)other.length;
return uint64_t(other.clock_rate) * uint64_t(length) >= uint64_t(clock_rate) * uint64_t(other.length);
}
inline bool operator == (const Time &other) const {
return (uint64_t)other.clock_rate * (uint64_t)length == (uint64_t)clock_rate * (uint64_t)other.length;
return uint64_t(other.clock_rate) * uint64_t(length) == uint64_t(clock_rate) * uint64_t(other.length);
}
inline Time operator + (const Time &other) const {
@ -77,11 +77,11 @@ struct Time {
uint64_t result_length;
uint64_t result_clock_rate;
if(clock_rate == other.clock_rate) {
result_length = (uint64_t)length + (uint64_t)other.length;
result_length = uint64_t(length) + uint64_t(other.length);
result_clock_rate = clock_rate;
} else {
result_length = (uint64_t)length * (uint64_t)other.clock_rate + (uint64_t)other.length * (uint64_t)clock_rate;
result_clock_rate = (uint64_t)clock_rate * (uint64_t)other.clock_rate;
result_length = uint64_t(length) * uint64_t(other.clock_rate) + uint64_t(other.length) * uint64_t(clock_rate);
result_clock_rate = uint64_t(clock_rate) * uint64_t(other.clock_rate);
}
return Time(result_length, result_clock_rate);
}
@ -96,11 +96,11 @@ struct Time {
uint64_t result_length;
uint64_t result_clock_rate;
if(clock_rate == other.clock_rate) {
result_length = (uint64_t)length + (uint64_t)other.length;
result_clock_rate = (uint64_t)clock_rate;
result_length = uint64_t(length) + uint64_t(other.length);
result_clock_rate = uint64_t(clock_rate);
} else {
result_length = (uint64_t)length * (uint64_t)other.clock_rate + (uint64_t)other.length * (uint64_t)clock_rate;
result_clock_rate = (uint64_t)clock_rate * (uint64_t)other.clock_rate;
result_length = uint64_t(length) * uint64_t(other.clock_rate) + uint64_t(other.length) * uint64_t(clock_rate);
result_clock_rate = uint64_t(clock_rate) * uint64_t(other.clock_rate);
}
install_result(result_length, result_clock_rate);
return *this;
@ -112,11 +112,11 @@ struct Time {
uint64_t result_length;
uint64_t result_clock_rate;
if(clock_rate == other.clock_rate) {
result_length = (uint64_t)length - (uint64_t)other.length;
result_length = uint64_t(length) - uint64_t(other.length);
result_clock_rate = clock_rate;
} else {
result_length = (uint64_t)length * (uint64_t)other.clock_rate - (uint64_t)other.length * (uint64_t)clock_rate;
result_clock_rate = (uint64_t)clock_rate * (uint64_t)other.clock_rate;
result_length = uint64_t(length) * uint64_t(other.clock_rate) - uint64_t(other.length) * uint64_t(clock_rate);
result_clock_rate = uint64_t(clock_rate) * uint64_t(other.clock_rate);
}
return Time(result_length, result_clock_rate);
}
@ -127,64 +127,64 @@ struct Time {
uint64_t result_length;
uint64_t result_clock_rate;
if(clock_rate == other.clock_rate) {
result_length = (uint64_t)length - (uint64_t)other.length;
result_clock_rate = (uint64_t)clock_rate;
result_length = uint64_t(length) - uint64_t(other.length);
result_clock_rate = uint64_t(clock_rate);
} else {
result_length = (uint64_t)length * (uint64_t)other.clock_rate - (uint64_t)other.length * (uint64_t)clock_rate;
result_clock_rate = (uint64_t)clock_rate * (uint64_t)other.clock_rate;
result_length = uint64_t(length) * uint64_t(other.clock_rate) - uint64_t(other.length) * uint64_t(clock_rate);
result_clock_rate = uint64_t(clock_rate) * uint64_t(other.clock_rate);
}
install_result(result_length, result_clock_rate);
return *this;
}
inline Time operator * (const Time &other) const {
uint64_t result_length = (uint64_t)length * (uint64_t)other.length;
uint64_t result_clock_rate = (uint64_t)clock_rate * (uint64_t)other.clock_rate;
uint64_t result_length = uint64_t(length) * uint64_t(other.length);
uint64_t result_clock_rate = uint64_t(clock_rate) * uint64_t(other.clock_rate);
return Time(result_length, result_clock_rate);
}
inline Time &operator *= (const Time &other) {
uint64_t result_length = (uint64_t)length * (uint64_t)other.length;
uint64_t result_clock_rate = (uint64_t)clock_rate * (uint64_t)other.clock_rate;
uint64_t result_length = uint64_t(length) * uint64_t(other.length);
uint64_t result_clock_rate = uint64_t(clock_rate) * uint64_t(other.clock_rate);
install_result(result_length, result_clock_rate);
return *this;
}
inline Time operator * (unsigned int multiplier) const {
uint64_t result_length = (uint64_t)length * (uint64_t)multiplier;
uint64_t result_clock_rate = (uint64_t)clock_rate;
uint64_t result_length = uint64_t(length) * uint64_t(multiplier);
uint64_t result_clock_rate = uint64_t(clock_rate);
return Time(result_length, result_clock_rate);
}
inline Time &operator *= (unsigned int multiplier) {
uint64_t result_length = (uint64_t)length * (uint64_t)multiplier;
uint64_t result_clock_rate = (uint64_t)clock_rate;
uint64_t result_length = uint64_t(length) * uint64_t(multiplier);
uint64_t result_clock_rate = uint64_t(clock_rate);
install_result(result_length, result_clock_rate);
return *this;
}
inline Time operator / (const Time &other) const {
uint64_t result_length = (uint64_t)length * (uint64_t)other.clock_rate;
uint64_t result_clock_rate = (uint64_t)clock_rate * (uint64_t)other.length;
uint64_t result_length = uint64_t(length) * uint64_t(other.clock_rate);
uint64_t result_clock_rate = uint64_t(clock_rate) * uint64_t(other.length);
return Time(result_length, result_clock_rate);
}
inline Time &operator /= (const Time &other) {
uint64_t result_length = (uint64_t)length * (uint64_t)other.clock_rate;
uint64_t result_clock_rate = (uint64_t)clock_rate * (uint64_t)other.length;
uint64_t result_length = uint64_t(length) * uint64_t(other.clock_rate);
uint64_t result_clock_rate = uint64_t(clock_rate) * uint64_t(other.length);
install_result(result_length, result_clock_rate);
return *this;
}
inline Time operator / (unsigned int divisor) const {
uint64_t result_length = (uint64_t)length;
uint64_t result_clock_rate = (uint64_t)clock_rate * (uint64_t)divisor;
uint64_t result_length = uint64_t(length);
uint64_t result_clock_rate = uint64_t(clock_rate) * uint64_t(divisor);
return Time(result_length, result_clock_rate);
}
inline Time &operator /= (unsigned int divisor) {
uint64_t result_length = (uint64_t)length;
uint64_t result_clock_rate = (uint64_t)clock_rate * (uint64_t)divisor;
uint64_t result_length = uint64_t(length);
uint64_t result_clock_rate = uint64_t(clock_rate) * uint64_t(divisor);
install_result(result_length, result_clock_rate);
return *this;
}
@ -206,8 +206,8 @@ struct Time {
private:
inline void install_result(uint64_t long_length, uint64_t long_clock_rate) {
if(long_length <= std::numeric_limits<unsigned int>::max() && long_clock_rate <= std::numeric_limits<unsigned int>::max()) {
length = static_cast<unsigned int>(long_length);
clock_rate = static_cast<unsigned int>(long_clock_rate);
length = unsigned(long_length);
clock_rate = unsigned(long_clock_rate);
return;
}
@ -243,8 +243,8 @@ struct Time {
}
if(long_length <= std::numeric_limits<unsigned int>::max() && long_clock_rate <= std::numeric_limits<unsigned int>::max()) {
length = static_cast<unsigned int>(long_length);
clock_rate = static_cast<unsigned int>(long_clock_rate);
length = unsigned(long_length);
clock_rate = unsigned(long_clock_rate);
} else {
length = std::numeric_limits<unsigned int>::max();
clock_rate = 1u;

Some files were not shown because too many files have changed in this diff Show More