2018-04-03 02:42:41 +00:00
|
|
|
//
|
|
|
|
// MachinePicker.swift
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 02/04/2018.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2018 Thomas Harte. All rights reserved.
|
2018-04-03 02:42:41 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
|
|
|
|
class MachinePicker: NSObject {
|
|
|
|
@IBOutlet var machineSelector: NSTabView?
|
|
|
|
|
2018-05-03 23:37:32 +00:00
|
|
|
// MARK: - Apple II properties
|
|
|
|
@IBOutlet var appleIIModelButton: NSPopUpButton?
|
|
|
|
@IBOutlet var appleIIDiskControllerButton: NSPopUpButton?
|
|
|
|
|
2018-04-03 02:42:41 +00:00
|
|
|
// MARK: - Electron properties
|
|
|
|
@IBOutlet var electronDFSButton: NSButton?
|
|
|
|
@IBOutlet var electronADFSButton: NSButton?
|
|
|
|
|
|
|
|
// MARK: - CPC properties
|
|
|
|
@IBOutlet var cpcModelTypeButton: NSPopUpButton?
|
|
|
|
|
|
|
|
// MARK: - MSX properties
|
2019-03-01 01:54:43 +00:00
|
|
|
@IBOutlet var msxRegionButton: NSPopUpButton?
|
2018-04-03 02:42:41 +00:00
|
|
|
@IBOutlet var msxHasDiskDriveButton: NSButton?
|
|
|
|
|
|
|
|
// MARK: - Oric properties
|
|
|
|
@IBOutlet var oricModelTypeButton: NSPopUpButton?
|
2018-05-09 02:05:43 +00:00
|
|
|
@IBOutlet var oricDiskInterfaceButton: NSPopUpButton?
|
2018-04-03 02:42:41 +00:00
|
|
|
|
|
|
|
// MARK: - Vic-20 properties
|
|
|
|
@IBOutlet var vic20RegionButton: NSPopUpButton?
|
|
|
|
@IBOutlet var vic20MemorySizeButton: NSPopUpButton?
|
|
|
|
@IBOutlet var vic20HasC1540Button: NSButton?
|
|
|
|
|
|
|
|
// MARK: - ZX80 properties
|
|
|
|
@IBOutlet var zx80MemorySizeButton: NSPopUpButton?
|
|
|
|
@IBOutlet var zx80UsesZX81ROMButton: NSButton?
|
|
|
|
|
|
|
|
// MARK: - ZX81 properties
|
|
|
|
@IBOutlet var zx81MemorySizeButton: NSPopUpButton?
|
|
|
|
|
2018-04-04 03:01:12 +00:00
|
|
|
// MARK: - Preferences
|
|
|
|
func establishStoredOptions() {
|
|
|
|
let standardUserDefaults = UserDefaults.standard
|
|
|
|
|
|
|
|
// Machine type
|
|
|
|
if let machineIdentifier = standardUserDefaults.string(forKey: "new.machine") {
|
|
|
|
machineSelector?.selectTabViewItem(withIdentifier: machineIdentifier as Any)
|
|
|
|
}
|
|
|
|
|
2018-05-03 23:37:32 +00:00
|
|
|
// Apple II settings
|
|
|
|
appleIIModelButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.appleIIModel"))
|
|
|
|
appleIIDiskControllerButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.appleIIDiskController"))
|
|
|
|
|
2018-04-04 03:01:12 +00:00
|
|
|
// Electron settings
|
|
|
|
electronDFSButton?.state = standardUserDefaults.bool(forKey: "new.electronDFS") ? .on : .off
|
|
|
|
electronADFSButton?.state = standardUserDefaults.bool(forKey: "new.electronADFS") ? .on : .off
|
|
|
|
|
|
|
|
// CPC settings
|
|
|
|
cpcModelTypeButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.cpcModel"))
|
|
|
|
|
|
|
|
// MSX settings
|
2019-03-01 01:54:43 +00:00
|
|
|
msxRegionButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.msxRegion"))
|
2018-04-04 03:01:12 +00:00
|
|
|
msxHasDiskDriveButton?.state = standardUserDefaults.bool(forKey: "new.msxDiskDrive") ? .on : .off
|
|
|
|
|
|
|
|
// Oric settings
|
2018-05-09 02:05:43 +00:00
|
|
|
oricDiskInterfaceButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.oricDiskInterface"))
|
2018-04-04 03:01:12 +00:00
|
|
|
oricModelTypeButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.oricModel"))
|
|
|
|
|
|
|
|
// Vic-20 settings
|
|
|
|
vic20RegionButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.vic20Region"))
|
|
|
|
vic20MemorySizeButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.vic20MemorySize"))
|
|
|
|
vic20HasC1540Button?.state = standardUserDefaults.bool(forKey: "new.vic20C1540") ? .on : .off
|
|
|
|
|
|
|
|
// ZX80
|
|
|
|
zx80MemorySizeButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.zx80MemorySize"))
|
|
|
|
zx80UsesZX81ROMButton?.state = standardUserDefaults.bool(forKey: "new.zx80UsesZX81ROM") ? .on : .off
|
|
|
|
|
|
|
|
// ZX81
|
|
|
|
zx81MemorySizeButton?.selectItem(withTag: standardUserDefaults.integer(forKey: "new.zx81MemorySize"))
|
|
|
|
}
|
|
|
|
|
|
|
|
fileprivate func storeOptions() {
|
|
|
|
let standardUserDefaults = UserDefaults.standard
|
|
|
|
|
|
|
|
// Machine type
|
|
|
|
standardUserDefaults.set(machineSelector!.selectedTabViewItem!.identifier as! String, forKey: "new.machine")
|
|
|
|
|
2018-05-03 23:37:32 +00:00
|
|
|
// Apple II settings
|
|
|
|
standardUserDefaults.set(appleIIModelButton!.selectedTag(), forKey: "new.appleIIModel")
|
|
|
|
standardUserDefaults.set(appleIIDiskControllerButton!.selectedTag(), forKey: "new.appleIIDiskController")
|
|
|
|
|
2018-04-04 03:01:12 +00:00
|
|
|
// Electron settings
|
|
|
|
standardUserDefaults.set(electronDFSButton!.state == .on, forKey: "new.electronDFS")
|
|
|
|
standardUserDefaults.set(electronADFSButton!.state == .on, forKey: "new.electronADFS")
|
|
|
|
|
|
|
|
// CPC settings
|
|
|
|
standardUserDefaults.set(cpcModelTypeButton!.selectedTag(), forKey: "new.cpcModel")
|
|
|
|
|
|
|
|
// MSX settings
|
2019-03-01 01:54:43 +00:00
|
|
|
standardUserDefaults.set(msxRegionButton!.selectedTag(), forKey: "new.msxRegion")
|
2018-04-04 03:01:12 +00:00
|
|
|
standardUserDefaults.set(msxHasDiskDriveButton?.state == .on, forKey: "new.msxDiskDrive")
|
|
|
|
|
|
|
|
// Oric settings
|
2018-05-09 02:05:43 +00:00
|
|
|
standardUserDefaults.set(oricDiskInterfaceButton!.selectedTag(), forKey: "new.oricDiskInterface")
|
2018-04-04 03:01:12 +00:00
|
|
|
standardUserDefaults.set(oricModelTypeButton!.selectedTag(), forKey: "new.oricModel")
|
|
|
|
|
|
|
|
// Vic-20 settings
|
|
|
|
standardUserDefaults.set(vic20RegionButton!.selectedTag(), forKey: "new.vic20Region")
|
|
|
|
standardUserDefaults.set(vic20MemorySizeButton!.selectedTag(), forKey: "new.vic20MemorySize")
|
|
|
|
standardUserDefaults.set(vic20HasC1540Button?.state == .on, forKey: "new.vic20C1540")
|
|
|
|
|
|
|
|
// ZX80
|
|
|
|
standardUserDefaults.set(zx80MemorySizeButton!.selectedTag(), forKey: "new.zx80MemorySize")
|
|
|
|
standardUserDefaults.set(zx80UsesZX81ROMButton?.state == .on, forKey: "new.zx80UsesZX81ROM")
|
|
|
|
|
|
|
|
// ZX81
|
|
|
|
standardUserDefaults.set(zx81MemorySizeButton!.selectedTag(), forKey: "new.zx81MemorySize")
|
|
|
|
}
|
|
|
|
|
2018-04-03 02:42:41 +00:00
|
|
|
// MARK: - Machine builder
|
|
|
|
func selectedMachine() -> CSStaticAnalyser {
|
2018-04-04 03:01:12 +00:00
|
|
|
storeOptions()
|
|
|
|
|
2018-04-03 02:42:41 +00:00
|
|
|
switch machineSelector!.selectedTabViewItem!.identifier as! String {
|
|
|
|
case "electron":
|
|
|
|
return CSStaticAnalyser(electronDFS: electronDFSButton!.state == .on, adfs: electronADFSButton!.state == .on)!
|
|
|
|
|
2018-04-14 23:46:15 +00:00
|
|
|
case "appleii":
|
2018-05-03 23:37:32 +00:00
|
|
|
var model: CSMachineAppleIIModel = .appleII
|
|
|
|
switch appleIIModelButton!.selectedTag() {
|
|
|
|
case 1: model = .appleIIPlus
|
2018-07-25 22:58:34 +00:00
|
|
|
case 2: model = .appleIIe
|
2018-08-11 14:26:30 +00:00
|
|
|
case 3: model = .appleEnhancedIIe
|
2018-05-03 23:37:32 +00:00
|
|
|
case 0: fallthrough
|
|
|
|
default: model = .appleII
|
|
|
|
}
|
|
|
|
|
|
|
|
var diskController: CSMachineAppleIIDiskController = .none
|
|
|
|
switch appleIIDiskControllerButton!.selectedTag() {
|
|
|
|
case 13: diskController = .thirteenSector
|
|
|
|
case 16: diskController = .sixteenSector
|
|
|
|
case 0: fallthrough
|
2018-11-24 03:32:32 +00:00
|
|
|
default: diskController = .none
|
2018-05-03 23:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return CSStaticAnalyser(appleIIModel: model, diskController: diskController)
|
2018-04-14 23:46:15 +00:00
|
|
|
|
2018-04-03 02:42:41 +00:00
|
|
|
case "cpc":
|
|
|
|
switch cpcModelTypeButton!.selectedItem!.tag {
|
|
|
|
case 464: return CSStaticAnalyser(amstradCPCModel: .model464)
|
|
|
|
case 664: return CSStaticAnalyser(amstradCPCModel: .model664)
|
|
|
|
case 6128: fallthrough
|
|
|
|
default: return CSStaticAnalyser(amstradCPCModel: .model6128)
|
|
|
|
}
|
|
|
|
|
2019-05-04 02:16:07 +00:00
|
|
|
case "mac":
|
2019-07-17 20:02:25 +00:00
|
|
|
return CSStaticAnalyser(macintoshModel: .model512ke)
|
2019-05-04 02:16:07 +00:00
|
|
|
|
2018-04-03 02:42:41 +00:00
|
|
|
case "msx":
|
2019-03-01 01:54:43 +00:00
|
|
|
let hasDiskDrive = msxHasDiskDriveButton!.state == .on
|
|
|
|
switch msxRegionButton!.selectedItem?.tag {
|
|
|
|
case 2:
|
|
|
|
return CSStaticAnalyser(msxRegion: .japanese, hasDiskDrive: hasDiskDrive)
|
|
|
|
case 1:
|
|
|
|
return CSStaticAnalyser(msxRegion: .american, hasDiskDrive: hasDiskDrive)
|
|
|
|
case 0: fallthrough
|
|
|
|
default:
|
|
|
|
return CSStaticAnalyser(msxRegion: .european, hasDiskDrive: hasDiskDrive)
|
|
|
|
}
|
2018-04-03 02:42:41 +00:00
|
|
|
|
|
|
|
case "oric":
|
2018-05-09 02:05:43 +00:00
|
|
|
var diskInterface: CSMachineOricDiskInterface = .none
|
|
|
|
switch oricDiskInterfaceButton!.selectedTag() {
|
|
|
|
case 1: diskInterface = .microdisc
|
|
|
|
case 2: diskInterface = .pravetz
|
2018-11-24 03:32:32 +00:00
|
|
|
default: break;
|
2018-05-09 02:05:43 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
var model: CSMachineOricModel = .oric1
|
2018-04-03 02:42:41 +00:00
|
|
|
switch oricModelTypeButton!.selectedItem!.tag {
|
2018-05-09 02:05:43 +00:00
|
|
|
case 1: model = .oricAtmos
|
|
|
|
case 2: model = .pravetz
|
|
|
|
default: break;
|
2018-04-03 02:42:41 +00:00
|
|
|
}
|
|
|
|
|
2018-05-09 02:05:43 +00:00
|
|
|
return CSStaticAnalyser(oricModel: model, diskInterface: diskInterface)
|
|
|
|
|
2018-04-03 02:42:41 +00:00
|
|
|
case "vic20":
|
|
|
|
let memorySize = Kilobytes(vic20MemorySizeButton!.selectedItem!.tag)
|
|
|
|
let hasC1540 = vic20HasC1540Button!.state == .on
|
|
|
|
switch vic20RegionButton!.selectedItem?.tag {
|
|
|
|
case 1:
|
|
|
|
return CSStaticAnalyser(vic20Region: .american, memorySize: memorySize, hasC1540: hasC1540)
|
|
|
|
case 2:
|
|
|
|
return CSStaticAnalyser(vic20Region: .danish, memorySize: memorySize, hasC1540: hasC1540)
|
|
|
|
case 3:
|
|
|
|
return CSStaticAnalyser(vic20Region: .swedish, memorySize: memorySize, hasC1540: hasC1540)
|
|
|
|
case 4:
|
|
|
|
return CSStaticAnalyser(vic20Region: .japanese, memorySize: memorySize, hasC1540: hasC1540)
|
|
|
|
case 0: fallthrough
|
|
|
|
default:
|
|
|
|
return CSStaticAnalyser(vic20Region: .european, memorySize: memorySize, hasC1540: hasC1540)
|
|
|
|
}
|
|
|
|
|
|
|
|
case "zx80":
|
|
|
|
return CSStaticAnalyser(zx80MemorySize: Kilobytes(zx80MemorySizeButton!.selectedItem!.tag), useZX81ROM: zx80UsesZX81ROMButton!.state == .on)
|
|
|
|
|
|
|
|
case "zx81":
|
|
|
|
return CSStaticAnalyser(zx81MemorySize: Kilobytes(zx81MemorySizeButton!.selectedItem!.tag))
|
|
|
|
|
|
|
|
default: return CSStaticAnalyser()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|