diff --git a/Components/6560/6560.cpp b/Components/6560/6560.cpp index 1377ea9fc..bd07fa194 100644 --- a/Components/6560/6560.cpp +++ b/Components/6560/6560.cpp @@ -95,8 +95,8 @@ static uint8_t noise_pattern[] = { 0xf0, 0xe1, 0xe0, 0x78, 0x70, 0x38, 0x3c, 0x3e, 0x1e, 0x3c, 0x1e, 0x1c, 0x70, 0x3c, 0x38, 0x3f, }; -#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 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) == 0x7f) { up(r); _counters[r] = _control_registers[r]&0x7f; } void Speaker::get_samples(unsigned int number_of_samples, int16_t *target) diff --git a/Components/6560/6560.hpp b/Components/6560/6560.hpp index 3b14c40be..c30e074a0 100644 --- a/Components/6560/6560.hpp +++ b/Components/6560/6560.hpp @@ -68,7 +68,11 @@ template class MOS6560 { // show only the centre _crt->set_visible_area(_crt->get_rect_for_area(16, 237, 11*4, 55*4, 4.0f / 3.0f)); - _speaker->set_input_rate(255681.75); // assuming NTSC; clock rate / 4 + } + + void set_clock_rate(double clock_rate) + { + _speaker->set_input_rate(clock_rate / 4.0); } std::shared_ptr get_crt() { return _crt; } diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index cbe58f3f4..6c2f206a5 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -181,11 +181,19 @@ void Machine::set_region(Commodore::Vic20::Region region) { case PAL: set_clock_rate(1108404); - if(_mos6560) _mos6560->set_output_mode(MOS::MOS6560::OutputMode::PAL); + if(_mos6560) + { + _mos6560->set_output_mode(MOS::MOS6560::OutputMode::PAL); + _mos6560->set_clock_rate(1108404); + } break; case NTSC: set_clock_rate(1022727); - if(_mos6560) _mos6560->set_output_mode(MOS::MOS6560::OutputMode::NTSC); + if(_mos6560) + { + _mos6560->set_output_mode(MOS::MOS6560::OutputMode::NTSC); + _mos6560->set_clock_rate(1022727); + } break; } }