diff --git a/Components/6532/6532.hpp b/Components/6532/6532.hpp index acfb7de78..bac2a3c3d 100644 --- a/Components/6532/6532.hpp +++ b/Components/6532/6532.hpp @@ -51,7 +51,7 @@ template class MOS6532 { 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) + 2; + timer_.value = ((unsigned int)value << timer_.activeShift) ; timer_.interrupt_enabled = !!(address&0x08); interrupt_status_ &= ~InterruptFlag::Timer; evaluate_interrupts(); @@ -119,7 +119,7 @@ template class MOS6532 { timer_.value -= number_of_cycles; } else { number_of_cycles -= timer_.value; - timer_.value = 0x100 - number_of_cycles; + timer_.value = (0x100 - number_of_cycles) & 0xff; timer_.activeShift = 0; interrupt_status_ |= InterruptFlag::Timer; evaluate_interrupts(); diff --git a/Machines/Atari2600/Atari2600.cpp b/Machines/Atari2600/Atari2600.cpp index aa6e3fdd7..e779952df 100644 --- a/Machines/Atari2600/Atari2600.cpp +++ b/Machines/Atari2600/Atari2600.cpp @@ -63,6 +63,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin cycles_since_speaker_update_ += cycles_run_for; cycles_since_video_update_ += cycles_run_for; + cycles_since_6532_update_ += (cycles_run_for / 3); if(operation != CPU6502::BusOperation::Ready) { @@ -218,7 +219,6 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin } if(!tia_->get_cycles_until_horizontal_blank(cycles_since_video_update_)) set_ready_line(false); - cycles_since_6532_update_ += (cycles_run_for / 3); return cycles_run_for / 3; } diff --git a/OSBindings/Mac/Clock SignalTests/6532Tests.swift b/OSBindings/Mac/Clock SignalTests/6532Tests.swift index 091fdfd0e..fa48039f5 100644 --- a/OSBindings/Mac/Clock SignalTests/6532Tests.swift +++ b/OSBindings/Mac/Clock SignalTests/6532Tests.swift @@ -21,10 +21,6 @@ class MOS6532Tests: XCTestCase { with6532 { // set a count of 128 at single-clock intervals $0.setValue(128, forRegister:0x14) - $0.run(forCycles: 1) - - // one cycle later the timer should still contain 128 - $0.run(forCycles: 1) XCTAssertEqual($0.value(forRegister: 4), 128) // run for one more clock and the count should now be 127 @@ -52,10 +48,6 @@ class MOS6532Tests: XCTestCase { with6532 { // set a count of 28 at eight-clock intervals $0.setValue(28, forRegister:0x15) - $0.run(forCycles: 1) - - // one cycle later the timer should still contain 28 - $0.run(forCycles: 1) XCTAssertEqual($0.value(forRegister: 4), 28) // one further cycle and the timer should hit 27 @@ -99,9 +91,6 @@ class MOS6532Tests: XCTestCase { $0.setValue(1, forRegister:0x1c) $0.run(forCycles: 1) - // run for two clocks and the count should now be zero - $0.run(forCycles: 2) - // interrupt shouldn't be signalled yet, bit should not be set XCTAssert(!$0.irqLine, "IRQ line should not be set") XCTAssert($0.value(forRegister: 5) == 0x00, "Counter interrupt should not be set")