diff --git a/Machines/Atari2600/Cartridges/Cartridge.hpp b/Machines/Atari2600/Cartridges/Cartridge.hpp index fa445fcd1..3eb467171 100644 --- a/Machines/Atari2600/Cartridges/Cartridge.hpp +++ b/Machines/Atari2600/Cartridges/Cartridge.hpp @@ -22,7 +22,7 @@ template class Cartridge: Cartridge(const std::vector &rom) : rom_(rom) {} - void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor>::run_for_cycles(number_of_cycles); } + void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor>::run_for(Cycles(number_of_cycles)); } void set_reset_line(bool state) { CPU::MOS6502::Processor>::set_reset_line(state); } void advance_cycles(unsigned int cycles) {} diff --git a/Machines/Commodore/1540/C1540.cpp b/Machines/Commodore/1540/C1540.cpp index ca92c51c2..ae3266038 100644 --- a/Machines/Commodore/1540/C1540.cpp +++ b/Machines/Commodore/1540/C1540.cpp @@ -80,7 +80,7 @@ void Machine::set_disk(std::shared_ptr disk) { } void Machine::run_for_cycles(int number_of_cycles) { - CPU::MOS6502::Processor::run_for_cycles(number_of_cycles); + CPU::MOS6502::Processor::run_for(Cycles(number_of_cycles)); set_motor_on(drive_VIA_.get_motor_enabled()); if(drive_VIA_.get_motor_enabled()) // TODO: motor speed up/down Storage::Disk::Controller::run_for_cycles(number_of_cycles); diff --git a/Machines/Commodore/Vic-20/Vic20.hpp b/Machines/Commodore/Vic-20/Vic20.hpp index e70c845cd..6981022b7 100644 --- a/Machines/Commodore/Vic-20/Vic20.hpp +++ b/Machines/Commodore/Vic-20/Vic20.hpp @@ -174,7 +174,7 @@ class Machine: virtual void close_output(); virtual std::shared_ptr get_crt() { return mos6560_->get_crt(); } virtual std::shared_ptr get_speaker() { return mos6560_->get_speaker(); } - virtual void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor::run_for_cycles(number_of_cycles); } + virtual void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor::run_for(Cycles(number_of_cycles)); } // to satisfy MOS::MOS6522::Delegate virtual void mos6522_did_change_interrupt_status(void *mos6522); diff --git a/Machines/Electron/Electron.hpp b/Machines/Electron/Electron.hpp index f24462a51..d730bc803 100644 --- a/Machines/Electron/Electron.hpp +++ b/Machines/Electron/Electron.hpp @@ -94,7 +94,7 @@ class Machine: virtual void close_output(); virtual std::shared_ptr get_crt(); virtual std::shared_ptr get_speaker(); - virtual void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor::run_for_cycles(number_of_cycles); } + virtual void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor::run_for(Cycles(number_of_cycles)); } // to satisfy Tape::Delegate virtual void tape_did_change_interrupt_status(Tape *tape); diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index 3310cc319..54a6100f7 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -199,7 +199,7 @@ std::shared_ptr Machine::get_speaker() { } void Machine::run_for_cycles(int number_of_cycles) { - CPU::MOS6502::Processor::run_for_cycles(number_of_cycles); + CPU::MOS6502::Processor::run_for(Cycles(number_of_cycles)); } #pragma mark - The 6522 diff --git a/Processors/6502/6502.hpp b/Processors/6502/6502.hpp index 75763455c..8eb871286 100644 --- a/Processors/6502/6502.hpp +++ b/Processors/6502/6502.hpp @@ -13,6 +13,7 @@ #include #include "../RegisterSizes.hpp" +#include "../../Components/ClockReceiver.hpp" namespace CPU { namespace MOS6502 { @@ -127,7 +128,7 @@ class ProcessorBase { that will cause call outs when the program counter reaches those addresses. @c return_from_subroutine can be used to exit from a jammed state. */ -template class Processor: public ProcessorBase { +template class Processor: public ProcessorBase, public ClockReceiver> { private: const MicroOp *scheduled_program_counter_; @@ -290,9 +291,9 @@ template class Processor: public ProcessorBase { The 6502 will call that method for all bus accesses. The 6502 is guaranteed to perform one bus operation call per cycle. If it is a read operation then @c value will be seeded with the value 0xff. - @param number_of_cycles The number of cycles to run the 6502 for. + @param cycles The number of cycles to run the 6502 for. */ - void run_for_cycles(int number_of_cycles) { + void run_for(const Cycles &cycles) { static const MicroOp doBranch[] = { CycleReadFromPC, CycleAddSignedOperandToPC, @@ -339,7 +340,7 @@ template class Processor: public ProcessorBase { if(number_of_cycles <= 0) break; checkSchedule(); - number_of_cycles += cycles_left_to_run_; + int number_of_cycles = int(cycles) + cycles_left_to_run_; while(number_of_cycles > 0) {