From a2b4003bb844d537811e4621c2adb8f8d048baa7 Mon Sep 17 00:00:00 2001 From: Luigi Thirty Date: Mon, 31 Jul 2017 22:39:28 -0400 Subject: [PATCH] more preferences work --- FruitMachine/AppleI/AppleI.swift | 7 +-- FruitMachine/PreferencesWindow.xib | 13 ++++- .../PreferencesWindowController.swift | 54 +++++++++++++++++++ 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/FruitMachine/AppleI/AppleI.swift b/FruitMachine/AppleI/AppleI.swift index 6cc7e18..ddc9f6b 100644 --- a/FruitMachine/AppleI/AppleI.swift +++ b/FruitMachine/AppleI/AppleI.swift @@ -57,16 +57,11 @@ class AppleI: NSObject { CPU.sharedInstance.memoryInterface.read_overrides.append(PIAOverrides.readKBDCR) } - func runFrame() { - let startTime = CFAbsoluteTimeGetCurrent() - + func runFrame() { CPU.sharedInstance.cycles = 0 CPU.sharedInstance.cyclesInBatch = AppleI.CYCLES_PER_BATCH CPU.sharedInstance.runCyclesBatch() - let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime - print("Time elapsed for runFrame: \(timeElapsed) s.") - //update the video display CVPixelBufferLockBaseAddress(emulatorViewDelegate.pixels!, CVPixelBufferLockFlags(rawValue: 0)) let pixelBase = CVPixelBufferGetBaseAddress(emulatorViewDelegate.pixels!) diff --git a/FruitMachine/PreferencesWindow.xib b/FruitMachine/PreferencesWindow.xib index 1f61b04..97b6d32 100644 --- a/FruitMachine/PreferencesWindow.xib +++ b/FruitMachine/PreferencesWindow.xib @@ -17,7 +17,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -102,6 +102,9 @@ + + + diff --git a/FruitMachine/PreferencesWindowController.swift b/FruitMachine/PreferencesWindowController.swift index 9adb100..1c9eb1b 100644 --- a/FruitMachine/PreferencesWindowController.swift +++ b/FruitMachine/PreferencesWindowController.swift @@ -36,8 +36,62 @@ class PreferencesWindowController: NSWindowController { } } + func windowWillClose(_ notification: Notification) { + defaults.set(path_ROMMonitor.stringValue, forKey: "path_ROMMonitor") + defaults.set(path_ROMCharacter.stringValue, forKey: "path_ROMCharacter") + defaults.set(path_ROMBasic.stringValue, forKey: "path_ROMBasic") + + defaults.synchronize() + } + override var windowNibName : NSNib.Name? { return NSNib.Name(rawValue: "PreferencesWindow") } + @IBAction func btn_click_Monitor(_ sender: NSButton) { + let picker = NSOpenPanel() + + picker.title = "Select your Monitor ROM (apple1.rom)" + picker.showsHiddenFiles = false + picker.canChooseFiles = true + picker.canChooseDirectories = false + picker.allowsMultipleSelection = false + picker.allowedFileTypes = ["rom"] + + if(picker.runModal() == .OK) { + path_ROMMonitor.stringValue = picker.url!.path + } + } + + @IBAction func btn_click_Character(_ sender: NSButton) { + let picker = NSOpenPanel() + + picker.title = "Select your Monitor ROM (apple1.vid)" + picker.showsHiddenFiles = false + picker.canChooseFiles = true + picker.canChooseDirectories = false + picker.allowsMultipleSelection = false + picker.allowedFileTypes = ["vid"] + + if(picker.runModal() == .OK) { + path_ROMCharacter.stringValue = picker.url!.path + } + } + + @IBAction func btn_click_BASIC(_ sender: NSButton) { + let picker = NSOpenPanel() + + picker.title = "Select your Monitor ROM (basic.bin)" + picker.showsHiddenFiles = false + picker.canChooseFiles = true + picker.canChooseDirectories = false + picker.allowsMultipleSelection = false + picker.allowedFileTypes = ["bin"] + + if(picker.runModal() == .OK) { + path_ROMBasic.stringValue = picker.url!.path + } + } + + }