Mac: Always save SRAM on window close and quit

This commit is contained in:
Michael Buckley 2020-03-18 17:22:51 -07:00
parent 7d028a4e74
commit a4b207cbaa
3 changed files with 10 additions and 2 deletions

View File

@ -68,12 +68,12 @@ static NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow";
[NSNotificationCenter.defaultCenter addObserverForName:NSWindowWillCloseNotification object:window queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification *notification)
{
[self.s9xEngine pause];
[self.s9xEngine quit];
}];
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
[self.s9xEngine quit];
}
- (void)setupDefaults

View File

@ -167,6 +167,7 @@ extern id<S9xInputDelegate> inputDelegate;
- (BOOL)isRunning;
- (BOOL)isPaused;
- (void)pause;
- (void)quit;
- (void)resume;
- (BOOL)setButton:(S9xButtonCode)button forKey:(int16)key player:(int8)player oldButton:(S9xButtonCode *)oldButton oldPlayer:(int8 *)oldPlayer oldKey:(int16 *)oldKey;

View File

@ -3015,6 +3015,7 @@ void QuitWithFatalError ( NSString *message)
- (void)stop
{
SNES9X_Quit();
S9xExit();
}
@ -3034,6 +3035,12 @@ void QuitWithFatalError ( NSString *message)
[s9xView setNeedsDisplay:YES];
}
- (void)quit
{
SNES9X_Quit();
[self pause];
}
- (void)resume
{
pauseEmulation = false;