mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-22 14:30:29 +00:00
Switches all unsigned int
and double
casts to functional style.
This commit is contained in:
parent
c52348d8d7
commit
5e3e91373a
@ -115,7 +115,7 @@ void WD1770::run_for(const Cycles cycles) {
|
||||
Storage::Disk::Controller::run_for(cycles);
|
||||
|
||||
if(delay_time_) {
|
||||
unsigned int number_of_cycles = (unsigned int)cycles.as_int();
|
||||
unsigned int number_of_cycles = static_cast<unsigned int>(cycles.as_int());
|
||||
if(delay_time_ <= number_of_cycles) {
|
||||
delay_time_ = 0;
|
||||
posit_event((int)Event1770::Timer);
|
||||
|
@ -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 = ((unsigned int)value << timer_.activeShift) ;
|
||||
timer_.value = (static_cast<unsigned int>(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 = (unsigned int)cycles.as_int();
|
||||
unsigned int number_of_cycles = static_cast<unsigned int>(cycles.as_int());
|
||||
|
||||
// permit counting _to_ zero; counting _through_ zero initiates the other behaviour
|
||||
if(timer_.value >= number_of_cycles) {
|
||||
@ -126,7 +126,7 @@ template <class T> class MOS6532 {
|
||||
port_{{.output_mask = 0, .output = 0}, {.output_mask = 0, .output = 0}},
|
||||
a7_interrupt_({.last_port_value = 0, .enabled = false}),
|
||||
interrupt_line_(false),
|
||||
timer_{.value = (unsigned int)((rand() & 0xff) << 10), .activeShift = 10, .writtenShift = 10, .interrupt_enabled = false} {}
|
||||
timer_{.value = static_cast<unsigned int>((rand() & 0xff) << 10), .activeShift = 10, .writtenShift = 10, .interrupt_enabled = false} {}
|
||||
|
||||
inline void set_port_did_change(int port) {
|
||||
if(!port) {
|
||||
|
@ -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] = (unsigned int)(control_registers_[r]&0x7f) << m; }
|
||||
#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; }
|
||||
// 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
|
||||
|
@ -66,7 +66,7 @@ template <class T> class MOS6560 {
|
||||
}
|
||||
|
||||
void set_clock_rate(double clock_rate) {
|
||||
speaker_->set_input_rate((float)(clock_rate / 4.0));
|
||||
speaker_->set_input_rate(static_cast<float>(clock_rate / 4.0));
|
||||
}
|
||||
|
||||
std::shared_ptr<Outputs::CRT::CRT> get_crt() { return crt_; }
|
||||
@ -128,7 +128,7 @@ template <class T> class MOS6560 {
|
||||
break;
|
||||
}
|
||||
|
||||
crt_->set_new_display_type((unsigned int)(timing_.cycles_per_line*4), display_type);
|
||||
crt_->set_new_display_type(static_cast<unsigned int>(timing_.cycles_per_line*4), display_type);
|
||||
crt_->set_visible_area(Outputs::CRT::Rect(0.05f, 0.05f, 0.9f, 0.9f));
|
||||
|
||||
// switch(output_mode) {
|
||||
|
@ -67,13 +67,13 @@ AY38910::AY38910() :
|
||||
float max_volume = 8192;
|
||||
float root_two = sqrtf(2.0f);
|
||||
for(int v = 0; v < 16; v++) {
|
||||
volumes_[v] = (int)(max_volume / powf(root_two, (float)(v ^ 0xf)));
|
||||
volumes_[v] = (int)(max_volume / powf(root_two, static_cast<float>(v ^ 0xf)));
|
||||
}
|
||||
volumes_[0] = 0;
|
||||
}
|
||||
|
||||
void AY38910::set_clock_rate(double clock_rate) {
|
||||
set_input_rate((float)clock_rate);
|
||||
set_input_rate(static_cast<float>(clock_rate));
|
||||
}
|
||||
|
||||
void AY38910::get_samples(unsigned int number_of_samples, int16_t *target) {
|
||||
|
@ -137,7 +137,7 @@ class ConcreteMachine:
|
||||
void setup_output(float aspect_ratio) override {
|
||||
bus_->tia_.reset(new TIA);
|
||||
bus_->speaker_.reset(new Speaker);
|
||||
bus_->speaker_->set_input_rate((float)(get_clock_rate() / (double)CPUTicksPerAudioTick));
|
||||
bus_->speaker_->set_input_rate(static_cast<float>(get_clock_rate() / static_cast<double>(CPUTicksPerAudioTick)));
|
||||
bus_->tia_->get_crt()->set_delegate(this);
|
||||
}
|
||||
|
||||
@ -188,8 +188,8 @@ class ConcreteMachine:
|
||||
bus_->tia_->set_output_mode(TIA::OutputMode::PAL);
|
||||
}
|
||||
|
||||
bus_->speaker_->set_input_rate((float)(clock_rate / (double)CPUTicksPerAudioTick));
|
||||
bus_->speaker_->set_high_frequency_cut_off((float)(clock_rate / ((double)CPUTicksPerAudioTick * 2.0)));
|
||||
bus_->speaker_->set_input_rate(static_cast<float>(clock_rate / static_cast<double>(CPUTicksPerAudioTick)));
|
||||
bus_->speaker_->set_high_frequency_cut_off(static_cast<float>(clock_rate / (static_cast<double>(CPUTicksPerAudioTick) * 2.0)));
|
||||
set_clock_rate(clock_rate);
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ void TIA::set_output_mode(Atari2600::TIA::OutputMode output_mode) {
|
||||
// cycles_per_line * 2 cycles of information from one sync edge to the next
|
||||
crt_->set_new_display_type(cycles_per_line * 2 - 1, display_type);
|
||||
|
||||
/* speaker_->set_input_rate((float)(get_clock_rate() / 38.0));*/
|
||||
/* speaker_->set_input_rate(static_cast<float>(get_clock_rate() / 38.0));*/
|
||||
}
|
||||
|
||||
void TIA::run_for(const Cycles cycles) {
|
||||
@ -412,11 +412,11 @@ void TIA::output_for_cycles(int number_of_cycles) {
|
||||
#define Period(function, target) \
|
||||
if(output_cursor < target) { \
|
||||
if(horizontal_counter_ <= target) { \
|
||||
if(crt_) crt_->function((unsigned int)((horizontal_counter_ - output_cursor) * 2)); \
|
||||
if(crt_) crt_->function(static_cast<unsigned int>((horizontal_counter_ - output_cursor) * 2)); \
|
||||
horizontal_counter_ %= cycles_per_line; \
|
||||
return; \
|
||||
} else { \
|
||||
if(crt_) crt_->function((unsigned int)((target - output_cursor) * 2)); \
|
||||
if(crt_) crt_->function(static_cast<unsigned int>((target - output_cursor) * 2)); \
|
||||
output_cursor = target; \
|
||||
} \
|
||||
}
|
||||
@ -442,12 +442,12 @@ void TIA::output_for_cycles(int number_of_cycles) {
|
||||
if(output_mode_ & blank_flag) {
|
||||
if(pixel_target_) {
|
||||
output_pixels(pixels_start_location_, output_cursor);
|
||||
if(crt_) crt_->output_data((unsigned int)(output_cursor - pixels_start_location_) * 2, 2);
|
||||
if(crt_) crt_->output_data(static_cast<unsigned int>(output_cursor - pixels_start_location_) * 2, 2);
|
||||
pixel_target_ = nullptr;
|
||||
pixels_start_location_ = 0;
|
||||
}
|
||||
int duration = std::min(228, horizontal_counter_) - output_cursor;
|
||||
if(crt_) crt_->output_blank((unsigned int)(duration * 2));
|
||||
if(crt_) crt_->output_blank(static_cast<unsigned int>(duration * 2));
|
||||
} else {
|
||||
if(!pixels_start_location_ && crt_) {
|
||||
pixels_start_location_ = output_cursor;
|
||||
@ -464,7 +464,7 @@ void TIA::output_for_cycles(int number_of_cycles) {
|
||||
}
|
||||
|
||||
if(horizontal_counter_ == cycles_per_line && crt_) {
|
||||
crt_->output_data((unsigned int)(output_cursor - pixels_start_location_) * 2, 2);
|
||||
crt_->output_data(static_cast<unsigned int>(output_cursor - pixels_start_location_) * 2, 2);
|
||||
pixel_target_ = nullptr;
|
||||
pixels_start_location_ = 0;
|
||||
}
|
||||
|
@ -136,7 +136,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((unsigned int)density));
|
||||
set_expected_bit_length(Storage::Encodings::CommodoreGCR::length_of_a_bit_in_time_zone(static_cast<unsigned int>(density)));
|
||||
}
|
||||
|
||||
#pragma mark - SerialPortVIA
|
||||
|
@ -80,7 +80,7 @@ void Tape::run_for(const Cycles cycles) {
|
||||
TapePlayer::run_for(cycles);
|
||||
}
|
||||
} else {
|
||||
output_.cycles_into_pulse += (unsigned int)cycles.as_int();
|
||||
output_.cycles_into_pulse += static_cast<unsigned int>(cycles.as_int());
|
||||
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);
|
||||
|
@ -86,7 +86,7 @@ void VideoOutput::start_pixel_line() {
|
||||
}
|
||||
|
||||
void VideoOutput::end_pixel_line() {
|
||||
if(current_output_target_) crt_->output_data((unsigned int)((current_output_target_ - initial_output_target_) * current_output_divider_), current_output_divider_);
|
||||
if(current_output_target_) crt_->output_data(static_cast<unsigned int>((current_output_target_ - initial_output_target_) * current_output_divider_), current_output_divider_);
|
||||
current_character_row_++;
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ void VideoOutput::output_pixels(unsigned int number_of_cycles) {
|
||||
}
|
||||
|
||||
if(!initial_output_target_ || divider != current_output_divider_) {
|
||||
if(current_output_target_) crt_->output_data((unsigned int)((current_output_target_ - initial_output_target_) * current_output_divider_), current_output_divider_);
|
||||
if(current_output_target_) crt_->output_data(static_cast<unsigned int>((current_output_target_ - initial_output_target_) * current_output_divider_), current_output_divider_);
|
||||
current_output_divider_ = divider;
|
||||
initial_output_target_ = current_output_target_ = crt_->allocate_write_area(640 / current_output_divider_, 4);
|
||||
}
|
||||
@ -223,15 +223,15 @@ void VideoOutput::run_for(const Cycles cycles) {
|
||||
while(number_of_cycles) {
|
||||
int draw_action_length = screen_map_[screen_map_pointer_].length;
|
||||
int time_left_in_action = std::min(number_of_cycles, draw_action_length - cycles_into_draw_action_);
|
||||
if(screen_map_[screen_map_pointer_].type == DrawAction::Pixels) output_pixels((unsigned int)time_left_in_action);
|
||||
if(screen_map_[screen_map_pointer_].type == DrawAction::Pixels) output_pixels(static_cast<unsigned int>(time_left_in_action));
|
||||
|
||||
number_of_cycles -= time_left_in_action;
|
||||
cycles_into_draw_action_ += time_left_in_action;
|
||||
if(cycles_into_draw_action_ == draw_action_length) {
|
||||
switch(screen_map_[screen_map_pointer_].type) {
|
||||
case DrawAction::Sync: crt_->output_sync((unsigned int)(draw_action_length * crt_cycles_multiplier)); break;
|
||||
case DrawAction::ColourBurst: crt_->output_default_colour_burst((unsigned int)(draw_action_length * crt_cycles_multiplier)); break;
|
||||
case DrawAction::Blank: crt_->output_blank((unsigned int)(draw_action_length * crt_cycles_multiplier)); break;
|
||||
case DrawAction::Sync: crt_->output_sync(static_cast<unsigned int>(draw_action_length * crt_cycles_multiplier)); break;
|
||||
case DrawAction::ColourBurst: crt_->output_default_colour_burst(static_cast<unsigned int>(draw_action_length * crt_cycles_multiplier)); break;
|
||||
case DrawAction::Blank: crt_->output_blank(static_cast<unsigned int>(draw_action_length * crt_cycles_multiplier)); break;
|
||||
case DrawAction::Pixels: end_pixel_line(); break;
|
||||
}
|
||||
screen_map_pointer_ = (screen_map_pointer_ + 1) % screen_map_.size();
|
||||
@ -376,9 +376,9 @@ unsigned int VideoOutput::get_cycles_until_next_ram_availability(int from_time)
|
||||
int output_position_line = graphics_line(output_position_);
|
||||
int implied_row = current_character_row_ + (current_line - output_position_line) % 10;
|
||||
if(implied_row < 8)
|
||||
result += (unsigned int)(80 - current_column);
|
||||
result += static_cast<unsigned int>(80 - current_column);
|
||||
}
|
||||
else result += (unsigned int)(80 - current_column);
|
||||
else result += static_cast<unsigned int>(80 - current_column);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -89,7 +89,7 @@ void VideoOutput::run_for(const Cycles cycles) {
|
||||
if(counter_ >= v_sync_start_position_ && counter_ < v_sync_end_position_) {
|
||||
// this is a sync line
|
||||
cycles_run_for = v_sync_end_position_ - counter_;
|
||||
clamp(crt_->output_sync((unsigned int)(v_sync_end_position_ - v_sync_start_position_) * 6));
|
||||
clamp(crt_->output_sync(static_cast<unsigned int>(v_sync_end_position_ - v_sync_start_position_) * 6));
|
||||
} else if(counter_ < 224*64 && h_counter < 40) {
|
||||
// this is a pixel line
|
||||
if(!h_counter) {
|
||||
@ -202,7 +202,7 @@ void VideoOutput::run_for(const Cycles cycles) {
|
||||
cycles_run_for = 48 - h_counter;
|
||||
clamp(
|
||||
int period = (counter_ < 224*64) ? 8 : 48;
|
||||
crt_->output_blank((unsigned int)period * 6);
|
||||
crt_->output_blank(static_cast<unsigned int>(period) * 6);
|
||||
);
|
||||
} else if(h_counter < 54) {
|
||||
cycles_run_for = 54 - h_counter;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <cstdlib>
|
||||
|
||||
void Memory::Fuzz(uint8_t *buffer, size_t size) {
|
||||
unsigned int divider = ((unsigned int)RAND_MAX + 1) / 256;
|
||||
unsigned int divider = (static_cast<unsigned int>(RAND_MAX) + 1) / 256;
|
||||
unsigned int shift = 1, value = 1;
|
||||
while(value < divider) {
|
||||
value <<= 1;
|
||||
|
@ -31,7 +31,7 @@ Video::Video() :
|
||||
|
||||
void Video::run_for(const HalfCycles half_cycles) {
|
||||
// Just keep a running total of the amount of time that remains owed to the CRT.
|
||||
cycles_since_update_ += (unsigned int)half_cycles.as_int();
|
||||
cycles_since_update_ += static_cast<unsigned int>(half_cycles.as_int());
|
||||
}
|
||||
|
||||
void Video::flush() {
|
||||
@ -48,7 +48,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.
|
||||
unsigned int data_length = (unsigned int)(line_data_pointer_ - line_data_);
|
||||
unsigned int data_length = static_cast<unsigned int>(line_data_pointer_ - line_data_);
|
||||
if(data_length < cycles_since_update_ || next_sync) {
|
||||
unsigned int output_length = std::min(data_length, cycles_since_update_);
|
||||
crt_->output_data(output_length, 1);
|
||||
|
@ -403,11 +403,11 @@ Outputs::CRT::Rect CRT::get_rect_for_area(int first_line_after_sync, int number_
|
||||
unsigned int horizontal_retrace_period = horizontal_period - horizontal_scan_period;
|
||||
|
||||
// make sure that the requested range is visible
|
||||
if((unsigned int)first_cycle_after_sync < horizontal_retrace_period) first_cycle_after_sync = (int)horizontal_retrace_period;
|
||||
if((unsigned int)(first_cycle_after_sync + number_of_cycles) > horizontal_scan_period) number_of_cycles = (int)(horizontal_scan_period - (unsigned)first_cycle_after_sync);
|
||||
if(static_cast<unsigned int>(first_cycle_after_sync) < horizontal_retrace_period) first_cycle_after_sync = (int)horizontal_retrace_period;
|
||||
if(static_cast<unsigned int>(first_cycle_after_sync + number_of_cycles) > horizontal_scan_period) number_of_cycles = (int)(horizontal_scan_period - (unsigned)first_cycle_after_sync);
|
||||
|
||||
float start_x = (float)((unsigned)first_cycle_after_sync - horizontal_retrace_period) / (float)horizontal_scan_period;
|
||||
float width = (float)number_of_cycles / (float)horizontal_scan_period;
|
||||
float start_x = static_cast<float>((unsigned)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);
|
||||
|
||||
// determine prima facie y extent
|
||||
unsigned int vertical_period = vertical_flywheel_->get_standard_period();
|
||||
@ -420,8 +420,8 @@ Outputs::CRT::Rect CRT::get_rect_for_area(int first_line_after_sync, int number_
|
||||
// if((first_line_after_sync + number_of_lines) * horizontal_period > vertical_scan_period)
|
||||
// number_of_lines = (int)(horizontal_scan_period - (unsigned)first_cycle_after_sync);
|
||||
|
||||
float start_y = (float)(((unsigned)first_line_after_sync * horizontal_period) - vertical_retrace_period) / (float)vertical_scan_period;
|
||||
float height = (float)((unsigned)number_of_lines * horizontal_period) / vertical_scan_period;
|
||||
float start_y = static_cast<float>(((unsigned)first_line_after_sync * horizontal_period) - vertical_retrace_period) / static_cast<float>(vertical_scan_period);
|
||||
float height = static_cast<float>((unsigned)number_of_lines * horizontal_period) / vertical_scan_period;
|
||||
|
||||
// adjust to ensure aspect ratio is correct
|
||||
float adjusted_aspect_ratio = (3.0f*aspect_ratio / 4.0f);
|
||||
|
@ -103,7 +103,7 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
|
||||
}
|
||||
|
||||
// make sure there's a target to draw to
|
||||
if(!framebuffer_ || (unsigned int)framebuffer_->get_height() != output_height || (unsigned int)framebuffer_->get_width() != output_width) {
|
||||
if(!framebuffer_ || static_cast<unsigned int>(framebuffer_->get_height()) != output_height || static_cast<unsigned int>(framebuffer_->get_width()) != output_width) {
|
||||
std::unique_ptr<OpenGL::TextureTarget> new_framebuffer(new OpenGL::TextureTarget((GLsizei)output_width, (GLsizei)output_height, pixel_accumulation_texture_unit, GL_LINEAR));
|
||||
if(framebuffer_) {
|
||||
new_framebuffer->bind_framebuffer();
|
||||
@ -111,7 +111,7 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
|
||||
|
||||
glActiveTexture(pixel_accumulation_texture_unit);
|
||||
framebuffer_->bind_texture();
|
||||
framebuffer_->draw((float)output_width / (float)output_height);
|
||||
framebuffer_->draw(static_cast<float>(output_width) / static_cast<float>(output_height));
|
||||
|
||||
new_framebuffer->bind_texture();
|
||||
}
|
||||
@ -223,7 +223,7 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
|
||||
|
||||
glActiveTexture(pixel_accumulation_texture_unit);
|
||||
framebuffer_->bind_texture();
|
||||
framebuffer_->draw((float)output_width / (float)output_height);
|
||||
framebuffer_->draw(static_cast<float>(output_width) / static_cast<float>(output_height));
|
||||
|
||||
fence_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
draw_mutex_.unlock();
|
||||
@ -381,7 +381,7 @@ void OpenGLOutputBuilder::set_gamma() {
|
||||
}
|
||||
|
||||
float OpenGLOutputBuilder::get_composite_output_width() const {
|
||||
return ((float)colour_cycle_numerator_ * 4.0f) / (float)(colour_cycle_denominator_ * IntermediateBufferWidth);
|
||||
return (static_cast<float>(colour_cycle_numerator_) * 4.0f) / static_cast<float>(colour_cycle_denominator_ * IntermediateBufferWidth);
|
||||
}
|
||||
|
||||
void OpenGLOutputBuilder::set_output_shader_width() {
|
||||
@ -392,7 +392,7 @@ void OpenGLOutputBuilder::set_output_shader_width() {
|
||||
}
|
||||
|
||||
void OpenGLOutputBuilder::set_timing_uniforms() {
|
||||
const float colour_subcarrier_frequency = (float)colour_cycle_numerator_ / (float)colour_cycle_denominator_;
|
||||
const float colour_subcarrier_frequency = static_cast<float>(colour_cycle_numerator_) / static_cast<float>(colour_cycle_denominator_);
|
||||
const float output_width = get_composite_output_width();
|
||||
const float sample_cycles_per_line = cycles_per_line_ / output_width;
|
||||
|
||||
@ -407,7 +407,7 @@ void OpenGLOutputBuilder::set_timing_uniforms() {
|
||||
}
|
||||
if(rgb_filter_shader_program_) {
|
||||
rgb_filter_shader_program_->set_width_scalers(1.0f, 1.0f);
|
||||
rgb_filter_shader_program_->set_filter_coefficients(sample_cycles_per_line, (float)input_frequency_ * 0.5f);
|
||||
rgb_filter_shader_program_->set_filter_coefficients(sample_cycles_per_line, static_cast<float>(input_frequency_) * 0.5f);
|
||||
}
|
||||
if(output_shader_program_) {
|
||||
set_output_shader_width();
|
||||
|
@ -350,7 +350,7 @@ void IntermediateShader::set_filter_coefficients(float sampling_rate, float cuto
|
||||
|
||||
// int halfSize = (taps >> 1);
|
||||
// while(c < halfSize && sample < 5) {
|
||||
// offsets[sample] = (float)(halfSize - c);
|
||||
// offsets[sample] = static_cast<float>(halfSize - c);
|
||||
// if((coefficients[c] < 0.0f) == (coefficients[c+1] < 0.0f) && c+1 < (taps >> 1)) {
|
||||
// weights[sample] = coefficients[c] + coefficients[c+1];
|
||||
// offsets[sample] -= (coefficients[c+1] / weights[sample]);
|
||||
|
@ -92,7 +92,7 @@ std::unique_ptr<OutputShader> OutputShader::make_shader(const char *fragment_met
|
||||
}
|
||||
|
||||
void OutputShader::set_output_size(unsigned int output_width, unsigned int output_height, Outputs::CRT::Rect visible_area) {
|
||||
GLfloat outputAspectRatioMultiplier = ((float)output_width / (float)output_height) / (4.0f / 3.0f);
|
||||
GLfloat outputAspectRatioMultiplier = (static_cast<float>(output_width) / static_cast<float>(output_height)) / (4.0f / 3.0f);
|
||||
|
||||
GLfloat bonusWidth = (outputAspectRatioMultiplier - 1.0f) * visible_area.size.width;
|
||||
visible_area.origin.x -= bonusWidth * 0.5f * visible_area.size.width;
|
||||
@ -107,9 +107,9 @@ void OutputShader::set_source_texture_unit(GLenum unit) {
|
||||
}
|
||||
|
||||
void OutputShader::set_timing(unsigned int height_of_display, unsigned int cycles_per_line, unsigned int horizontal_scan_period, unsigned int vertical_scan_period, unsigned int vertical_period_divider) {
|
||||
GLfloat scan_angle = atan2f(1.0f / (float)height_of_display, 1.0f);
|
||||
GLfloat scan_angle = atan2f(1.0f / static_cast<float>(height_of_display), 1.0f);
|
||||
GLfloat scan_normal[] = { -sinf(scan_angle), cosf(scan_angle)};
|
||||
GLfloat multiplier = (float)cycles_per_line / ((float)height_of_display * (float)horizontal_scan_period);
|
||||
GLfloat multiplier = static_cast<float>(cycles_per_line) / (static_cast<float>(height_of_display) * static_cast<float>(horizontal_scan_period));
|
||||
scan_normal[0] *= multiplier;
|
||||
scan_normal[1] *= multiplier;
|
||||
|
||||
|
@ -114,14 +114,14 @@ void TextureTarget::draw(float aspect_ratio) {
|
||||
buffer[2] = 0.0f;
|
||||
buffer[3] = 0.0f;
|
||||
buffer[6] = 0.0f;
|
||||
buffer[7] = (float)_height / (float)_expanded_height;
|
||||
buffer[10] = (float)_width / (float)_expanded_width;
|
||||
buffer[7] = static_cast<float>(_height) / static_cast<float>(_expanded_height);
|
||||
buffer[10] = static_cast<float>(_width) / static_cast<float>(_expanded_width);
|
||||
buffer[11] = 0;
|
||||
buffer[14] = buffer[10];
|
||||
buffer[15] = buffer[7];
|
||||
|
||||
// determine positions; rule is to keep the same height and centre
|
||||
float internal_aspect_ratio = (float)_width / (float)_height;
|
||||
float internal_aspect_ratio = static_cast<float>(_width) / static_cast<float>(_height);
|
||||
float aspect_ratio_ratio = internal_aspect_ratio / aspect_ratio;
|
||||
|
||||
buffer[0] = -aspect_ratio_ratio; buffer[1] = -1.0f;
|
||||
|
@ -144,13 +144,13 @@ template <class T> class Filter: public Speaker {
|
||||
|
||||
void run_for(const Cycles cycles) {
|
||||
enqueue([=]() {
|
||||
unsigned int cycles_remaining = (unsigned int)cycles.as_int();
|
||||
unsigned int cycles_remaining = static_cast<unsigned int>(cycles.as_int());
|
||||
if(coefficients_are_dirty_) update_filter_coefficients();
|
||||
|
||||
// if input and output rates exactly match, just accumulate results and pass on
|
||||
if(input_cycles_per_second_ == output_cycles_per_second_ && high_frequency_cut_off_ < 0.0) {
|
||||
while(cycles_remaining) {
|
||||
unsigned int cycles_to_read = (unsigned int)(buffer_in_progress_.size() - (size_t)buffer_in_progress_pointer_);
|
||||
unsigned int cycles_to_read = static_cast<unsigned int>(buffer_in_progress_.size() - (size_t)buffer_in_progress_pointer_);
|
||||
if(cycles_to_read > cycles_remaining) cycles_to_read = cycles_remaining;
|
||||
|
||||
static_cast<T *>(this)->get_samples(cycles_to_read, &buffer_in_progress_[(size_t)buffer_in_progress_pointer_]);
|
||||
@ -173,7 +173,7 @@ template <class T> class Filter: public Speaker {
|
||||
// if the output rate is less than the input rate, use the filter
|
||||
if(input_cycles_per_second_ > output_cycles_per_second_ || (input_cycles_per_second_ == output_cycles_per_second_ && high_frequency_cut_off_ >= 0.0)) {
|
||||
while(cycles_remaining) {
|
||||
unsigned int cycles_to_read = (unsigned int)std::min((size_t)cycles_remaining, number_of_taps_ - input_buffer_depth_);
|
||||
unsigned int cycles_to_read = static_cast<unsigned int>(std::min((size_t)cycles_remaining, number_of_taps_ - input_buffer_depth_));
|
||||
static_cast<T *>(this)->get_samples(cycles_to_read, &input_buffer_[(size_t)input_buffer_depth_]);
|
||||
cycles_remaining -= cycles_to_read;
|
||||
input_buffer_depth_ += cycles_to_read;
|
||||
@ -200,7 +200,7 @@ template <class T> class Filter: public Speaker {
|
||||
input_buffer_depth_ -= steps;
|
||||
} else {
|
||||
if(steps > number_of_taps_)
|
||||
static_cast<T *>(this)->skip_samples((unsigned int)steps - (unsigned int)number_of_taps_);
|
||||
static_cast<T *>(this)->skip_samples(static_cast<unsigned int>(steps) - static_cast<unsigned int>(number_of_taps_));
|
||||
input_buffer_depth_ = 0;
|
||||
}
|
||||
}
|
||||
@ -241,7 +241,7 @@ template <class T> class Filter: public Speaker {
|
||||
} else {
|
||||
high_pass_frequency = output_cycles_per_second_ / 2.0f;
|
||||
}
|
||||
filter_.reset(new SignalProcessing::FIRFilter((unsigned int)number_of_taps_, (float)input_cycles_per_second_, 0.0, high_pass_frequency, SignalProcessing::FIRFilter::DefaultAttenuation));
|
||||
filter_.reset(new SignalProcessing::FIRFilter(static_cast<unsigned int>(number_of_taps_), static_cast<float>(input_cycles_per_second_), 0.0, high_pass_frequency, SignalProcessing::FIRFilter::DefaultAttenuation));
|
||||
|
||||
input_buffer_.resize((size_t)number_of_taps_);
|
||||
input_buffer_depth_ = 0;
|
||||
|
@ -69,11 +69,11 @@ void FIRFilter::coefficients_for_idealised_filter_response(short *filterCoeffici
|
||||
/* work out the right hand side of the filter coefficients */
|
||||
unsigned int Np = (numberOfTaps - 1) / 2;
|
||||
float I0 = ino(a);
|
||||
float NpSquared = (float)(Np * Np);
|
||||
float NpSquared = static_cast<float>(Np * Np);
|
||||
for(unsigned int i = 0; i <= Np; i++) {
|
||||
filterCoefficientsFloat[Np + i] =
|
||||
A[i] *
|
||||
ino(a * sqrtf(1.0f - ((float)(i * i) / NpSquared) )) /
|
||||
ino(a * sqrtf(1.0f - (static_cast<float>(i * i) / NpSquared) )) /
|
||||
I0;
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ void FIRFilter::coefficients_for_idealised_filter_response(short *filterCoeffici
|
||||
|
||||
void FIRFilter::get_coefficients(float *coefficients) {
|
||||
for(unsigned int i = 0; i < number_of_taps_; i++) {
|
||||
coefficients[i] = (float)filter_coefficients_[i] / kCSKaiserBesselFilterFixedMultiplier;
|
||||
coefficients[i] = static_cast<float>(filter_coefficients_[i]) / kCSKaiserBesselFilterFixedMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ FIRFilter::FIRFilter(unsigned int number_of_taps, float input_sample_rate, float
|
||||
float *A = new float[Np+1];
|
||||
A[0] = 2.0f * (high_frequency - low_frequency) / input_sample_rate;
|
||||
for(unsigned int i = 1; i <= Np; i++) {
|
||||
float iPi = (float)i * (float)M_PI;
|
||||
float iPi = static_cast<float>(i) * static_cast<float>(M_PI);
|
||||
A[i] =
|
||||
(
|
||||
sinf(twoOverSampleRate * iPi * high_frequency) -
|
||||
|
@ -67,7 +67,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) | (unsigned int)value) & 0x3ff;
|
||||
shift_register_ = ((shift_register_ << 1) | static_cast<unsigned int>(value)) & 0x3ff;
|
||||
bit_count_++;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ using namespace Storage::Disk;
|
||||
Controller::Controller(Cycles clock_rate) :
|
||||
clock_rate_multiplier_(128000000 / clock_rate.as_int()),
|
||||
clock_rate_(clock_rate.as_int() * clock_rate_multiplier_),
|
||||
empty_drive_(new Drive((unsigned int)clock_rate.as_int(), 1, 1)) {
|
||||
empty_drive_(new Drive(static_cast<unsigned int>(clock_rate.as_int()), 1, 1)) {
|
||||
// seed this class with a PLL, any PLL, so that it's safe to assume non-nullptr later
|
||||
Time one(1);
|
||||
set_expected_bit_length(one);
|
||||
|
@ -85,7 +85,7 @@ std::shared_ptr<Track> D64::get_track_at_position(Track::Address address) {
|
||||
|
||||
PCMSegment track;
|
||||
size_t track_bytes = 349 * (size_t)sectors_by_zone[zone];
|
||||
track.number_of_bits = (unsigned int)track_bytes * 8;
|
||||
track.number_of_bits = static_cast<unsigned int>(track_bytes) * 8;
|
||||
track.data.resize(track_bytes);
|
||||
uint8_t *data = &track.data[0];
|
||||
|
||||
|
@ -106,7 +106,7 @@ std::shared_ptr<Track> G64::get_track_at_position(Track::Address address) {
|
||||
} else {
|
||||
PCMSegment segment;
|
||||
segment.number_of_bits = track_length * 8;
|
||||
segment.length_of_a_bit = Encodings::CommodoreGCR::length_of_a_bit_in_time_zone((unsigned int)speed_zone_offset);
|
||||
segment.length_of_a_bit = Encodings::CommodoreGCR::length_of_a_bit_in_time_zone(static_cast<unsigned int>(speed_zone_offset));
|
||||
segment.data = std::move(track_contents);
|
||||
|
||||
resulting_track.reset(new PCMTrack(std::move(segment)));
|
||||
|
@ -108,7 +108,7 @@ std::shared_ptr<Track> OricMFMDSK::get_track_at_position(Track::Address address)
|
||||
}
|
||||
}
|
||||
|
||||
segment.number_of_bits = (unsigned int)(segment.data.size() * 8);
|
||||
segment.number_of_bits = static_cast<unsigned int>(segment.data.size() * 8);
|
||||
|
||||
std::shared_ptr<PCMTrack> track(new PCMTrack(segment));
|
||||
return track;
|
||||
|
@ -102,7 +102,7 @@ void Drive::set_event_delegate(Storage::Disk::Drive::EventDelegate *delegate) {
|
||||
}
|
||||
|
||||
void Drive::advance(const Cycles cycles) {
|
||||
cycles_since_index_hole_ += (unsigned int)cycles.as_int();
|
||||
cycles_since_index_hole_ += static_cast<unsigned int>(cycles.as_int());
|
||||
if(event_delegate_) event_delegate_->advance(cycles);
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ template<class T> std::shared_ptr<Storage::Disk::Track>
|
||||
size_t max_size = expected_track_bytes + (expected_track_bytes / 10);
|
||||
if(segment.data.size() > max_size) segment.data.resize(max_size);
|
||||
|
||||
segment.number_of_bits = (unsigned int)(segment.data.size() * 8);
|
||||
segment.number_of_bits = static_cast<unsigned int>(segment.data.size() * 8);
|
||||
return std::shared_ptr<Storage::Disk::Track>(new Storage::Disk::PCMTrack(std::move(segment)));
|
||||
}
|
||||
|
||||
|
@ -109,5 +109,5 @@ Storage::Time PCMSegmentEventSource::seek_to(const Time &time_from_start) {
|
||||
bit_pointer_ = 1 + (relative_time / segment_->length_of_a_bit).get_unsigned_int();
|
||||
|
||||
// map up to the correct amount of time
|
||||
return half_bit_length + segment_->length_of_a_bit * (unsigned int)(bit_pointer_ - 1);
|
||||
return half_bit_length + segment_->length_of_a_bit * static_cast<unsigned int>(bit_pointer_ - 1);
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ struct Time {
|
||||
unsigned int length, clock_rate;
|
||||
Time() : length(0), clock_rate(1) {}
|
||||
Time(unsigned int unsigned_int_value) : length(unsigned_int_value), clock_rate(1) {}
|
||||
Time(int int_value) : Time((unsigned int)int_value) {}
|
||||
Time(int int_value) : Time(static_cast<unsigned int>(int_value)) {}
|
||||
Time(unsigned int length, unsigned int clock_rate) : length(length), clock_rate(clock_rate) {}
|
||||
Time(int length, int clock_rate) : Time((unsigned int)length, (unsigned int)clock_rate) {}
|
||||
Time(int length, int clock_rate) : Time(static_cast<unsigned int>(length), static_cast<unsigned int>(clock_rate)) {}
|
||||
Time(uint64_t length, uint64_t clock_rate) {
|
||||
install_result(length, clock_rate);
|
||||
}
|
||||
@ -48,7 +48,7 @@ struct Time {
|
||||
@returns the floating point conversion of this @c Time. This will often be less precise.
|
||||
*/
|
||||
inline float get_float() const {
|
||||
return (float)length / (float)clock_rate;
|
||||
return static_cast<float>(length) / static_cast<float>(clock_rate);
|
||||
}
|
||||
|
||||
inline unsigned int get_unsigned_int() const {
|
||||
@ -210,8 +210,8 @@ struct Time {
|
||||
private:
|
||||
inline void install_result(uint64_t long_length, uint64_t long_clock_rate) {
|
||||
if(long_length <= std::numeric_limits<unsigned int>::max() && long_clock_rate <= std::numeric_limits<unsigned int>::max()) {
|
||||
length = (unsigned int)long_length;
|
||||
clock_rate = (unsigned int)long_clock_rate;
|
||||
length = static_cast<unsigned int>(long_length);
|
||||
clock_rate = static_cast<unsigned int>(long_clock_rate);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -247,8 +247,8 @@ struct Time {
|
||||
}
|
||||
|
||||
if(long_length <= std::numeric_limits<unsigned int>::max() && long_clock_rate <= std::numeric_limits<unsigned int>::max()) {
|
||||
length = (unsigned int)long_length;
|
||||
clock_rate = (unsigned int)long_clock_rate;
|
||||
length = static_cast<unsigned int>(long_length);
|
||||
clock_rate = static_cast<unsigned int>(long_clock_rate);
|
||||
} else {
|
||||
length = std::numeric_limits<unsigned int>::max();
|
||||
clock_rate = 1u;
|
||||
|
@ -25,14 +25,14 @@ static float gzgetfloat(gzFile file) {
|
||||
int mantissa;
|
||||
mantissa = bytes[0] | (bytes[1] << 8) | ((bytes[2]&0x7f)|0x80) << 16;
|
||||
|
||||
float result = (float)mantissa;
|
||||
result = (float)ldexp(result, -23);
|
||||
float result = static_cast<float>(mantissa);
|
||||
result = static_cast<float>(ldexp(result, -23));
|
||||
|
||||
/* decode exponent */
|
||||
int exponent;
|
||||
exponent = ((bytes[2]&0x80) >> 7) | (bytes[3]&0x7f) << 1;
|
||||
exponent -= 127;
|
||||
result = (float)ldexp(result, exponent);
|
||||
result = static_cast<float>(ldexp(result, exponent));
|
||||
|
||||
/* flip sign if necessary */
|
||||
if(bytes[3]&0x80)
|
||||
@ -145,7 +145,7 @@ void UEF::get_next_pulses() {
|
||||
case 0x0113: {
|
||||
// TODO: something smarter than just converting this to an int
|
||||
float new_time_base = gzgetfloat(file_);
|
||||
time_base_ = (unsigned int)roundf(new_time_base);
|
||||
time_base_ = static_cast<unsigned int>(roundf(new_time_base));
|
||||
}
|
||||
break;
|
||||
|
||||
@ -184,7 +184,7 @@ void UEF::queue_explicit_bit_pattern(uint32_t length) {
|
||||
|
||||
void UEF::queue_integer_gap() {
|
||||
Time duration;
|
||||
duration.length = (unsigned int)gzget16(file_);
|
||||
duration.length = static_cast<unsigned int>(gzget16(file_));
|
||||
duration.clock_rate = time_base_;
|
||||
emplace_back(Pulse::Zero, duration);
|
||||
}
|
||||
@ -192,19 +192,19 @@ void UEF::queue_integer_gap() {
|
||||
void UEF::queue_floating_point_gap() {
|
||||
float length = gzgetfloat(file_);
|
||||
Time duration;
|
||||
duration.length = (unsigned int)(length * 4000000);
|
||||
duration.length = static_cast<unsigned int>(length * 4000000);
|
||||
duration.clock_rate = 4000000;
|
||||
emplace_back(Pulse::Zero, duration);
|
||||
}
|
||||
|
||||
void UEF::queue_carrier_tone() {
|
||||
unsigned int number_of_cycles = (unsigned int)gzget16(file_);
|
||||
unsigned int number_of_cycles = static_cast<unsigned int>(gzget16(file_));
|
||||
while(number_of_cycles--) queue_bit(1);
|
||||
}
|
||||
|
||||
void UEF::queue_carrier_tone_with_dummy() {
|
||||
unsigned int pre_cycles = (unsigned int)gzget16(file_);
|
||||
unsigned int post_cycles = (unsigned int)gzget16(file_);
|
||||
unsigned int pre_cycles = static_cast<unsigned int>(gzget16(file_));
|
||||
unsigned int post_cycles = static_cast<unsigned int>(gzget16(file_));
|
||||
while(pre_cycles--) queue_bit(1);
|
||||
queue_implicit_byte(0xaa);
|
||||
while(post_cycles--) queue_bit(1);
|
||||
|
@ -75,7 +75,7 @@ Shifter::Shifter() :
|
||||
}
|
||||
|
||||
void Shifter::process_pulse(const Storage::Tape::Tape::Pulse &pulse) {
|
||||
pll_.run_for(Cycles((int)((float)PLLClockRate * pulse.length.get_float())));
|
||||
pll_.run_for(Cycles((int)(static_cast<float>(PLLClockRate) * pulse.length.get_float())));
|
||||
|
||||
bool is_high = pulse.type == Storage::Tape::Tape::Pulse::High;
|
||||
if(is_high != was_high_) {
|
||||
@ -85,10 +85,10 @@ void Shifter::process_pulse(const Storage::Tape::Tape::Pulse &pulse) {
|
||||
}
|
||||
|
||||
void Shifter::digital_phase_locked_loop_output_bit(int value) {
|
||||
input_pattern_ = ((input_pattern_ << 1) | (unsigned int)value) & 0xf;
|
||||
input_pattern_ = ((input_pattern_ << 1) | static_cast<unsigned int>(value)) & 0xf;
|
||||
switch(input_pattern_) {
|
||||
case 0x5: delegate_->acorn_shifter_output_bit(0); input_pattern_ = 0; break;
|
||||
case 0xf: delegate_->acorn_shifter_output_bit(1); input_pattern_ = 0; break;
|
||||
default: break;;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ void TimedEventLoop::run_for(const Cycles cycles) {
|
||||
}
|
||||
|
||||
unsigned int TimedEventLoop::get_cycles_until_next_event() {
|
||||
return (unsigned int)std::max(cycles_until_event_, 0);
|
||||
return static_cast<unsigned int>(std::max(cycles_until_event_, 0));
|
||||
}
|
||||
|
||||
unsigned int TimedEventLoop::get_input_clock_rate() {
|
||||
@ -82,8 +82,8 @@ void TimedEventLoop::set_next_event_time_interval(Time interval) {
|
||||
assert(cycles_until_event_ == 0);
|
||||
cycles_until_event_ += (int)(numerator / denominator);
|
||||
assert(cycles_until_event_ >= 0);
|
||||
subcycles_until_event_.length = (unsigned int)(numerator % denominator);
|
||||
subcycles_until_event_.clock_rate = (unsigned int)denominator;
|
||||
subcycles_until_event_.length = static_cast<unsigned int>(numerator % denominator);
|
||||
subcycles_until_event_.clock_rate = static_cast<unsigned int>(denominator);
|
||||
subcycles_until_event_.simplify();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user