diff --git a/Machines/Atari2600/Atari2600.hpp b/Machines/Atari2600/Atari2600.hpp index a682001bb..3ba31e972 100644 --- a/Machines/Atari2600/Atari2600.hpp +++ b/Machines/Atari2600/Atari2600.hpp @@ -44,7 +44,7 @@ class Machine: virtual void close_output(); virtual std::shared_ptr get_crt() { return bus_->tia_->get_crt(); } virtual std::shared_ptr get_speaker() { return bus_->speaker_; } - virtual void run_for_cycles(int number_of_cycles) { bus_->run_for_cycles(number_of_cycles); } + virtual void run_for(const Cycles &cycles) { bus_->run_for(cycles); } // to satisfy Outputs::CRT::Delegate virtual void crt_did_end_batch_of_frames(Outputs::CRT::CRT *crt, unsigned int number_of_frames, unsigned int number_of_unexpected_vertical_syncs); diff --git a/Machines/Atari2600/Bus.hpp b/Machines/Atari2600/Bus.hpp index 8d5d731a9..81e0fe5b1 100644 --- a/Machines/Atari2600/Bus.hpp +++ b/Machines/Atari2600/Bus.hpp @@ -13,6 +13,7 @@ #include "PIA.hpp" #include "Speaker.hpp" #include "TIA.hpp" +#include "../../Components/ClockReceiver.hpp" namespace Atari2600 { @@ -24,7 +25,7 @@ class Bus { cycles_since_video_update_(0), cycles_since_6532_update_(0) {} - virtual void run_for_cycles(int number_of_cycles) = 0; + virtual void run_for(const Cycles &cycles) = 0; virtual void set_reset_line(bool state) = 0; // the RIOT, TIA and speaker diff --git a/Machines/Atari2600/Cartridges/Cartridge.hpp b/Machines/Atari2600/Cartridges/Cartridge.hpp index 3eb467171..38dc63ecb 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(const Cycles &cycles) { CPU::MOS6502::Processor>::run_for(cycles); } void set_reset_line(bool state) { CPU::MOS6502::Processor>::set_reset_line(state); } void advance_cycles(unsigned int cycles) {} diff --git a/Machines/CRTMachine.hpp b/Machines/CRTMachine.hpp index 0a192a3c7..84a57684d 100644 --- a/Machines/CRTMachine.hpp +++ b/Machines/CRTMachine.hpp @@ -11,6 +11,7 @@ #include "../Outputs/CRT/CRT.hpp" #include "../Outputs/Speaker.hpp" +#include "../Components/ClockReceiver.hpp" namespace CRTMachine { @@ -41,8 +42,8 @@ class Machine { /// @returns The speaker that receives this machine's output, or @c nullptr if this machine is mute. virtual std::shared_ptr get_speaker() = 0; - /// Runs the machine for @c number_of_cycle cycles. - virtual void run_for_cycles(int number_of_cycles) = 0; + /// Runs the machine for @c cycles. + virtual void run_for(const Cycles &cycles) = 0; // TODO: sever the clock-rate stuff. double get_clock_rate() { diff --git a/Machines/Commodore/Vic-20/Vic20.hpp b/Machines/Commodore/Vic-20/Vic20.hpp index 6981022b7..2bda32a8e 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(const Cycles &cycles) { CPU::MOS6502::Processor::run_for(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 d730bc803..b6824535b 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(const Cycles &cycles) { CPU::MOS6502::Processor::run_for(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 54a6100f7..d82639d54 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -198,8 +198,8 @@ std::shared_ptr Machine::get_speaker() { return via_.ay8910; } -void Machine::run_for_cycles(int number_of_cycles) { - CPU::MOS6502::Processor::run_for(Cycles(number_of_cycles)); +void Machine::run_for(const Cycles &cycles) { + CPU::MOS6502::Processor::run_for(cycles); } #pragma mark - The 6522 diff --git a/Machines/Oric/Oric.hpp b/Machines/Oric/Oric.hpp index 43766d710..be1df2c78 100644 --- a/Machines/Oric/Oric.hpp +++ b/Machines/Oric/Oric.hpp @@ -85,7 +85,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); + virtual void run_for(const Cycles &cyclesß); // to satisfy MOS::MOS6522IRQDelegate::Delegate void mos6522_did_change_interrupt_status(void *mos6522); diff --git a/Machines/ZX8081/ZX8081.cpp b/Machines/ZX8081/ZX8081.cpp index 23fe0db44..8d0d2b42a 100644 --- a/Machines/ZX8081/ZX8081.cpp +++ b/Machines/ZX8081/ZX8081.cpp @@ -205,8 +205,8 @@ std::shared_ptr Machine::get_speaker() { return nullptr; } -void Machine::run_for_cycles(int number_of_cycles) { - CPU::Z80::Processor::run_for_cycles(number_of_cycles); +void Machine::run_for(const Cycles &cycles) { + CPU::Z80::Processor::run_for_cycles(int(cycles)); } void Machine::configure_as_target(const StaticAnalyser::Target &target) { diff --git a/Machines/ZX8081/ZX8081.hpp b/Machines/ZX8081/ZX8081.hpp index c2f36a6ff..e6b460c4e 100644 --- a/Machines/ZX8081/ZX8081.hpp +++ b/Machines/ZX8081/ZX8081.hpp @@ -56,7 +56,7 @@ class Machine: std::shared_ptr get_crt(); std::shared_ptr get_speaker(); - void run_for_cycles(int number_of_cycles); + void run_for(const Cycles &cycles); void configure_as_target(const StaticAnalyser::Target &target); diff --git a/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm b/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm index 16861bdaa..6ed1e1d79 100644 --- a/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm +++ b/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm @@ -104,7 +104,7 @@ struct MachineDelegate: CRTMachine::Machine::Delegate { - (void)runForNumberOfCycles:(int)numberOfCycles { @synchronized(self) { - self.machine->run_for_cycles(numberOfCycles); + self.machine->run_for(Cycles(numberOfCycles)); } } diff --git a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm index 493b4836c..0dfd05a63 100644 --- a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm +++ b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm @@ -25,8 +25,7 @@ - (instancetype)init { self = [super init]; - if(self) - { + if(self) { [self setOSROM:[self rom:@"os"]]; [self setBASICROM:[self rom:@"basic"]]; [self setDFSROM:[self rom:@"DFS-1770-2.20"]]; @@ -38,8 +37,7 @@ return self; } -- (NSData *)rom:(NSString *)name -{ +- (NSData *)rom:(NSString *)name { return [[NSBundle mainBundle] dataForResource:name withExtension:@"rom" subdirectory:@"ROMImages/Electron"]; } diff --git a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSOric.mm b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSOric.mm index 4680b4464..de5bcb3ef 100644 --- a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSOric.mm +++ b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSOric.mm @@ -15,16 +15,13 @@ #import "NSData+StdVector.h" #import "NSBundle+DataResource.h" -@implementation CSOric -{ +@implementation CSOric { Oric::Machine _oric; } -- (instancetype)init -{ +- (instancetype)init { self = [super init]; - if(self) - { + if(self) { NSData *basic10 = [self rom:@"basic10"]; NSData *basic11 = [self rom:@"basic11"]; NSData *colour = [self rom:@"colour"]; @@ -38,23 +35,19 @@ return self; } -- (NSData *)rom:(NSString *)name -{ +- (NSData *)rom:(NSString *)name { return [[NSBundle mainBundle] dataForResource:name withExtension:@"rom" subdirectory:@"ROMImages/Oric"]; } -- (CRTMachine::Machine * const)machine -{ +- (CRTMachine::Machine * const)machine { return &_oric; } #pragma mark - CSKeyboardMachine -- (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed -{ +- (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed { @synchronized(self) { - switch(key) - { + switch(key) { case VK_ANSI_0: _oric.set_key_state(Oric::Key::Key0, isPressed); break; case VK_ANSI_1: _oric.set_key_state(Oric::Key::Key1, isPressed); break; case VK_ANSI_2: _oric.set_key_state(Oric::Key::Key2, isPressed); break; @@ -137,8 +130,7 @@ } } -- (void)clearAllKeys -{ +- (void)clearAllKeys { _oric.clear_all_keys(); } diff --git a/Processors/6502/6502AllRAM.cpp b/Processors/6502/6502AllRAM.cpp index e9d864fe8..e706f599f 100644 --- a/Processors/6502/6502AllRAM.cpp +++ b/Processors/6502/6502AllRAM.cpp @@ -36,8 +36,8 @@ class ConcreteAllRAMProcessor: public AllRAMProcessor, public Processor::run_for_cycles(number_of_cycles); + void run_for(const Cycles &cycles) { + Processor::run_for(cycles); } bool is_jammed() { diff --git a/Processors/6502/6502AllRAM.hpp b/Processors/6502/6502AllRAM.hpp index a2009a323..8f9190668 100644 --- a/Processors/6502/6502AllRAM.hpp +++ b/Processors/6502/6502AllRAM.hpp @@ -22,7 +22,7 @@ class AllRAMProcessor: static AllRAMProcessor *Processor(); virtual ~AllRAMProcessor() {} - virtual void run_for_cycles(int number_of_cycles) = 0; + virtual void run_for(const Cycles &cycles) = 0; virtual bool is_jammed() = 0; virtual void set_irq_line(bool value) = 0; virtual void set_nmi_line(bool value) = 0;