2016-09-01 00:43:29 +00:00
|
|
|
//
|
|
|
|
// CSStaticAnalyser.m
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 31/08/2016.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2016 Thomas Harte. All rights reserved.
|
2016-09-01 00:43:29 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "CSStaticAnalyser.h"
|
|
|
|
|
|
|
|
#import "CSMachine.h"
|
|
|
|
#import "CSMachine+Target.h"
|
|
|
|
|
2016-10-12 02:20:13 +00:00
|
|
|
#include "StaticAnalyser.hpp"
|
|
|
|
|
2018-04-03 02:42:41 +00:00
|
|
|
#include "../../../../../Analyser/Static/Acorn/Target.hpp"
|
|
|
|
#include "../../../../../Analyser/Static/AmstradCPC/Target.hpp"
|
2018-04-24 04:14:45 +00:00
|
|
|
#include "../../../../../Analyser/Static/AppleII/Target.hpp"
|
2018-04-03 02:42:41 +00:00
|
|
|
#include "../../../../../Analyser/Static/Commodore/Target.hpp"
|
2019-06-03 18:50:36 +00:00
|
|
|
#include "../../../../../Analyser/Static/Macintosh/Target.hpp"
|
2018-04-03 02:42:41 +00:00
|
|
|
#include "../../../../../Analyser/Static/MSX/Target.hpp"
|
|
|
|
#include "../../../../../Analyser/Static/Oric/Target.hpp"
|
|
|
|
#include "../../../../../Analyser/Static/ZX8081/Target.hpp"
|
|
|
|
|
2016-10-12 02:20:13 +00:00
|
|
|
#import "Clock_Signal-Swift.h"
|
|
|
|
|
2017-07-31 02:05:29 +00:00
|
|
|
@implementation CSStaticAnalyser {
|
2018-04-14 23:46:15 +00:00
|
|
|
Analyser::Static::TargetList _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;
|
|
|
|
}
|
|
|
|
|
2018-04-03 02:42:41 +00:00
|
|
|
- (instancetype)initWithElectronDFS:(BOOL)dfs adfs:(BOOL)adfs {
|
|
|
|
self = [super init];
|
|
|
|
if(self) {
|
|
|
|
using Target = Analyser::Static::Acorn::Target;
|
|
|
|
std::unique_ptr<Target> target(new Target);
|
|
|
|
target->machine = Analyser::Machine::Electron;
|
|
|
|
target->has_dfs = !!dfs;
|
|
|
|
target->has_adfs = !!adfs;
|
|
|
|
_targets.push_back(std::move(target));
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype)initWithAmstradCPCModel:(CSMachineCPCModel)model {
|
|
|
|
self = [super init];
|
|
|
|
if(self) {
|
|
|
|
using Target = Analyser::Static::AmstradCPC::Target;
|
|
|
|
std::unique_ptr<Target> target(new Target);
|
|
|
|
target->machine = Analyser::Machine::AmstradCPC;
|
|
|
|
switch(model) {
|
|
|
|
case CSMachineCPCModel464: target->model = Analyser::Static::AmstradCPC::Target::Model::CPC464; break;
|
|
|
|
case CSMachineCPCModel664: target->model = Analyser::Static::AmstradCPC::Target::Model::CPC664; break;
|
|
|
|
case CSMachineCPCModel6128: target->model = Analyser::Static::AmstradCPC::Target::Model::CPC6128; break;
|
|
|
|
}
|
|
|
|
_targets.push_back(std::move(target));
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2019-03-01 01:54:43 +00:00
|
|
|
- (instancetype)initWithMSXRegion:(CSMachineMSXRegion)region hasDiskDrive:(BOOL)hasDiskDrive {
|
2018-04-03 02:42:41 +00:00
|
|
|
self = [super init];
|
|
|
|
if(self) {
|
|
|
|
using Target = Analyser::Static::MSX::Target;
|
|
|
|
std::unique_ptr<Target> target(new Target);
|
|
|
|
target->machine = Analyser::Machine::MSX;
|
|
|
|
target->has_disk_drive = !!hasDiskDrive;
|
2019-03-01 01:54:43 +00:00
|
|
|
switch(region) {
|
|
|
|
case CSMachineMSXRegionAmerican: target->region = Analyser::Static::MSX::Target::Region::USA; break;
|
|
|
|
case CSMachineMSXRegionEuropean: target->region = Analyser::Static::MSX::Target::Region::Europe; break;
|
|
|
|
case CSMachineMSXRegionJapanese: target->region = Analyser::Static::MSX::Target::Region::Japan; break;
|
|
|
|
}
|
2018-04-03 02:42:41 +00:00
|
|
|
_targets.push_back(std::move(target));
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2018-05-09 02:05:43 +00:00
|
|
|
- (instancetype)initWithOricModel:(CSMachineOricModel)model diskInterface:(CSMachineOricDiskInterface)diskInterface {
|
2018-04-03 02:42:41 +00:00
|
|
|
self = [super init];
|
|
|
|
if(self) {
|
|
|
|
using Target = Analyser::Static::Oric::Target;
|
|
|
|
std::unique_ptr<Target> target(new Target);
|
|
|
|
target->machine = Analyser::Machine::Oric;
|
2018-05-09 02:05:43 +00:00
|
|
|
switch(model) {
|
|
|
|
case CSMachineOricModelOric1: target->rom = Target::ROM::BASIC10; break;
|
|
|
|
case CSMachineOricModelOricAtmos: target->rom = Target::ROM::BASIC11; break;
|
|
|
|
case CSMachineOricModelPravetz: target->rom = Target::ROM::Pravetz; break;
|
|
|
|
}
|
|
|
|
switch(diskInterface) {
|
|
|
|
case CSMachineOricDiskInterfaceNone: target->disk_interface = Target::DiskInterface::None; break;
|
|
|
|
case CSMachineOricDiskInterfaceMicrodisc: target->disk_interface = Target::DiskInterface::Microdisc; break;
|
|
|
|
case CSMachineOricDiskInterfacePravetz: target->disk_interface = Target::DiskInterface::Pravetz; break;
|
|
|
|
}
|
2018-04-03 02:42:41 +00:00
|
|
|
_targets.push_back(std::move(target));
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype)initWithVic20Region:(CSMachineVic20Region)region memorySize:(Kilobytes)memorySize hasC1540:(BOOL)hasC1540 {
|
|
|
|
self = [super init];
|
|
|
|
if(self) {
|
|
|
|
using Target = Analyser::Static::Commodore::Target;
|
|
|
|
std::unique_ptr<Target> target(new Target);
|
|
|
|
target->machine = Analyser::Machine::Vic20;
|
|
|
|
switch(region) {
|
|
|
|
case CSMachineVic20RegionDanish: target->region = Target::Region::Danish; break;
|
|
|
|
case CSMachineVic20RegionSwedish: target->region = Target::Region::Swedish; break;
|
|
|
|
case CSMachineVic20RegionAmerican: target->region = Target::Region::American; break;
|
|
|
|
case CSMachineVic20RegionEuropean: target->region = Target::Region::European; break;
|
|
|
|
case CSMachineVic20RegionJapanese: target->region = Target::Region::Japanese; break;
|
|
|
|
}
|
|
|
|
switch(memorySize) {
|
|
|
|
default: target->memory_model = Target::MemoryModel::Unexpanded; break;
|
|
|
|
case 8: target->memory_model = Target::MemoryModel::EightKB; break;
|
|
|
|
case 32: target->memory_model = Target::MemoryModel::ThirtyTwoKB; break;
|
|
|
|
}
|
|
|
|
target->has_c1540 = !!hasC1540;
|
|
|
|
_targets.push_back(std::move(target));
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Analyser::Static::ZX8081::Target::MemoryModel ZX8081MemoryModelFromSize(Kilobytes size) {
|
|
|
|
using MemoryModel = Analyser::Static::ZX8081::Target::MemoryModel;
|
|
|
|
switch(size) {
|
|
|
|
default: return MemoryModel::Unexpanded;
|
|
|
|
case 16: return MemoryModel::SixteenKB;
|
|
|
|
case 64: return MemoryModel::SixtyFourKB;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype)initWithZX80MemorySize:(Kilobytes)memorySize useZX81ROM:(BOOL)useZX81ROM {
|
|
|
|
self = [super init];
|
|
|
|
if(self) {
|
|
|
|
using Target = Analyser::Static::ZX8081::Target;
|
|
|
|
std::unique_ptr<Target> target(new Target);
|
|
|
|
target->machine = Analyser::Machine::ZX8081;
|
|
|
|
target->is_ZX81 = false;
|
|
|
|
target->ZX80_uses_ZX81_ROM = !!useZX81ROM;
|
|
|
|
target->memory_model = ZX8081MemoryModelFromSize(memorySize);
|
|
|
|
_targets.push_back(std::move(target));
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype)initWithZX81MemorySize:(Kilobytes)memorySize {
|
|
|
|
self = [super init];
|
|
|
|
if(self) {
|
|
|
|
using Target = Analyser::Static::ZX8081::Target;
|
|
|
|
std::unique_ptr<Target> target(new Target);
|
|
|
|
target->machine = Analyser::Machine::ZX8081;
|
|
|
|
target->is_ZX81 = true;
|
|
|
|
target->memory_model = ZX8081MemoryModelFromSize(memorySize);
|
|
|
|
_targets.push_back(std::move(target));
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2018-05-03 23:37:32 +00:00
|
|
|
- (instancetype)initWithAppleIIModel:(CSMachineAppleIIModel)model diskController:(CSMachineAppleIIDiskController)diskController {
|
2018-04-14 23:46:15 +00:00
|
|
|
self = [super init];
|
|
|
|
if(self) {
|
2018-04-24 04:14:45 +00:00
|
|
|
using Target = Analyser::Static::AppleII::Target;
|
2018-04-14 23:46:15 +00:00
|
|
|
std::unique_ptr<Target> target(new Target);
|
|
|
|
target->machine = Analyser::Machine::AppleII;
|
2018-07-25 22:58:34 +00:00
|
|
|
switch(model) {
|
2018-11-24 03:32:32 +00:00
|
|
|
default: target->model = Target::Model::II; break;
|
2018-08-11 14:26:30 +00:00
|
|
|
case CSMachineAppleIIModelAppleIIPlus: target->model = Target::Model::IIplus; break;
|
|
|
|
case CSMachineAppleIIModelAppleIIe: target->model = Target::Model::IIe; break;
|
|
|
|
case CSMachineAppleIIModelAppleEnhancedIIe: target->model = Target::Model::EnhancedIIe; break;
|
2018-07-25 22:58:34 +00:00
|
|
|
}
|
2018-05-03 23:37:32 +00:00
|
|
|
switch(diskController) {
|
|
|
|
default:
|
|
|
|
case CSMachineAppleIIDiskControllerNone: target->disk_controller = Target::DiskController::None; break;
|
|
|
|
case CSMachineAppleIIDiskControllerSixteenSector: target->disk_controller = Target::DiskController::SixteenSector; break;
|
|
|
|
case CSMachineAppleIIDiskControllerThirteenSector: target->disk_controller = Target::DiskController::ThirteenSector; break;
|
|
|
|
}
|
2018-04-14 23:46:15 +00:00
|
|
|
_targets.push_back(std::move(target));
|
|
|
|
}
|
|
|
|
return self;
|
2019-05-04 02:16:07 +00:00
|
|
|
}
|
2018-04-14 23:46:15 +00:00
|
|
|
|
2019-05-04 02:16:07 +00:00
|
|
|
- (instancetype)initWithMacintoshModel:(CSMachineMacintoshModel)model {
|
|
|
|
self = [super init];
|
|
|
|
if(self) {
|
2019-06-03 18:50:36 +00:00
|
|
|
using Target = Analyser::Static::Macintosh::Target;
|
2019-05-04 02:16:07 +00:00
|
|
|
std::unique_ptr<Target> target(new Target);
|
|
|
|
target->machine = Analyser::Machine::Macintosh;
|
2019-07-17 20:02:25 +00:00
|
|
|
|
|
|
|
using Model = Target::Model;
|
|
|
|
switch(model) {
|
|
|
|
default:
|
|
|
|
case CSMachineMacintoshModel128k: target->model = Model::Mac128k; break;
|
|
|
|
case CSMachineMacintoshModel512k: target->model = Model::Mac512k; break;
|
|
|
|
case CSMachineMacintoshModel512ke: target->model = Model::Mac512ke; break;
|
|
|
|
case CSMachineMacintoshModelPlus: target->model = Model::MacPlus; break;
|
|
|
|
}
|
|
|
|
|
2019-05-04 02:16:07 +00:00
|
|
|
_targets.push_back(std::move(target));
|
|
|
|
}
|
|
|
|
return self;
|
2018-04-14 23:46:15 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 04:04:12 +00:00
|
|
|
- (instancetype)initWithAtariSTModel:(CSMachineAtariSTModel)model {
|
|
|
|
self = [super init];
|
|
|
|
if(self) {
|
|
|
|
using Target = Analyser::Static::Macintosh::Target;
|
|
|
|
std::unique_ptr<Target> target(new Target);
|
|
|
|
target->machine = Analyser::Machine::AtariST;
|
|
|
|
_targets.push_back(std::move(target));
|
|
|
|
}
|
|
|
|
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-10-24 02:30:24 +00:00
|
|
|
case Analyser::Machine::AmstradCPC: return @"CompositeOptions";
|
2019-02-13 00:52:32 +00:00
|
|
|
case Analyser::Machine::AppleII: return @"AppleIIOptions";
|
2018-10-24 02:30:24 +00:00
|
|
|
case Analyser::Machine::Atari2600: return @"Atari2600Options";
|
2019-03-03 03:59:40 +00:00
|
|
|
case Analyser::Machine::ColecoVision: return @"CompositeOptions";
|
2018-10-24 02:30:24 +00:00
|
|
|
case Analyser::Machine::Electron: return @"QuickLoadCompositeOptions";
|
2019-09-20 02:32:12 +00:00
|
|
|
case Analyser::Machine::Macintosh: return @"MacintoshOptions";
|
2018-10-24 02:30:24 +00:00
|
|
|
case Analyser::Machine::MasterSystem: return @"CompositeOptions";
|
|
|
|
case Analyser::Machine::MSX: return @"QuickLoadCompositeOptions";
|
|
|
|
case Analyser::Machine::Oric: return @"OricOptions";
|
|
|
|
case Analyser::Machine::Vic20: return @"QuickLoadCompositeOptions";
|
|
|
|
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-04-14 23:46:15 +00:00
|
|
|
- (Analyser::Static::TargetList &)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
|