1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Merge pull request #788 from TomHarte/ConstFun

Cleans up a variety of dangling issues.
This commit is contained in:
Thomas Harte 2020-05-09 23:57:22 -04:00 committed by GitHub
commit fc0f290c85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
154 changed files with 851 additions and 1157 deletions

View File

@ -11,20 +11,20 @@
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() {
hits_++;
++hits_;
}
void ConfidenceCounter::add_miss() {
misses_++;
++misses_;
}
void ConfidenceCounter::add_equivocal() {
if(hits_ > misses_) {
hits_++;
misses_++;
++hits_;
++misses_;
}
}

View File

@ -35,8 +35,8 @@ class ConfidenceSummary: public ConfidenceSource {
float get_confidence() final;
private:
std::vector<ConfidenceSource *> sources_;
std::vector<float> weights_;
const std::vector<ConfidenceSource *> sources_;
const std::vector<float> weights_;
float weight_sum_;
};

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

@ -21,8 +21,8 @@ std::unique_ptr<Catalogue> Analyser::Static::Acorn::GetDFSCatalogue(const std::s
auto catalogue = std::make_unique<Catalogue>();
Storage::Encodings::MFM::Parser parser(false, disk);
Storage::Encodings::MFM::Sector *names = parser.get_sector(0, 0, 0);
Storage::Encodings::MFM::Sector *details = parser.get_sector(0, 0, 1);
const Storage::Encodings::MFM::Sector *const names = parser.get_sector(0, 0, 0);
const Storage::Encodings::MFM::Sector *const details = parser.get_sector(0, 0, 1);
if(!names || !details) return nullptr;
if(names->samples.empty() || details->samples.empty()) return nullptr;
@ -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);
@ -84,7 +84,7 @@ std::unique_ptr<Catalogue> Analyser::Static::Acorn::GetADFSCatalogue(const std::
std::vector<uint8_t> root_directory;
root_directory.reserve(5 * 256);
for(uint8_t c = 2; c < 7; c++) {
Storage::Encodings::MFM::Sector *sector = parser.get_sector(0, 0, c);
const Storage::Encodings::MFM::Sector *const sector = parser.get_sector(0, 0, c);
if(!sector) return nullptr;
root_directory.insert(root_directory.end(), sector->samples[0].begin(), sector->samples[0].end());
}

View File

@ -29,7 +29,7 @@ static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>>
if(segment.data.size() != 0x4000 && segment.data.size() != 0x2000) continue;
// is a copyright string present?
uint8_t copyright_offset = segment.data[7];
const uint8_t copyright_offset = segment.data[7];
if(
segment.data[copyright_offset] != 0x00 ||
segment.data[copyright_offset+1] != 0x28 ||
@ -83,8 +83,8 @@ Analyser::Static::TargetList Analyser::Static::Acorn::GetTargets(const Media &me
// check also for a continuous threading of BASIC lines; if none then this probably isn't BASIC code,
// so that's also justification to *RUN
std::size_t pointer = 0;
uint8_t *data = &files.front().data[0];
std::size_t data_size = files.front().data.size();
uint8_t *const data = &files.front().data[0];
const std::size_t data_size = files.front().data.size();
while(1) {
if(pointer >= data_size-1 || data[pointer] != 13) {
is_basic = false;

View File

@ -41,24 +41,24 @@ 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++;
++name_ptr;
}
name[sizeof(name)-1] = '\0';
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

@ -16,24 +16,22 @@ using namespace Analyser::Static::Atari2600;
using Target = Analyser::Static::Atari2600::Target;
static void DeterminePagingFor2kCartridge(Target &target, const Storage::Cartridge::Cartridge::Segment &segment) {
// if this is a 2kb cartridge then it's definitely either unpaged or a CommaVid
uint16_t entry_address, break_address;
// If this is a 2kb cartridge then it's definitely either unpaged or a CommaVid.
const uint16_t entry_address = uint16_t(segment.data[0x7fc] | (segment.data[0x7fd] << 8)) & 0x1fff;
const uint16_t break_address = uint16_t(segment.data[0x7fe] | (segment.data[0x7ff] << 8)) & 0x1fff;
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;
// a CommaVid start address needs to be outside of its RAM
// 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});
// assume that any kind of store that looks likely to be intended for large amounts of memory implies
// large amounts of memory
// Assume that any kind of store that looks likely to be intended for large amounts of memory implies
// large amounts of memory.
bool has_wide_area_store = false;
for(std::map<uint16_t, Analyser::Static::MOS6502::Instruction>::value_type &entry : high_location_disassembly.instructions_by_address) {
if(entry.second.operation == Analyser::Static::MOS6502::Instruction::STA) {
@ -45,17 +43,17 @@ static void DeterminePagingFor2kCartridge(Target &target, const Storage::Cartrid
}
}
// conclude that this is a CommaVid if it attempted to write something to the CommaVid RAM locations;
// Conclude that this is a CommaVid if it attempted to write something to the CommaVid RAM locations;
// caveat: false positives aren't likely to be problematic; a false positive is a 2KB ROM that always addresses
// itself so as to land in ROM even if mapped as a CommaVid and this code is on the fence as to whether it
// attempts to modify itself but it probably doesn't
// attempts to modify itself but it probably doesn't.
if(has_wide_area_store) target.paging_model = Target::PagingModel::CommaVid;
}
static void DeterminePagingFor8kCartridge(Target &target, const Storage::Cartridge::Cartridge::Segment &segment, const Analyser::Static::MOS6502::Disassembly &disassembly) {
// Activision stack titles have their vectors at the top of the low 4k, not the top, and
// always list 0xf000 as both vectors; they do not repeat them, and, inexplicably, they all
// issue an SEI as their first instruction (maybe some sort of relic of the development environment?)
// issue an SEI as their first instruction (maybe some sort of relic of the development environment?).
if(
segment.data[4095] == 0xf0 && segment.data[4093] == 0xf0 && segment.data[4094] == 0x00 && segment.data[4092] == 0x00 &&
(segment.data[8191] != 0xf0 || segment.data[8189] != 0xf0 || segment.data[8190] != 0x00 || segment.data[8188] != 0x00) &&
@ -65,7 +63,7 @@ static void DeterminePagingFor8kCartridge(Target &target, const Storage::Cartrid
return;
}
// make an assumption that this is the Atari paging model
// Make an assumption that this is the Atari paging model.
target.paging_model = Target::PagingModel::Atari8k;
std::set<uint16_t> internal_accesses;
@ -91,7 +89,7 @@ static void DeterminePagingFor8kCartridge(Target &target, const Storage::Cartrid
}
static void DeterminePagingFor16kCartridge(Target &target, const Storage::Cartridge::Cartridge::Segment &segment, const Analyser::Static::MOS6502::Disassembly &disassembly) {
// make an assumption that this is the Atari paging model
// Make an assumption that this is the Atari paging model.
target.paging_model = Target::PagingModel::Atari16k;
std::set<uint16_t> internal_accesses;
@ -111,7 +109,7 @@ static void DeterminePagingFor16kCartridge(Target &target, const Storage::Cartri
}
static void DeterminePagingFor64kCartridge(Target &target, const Storage::Cartridge::Cartridge::Segment &segment, const Analyser::Static::MOS6502::Disassembly &disassembly) {
// make an assumption that this is a Tigervision if there is a write to 3F
// Make an assumption that this is a Tigervision if there is a write to 3F.
target.paging_model =
(disassembly.external_stores.find(0x3f) != disassembly.external_stores.end()) ?
Target::PagingModel::Tigervision : Target::PagingModel::MegaBoy;
@ -123,17 +121,15 @@ static void DeterminePagingForCartridge(Target &target, const Storage::Cartridge
return;
}
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));
const uint16_t entry_address = uint16_t(segment.data[segment.data.size() - 4] | (segment.data[segment.data.size() - 3] << 8));
const uint16_t 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());
const std::vector<uint8_t> final_4k(segment.data.end() - 4096, segment.data.end());
Analyser::Static::MOS6502::Disassembly disassembly = Analyser::Static::MOS6502::Disassemble(final_4k, address_mapper, {entry_address, break_address});
switch(segment.data.size()) {
@ -159,7 +155,7 @@ static void DeterminePagingForCartridge(Target &target, const Storage::Cartridge
break;
}
// check for a Super Chip. Atari ROM images [almost] always have the same value stored over RAM
// Check for a Super Chip. Atari ROM images [almost] always have the same value stored over RAM
// regions; when they don't they at least seem to have the first 128 bytes be the same as the
// next 128 bytes. So check for that.
if( target.paging_model != Target::PagingModel::CBSRamPlus &&
@ -174,7 +170,7 @@ static void DeterminePagingForCartridge(Target &target, const Storage::Cartridge
target.uses_superchip = has_superchip;
}
// check for a Tigervision or Tigervision-esque scheme
// Check for a Tigervision or Tigervision-esque scheme
if(target.paging_model == Target::PagingModel::None && segment.data.size() > 4096) {
bool looks_like_tigervision = disassembly.external_stores.find(0x3f) != disassembly.external_stores.end();
if(looks_like_tigervision) target.paging_model = Target::PagingModel::Tigervision;

View File

@ -17,7 +17,7 @@ Analyser::Static::TargetList Analyser::Static::AtariST::GetTargets(const Media &
Analyser::Static::TargetList targets;
using Target = Analyser::Static::AtariST::Target;
auto *target = new Target();
auto *const target = new Target();
target->media = media;
targets.push_back(std::unique_ptr<Analyser::Static::Target>(target));

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

@ -26,12 +26,12 @@ static void AddToDisassembly(PartialDisassembly &disassembly, const std::vector<
Instruction instruction;
instruction.address = address;
address++;
++address;
// get operation
uint8_t operation = memory[local_address];
// Get operation.
const uint8_t operation = memory[local_address];
// decode addressing mode
// Decode addressing mode.
switch(operation&0x1f) {
case 0x00:
if(operation >= 0x80) instruction.addressing_mode = Instruction::Immediate;
@ -74,7 +74,7 @@ static void AddToDisassembly(PartialDisassembly &disassembly, const std::vector<
break;
}
// decode operation
// Decode operation.
#define RM_INSTRUCTION(base, op) \
case base+0x09: case base+0x05: case base+0x15: case base+0x01: case base+0x11: case base+0x0d: case base+0x1d: case base+0x19: \
instruction.operation = op; \
@ -222,14 +222,14 @@ static void AddToDisassembly(PartialDisassembly &disassembly, const std::vector<
#undef M_INSTRUCTION
#undef IM_INSTRUCTION
// get operand
// Get operand.
switch(instruction.addressing_mode) {
// zero-byte operands
// Zero-byte operands.
case Instruction::Implied:
instruction.operand = 0;
break;
// one-byte operands
// One-byte operands.
case Instruction::Immediate:
case Instruction::ZeroPage: case Instruction::ZeroPageX: case Instruction::ZeroPageY:
case Instruction::IndexedIndirectX: case Instruction::IndirectIndexedY:
@ -242,7 +242,7 @@ static void AddToDisassembly(PartialDisassembly &disassembly, const std::vector<
}
break;
// two-byte operands
// Two-byte operands.
case Instruction::Absolute: case Instruction::AbsoluteX: case Instruction::AbsoluteY:
case Instruction::Indirect: {
std::size_t low_operand_address = address_mapper(address);
@ -250,18 +250,18 @@ 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;
}
// store the instruction away
// Store the instruction.
disassembly.disassembly.instructions_by_address[instruction.address] = instruction;
// TODO: something wider-ranging than this
if(instruction.addressing_mode == Instruction::Absolute || instruction.addressing_mode == Instruction::ZeroPage) {
std::size_t mapped_address = address_mapper(instruction.operand);
bool is_external = mapped_address >= memory.size();
const size_t mapped_address = address_mapper(instruction.operand);
const bool is_external = mapped_address >= memory.size();
switch(instruction.operation) {
default: break;
@ -290,7 +290,7 @@ static void AddToDisassembly(PartialDisassembly &disassembly, const std::vector<
}
}
// decide on overall flow control
// Decide on overall flow control.
if(instruction.operation == Instruction::RTS || instruction.operation == Instruction::RTI) return;
if(instruction.operation == Instruction::BRK) return; // TODO: check whether IRQ vector is within memory range
if(instruction.operation == Instruction::JSR) {
@ -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

@ -1,9 +0,0 @@
//
// AddressMapper.cpp
// Clock Signal
//
// Created by Thomas Harte on 30/12/2017.
// Copyright 2017 Thomas Harte. All rights reserved.
//
#include "AddressMapper.hpp"

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

@ -17,7 +17,7 @@ Analyser::Static::TargetList Analyser::Static::Macintosh::GetTargets(const Media
Analyser::Static::TargetList targets;
using Target = Analyser::Static::Macintosh::Target;
auto *target = new Target;
auto *const target = new Target;
target->media = media;
targets.push_back(std::unique_ptr<Analyser::Static::Target>(target));

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

@ -34,7 +34,7 @@ Analyser::Static::TargetList Analyser::Static::ZX8081::GetTargets(const Media &m
std::vector<Storage::Data::ZX8081::File> files = GetFiles(media.tapes.front());
media.tapes.front()->reset();
if(!files.empty()) {
Target *target = new Target;
Target *const target = new Target;
destination.push_back(std::unique_ptr<::Analyser::Static::Target>(target));
target->machine = Machine::ZX8081;

View File

@ -67,7 +67,7 @@ class Source {
}
/// @returns the current preferred clocking strategy.
virtual Preference preferred_clocking() = 0;
virtual Preference preferred_clocking() const = 0;
private:
Observer *observer_ = nullptr;

View File

@ -824,11 +824,11 @@ void WD1770::set_head_loaded(bool head_loaded) {
if(head_loaded) posit_event(int(Event1770::HeadLoad));
}
bool WD1770::get_head_loaded() {
bool WD1770::get_head_loaded() const {
return head_is_loaded_;
}
ClockingHint::Preference WD1770::preferred_clocking() {
ClockingHint::Preference WD1770::preferred_clocking() const {
if(status_.busy) return ClockingHint::Preference::RealTime;
return Storage::Disk::MFMController::preferred_clocking();
}

View File

@ -62,18 +62,18 @@ class WD1770: public Storage::Disk::MFMController {
};
/// @returns The current value of the IRQ line output.
inline bool get_interrupt_request_line() { return status_.interrupt_request; }
inline bool get_interrupt_request_line() const { return status_.interrupt_request; }
/// @returns The current value of the DRQ line output.
inline bool get_data_request_line() { return status_.data_request; }
inline bool get_data_request_line() const { return status_.data_request; }
class Delegate {
public:
virtual void wd1770_did_change_output(WD1770 *wd1770) = 0;
};
inline void set_delegate(Delegate *delegate) { delegate_ = delegate; }
inline void set_delegate(Delegate *delegate) { delegate_ = delegate; }
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
protected:
virtual void set_head_load_request(bool head_load);
@ -81,12 +81,12 @@ class WD1770: public Storage::Disk::MFMController {
void set_head_loaded(bool head_loaded);
/// @returns The last value posted to @c set_head_loaded.
bool get_head_loaded();
bool get_head_loaded() const;
private:
Personality personality_;
inline bool has_motor_on_line() { return (personality_ != P1793 ) && (personality_ != P1773); }
inline bool has_head_load_line() { return (personality_ == P1793 ); }
const Personality personality_;
bool has_motor_on_line() const { return (personality_ != P1793 ) && (personality_ != P1773); }
bool has_head_load_line() const { return (personality_ == P1793 ); }
struct Status {
bool write_protect = false;

View File

@ -112,7 +112,7 @@ template <class T> class MOS6522: public MOS6522Storage {
void run_for(const Cycles cycles);
/// @returns @c true if the IRQ line is currently active; @c false otherwise.
bool get_interrupt_line();
bool get_interrupt_line() const;
/// Updates the port handler to the current time and then requests that it flush.
void flush();

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;
}
@ -383,9 +383,9 @@ template <typename T> void MOS6522<T>::run_for(const Cycles cycles) {
}
/*! @returns @c true if the IRQ line is currently active; @c false otherwise. */
template <typename T> bool MOS6522<T>::get_interrupt_line() {
template <typename T> bool MOS6522<T>::get_interrupt_line() const {
uint8_t interrupt_status = registers_.interrupt_flags & registers_.interrupt_enable & 0x7f;
return !!interrupt_status;
return interrupt_status;
}
template <typename T> void MOS6522<T>::evaluate_cb2_output() {

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) {
@ -142,7 +142,7 @@ template <class T> class MOS6532 {
}
}
inline bool get_inerrupt_line() {
inline bool get_inerrupt_line() const {
return interrupt_line_;
}

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,14 +81,14 @@ 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); }
Outputs::Display::ScanStatus get_scaled_scan_status() const { return crt_.get_scaled_scan_status() / 4.0f; }
void set_display_type(Outputs::Display::DisplayType display_type) { crt_.set_display_type(display_type); }
Outputs::Display::DisplayType get_display_type() { return crt_.get_display_type(); }
Outputs::Speaker::Speaker *get_speaker() { return &speaker_; }
Outputs::Display::DisplayType get_display_type() const { return crt_.get_display_type(); }
Outputs::Speaker::Speaker *get_speaker() { return &speaker_; }
void set_high_frequency_cutoff(float cutoff) {
speaker_.set_high_frequency_cutoff(cutoff);
@ -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:
@ -420,11 +420,11 @@ template <class BusHandler> class MOS6560 {
/*
Reads from a 6560 register.
*/
uint8_t read(int address) {
uint8_t read(int address) const {
address &= 0xf;
switch(address) {
default: return registers_.direct_values[address];
case 0x03: return static_cast<uint8_t>(raster_value() << 7) | (registers_.direct_values[3] & 0x7f);
case 0x03: return uint8_t(raster_value() << 7) | (registers_.direct_values[3] & 0x7f);
case 0x04: return (raster_value() >> 1) & 0xff;
}
}
@ -462,11 +462,11 @@ template <class BusHandler> class MOS6560 {
// counters that cover an entire field
int horizontal_counter_ = 0, vertical_counter_ = 0;
const int lines_this_field() {
int lines_this_field() const {
// Necessary knowledge here: only the NTSC 6560 supports interlaced video.
return registers_.interlaced ? (is_odd_frame_ ? 262 : 263) : timing_.lines_per_progressive_field;
}
const int raster_value() {
int raster_value() const {
const int bonus_line = (horizontal_counter_ + timing_.line_counter_increment_offset) / timing_.cycles_per_line;
const int line = vertical_counter_ + bonus_line;
const int final_line = lines_this_field();
@ -481,7 +481,7 @@ template <class BusHandler> class MOS6560 {
}
// Cf. http://www.sleepingelephant.com/ipw-web/bulletin/bb/viewtopic.php?f=14&t=7237&start=15#p80737
}
bool is_odd_frame() {
bool is_odd_frame() const {
return is_odd_frame_ || !registers_.interlaced;
}

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

@ -120,7 +120,7 @@ void ACIA::consider_transmission() {
}
}
ClockingHint::Preference ACIA::preferred_clocking() {
ClockingHint::Preference ACIA::preferred_clocking() const {
// Real-time clocking is required if a transmission is ongoing; this is a courtesy for whomever
// is on the receiving end.
if(transmit.transmission_data_time_remaining() > 0) return ClockingHint::Preference::RealTime;

View File

@ -86,7 +86,7 @@ class ACIA: public ClockingHint::Source, private Serial::Line::ReadDelegate {
Serial::Line request_to_send;
// ClockingHint::Source.
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
struct InterruptDelegate {
virtual void acia6850_did_change_interrupt_status(ACIA *acia) = 0;

View File

@ -20,7 +20,7 @@
using namespace Motorola::MFP68901;
ClockingHint::Preference MFP68901::preferred_clocking() {
ClockingHint::Preference MFP68901::preferred_clocking() const {
// Rule applied: if any timer is actively running and permitted to produce an
// interrupt, request real-time running.
return

View File

@ -76,7 +76,7 @@ class MFP68901: public ClockingHint::Source {
void set_interrupt_delegate(InterruptDelegate *delegate);
// ClockingHint::Source.
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
private:
// MARK: - Timers

View File

@ -79,10 +79,10 @@ 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() {
ClockingHint::Preference i8272::preferred_clocking() const {
const auto mfm_controller_preferred_clocking = Storage::Disk::MFMController::preferred_clocking();
if(mfm_controller_preferred_clocking != ClockingHint::Preference::None) return mfm_controller_preferred_clocking;
return is_sleeping_ ? ClockingHint::Preference::None : ClockingHint::Preference::JustInTime;
@ -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

@ -39,7 +39,7 @@ class i8272 : public Storage::Disk::MFMController {
void set_dma_acknowledge(bool dack);
void set_terminal_count(bool tc);
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
protected:
virtual void select_drive(int number) = 0;
@ -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

@ -16,7 +16,7 @@ void z8530::reset() {
// TODO.
}
bool z8530::get_interrupt_line() {
bool z8530::get_interrupt_line() const {
return
(master_interrupt_control_ & 0x8) &&
(
@ -253,7 +253,7 @@ void z8530::Channel::set_dcd(bool level) {
}
}
bool z8530::Channel::get_interrupt_line() {
bool z8530::Channel::get_interrupt_line() const {
return
(interrupt_mask_ & 1) && external_status_interrupt_;
// TODO: other potential causes of an interrupt.

View File

@ -33,7 +33,7 @@ class z8530 {
std::uint8_t read(int address);
void write(int address, std::uint8_t value);
void reset();
bool get_interrupt_line();
bool get_interrupt_line() const;
struct Delegate {
virtual void did_change_interrupt_status(z8530 *, bool new_status) = 0;
@ -53,7 +53,7 @@ class z8530 {
uint8_t read(bool data, uint8_t pointer);
void write(bool data, uint8_t pointer, uint8_t value);
void set_dcd(bool level);
bool get_interrupt_line();
bool get_interrupt_line() const;
private:
uint8_t data_ = 0xff;

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

@ -33,6 +33,6 @@ void Toggle::set_output(bool enabled) {
});
}
bool Toggle::get_output() {
bool Toggle::get_output() const {
return is_enabled_;
}

View File

@ -24,10 +24,9 @@ class Toggle: public Outputs::Speaker::SampleSource {
void get_samples(std::size_t number_of_samples, std::int16_t *target);
void set_sample_volume_range(std::int16_t range);
void skip_samples(const std::size_t number_of_samples);
static constexpr bool get_is_stereo() { return false; }
void set_output(bool enabled);
bool get_output();
bool get_output() const;
private:
// Accessed on the calling thread.

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?
@ -225,7 +225,7 @@ void DiskII::set_component_prefers_clocking(ClockingHint::Source *component, Clo
decide_clocking_preference();
}
ClockingHint::Preference DiskII::preferred_clocking() {
ClockingHint::Preference DiskII::preferred_clocking() const {
return clocking_preference_;
}

View File

@ -76,7 +76,7 @@ class DiskII :
void set_disk(const std::shared_ptr<Storage::Disk::Disk> &disk, int drive);
// As per Sleeper.
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
// The Disk II functions as a potential target for @c Activity::Sources.
void set_activity_observer(Activity::Observer *observer);

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

@ -1,100 +0,0 @@
//
// BestEffortUpdater.cpp
// Clock Signal
//
// Created by Thomas Harte on 04/10/2017.
// Copyright 2017 Thomas Harte. All rights reserved.
//
#include "BestEffortUpdater.hpp"
#include <cmath>
using namespace Concurrency;
BestEffortUpdater::BestEffortUpdater() :
update_thread_([this]() {
this->update_loop();
}) {}
BestEffortUpdater::~BestEffortUpdater() {
// Sever the delegate now, as soon as possible, then wait for any
// pending tasks to finish.
set_delegate(nullptr);
flush();
// Wind up the update thread.
should_quit_ = true;
update();
update_thread_.join();
}
void BestEffortUpdater::update(int flags) {
// Bump the requested target time and set the update requested flag.
{
std::lock_guard<decltype(update_mutex_)> lock(update_mutex_);
has_skipped_ = update_requested_;
update_requested_ = true;
flags_ |= flags;
target_time_ = std::chrono::high_resolution_clock::now().time_since_epoch().count();
}
update_condition_.notify_one();
}
void BestEffortUpdater::update_loop() {
while(true) {
std::unique_lock<decltype(update_mutex_)> lock(update_mutex_);
is_updating_ = false;
// Wait to be signalled.
update_condition_.wait(lock, [this]() -> bool {
return update_requested_;
});
// Possibly this signalling really means 'quit'.
if(should_quit_) return;
// Note update started, crib the target time.
auto target_time = target_time_;
update_requested_ = false;
// If this was actually the first update request, silently swallow it.
if(!has_previous_time_point_) {
has_previous_time_point_ = true;
previous_time_point_ = target_time;
continue;
}
// Release the lock on requesting new updates.
is_updating_ = true;
const int flags = flags_;
flags_ = 0;
lock.unlock();
// Invoke the delegate, if supplied, in order to run.
const int64_t integer_duration = std::max(target_time - previous_time_point_, int64_t(0));
const auto delegate = delegate_.load();
if(delegate) {
// Cap running at 1/5th of a second, to avoid doing a huge amount of work after any
// brief system interruption.
const double duration = std::min(double(integer_duration) / 1e9, 0.2);
const double elapsed_duration = delegate->update(this, duration, has_skipped_, flags);
previous_time_point_ += int64_t(elapsed_duration * 1e9);
has_skipped_ = false;
}
}
}
void BestEffortUpdater::flush() {
// Spin lock; this is allowed to be slow.
while(true) {
std::lock_guard<decltype(update_mutex_)> lock(update_mutex_);
if(!is_updating_) return;
}
}
void BestEffortUpdater::set_delegate(Delegate *const delegate) {
delegate_.store(delegate);
}

View File

@ -1,82 +0,0 @@
//
// BestEffortUpdater.hpp
// Clock Signal
//
// Created by Thomas Harte on 04/10/2017.
// Copyright 2017 Thomas Harte. All rights reserved.
//
#ifndef BestEffortUpdater_hpp
#define BestEffortUpdater_hpp
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <mutex>
#include <thread>
#include "../ClockReceiver/TimeTypes.hpp"
namespace Concurrency {
/*!
Accepts timing cues from multiple threads and ensures that a delegate receives calls to total
a certain number of cycles per second, that those calls are strictly serialised, and that no
backlog of calls accrues.
No guarantees about the thread that the delegate will be called on are made.
*/
class BestEffortUpdater {
public:
BestEffortUpdater();
~BestEffortUpdater();
/// A delegate receives timing cues.
struct Delegate {
/*!
Instructs the delegate to run for at least @c duration, providing hints as to whether multiple updates were requested before the previous had completed
(as @c did_skip_previous_update) and providing the union of any flags supplied to @c update.
@returns The amount of time actually run for.
*/
virtual Time::Seconds update(BestEffortUpdater *updater, Time::Seconds duration, bool did_skip_previous_update, int flags) = 0;
};
/// Sets the current delegate.
void set_delegate(Delegate *);
/*!
If the delegate is not currently in the process of an `update` call, calls it now to catch up to the current time.
The call is asynchronous; this method will return immediately.
*/
void update(int flags = 0);
/// Blocks until any ongoing update is complete; may spin.
void flush();
private:
std::atomic<bool> should_quit_;
std::atomic<bool> is_updating_;
int64_t target_time_;
int flags_ = 0;
bool update_requested_;
std::mutex update_mutex_;
std::condition_variable update_condition_;
decltype(target_time_) previous_time_point_;
bool has_previous_time_point_ = false;
std::atomic<bool> has_skipped_ = false;
std::atomic<Delegate *>delegate_ = nullptr;
void update_loop();
// This is deliberately at the bottom, to ensure it constructs after the various
// mutexs, conditions, etc, that it'll depend upon.
std::thread update_thread_;
};
}
#endif /* BestEffortUpdater_hpp */

View File

@ -1,88 +0,0 @@
//
// StandardOptions.cpp
// Clock Signal
//
// Created by Thomas Harte on 20/11/2017.
// Copyright 2017 Thomas Harte. All rights reserved.
//
#include "StandardOptions.hpp"
/*
// MARK: - Standard option list builder
std::vector<std::unique_ptr<Configurable::Option>> Configurable::standard_options(Configurable::StandardOptions mask) {
std::vector<std::unique_ptr<Configurable::Option>> options;
if(mask & QuickLoadTape) options.emplace_back(new Configurable::BooleanOption("Load Tapes Quickly", "quickload"));
if(mask & (DisplayRGB | DisplayCompositeColour | DisplayCompositeMonochrome | DisplaySVideo)) {
std::vector<std::string> display_options;
if(mask & DisplayCompositeColour) display_options.emplace_back("composite");
if(mask & DisplayCompositeMonochrome) display_options.emplace_back("composite-mono");
if(mask & DisplaySVideo) display_options.emplace_back("svideo");
if(mask & DisplayRGB) display_options.emplace_back("rgb");
options.emplace_back(new Configurable::ListOption("Display", "display", display_options));
}
if(mask & AutomaticTapeMotorControl) options.emplace_back(new Configurable::BooleanOption("Automatic Tape Motor Control", "autotapemotor"));
if(mask & QuickBoot) options.emplace_back(new Configurable::BooleanOption("Boot Quickly", "quickboot"));
return options;
}
// MARK: - Selection appenders
void Configurable::append_quick_load_tape_selection(Configurable::SelectionSet &selection_set, bool selection) {
append_bool(selection_set, "quickload", selection);
}
void Configurable::append_automatic_tape_motor_control_selection(SelectionSet &selection_set, bool selection) {
append_bool(selection_set, "autotapemotor", selection);
}
void Configurable::append_display_selection(Configurable::SelectionSet &selection_set, Display selection) {
std::string string_selection;
switch(selection) {
default:
case Display::RGB: string_selection = "rgb"; break;
case Display::SVideo: string_selection = "svideo"; break;
case Display::CompositeMonochrome: string_selection = "composite-mono"; break;
case Display::CompositeColour: string_selection = "composite"; break;
}
selection_set["display"] = std::make_unique<Configurable::ListSelection>(string_selection);
}
void Configurable::append_quick_boot_selection(Configurable::SelectionSet &selection_set, bool selection) {
append_bool(selection_set, "quickboot", selection);
}
// MARK: - Selection parsers
bool Configurable::get_quick_load_tape(const Configurable::SelectionSet &selections_by_option, bool &result) {
return get_bool(selections_by_option, "quickload", result);
}
bool Configurable::get_automatic_tape_motor_control_selection(const SelectionSet &selections_by_option, bool &result) {
return get_bool(selections_by_option, "autotapemotor", result);
}
bool Configurable::get_display(const Configurable::SelectionSet &selections_by_option, Configurable::Display &result) {
auto display = Configurable::selection<Configurable::ListSelection>(selections_by_option, "display");
if(display) {
if(display->value == "rgb") {
result = Configurable::Display::RGB;
return true;
}
if(display->value == "svideo") {
result = Configurable::Display::SVideo;
return true;
}
if(display->value == "composite") {
result = Configurable::Display::CompositeColour;
return true;
}
if(display->value == "composite-mono") {
result = Configurable::Display::CompositeMonochrome;
return true;
}
}
return false;
}
bool Configurable::get_quick_boot(const Configurable::SelectionSet &selections_by_option, bool &result) {
return get_bool(selections_by_option, "quickboot", result);
}*/

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);
const 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);
const size_t key_offset = size_t(key);
if(key_offset >= key_states_.size()) return false;
return key_states_[key_offset];
}

View File

@ -110,7 +110,7 @@ class QuadratureMouse: public Mouse {
}
private:
int number_of_buttons_ = 0;
const int number_of_buttons_ = 0;
std::atomic<int> button_flags_;
std::atomic<int> axes_[2];

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

@ -251,7 +251,7 @@ void DMAController::set_component_prefers_clocking(ClockingHint::Source *, Clock
update_clocking_observer();
}
ClockingHint::Preference DMAController::preferred_clocking() {
ClockingHint::Preference DMAController::preferred_clocking() const {
return (fdc_.preferred_clocking() == ClockingHint::Preference::None) ? ClockingHint::Preference::None : ClockingHint::Preference::RealTime;
}

View File

@ -50,7 +50,7 @@ class DMAController: public WD::WD1770::Delegate, public ClockingHint::Source, p
void set_activity_observer(Activity::Observer *observer);
// ClockingHint::Source.
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
private:
HalfCycles running_time_;

View File

@ -45,7 +45,7 @@ bool IntelligentKeyboard::serial_line_did_produce_bit(Serial::Line *, int bit) {
return true;
}
ClockingHint::Preference IntelligentKeyboard::preferred_clocking() {
ClockingHint::Preference IntelligentKeyboard::preferred_clocking() const {
return output_line_.transmission_data_time_remaining().as_integral() ? ClockingHint::Preference::RealTime : ClockingHint::Preference::None;
}

View File

@ -58,7 +58,7 @@ class IntelligentKeyboard:
public Inputs::Mouse {
public:
IntelligentKeyboard(Serial::Line &input, Serial::Line &output);
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
void run_for(HalfCycles duration);
void set_key_state(Key key, bool is_pressed);

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

@ -15,7 +15,7 @@ MachineTypes::MappedKeyboardMachine::MappedKeyboardMachine(const std::set<Inputs
}
bool MappedKeyboardMachine::keyboard_did_change_key(Inputs::Keyboard *keyboard, Inputs::Keyboard::Key key, bool is_pressed) {
uint16_t mapped_key = get_keyboard_mapper()->mapped_key_for_key(key);
const uint16_t mapped_key = get_keyboard_mapper()->mapped_key_for_key(key);
if(mapped_key == KeyNotMapped) return false;
set_key_state(mapped_key, is_pressed);
return true;

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

View File

@ -9,7 +9,7 @@
#include "MemoryPacker.hpp"
void Memory::PackBigEndian16(const std::vector<uint8_t> &source, uint16_t *target) {
for(std::size_t c = 0; c < source.size(); c += 2) {
for(size_t c = 0; c < source.size(); c += 2) {
target[c >> 1] = uint16_t(source[c] << 8) | uint16_t(source[c+1]);
}
}

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

@ -86,11 +86,11 @@ class Typer {
std::string string_;
std::size_t string_pointer_ = 0;
HalfCycles frequency_;
const HalfCycles frequency_;
HalfCycles counter_;
int phase_ = 0;
Delegate *delegate_;
Delegate *const delegate_;
CharacterMapper &character_mapper_;
uint16_t try_type_next_character();

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

@ -17,7 +17,6 @@
4B055A7A1FAE78A00060FFFF /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B055A771FAE78210060FFFF /* SDL2.framework */; };
4B055A7E1FAE84AA0060FFFF /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B055A7C1FAE84A50060FFFF /* main.cpp */; };
4B055A8D1FAE85920060FFFF /* AsyncTaskQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B3940E51DA83C8300427841 /* AsyncTaskQueue.cpp */; };
4B055A8E1FAE85920060FFFF /* BestEffortUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B80ACFE1F85CAC900176895 /* BestEffortUpdater.cpp */; };
4B055A8F1FAE85A90060FFFF /* FileHolder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B5FADB81DE3151600AEC565 /* FileHolder.cpp */; };
4B055A901FAE85A90060FFFF /* TimedEventLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BB697C91D4B6D3E00248BDF /* TimedEventLoop.cpp */; };
4B055A911FAE85B50060FFFF /* Cartridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BEE0A6A1D72496600532C7B /* Cartridge.cpp */; };
@ -327,7 +326,6 @@
4B778F3723A5F11C0000D260 /* Parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B71368C1F788112008B8ED9 /* Parser.cpp */; };
4B778F3823A5F11C0000D260 /* SegmentParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B71368F1F789C93008B8ED9 /* SegmentParser.cpp */; };
4B778F3923A5F11C0000D260 /* Shifter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B7136871F78725F008B8ED9 /* Shifter.cpp */; };
4B778F3A23A5F1570000D260 /* StandardOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFE7B851FC39BF100160B38 /* StandardOptions.cpp */; };
4B778F3B23A5F1650000D260 /* KeyboardMachine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B54C0BB1F8D8E790050900F /* KeyboardMachine.cpp */; };
4B778F3C23A5F16F0000D260 /* FIRFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC76E671C98E31700E6EF73 /* FIRFilter.cpp */; };
4B778F3D23A5F1750000D260 /* ncr5380.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BDACBEA22FFA5D20045EF7E /* ncr5380.cpp */; };
@ -385,7 +383,6 @@
4B7F188F2154825E00388727 /* MasterSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B7F188C2154825D00388727 /* MasterSystem.cpp */; };
4B7F1897215486A200388727 /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B7F1896215486A100388727 /* StaticAnalyser.cpp */; };
4B7F1898215486A200388727 /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B7F1896215486A100388727 /* StaticAnalyser.cpp */; };
4B80AD001F85CACA00176895 /* BestEffortUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B80ACFE1F85CAC900176895 /* BestEffortUpdater.cpp */; };
4B8318B022D3E531006DB630 /* AppleII.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BCE0050227CE8CA000CA200 /* AppleII.cpp */; };
4B8318B122D3E53A006DB630 /* DiskIICard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BCE004E227CE8CA000CA200 /* DiskIICard.cpp */; };
4B8318B222D3E53C006DB630 /* Video.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BCE004D227CE8CA000CA200 /* Video.cpp */; };
@ -436,8 +433,6 @@
4B894531201967B4007DE474 /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B894506201967B4007DE474 /* StaticAnalyser.cpp */; };
4B894532201967B4007DE474 /* 6502.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B89450B201967B4007DE474 /* 6502.cpp */; };
4B894533201967B4007DE474 /* 6502.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B89450B201967B4007DE474 /* 6502.cpp */; };
4B894534201967B4007DE474 /* AddressMapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B89450C201967B4007DE474 /* AddressMapper.cpp */; };
4B894535201967B4007DE474 /* AddressMapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B89450C201967B4007DE474 /* AddressMapper.cpp */; };
4B894536201967B4007DE474 /* Z80.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B89450D201967B4007DE474 /* Z80.cpp */; };
4B894537201967B4007DE474 /* Z80.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B89450D201967B4007DE474 /* Z80.cpp */; };
4B894538201967B4007DE474 /* Tape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B894512201967B4007DE474 /* Tape.cpp */; };
@ -868,8 +863,6 @@
4BFCA1291ECBE7A700AC40C1 /* zexall.com in Resources */ = {isa = PBXBuildFile; fileRef = 4BFCA1281ECBE7A700AC40C1 /* zexall.com */; };
4BFCA12B1ECBE7C400AC40C1 /* ZexallTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BFCA12A1ECBE7C400AC40C1 /* ZexallTests.swift */; };
4BFDD78C1F7F2DB4008579B9 /* ImplicitSectors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFDD78B1F7F2DB4008579B9 /* ImplicitSectors.cpp */; };
4BFE7B871FC39BF100160B38 /* StandardOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFE7B851FC39BF100160B38 /* StandardOptions.cpp */; };
4BFE7B881FC39D8900160B38 /* StandardOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFE7B851FC39BF100160B38 /* StandardOptions.cpp */; };
4BFF1D3922337B0300838EA1 /* 68000Storage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFF1D3822337B0300838EA1 /* 68000Storage.cpp */; };
4BFF1D3A22337B0300838EA1 /* 68000Storage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFF1D3822337B0300838EA1 /* 68000Storage.cpp */; };
4BFF1D3D2235C3C100838EA1 /* EmuTOSTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BFF1D3C2235C3C100838EA1 /* EmuTOSTests.mm */; };
@ -1221,8 +1214,6 @@
4B7F1895215486A100388727 /* StaticAnalyser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StaticAnalyser.hpp; sourceTree = "<group>"; };
4B7F1896215486A100388727 /* StaticAnalyser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StaticAnalyser.cpp; sourceTree = "<group>"; };
4B80214322EE7C3E00068002 /* JustInTime.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = JustInTime.hpp; sourceTree = "<group>"; };
4B80ACFE1F85CAC900176895 /* BestEffortUpdater.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BestEffortUpdater.cpp; path = ../../Concurrency/BestEffortUpdater.cpp; sourceTree = "<group>"; };
4B80ACFF1F85CACA00176895 /* BestEffortUpdater.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = BestEffortUpdater.hpp; path = ../../Concurrency/BestEffortUpdater.hpp; sourceTree = "<group>"; };
4B8334811F5D9FF70097E338 /* PartialMachineCycle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PartialMachineCycle.cpp; sourceTree = "<group>"; };
4B8334831F5DA0360097E338 /* Z80Storage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Z80Storage.cpp; sourceTree = "<group>"; };
4B8334851F5DA3780097E338 /* 6502Storage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = 6502Storage.cpp; sourceTree = "<group>"; };
@ -1276,7 +1267,6 @@
4B894509201967B4007DE474 /* AddressMapper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AddressMapper.hpp; sourceTree = "<group>"; };
4B89450A201967B4007DE474 /* Z80.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Z80.hpp; sourceTree = "<group>"; };
4B89450B201967B4007DE474 /* 6502.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = 6502.cpp; sourceTree = "<group>"; };
4B89450C201967B4007DE474 /* AddressMapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AddressMapper.cpp; sourceTree = "<group>"; };
4B89450D201967B4007DE474 /* Z80.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Z80.cpp; sourceTree = "<group>"; };
4B89450E201967B4007DE474 /* Kernel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Kernel.hpp; sourceTree = "<group>"; };
4B894510201967B4007DE474 /* StaticAnalyser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = StaticAnalyser.hpp; sourceTree = "<group>"; };
@ -1792,7 +1782,6 @@
4BFCA12A1ECBE7C400AC40C1 /* ZexallTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZexallTests.swift; sourceTree = "<group>"; };
4BFDD78A1F7F2DB4008579B9 /* ImplicitSectors.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ImplicitSectors.hpp; sourceTree = "<group>"; };
4BFDD78B1F7F2DB4008579B9 /* ImplicitSectors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImplicitSectors.cpp; sourceTree = "<group>"; };
4BFE7B851FC39BF100160B38 /* StandardOptions.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StandardOptions.cpp; sourceTree = "<group>"; };
4BFE7B861FC39BF100160B38 /* StandardOptions.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = StandardOptions.hpp; sourceTree = "<group>"; };
4BFF1D342233778C00838EA1 /* 68000.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = 68000.hpp; sourceTree = "<group>"; };
4BFF1D37223379D500838EA1 /* 68000Storage.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = 68000Storage.hpp; sourceTree = "<group>"; };
@ -2163,7 +2152,6 @@
isa = PBXGroup;
children = (
4B31B88F1FBFBCD800C140D5 /* Configurable.hpp */,
4BFE7B851FC39BF100160B38 /* StandardOptions.cpp */,
4BFE7B861FC39BF100160B38 /* StandardOptions.hpp */,
);
name = Configurable;
@ -2224,8 +2212,6 @@
children = (
4B3940E51DA83C8300427841 /* AsyncTaskQueue.cpp */,
4B3940E61DA83C8300427841 /* AsyncTaskQueue.hpp */,
4B80ACFE1F85CAC900176895 /* BestEffortUpdater.cpp */,
4B80ACFF1F85CACA00176895 /* BestEffortUpdater.hpp */,
);
name = Concurrency;
sourceTree = "<group>";
@ -2886,7 +2872,6 @@
isa = PBXGroup;
children = (
4B89450B201967B4007DE474 /* 6502.cpp */,
4B89450C201967B4007DE474 /* AddressMapper.cpp */,
4B89450D201967B4007DE474 /* Z80.cpp */,
4B894508201967B4007DE474 /* 6502.hpp */,
4B894509201967B4007DE474 /* AddressMapper.hpp */,
@ -4415,7 +4400,6 @@
4B055AC31FAE9AE80060FFFF /* AmstradCPC.cpp in Sources */,
4B055A9E1FAE85DA0060FFFF /* G64.cpp in Sources */,
4B055AB81FAE860F0060FFFF /* ZX80O81P.cpp in Sources */,
4B055A8E1FAE85920060FFFF /* BestEffortUpdater.cpp in Sources */,
4B055AB01FAE86070060FFFF /* PulseQueuedTape.cpp in Sources */,
4B055AAC1FAE85FD0060FFFF /* PCMSegment.cpp in Sources */,
4BB307BC235001C300457D33 /* 6850.cpp in Sources */,
@ -4460,7 +4444,6 @@
4B0ACC03237756F6008902D0 /* Line.cpp in Sources */,
4B055AB11FAE86070060FFFF /* Tape.cpp in Sources */,
4BC1317B2346DF2B00E4FF3D /* MSA.cpp in Sources */,
4BFE7B881FC39D8900160B38 /* StandardOptions.cpp in Sources */,
4B894533201967B4007DE474 /* 6502.cpp in Sources */,
4B055AA91FAE85EF0060FFFF /* CommodoreGCR.cpp in Sources */,
4B055ADB1FAE9B460060FFFF /* 6560.cpp in Sources */,
@ -4508,7 +4491,6 @@
4B8318BA22D3E579006DB630 /* MacintoshIMG.cpp in Sources */,
4B8318B822D3E566006DB630 /* IWM.cpp in Sources */,
4B0333B02094081A0050B93D /* AppleDSK.cpp in Sources */,
4B894535201967B4007DE474 /* AddressMapper.cpp in Sources */,
4B055AD41FAE9B0B0060FFFF /* Oric.cpp in Sources */,
4B055A921FAE85B50060FFFF /* PRG.cpp in Sources */,
4B055AAF1FAE85FD0060FFFF /* UnformattedTrack.cpp in Sources */,
@ -4669,7 +4651,6 @@
4B4518821F75E91A00926311 /* PCMSegment.cpp in Sources */,
4B74CF812312FA9C00500CE8 /* HFV.cpp in Sources */,
4B17B58B20A8A9D9007CCA8F /* StringSerialiser.cpp in Sources */,
4B80AD001F85CACA00176895 /* BestEffortUpdater.cpp in Sources */,
4B2E2D9D1C3A070400138695 /* Electron.cpp in Sources */,
4B3940E71DA83C8300427841 /* AsyncTaskQueue.cpp in Sources */,
4B0E04FA1FC9FA3100F43484 /* 9918.cpp in Sources */,
@ -4713,7 +4694,6 @@
4BEE0A6F1D72496600532C7B /* Cartridge.cpp in Sources */,
4B8805FB1DCFF807003085B1 /* Oric.cpp in Sources */,
4B6ED2F0208E2F8A0047B343 /* WOZ.cpp in Sources */,
4BFE7B871FC39BF100160B38 /* StandardOptions.cpp in Sources */,
4B15A9FC208249BB005E6C8D /* StaticAnalyser.cpp in Sources */,
4B5FADC01DE3BF2B00AEC565 /* Microdisc.cpp in Sources */,
4B54C0C81F8D91E50050900F /* Keyboard.cpp in Sources */,
@ -4739,7 +4719,6 @@
4B54C0BC1F8D8E790050900F /* KeyboardMachine.cpp in Sources */,
4BB244D522AABAF600BE20E5 /* z8530.cpp in Sources */,
4BB73EA21B587A5100552FC2 /* AppDelegate.swift in Sources */,
4B894534201967B4007DE474 /* AddressMapper.cpp in Sources */,
4B1B88C8202E469300B67DFF /* MultiJoystickMachine.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -4818,7 +4797,6 @@
4BB73EB71B587A5100552FC2 /* AllSuiteATests.swift in Sources */,
4B778EF023A5D68C0000D260 /* 68000Storage.cpp in Sources */,
4B01A6881F22F0DB001FD6E3 /* Z80MemptrTests.swift in Sources */,
4B778F3A23A5F1570000D260 /* StandardOptions.cpp in Sources */,
4B778EFA23A5EB790000D260 /* DMK.cpp in Sources */,
4BEE1EC122B5E2FD000A26A6 /* Encoder.cpp in Sources */,
4B121F9B1E06293F00BFDA12 /* PCMSegmentEventSourceTests.mm in Sources */,

View File

@ -67,7 +67,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableASanStackUseAfterReturn = "YES"

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

@ -93,7 +93,7 @@ void CRT::set_display_type(Outputs::Display::DisplayType display_type) {
scan_target_->set_modals(scan_target_modals_);
}
Outputs::Display::DisplayType CRT::get_display_type() {
Outputs::Display::DisplayType CRT::get_display_type() const {
return scan_target_modals_.display_type;
}
@ -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

@ -299,7 +299,7 @@ class CRT {
void set_display_type(Outputs::Display::DisplayType);
/*! Gets the last display type provided to set_display_type. */
Outputs::Display::DisplayType get_display_type();
Outputs::Display::DisplayType get_display_type() const;
/*! Sets the offset to apply to phase when using the PhaseLinkedLuminance8 input data type. */
void set_phase_linked_luminance_offset(float);

View File

@ -129,7 +129,7 @@ struct Flywheel {
@returns The current output position.
*/
inline int get_current_output_position() {
inline int get_current_output_position() const {
if(counter_ < retrace_time_) {
const int retrace_distance = int((int64_t(counter_) * int64_t(standard_period_)) / int64_t(retrace_time_));
if(retrace_distance > counter_before_retrace_) return 0;
@ -145,56 +145,56 @@ struct Flywheel {
@returns The current output position.
*/
inline int get_current_phase() {
inline int get_current_phase() const {
return counter_ - retrace_time_;
}
/*!
@returns the amount of time since retrace last began. Time then counts monotonically up from zero.
*/
inline int get_current_time() {
inline int get_current_time() const {
return counter_;
}
/*!
@returns whether the output is currently retracing.
*/
inline bool is_in_retrace() {
inline bool is_in_retrace() const {
return counter_ < retrace_time_;
}
/*!
@returns the expected length of the scan period (excluding retrace).
*/
inline int get_scan_period() {
inline int get_scan_period() const {
return standard_period_ - retrace_time_;
}
/*!
@returns the actual length of the scan period (excluding retrace).
*/
inline int get_locked_scan_period() {
inline int get_locked_scan_period() const {
return expected_next_sync_ - retrace_time_;
}
/*!
@returns the expected length of a complete scan and retrace cycle.
*/
inline int get_standard_period() {
inline int get_standard_period() const {
return standard_period_;
}
/*!
@returns the actual current period for a complete scan (including retrace).
*/
inline int get_locked_period() {
inline int get_locked_period() const {
return expected_next_sync_;
}
/*!
@returns the amount by which the @c locked_period was adjusted, the last time that an adjustment was applied.
*/
inline int get_last_period_adjustment() {
inline int get_last_period_adjustment() const {
return last_adjustment_;
}
@ -211,21 +211,21 @@ struct Flywheel {
/*!
@returns A count of the number of retraces so far performed.
*/
inline int get_number_of_retraces() {
inline int get_number_of_retraces() const {
return number_of_retraces_;
}
/*!
@returns The amount of time this flywheel spends in retrace, as supplied at construction.
*/
inline int get_retrace_period() {
inline int get_retrace_period() const {
return retrace_time_;
}
/*!
@returns `true` if a sync is expected soon or if the time at which it was expected (or received) was recent.
*/
inline bool is_near_expected_sync() {
inline bool is_near_expected_sync() const {
return
(counter_ < (standard_period_ / 100)) ||
(counter_ >= expected_next_sync_ - (standard_period_ / 100));

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;

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