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-10-12 02:20:13 +00:00
|
|
|
#include "StaticAnalyser.hpp"
|
|
|
|
|
|
|
|
#import "Clock_Signal-Swift.h"
|
|
|
|
|
2017-07-31 02:05:29 +00:00
|
|
|
@implementation CSStaticAnalyser {
|
2018-01-25 03:35:54 +00:00
|
|
|
std::vector<std::unique_ptr<Analyser::Static::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-25 02:48:44 +00:00
|
|
|
_targets = Analyser::Static::GetTargets([url fileSystemRepresentation]);
|
2018-01-24 03:18:16 +00:00
|
|
|
if(!_targets.size()) return nil;
|
2016-09-13 02:15:38 +00:00
|
|
|
|
2018-01-25 01:14:15 +00:00
|
|
|
// TODO: could this better be supplied by the analyser? A hypothetical file format might
|
|
|
|
// provide a better name for it contents than the file name?
|
2016-09-13 02:15:38 +00:00
|
|
|
_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-25 03:35:54 +00:00
|
|
|
switch(_targets.front()->machine) {
|
2018-01-25 02:48:44 +00:00
|
|
|
case Analyser::Machine::AmstradCPC: return nil;
|
|
|
|
case Analyser::Machine::Atari2600: return @"Atari2600Options";
|
|
|
|
case Analyser::Machine::Electron: return @"QuickLoadCompositeOptions";
|
|
|
|
case Analyser::Machine::MSX: return @"QuickLoadCompositeOptions";
|
|
|
|
case Analyser::Machine::Oric: return @"OricOptions";
|
2018-03-28 01:55:43 +00:00
|
|
|
case Analyser::Machine::Vic20: return @"QuickLoadOptions";
|
2018-01-25 02:48:44 +00:00
|
|
|
case Analyser::Machine::ZX8081: return @"ZX8081Options";
|
2016-10-11 11:39:48 +00:00
|
|
|
default: return nil;
|
2016-10-02 20:31:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-25 03:35:54 +00:00
|
|
|
- (std::vector<std::unique_ptr<Analyser::Static::Target>> &)targets {
|
2018-01-25 01:14:15 +00:00
|
|
|
return _targets;
|
|
|
|
}
|
|
|
|
|
2016-09-01 00:43:29 +00:00
|
|
|
@end
|
2017-08-17 15:00:08 +00:00
|
|
|
|
|
|
|
@implementation CSMediaSet {
|
2018-01-25 02:48:44 +00:00
|
|
|
Analyser::Static::Media _media;
|
2017-08-17 15:00:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype)initWithFileAtURL:(NSURL *)url {
|
|
|
|
self = [super init];
|
|
|
|
if(self) {
|
2018-01-25 02:48:44 +00:00
|
|
|
_media = Analyser::Static::GetMedia([url fileSystemRepresentation]);
|
2017-08-17 15:00:08 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)applyToMachine:(CSMachine *)machine {
|
|
|
|
[machine applyMedia:_media];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|