diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 63a0de718..f47d5b53d 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -23,7 +23,6 @@ 4B2A53A21D117D36003C6002 /* CSElectron.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B2A539C1D117D36003C6002 /* CSElectron.mm */; }; 4B2A53A31D117D36003C6002 /* CSVic20.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B2A539E1D117D36003C6002 /* CSVic20.mm */; }; 4B2BFC5F1D613E0200BA3AA9 /* TapePRG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2BFC5D1D613E0200BA3AA9 /* TapePRG.cpp */; }; - 4B2E2D951C399D1200138695 /* ElectronDocument.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B2E2D931C399D1200138695 /* ElectronDocument.xib */; }; 4B2E2D9A1C3A06EC00138695 /* Atari2600.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2E2D971C3A06EC00138695 /* Atari2600.cpp */; }; 4B2E2D9D1C3A070400138695 /* Electron.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2E2D9B1C3A070400138695 /* Electron.cpp */; }; 4B30512D1D989E2200B4FED8 /* Drive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B30512B1D989E2200B4FED8 /* Drive.cpp */; }; @@ -49,13 +48,14 @@ 4B69FB461C4D950F00B5F0AA /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B69FB451C4D950F00B5F0AA /* libz.tbd */; }; 4B6C73BD1D387AE500AFCFCA /* DiskController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B6C73BB1D387AE500AFCFCA /* DiskController.cpp */; }; 4B73C71A1D036BD90074D992 /* Vic20Document.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B73C7191D036BD90074D992 /* Vic20Document.swift */; }; - 4B73C71D1D036C030074D992 /* Vic20Document.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B73C71B1D036C030074D992 /* Vic20Document.xib */; }; 4B8FE21B1DA19D5F0090D3CE /* Atari2600Options.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B8FE2131DA19D5F0090D3CE /* Atari2600Options.xib */; }; 4B8FE21C1DA19D5F0090D3CE /* MachineDocument.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B8FE2151DA19D5F0090D3CE /* MachineDocument.xib */; }; 4B8FE21D1DA19D5F0090D3CE /* ElectronOptions.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B8FE2171DA19D5F0090D3CE /* ElectronOptions.xib */; }; 4B8FE21E1DA19D5F0090D3CE /* Vic20Options.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B8FE2191DA19D5F0090D3CE /* Vic20Options.xib */; }; 4B8FE2201DA19D7C0090D3CE /* Atari2600OptionsPanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8FE21F1DA19D7C0090D3CE /* Atari2600OptionsPanel.swift */; }; 4B8FE2221DA19FB20090D3CE /* MachinePanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8FE2211DA19FB20090D3CE /* MachinePanel.swift */; }; + 4B8FE2241DA1DC2D0090D3CE /* Bundle+DataForResource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8FE2231DA1DC2D0090D3CE /* Bundle+DataForResource.swift */; }; + 4B8FE2271DA1DE2D0090D3CE /* NSBundle+DataResource.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8FE2261DA1DE2D0090D3CE /* NSBundle+DataResource.m */; }; 4B92EACA1B7C112B00246143 /* 6502TimingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B92EAC91B7C112B00246143 /* 6502TimingTests.swift */; }; 4B96F7221D75119A0058BB2D /* Tape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B96F7201D75119A0058BB2D /* Tape.cpp */; }; 4BA22B071D8817CE0008C640 /* Disk.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BA22B051D8817CE0008C640 /* Disk.cpp */; }; @@ -334,7 +334,6 @@ 4BB697CB1D4B6D3E00248BDF /* TimedEventLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BB697C91D4B6D3E00248BDF /* TimedEventLoop.cpp */; }; 4BB697CE1D4BA44400248BDF /* CommodoreGCR.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BB697CC1D4BA44400248BDF /* CommodoreGCR.cpp */; }; 4BB73EA21B587A5100552FC2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB73EA11B587A5100552FC2 /* AppDelegate.swift */; }; - 4BB73EA71B587A5100552FC2 /* Atari2600Document.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4BB73EA51B587A5100552FC2 /* Atari2600Document.xib */; }; 4BB73EA91B587A5100552FC2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4BB73EA81B587A5100552FC2 /* Assets.xcassets */; }; 4BB73EAC1B587A5100552FC2 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4BB73EAA1B587A5100552FC2 /* MainMenu.xib */; }; 4BB73EB71B587A5100552FC2 /* AllSuiteATests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB73EB61B587A5100552FC2 /* AllSuiteATests.swift */; }; @@ -426,7 +425,6 @@ 4B2A539E1D117D36003C6002 /* CSVic20.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CSVic20.mm; sourceTree = ""; }; 4B2BFC5D1D613E0200BA3AA9 /* TapePRG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TapePRG.cpp; sourceTree = ""; }; 4B2BFC5E1D613E0200BA3AA9 /* TapePRG.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TapePRG.hpp; sourceTree = ""; }; - 4B2E2D941C399D1200138695 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/ElectronDocument.xib; sourceTree = ""; }; 4B2E2D971C3A06EC00138695 /* Atari2600.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Atari2600.cpp; sourceTree = ""; }; 4B2E2D981C3A06EC00138695 /* Atari2600.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Atari2600.hpp; sourceTree = ""; }; 4B2E2D991C3A06EC00138695 /* Atari2600Inputs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Atari2600Inputs.h; sourceTree = ""; }; @@ -473,13 +471,15 @@ 4B6C73BB1D387AE500AFCFCA /* DiskController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DiskController.cpp; sourceTree = ""; }; 4B6C73BC1D387AE500AFCFCA /* DiskController.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DiskController.hpp; sourceTree = ""; }; 4B73C7191D036BD90074D992 /* Vic20Document.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Vic20Document.swift; sourceTree = ""; }; - 4B73C71C1D036C030074D992 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = "Clock Signal/Base.lproj/Vic20Document.xib"; sourceTree = SOURCE_ROOT; }; 4B8FE2141DA19D5F0090D3CE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = "Clock Signal/Base.lproj/Atari2600Options.xib"; sourceTree = SOURCE_ROOT; }; 4B8FE2161DA19D5F0090D3CE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = "Clock Signal/Base.lproj/MachineDocument.xib"; sourceTree = SOURCE_ROOT; }; 4B8FE2181DA19D5F0090D3CE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = "Clock Signal/Base.lproj/ElectronOptions.xib"; sourceTree = SOURCE_ROOT; }; 4B8FE21A1DA19D5F0090D3CE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = "Clock Signal/Base.lproj/Vic20Options.xib"; sourceTree = SOURCE_ROOT; }; 4B8FE21F1DA19D7C0090D3CE /* Atari2600OptionsPanel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Atari2600OptionsPanel.swift; sourceTree = ""; }; 4B8FE2211DA19FB20090D3CE /* MachinePanel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MachinePanel.swift; sourceTree = ""; }; + 4B8FE2231DA1DC2D0090D3CE /* Bundle+DataForResource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Bundle+DataForResource.swift"; sourceTree = ""; }; + 4B8FE2251DA1DE2D0090D3CE /* NSBundle+DataResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSBundle+DataResource.h"; sourceTree = ""; }; + 4B8FE2261DA1DE2D0090D3CE /* NSBundle+DataResource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSBundle+DataResource.m"; sourceTree = ""; }; 4B92EAC91B7C112B00246143 /* 6502TimingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = 6502TimingTests.swift; sourceTree = ""; }; 4B96F7201D75119A0058BB2D /* Tape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Tape.cpp; path = ../../StaticAnalyser/Acorn/Tape.cpp; sourceTree = ""; }; 4B96F7211D75119A0058BB2D /* Tape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Tape.hpp; path = ../../StaticAnalyser/Acorn/Tape.hpp; sourceTree = ""; }; @@ -771,7 +771,6 @@ 4BB697CD1D4BA44400248BDF /* CommodoreGCR.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CommodoreGCR.hpp; path = Encodings/CommodoreGCR.hpp; sourceTree = ""; }; 4BB73E9E1B587A5100552FC2 /* Clock Signal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Clock Signal.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 4BB73EA11B587A5100552FC2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 4BB73EA61B587A5100552FC2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/Atari2600Document.xib; sourceTree = ""; }; 4BB73EA81B587A5100552FC2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 4BB73EAB1B587A5100552FC2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 4BB73EAD1B587A5100552FC2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -951,6 +950,8 @@ 4B2A53981D117D36003C6002 /* Wrappers */, 4BA61EAE1D91515900B3C876 /* NSData+StdVector.h */, 4BA61EAF1D91515900B3C876 /* NSData+StdVector.mm */, + 4B8FE2251DA1DE2D0090D3CE /* NSBundle+DataResource.h */, + 4B8FE2261DA1DE2D0090D3CE /* NSBundle+DataResource.m */, ); path = Machine; sourceTree = ""; @@ -1050,18 +1051,16 @@ isa = PBXGroup; children = ( 4B55CE561C3B7D360093A61B /* Atari2600Document.swift */, + 4B8FE21F1DA19D7C0090D3CE /* Atari2600OptionsPanel.swift */, 4B55CE571C3B7D360093A61B /* ElectronDocument.swift */, 4B55CE5E1C3B7D960093A61B /* MachineDocument.swift */, - 4B73C7191D036BD90074D992 /* Vic20Document.swift */, - 4BB73EA51B587A5100552FC2 /* Atari2600Document.xib */, - 4B8FE2131DA19D5F0090D3CE /* Atari2600Options.xib */, - 4B8FE2151DA19D5F0090D3CE /* MachineDocument.xib */, - 4B2E2D931C399D1200138695 /* ElectronDocument.xib */, - 4B8FE2171DA19D5F0090D3CE /* ElectronOptions.xib */, - 4B73C71B1D036C030074D992 /* Vic20Document.xib */, - 4B8FE2191DA19D5F0090D3CE /* Vic20Options.xib */, - 4B8FE21F1DA19D7C0090D3CE /* Atari2600OptionsPanel.swift */, 4B8FE2211DA19FB20090D3CE /* MachinePanel.swift */, + 4B73C7191D036BD90074D992 /* Vic20Document.swift */, + 4B8FE2131DA19D5F0090D3CE /* Atari2600Options.xib */, + 4B8FE2171DA19D5F0090D3CE /* ElectronOptions.xib */, + 4B8FE2151DA19D5F0090D3CE /* MachineDocument.xib */, + 4B8FE2191DA19D5F0090D3CE /* Vic20Options.xib */, + 4B8FE2231DA1DC2D0090D3CE /* Bundle+DataForResource.swift */, ); path = Documents; sourceTree = ""; @@ -1843,13 +1842,10 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 4B2E2D951C399D1200138695 /* ElectronDocument.xib in Resources */, 4BB73EA91B587A5100552FC2 /* Assets.xcassets in Resources */, - 4BB73EA71B587A5100552FC2 /* Atari2600Document.xib in Resources */, 4B8FE21B1DA19D5F0090D3CE /* Atari2600Options.xib in Resources */, 4B8FE21C1DA19D5F0090D3CE /* MachineDocument.xib in Resources */, 4B8FE21E1DA19D5F0090D3CE /* Vic20Options.xib in Resources */, - 4B73C71D1D036C030074D992 /* Vic20Document.xib in Resources */, 4BB73EAC1B587A5100552FC2 /* MainMenu.xib in Resources */, 4B8FE21D1DA19D5F0090D3CE /* ElectronOptions.xib in Resources */, 4BC9DF451D044FCA00F44158 /* ROMImages in Resources */, @@ -2156,6 +2152,7 @@ 4BA799951D8B656E0045123D /* StaticAnalyser.cpp in Sources */, 4BF829601D8F3C87001BAE39 /* CRC.cpp in Sources */, 4B55CE591C3B7D360093A61B /* ElectronDocument.swift in Sources */, + 4B8FE2241DA1DC2D0090D3CE /* Bundle+DataForResource.swift in Sources */, 4B4DC82B1D2C27A4003C5BF8 /* SerialBus.cpp in Sources */, 4BC3B74F1CD194CC00F86E85 /* Shader.cpp in Sources */, 4B8FE2221DA19FB20090D3CE /* MachinePanel.swift in Sources */, @@ -2207,6 +2204,7 @@ 4B14145B1B58879D00E04248 /* CPU6502.cpp in Sources */, 4BEE0A6F1D72496600532C7B /* Cartridge.cpp in Sources */, 4BEE0A701D72496600532C7B /* PRG.cpp in Sources */, + 4B8FE2271DA1DE2D0090D3CE /* NSBundle+DataResource.m in Sources */, 4B2A53A01D117D36003C6002 /* CSMachine.mm in Sources */, 4BC91B831D1F160E00884B76 /* CommodoreTAP.cpp in Sources */, 4B2A539F1D117D36003C6002 /* CSAudioQueue.m in Sources */, @@ -2262,23 +2260,6 @@ /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ - 4B2E2D931C399D1200138695 /* ElectronDocument.xib */ = { - isa = PBXVariantGroup; - children = ( - 4B2E2D941C399D1200138695 /* Base */, - ); - name = ElectronDocument.xib; - path = ..; - sourceTree = ""; - }; - 4B73C71B1D036C030074D992 /* Vic20Document.xib */ = { - isa = PBXVariantGroup; - children = ( - 4B73C71C1D036C030074D992 /* Base */, - ); - name = Vic20Document.xib; - sourceTree = ""; - }; 4B8FE2131DA19D5F0090D3CE /* Atari2600Options.xib */ = { isa = PBXVariantGroup; children = ( @@ -2311,15 +2292,6 @@ name = Vic20Options.xib; sourceTree = ""; }; - 4BB73EA51B587A5100552FC2 /* Atari2600Document.xib */ = { - isa = PBXVariantGroup; - children = ( - 4BB73EA61B587A5100552FC2 /* Base */, - ); - name = Atari2600Document.xib; - path = ..; - sourceTree = ""; - }; 4BB73EAA1B587A5100552FC2 /* MainMenu.xib */ = { isa = PBXVariantGroup; children = ( diff --git a/OSBindings/Mac/Clock Signal/Base.lproj/Atari2600Document.xib b/OSBindings/Mac/Clock Signal/Base.lproj/Atari2600Document.xib deleted file mode 100644 index 8b6eb5532..000000000 --- a/OSBindings/Mac/Clock Signal/Base.lproj/Atari2600Document.xib +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OSBindings/Mac/Clock Signal/Base.lproj/ElectronDocument.xib b/OSBindings/Mac/Clock Signal/Base.lproj/ElectronDocument.xib deleted file mode 100644 index a74f5d383..000000000 --- a/OSBindings/Mac/Clock Signal/Base.lproj/ElectronDocument.xib +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OSBindings/Mac/Clock Signal/Base.lproj/Vic20Document.xib b/OSBindings/Mac/Clock Signal/Base.lproj/Vic20Document.xib deleted file mode 100644 index d96154920..000000000 --- a/OSBindings/Mac/Clock Signal/Base.lproj/Vic20Document.xib +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OSBindings/Mac/Clock Signal/Documents/Bundle+DataForResource.swift b/OSBindings/Mac/Clock Signal/Documents/Bundle+DataForResource.swift new file mode 100644 index 000000000..8dcb5ac96 --- /dev/null +++ b/OSBindings/Mac/Clock Signal/Documents/Bundle+DataForResource.swift @@ -0,0 +1,19 @@ +// +// Bundle+DataForResource.swift +// Clock Signal +// +// Created by Thomas Harte on 02/10/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +import Foundation + +extension Bundle { + func dataForResource(_ name : String, ofType type: String, inDirectory directory: String) -> Data? { + if let path = self.path(forResource: name, ofType: type, inDirectory: directory) { + return try? Data(contentsOf: URL(fileURLWithPath: path)) + } + return nil + } + +} diff --git a/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift b/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift index 3517d5b53..a3f04455e 100644 --- a/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift +++ b/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift @@ -11,19 +11,7 @@ import AudioToolbox class ElectronDocument: MachineDocument { -/* fileprivate lazy var electron = CSElectron() - override var machine: CSMachine! { - get { - return electron - } - } - override var name: String! { - get { - return "electron" - } - } - - override func aspectRatio() -> NSSize { +/* override func aspectRatio() -> NSSize { return NSSize(width: 11.0, height: 10.0) } @@ -48,23 +36,6 @@ class ElectronDocument: MachineDocument { } } - override var windowNibName: String? { - return "ElectronDocument" - } - -/* override func readFromURL(url: NSURL, ofType typeName: String) throws { - if let pathExtension = url.pathExtension { - switch pathExtension.lowercaseString { - case "uef": - electron.openUEFAtURL(url) - return - default: break; - } - } - - let fileWrapper = try NSFileWrapper(URL: url, options: NSFileWrapperReadingOptions(rawValue: 0)) - try self.readFromFileWrapper(fileWrapper, ofType: typeName) - }*/ // MARK: IBActions @IBOutlet var displayTypeButton: NSPopUpButton? diff --git a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift index 8fbb49de6..7bf604a0b 100644 --- a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift +++ b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift @@ -144,15 +144,6 @@ class MachineDocument: } } - // MARK: Utilities for children - func dataForResource(_ name : String, ofType type: String, inDirectory directory: String) -> Data? { - if let path = Bundle.main.path(forResource: name, ofType: type, inDirectory: directory) { - return (try? Data(contentsOf: URL(fileURLWithPath: path))) - } - - return nil - } - // MARK: CSAudioQueueDelegate final func audioQueueDidCompleteBuffer(_ audioQueue: CSAudioQueue) { bestEffortUpdater.update() diff --git a/OSBindings/Mac/Clock Signal/Machine/NSBundle+DataResource.h b/OSBindings/Mac/Clock Signal/Machine/NSBundle+DataResource.h new file mode 100644 index 000000000..46833748c --- /dev/null +++ b/OSBindings/Mac/Clock Signal/Machine/NSBundle+DataResource.h @@ -0,0 +1,15 @@ +// +// NSBundle+DataResource.h +// Clock Signal +// +// Created by Thomas Harte on 02/10/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#import + +@interface NSBundle (DataResource) + +- (nullable NSData *)dataForResource:(nullable NSString *)resource withExtension:(nullable NSString *)extension subdirectory:(nullable NSString *)subdirectory; + +@end diff --git a/OSBindings/Mac/Clock Signal/Machine/NSBundle+DataResource.m b/OSBindings/Mac/Clock Signal/Machine/NSBundle+DataResource.m new file mode 100644 index 000000000..46c9e4035 --- /dev/null +++ b/OSBindings/Mac/Clock Signal/Machine/NSBundle+DataResource.m @@ -0,0 +1,20 @@ +// +// NSBundle+DataResource.m +// Clock Signal +// +// Created by Thomas Harte on 02/10/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#import "NSBundle+DataResource.h" + +@implementation NSBundle (DataResource) + +- (NSData *)dataForResource:(NSString *)resource withExtension:(NSString *)extension subdirectory:(NSString *)subdirectory +{ + NSURL *url = [self URLForResource:resource withExtension:extension subdirectory:subdirectory]; + if(!url) return nil; + return [NSData dataWithContentsOfURL:url]; +} + +@end diff --git a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.h b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.h index d96647745..622ab749b 100644 --- a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.h +++ b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.h @@ -10,15 +10,8 @@ #import "CSKeyboardMachine.h" #import "CSFastLoading.h" -@class CSStaticAnalyser; - @interface CSElectron : CSMachine -- (void)setOSROM:(nonnull NSData *)rom; -- (void)setBASICROM:(nonnull NSData *)rom; -- (void)setDFSROM:(nonnull NSData *)rom; -- (void)setADFSROM:(nonnull NSData *)rom; - @property (nonatomic, assign) BOOL useFastLoadingHack; @property (nonatomic, assign) BOOL useTelevisionOutput; diff --git a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm index 97f3ed865..6717b826e 100644 --- a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm +++ b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm @@ -9,11 +9,13 @@ #import "CSElectron.h" #include "Electron.hpp" -#import "CSMachine+Subclassing.h" -#import "NSData+StdVector.h" #include "StaticAnalyser.hpp" #include "TapeUEF.hpp" +#import "CSMachine+Subclassing.h" +#import "NSData+StdVector.h" +#import "NSBundle+DataResource.h" + @implementation CSElectron { Electron::Machine _electron; } @@ -22,32 +24,43 @@ return &_electron; } -- (void)analyse:(NSURL *)url { - StaticAnalyser::GetTargets([url fileSystemRepresentation]); +- (instancetype)init { + self = [super init]; + if(self) + { + [self setOSROM:[self rom:@"os"]]; + [self setBASICROM:[self rom:@"basic"]]; + [self setDFSROM:[self rom:@"DFS-1770-2.20"]]; + + NSMutableData *adfs = [[self rom:@"ADFS-E00_1"] mutableCopy]; + [adfs appendData:[self rom:@"ADFS-E00_2"]]; + [self setADFSROM:adfs]; + } + return self; } +- (NSData *)rom:(NSString *)name +{ + return [[NSBundle mainBundle] dataForResource:name withExtension:@"rom" subdirectory:@"ROMImages/Electron"]; +} + +#pragma mark - ROM setting + - (void)setOSROM:(nonnull NSData *)rom { [self setROM:rom slot:Electron::ROMSlotOS]; } - (void)setBASICROM:(nonnull NSData *)rom { [self setROM:rom slot:Electron::ROMSlotBASIC]; } - (void)setADFSROM:(nonnull NSData *)rom { [self setROM:rom slot:Electron::ROMSlotADFS]; } - (void)setDFSROM:(nonnull NSData *)rom { [self setROM:rom slot:Electron::ROMSlotDFS]; } - (void)setROM:(nonnull NSData *)rom slot:(int)slot { - @synchronized(self) { - _electron.set_rom((Electron::ROMSlot)slot, rom.stdVector8, false); + if(rom) + { + @synchronized(self) { + _electron.set_rom((Electron::ROMSlot)slot, rom.stdVector8, false); + } } } -/*- (BOOL)openUEFAtURL:(NSURL *)URL { - @synchronized(self) { - try { - std::shared_ptr tape(new Storage::Tape::UEF([URL fileSystemRepresentation])); - _electron.set_tape(tape); - return YES; - } catch(...) { - return NO; - } - } -}*/ +#pragma mark - Keyboard Mapping - (void)clearAllKeys { @synchronized(self) { @@ -135,6 +148,8 @@ } } +#pragma mark - Options + - (void)setUseFastLoadingHack:(BOOL)useFastLoadingHack { @synchronized(self) { _useFastLoadingHack = useFastLoadingHack;