1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-23 20:29:42 +00:00

Attempted to bring some uniformity in application of configurations.

This commit is contained in:
Thomas Harte 2016-09-08 05:32:17 -04:00
parent 50175a9aed
commit 8c84f3581a
10 changed files with 46 additions and 27 deletions

View File

@ -9,6 +9,7 @@
#ifndef Vic20_hpp
#define Vic20_hpp
#include "../../ConfigurationTarget.hpp"
#include "../../CRTMachine.hpp"
#include "../../Typer.hpp"
@ -21,7 +22,6 @@
#include "../../../Storage/Tape/Tape.hpp"
#include "../../../Storage/Disk/Disk.hpp"
#include "../../../StaticAnalyser/StaticAnalyser.hpp"
namespace Commodore {
namespace Vic20 {
@ -254,7 +254,8 @@ class Machine:
public CRTMachine::Machine,
public MOS::MOS6522IRQDelegate::Delegate,
public Utility::TypeRecipient,
public Tape::Delegate {
public Tape::Delegate,
public ConfigurationTarget::Machine {
public:
Machine();

View File

@ -0,0 +1,27 @@
//
// ConfigurationTarget.h
// Clock Signal
//
// Created by Thomas Harte on 08/09/2016.
// Copyright © 2016 Thomas Harte. All rights reserved.
//
#ifndef ConfigurationTarget_hpp
#define ConfigurationTarget_hpp
#include "../StaticAnalyser/StaticAnalyser.hpp"
namespace ConfigurationTarget {
/*!
A ConfigurationTarget::Machine is anything that can accept a StaticAnalyser::Target
and configure itself appropriately.
*/
class Machine {
public:
virtual void configure_as_target(const StaticAnalyser::Target &target) =0;
};
}
#endif /* ConfigurationTarget_h */

View File

@ -11,8 +11,8 @@
#include "../../Processors/6502/CPU6502.hpp"
#include "../../Storage/Tape/Tape.hpp"
#include "../../StaticAnalyser/StaticAnalyser.hpp"
#include "../ConfigurationTarget.hpp"
#include "../CRTMachine.hpp"
#include "../Typer.hpp"
@ -139,8 +139,9 @@ class Speaker: public ::Outputs::Filter<Speaker> {
class Machine:
public CPU6502::Processor<Machine>,
public CRTMachine::Machine,
Tape::Delegate,
public Utility::TypeRecipient {
public Tape::Delegate,
public Utility::TypeRecipient,
public ConfigurationTarget::Machine {
public:
Machine();

View File

@ -454,6 +454,7 @@
4B92EAC91B7C112B00246143 /* 6502TimingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = 6502TimingTests.swift; sourceTree = "<group>"; };
4B96F7201D75119A0058BB2D /* Tape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Tape.cpp; path = ../../StaticAnalyser/Acorn/Tape.cpp; sourceTree = "<group>"; };
4B96F7211D75119A0058BB2D /* Tape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Tape.hpp; path = ../../StaticAnalyser/Acorn/Tape.hpp; sourceTree = "<group>"; };
4BA9C3CF1D8164A9002DDB61 /* ConfigurationTarget.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ConfigurationTarget.hpp; sourceTree = "<group>"; };
4BAB62AB1D3272D200DF5BA0 /* Disk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Disk.cpp; sourceTree = "<group>"; };
4BAB62AC1D3272D200DF5BA0 /* Disk.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Disk.hpp; sourceTree = "<group>"; };
4BAB62AE1D32730D00DF5BA0 /* Storage.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Storage.hpp; sourceTree = "<group>"; };
@ -1474,6 +1475,7 @@
4B2E2D9E1C3A070900138695 /* Electron */,
4B1E85731D170228001EF87D /* Typer.cpp */,
4B1E85741D170228001EF87D /* Typer.hpp */,
4BA9C3CF1D8164A9002DDB61 /* ConfigurationTarget.hpp */,
);
name = Machines;
path = ../../Machines;

View File

@ -44,10 +44,6 @@ class ElectronDocument: MachineDocument {
return "ElectronDocument"
}
override func configureAs(analysis: CSStaticAnalyser) {
analysis.applyToMachine(electron)
}
/* override func readFromURL(url: NSURL, ofType typeName: String) throws {
if let pathExtension = url.pathExtension {
switch pathExtension.lowercaseString {

View File

@ -100,6 +100,7 @@ class MachineDocument:
// MARK: configuring
func configureAs(analysis: CSStaticAnalyser) {
analysis.applyToMachine(self.machine)
}
// MARK: the pasteboard

View File

@ -41,10 +41,6 @@ class Vic20Document: MachineDocument {
return "Vic20Document"
}
override func configureAs(analysis: CSStaticAnalyser) {
analysis.applyToMachine(vic20)
}
override func readFromURL(url: NSURL, ofType typeName: String) throws {
if let pathExtension = url.pathExtension {
switch pathExtension.lowercaseString {

View File

@ -9,7 +9,9 @@
#import "CSMachine.h"
#import "CSMachine+Subclassing.h"
#import "CSMachine+Target.h"
#include "Typer.hpp"
#include "ConfigurationTarget.hpp"
@interface CSMachine()
- (void)speaker:(Outputs::Speaker *)speaker didCompleteSamples:(const int16_t *)samples length:(int)length;
@ -123,6 +125,12 @@ struct MachineDelegate: CRTMachine::Machine::Delegate {
typeRecipient->set_typer_for_string([paste UTF8String]);
}
- (void)applyTarget:(StaticAnalyser::Target)target {}
- (void)applyTarget:(StaticAnalyser::Target)target {
@synchronized(self) {
ConfigurationTarget::Machine *const configurationTarget =
dynamic_cast<ConfigurationTarget::Machine *>(self.machine);
if(configurationTarget) configurationTarget->configure_as_target(target);
}
}
@end

View File

@ -10,7 +10,6 @@
#include "Electron.hpp"
#import "CSMachine+Subclassing.h"
#import "CSMachine+Target.h"
#include "StaticAnalyser.hpp"
#include "TapeUEF.hpp"
@ -38,12 +37,6 @@
}
}
- (void)applyTarget:(StaticAnalyser::Target)target {
@synchronized(self) {
_electron.configure_as_target(target);
}
}
- (void)setROM:(nonnull NSData *)rom slot:(int)slot {
@synchronized(self) {
_electron.set_rom((Electron::ROMSlot)slot, rom.length, (const uint8_t *)rom.bytes);

View File

@ -46,12 +46,6 @@ using namespace Commodore::Vic20;
[self setROM:rom slot:Drive];
}
- (void)applyTarget:(StaticAnalyser::Target)target {
@synchronized(self) {
_vic20.configure_as_target(target);
}
}
- (BOOL)openTAPAtURL:(NSURL *)URL {
@synchronized(self) {
try {