mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-25 03:32:01 +00:00
Endeavoured to ensure safe shutdown.
This commit is contained in:
parent
0a09762be6
commit
0527888b15
@ -11,7 +11,7 @@ import AudioToolbox
|
||||
|
||||
class ElectronDocument: MachineDocument {
|
||||
|
||||
private var electron = CSElectron()
|
||||
private var electron: CSElectron! = CSElectron()
|
||||
override init() {
|
||||
super.init()
|
||||
self.intendedCyclesPerSecond = 2000000
|
||||
@ -55,9 +55,21 @@ class ElectronDocument: MachineDocument {
|
||||
electron.setROM(data, slot: 15)
|
||||
}
|
||||
|
||||
override func close() {
|
||||
objc_sync_enter(self)
|
||||
electron.sync()
|
||||
openGLView.invalidate()
|
||||
openGLView.openGLContext!.makeCurrentContext()
|
||||
electron = nil
|
||||
super.close()
|
||||
objc_sync_exit(self)
|
||||
}
|
||||
|
||||
// MARK: CSOpenGLViewDelegate
|
||||
override func runForNumberOfCycles(numberOfCycles: Int32) {
|
||||
electron.runForNumberOfCycles(numberOfCycles)
|
||||
objc_sync_enter(self)
|
||||
electron?.runForNumberOfCycles(numberOfCycles)
|
||||
objc_sync_exit(self)
|
||||
}
|
||||
|
||||
override func openGLView(view: CSCathodeRayView, drawViewOnlyIfDirty onlyIfDirty: Bool) {
|
||||
@ -78,5 +90,4 @@ class ElectronDocument: MachineDocument {
|
||||
electron.setKey(kVK_Control, isPressed: newModifiers.modifierFlags.contains(.ControlKeyMask))
|
||||
electron.setKey(kVK_Command, isPressed: newModifiers.modifierFlags.contains(.CommandKeyMask))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
@interface CSMachine : NSObject
|
||||
|
||||
- (void)runForNumberOfCycles:(int)numberOfCycles;
|
||||
- (void)sync;
|
||||
|
||||
@property (nonatomic, weak) CSCathodeRayView *view;
|
||||
@property (nonatomic, weak) AudioQueue *audioQueue;
|
||||
|
@ -47,6 +47,10 @@ typedef NS_ENUM(NSInteger, CSAtari2600RunningState) {
|
||||
}
|
||||
}
|
||||
|
||||
- (void)sync {
|
||||
dispatch_sync(_serialDispatchQueue, ^{});
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user