1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-26 09:29:45 +00:00

Switched CRTMachine over to use Cycles as an explicit statement of units, and followed through on the effects of that.

This commit is contained in:
Thomas Harte 2017-07-22 22:17:29 -04:00
parent 83628b285b
commit 2ff157cf7a
15 changed files with 29 additions and 37 deletions

View File

@ -44,7 +44,7 @@ class Machine:
virtual void close_output();
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt() { return bus_->tia_->get_crt(); }
virtual std::shared_ptr<Outputs::Speaker> 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);

View File

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

View File

@ -22,7 +22,7 @@ template<class T> class Cartridge:
Cartridge(const std::vector<uint8_t> &rom) :
rom_(rom) {}
void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor<Cartridge<T>>::run_for(Cycles(number_of_cycles)); }
void run_for(const Cycles &cycles) { CPU::MOS6502::Processor<Cartridge<T>>::run_for(cycles); }
void set_reset_line(bool state) { CPU::MOS6502::Processor<Cartridge<T>>::set_reset_line(state); }
void advance_cycles(unsigned int cycles) {}

View File

@ -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<Outputs::Speaker> 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() {

View File

@ -174,7 +174,7 @@ class Machine:
virtual void close_output();
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt() { return mos6560_->get_crt(); }
virtual std::shared_ptr<Outputs::Speaker> get_speaker() { return mos6560_->get_speaker(); }
virtual void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor<Machine>::run_for(Cycles(number_of_cycles)); }
virtual void run_for(const Cycles &cycles) { CPU::MOS6502::Processor<Machine>::run_for(cycles); }
// to satisfy MOS::MOS6522::Delegate
virtual void mos6522_did_change_interrupt_status(void *mos6522);

View File

@ -94,7 +94,7 @@ class Machine:
virtual void close_output();
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt();
virtual std::shared_ptr<Outputs::Speaker> get_speaker();
virtual void run_for_cycles(int number_of_cycles) { CPU::MOS6502::Processor<Machine>::run_for(Cycles(number_of_cycles)); }
virtual void run_for(const Cycles &cycles) { CPU::MOS6502::Processor<Machine>::run_for(cycles); }
// to satisfy Tape::Delegate
virtual void tape_did_change_interrupt_status(Tape *tape);

View File

@ -198,8 +198,8 @@ std::shared_ptr<Outputs::Speaker> Machine::get_speaker() {
return via_.ay8910;
}
void Machine::run_for_cycles(int number_of_cycles) {
CPU::MOS6502::Processor<Machine>::run_for(Cycles(number_of_cycles));
void Machine::run_for(const Cycles &cycles) {
CPU::MOS6502::Processor<Machine>::run_for(cycles);
}
#pragma mark - The 6522

View File

@ -85,7 +85,7 @@ class Machine:
virtual void close_output();
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt();
virtual std::shared_ptr<Outputs::Speaker> 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);

View File

@ -205,8 +205,8 @@ std::shared_ptr<Outputs::Speaker> Machine::get_speaker() {
return nullptr;
}
void Machine::run_for_cycles(int number_of_cycles) {
CPU::Z80::Processor<Machine>::run_for_cycles(number_of_cycles);
void Machine::run_for(const Cycles &cycles) {
CPU::Z80::Processor<Machine>::run_for_cycles(int(cycles));
}
void Machine::configure_as_target(const StaticAnalyser::Target &target) {

View File

@ -56,7 +56,7 @@ class Machine:
std::shared_ptr<Outputs::CRT::CRT> get_crt();
std::shared_ptr<Outputs::Speaker> get_speaker();
void run_for_cycles(int number_of_cycles);
void run_for(const Cycles &cycles);
void configure_as_target(const StaticAnalyser::Target &target);

View File

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

View File

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

View File

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

View File

@ -36,8 +36,8 @@ class ConcreteAllRAMProcessor: public AllRAMProcessor, public Processor<Concrete
return 1;
}
void run_for_cycles(int number_of_cycles) {
Processor<ConcreteAllRAMProcessor>::run_for_cycles(number_of_cycles);
void run_for(const Cycles &cycles) {
Processor<ConcreteAllRAMProcessor>::run_for(cycles);
}
bool is_jammed() {

View File

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