2016-09-01 00:43:29 +00:00
|
|
|
//
|
|
|
|
// CSStaticAnalyser.m
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 31/08/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "CSStaticAnalyser.h"
|
|
|
|
|
|
|
|
#import "CSMachine.h"
|
|
|
|
#import "CSMachine+Target.h"
|
2016-09-01 02:03:42 +00:00
|
|
|
#import "CSMachine+Subclassing.h"
|
2016-09-01 00:43:29 +00:00
|
|
|
|
2016-10-12 02:20:13 +00:00
|
|
|
#include "StaticAnalyser.hpp"
|
|
|
|
|
2017-07-31 02:05:29 +00:00
|
|
|
#import "CSAmstradCPC.h"
|
2016-10-12 02:20:13 +00:00
|
|
|
#import "CSAtari2600.h"
|
|
|
|
#import "CSElectron.h"
|
2017-12-03 20:42:54 +00:00
|
|
|
#import "CSMSX.h"
|
2016-10-12 02:20:13 +00:00
|
|
|
#import "CSOric.h"
|
|
|
|
#import "CSVic20.h"
|
2017-08-27 20:42:16 +00:00
|
|
|
#import "CSZX8081+Instantiation.h"
|
2016-10-12 02:20:13 +00:00
|
|
|
|
|
|
|
#import "Clock_Signal-Swift.h"
|
|
|
|
|
2017-07-31 02:05:29 +00:00
|
|
|
@implementation CSStaticAnalyser {
|
2018-01-24 03:18:16 +00:00
|
|
|
std::vector<StaticAnalyser::Target> _targets;
|
2016-09-01 00:43:29 +00:00
|
|
|
}
|
|
|
|
|
2017-07-31 02:05:29 +00:00
|
|
|
- (instancetype)initWithFileAtURL:(NSURL *)url {
|
2016-09-01 00:43:29 +00:00
|
|
|
self = [super init];
|
2017-07-31 02:05:29 +00:00
|
|
|
if(self) {
|
2018-01-24 03:18:16 +00:00
|
|
|
_targets = StaticAnalyser::GetTargets([url fileSystemRepresentation]);
|
|
|
|
if(!_targets.size()) return nil;
|
2016-09-13 02:15:38 +00:00
|
|
|
|
|
|
|
// TODO: can this better be supplied by the analyser?
|
|
|
|
_displayName = [[url pathComponents] lastObject];
|
2016-09-01 00:43:29 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2017-07-31 02:05:29 +00:00
|
|
|
- (NSString *)optionsPanelNibName {
|
2018-01-24 03:18:16 +00:00
|
|
|
switch(_targets.front().machine) {
|
2017-08-27 21:11:35 +00:00
|
|
|
case StaticAnalyser::Target::AmstradCPC: return nil;
|
2017-07-31 02:05:29 +00:00
|
|
|
case StaticAnalyser::Target::Atari2600: return @"Atari2600Options";
|
2018-01-15 23:36:22 +00:00
|
|
|
case StaticAnalyser::Target::Electron: return @"QuickLoadCompositeOptions";
|
|
|
|
case StaticAnalyser::Target::MSX: return @"QuickLoadCompositeOptions";
|
2017-07-31 02:05:29 +00:00
|
|
|
case StaticAnalyser::Target::Oric: return @"OricOptions";
|
|
|
|
case StaticAnalyser::Target::Vic20: return @"Vic20Options";
|
|
|
|
case StaticAnalyser::Target::ZX8081: return @"ZX8081Options";
|
2016-10-11 11:39:48 +00:00
|
|
|
default: return nil;
|
2016-10-02 20:31:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-31 02:05:29 +00:00
|
|
|
- (CSMachine *)newMachine {
|
2018-01-24 03:18:16 +00:00
|
|
|
switch(_targets.front().machine) {
|
2017-07-31 02:05:29 +00:00
|
|
|
case StaticAnalyser::Target::AmstradCPC: return [[CSAmstradCPC alloc] init];
|
|
|
|
case StaticAnalyser::Target::Atari2600: return [[CSAtari2600 alloc] init];
|
|
|
|
case StaticAnalyser::Target::Electron: return [[CSElectron alloc] init];
|
2017-12-03 20:42:54 +00:00
|
|
|
case StaticAnalyser::Target::MSX: return [[CSMSX alloc] init];
|
2017-07-31 02:05:29 +00:00
|
|
|
case StaticAnalyser::Target::Oric: return [[CSOric alloc] init];
|
|
|
|
case StaticAnalyser::Target::Vic20: return [[CSVic20 alloc] init];
|
2018-01-24 03:18:16 +00:00
|
|
|
case StaticAnalyser::Target::ZX8081: return [[CSZX8081 alloc] initWithIntendedTarget:_targets.front()];
|
2016-10-11 11:39:48 +00:00
|
|
|
default: return nil;
|
2016-10-02 20:57:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-31 02:05:29 +00:00
|
|
|
- (void)applyToMachine:(CSMachine *)machine {
|
2018-01-24 03:18:16 +00:00
|
|
|
[machine applyTarget:_targets.front()];
|
2016-09-01 00:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
2017-08-17 15:00:08 +00:00
|
|
|
|
|
|
|
@implementation CSMediaSet {
|
|
|
|
StaticAnalyser::Media _media;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype)initWithFileAtURL:(NSURL *)url {
|
|
|
|
self = [super init];
|
|
|
|
if(self) {
|
|
|
|
_media = StaticAnalyser::GetMedia([url fileSystemRepresentation]);
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)applyToMachine:(CSMachine *)machine {
|
|
|
|
[machine applyMedia:_media];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|