1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-11 08:30:55 +00:00

Tested against public ROMs and corrected. Also moved the deferred adjustment into a more canonical place.

This commit is contained in:
Thomas Harte 2017-03-04 17:00:28 -05:00
parent e09b76bf32
commit d3257c345a
3 changed files with 3 additions and 14 deletions

View File

@ -51,7 +51,7 @@ template <class T> 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 T> 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();

View File

@ -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;
}

View File

@ -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")