Mac: Return hardware and software reset menu items

This commit is contained in:
Michael Buckley 2020-09-07 13:54:19 -07:00
parent a893ad05e3
commit c4cdc18068
4 changed files with 60 additions and 5 deletions

View File

@ -471,6 +471,11 @@ static NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow";
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem - (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{ {
SEL action = menuItem.action;
if (action == @selector(resume:) || action == @selector(softwareReset:) || action == @selector(hardwareReset:)) {
return [self.s9xEngine isRunning] && [self.s9xEngine isPaused];
}
return !self.isRunningEmulation; return !self.isRunningEmulation;
} }
@ -520,6 +525,16 @@ static NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow";
[self.s9xEngine resume]; [self.s9xEngine resume];
} }
- (IBAction)softwareReset:(id)sender
{
[self.s9xEngine softwareReset];
}
- (IBAction)hardwareReset:(id)sender
{
[self.s9xEngine hardwareReset];
}
- (BOOL)handleInput:(S9xJoypadInput *)input fromJoypad:(S9xJoypad *)joypad - (BOOL)handleInput:(S9xJoypadInput *)input fromJoypad:(S9xJoypad *)joypad
{ {
if (NSApp.keyWindow != nil && NSApp.keyWindow == self.prefsWindowController.window) if (NSApp.keyWindow != nil && NSApp.keyWindow == self.prefsWindowController.window)

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15400" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17154" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies> <dependencies>
<deployment identifier="macosx"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15400"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17154"/>
</dependencies> </dependencies>
<objects> <objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication"> <customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@ -104,6 +104,18 @@
<action selector="resume:" target="-1" id="jxw-ZM-JXi"/> <action selector="resume:" target="-1" id="jxw-ZM-JXi"/>
</connections> </connections>
</menuItem> </menuItem>
<menuItem isSeparatorItem="YES" id="wRV-3p-Ovs"/>
<menuItem title="Software Reset" keyEquivalent="R" id="rpq-ak-IWU">
<connections>
<action selector="softwareReset:" target="-1" id="SCG-64-bMI"/>
</connections>
</menuItem>
<menuItem title="Hardware Reset" keyEquivalent="r" id="tbk-CC-2si">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="hardwareReset:" target="-1" id="dRy-5Q-N2I"/>
</connections>
</menuItem>
</items> </items>
</menu> </menu>
</menuItem> </menuItem>

View File

@ -168,6 +168,8 @@ extern id<S9xInputDelegate> inputDelegate;
- (void)start; - (void)start;
- (void)stop; - (void)stop;
- (void)softwareReset;
- (void)hardwareReset;
- (BOOL)isRunning; - (BOOL)isRunning;
- (BOOL)isPaused; - (BOOL)isPaused;

View File

@ -1710,6 +1710,7 @@ int PromptFreezeDefrost (Boolean freezing)
const char letters[] = "123456789ABC", *filename; const char letters[] = "123456789ABC", *filename;
frzselecting = true; frzselecting = true;
[s9xView updatePauseOverlay];
oldInactiveMode = inactiveMode; oldInactiveMode = inactiveMode;
if (inactiveMode == 3) if (inactiveMode == 3)
inactiveMode = 2; inactiveMode = 2;
@ -2036,7 +2037,7 @@ int PromptFreezeDefrost (Boolean freezing)
usleep(30000); usleep(30000);
UpdateFreezeDefrostScreen(current_selection, image, draw, ctx); UpdateFreezeDefrostScreen(current_selection, image, draw, ctx);
} while (result == -2); } while (result == -2 && frzselecting);
CocoaPlayFreezeDefrostSound(); CocoaPlayFreezeDefrostSound();
@ -2050,6 +2051,9 @@ int PromptFreezeDefrost (Boolean freezing)
inactiveMode = oldInactiveMode; inactiveMode = oldInactiveMode;
frzselecting = false; frzselecting = false;
pauseEmulation = false;
[s9xView updatePauseOverlay];
return (result); return (result);
} }
@ -2610,6 +2614,7 @@ static void Initialize (void)
} }
frzselecting = false; frzselecting = false;
[s9xView updatePauseOverlay];
S9xSetControllerCrosshair(X_MOUSE1, 0, NULL, NULL); S9xSetControllerCrosshair(X_MOUSE1, 0, NULL, NULL);
S9xSetControllerCrosshair(X_MOUSE2, 0, NULL, NULL); S9xSetControllerCrosshair(X_MOUSE2, 0, NULL, NULL);
@ -2936,8 +2941,7 @@ void QuitWithFatalError ( NSString *message)
- (void)updatePauseOverlay - (void)updatePauseOverlay
{ {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"%d", pauseEmulation); self.subviews[0].hidden = (frzselecting || !pauseEmulation);
self.subviews[0].hidden = !pauseEmulation;
CGFloat scaleFactor = MAX(self.window.backingScaleFactor, 1.0); CGFloat scaleFactor = MAX(self.window.backingScaleFactor, 1.0);
glScreenW = self.frame.size.width * scaleFactor; glScreenW = self.frame.size.width * scaleFactor;
glScreenH = self.frame.size.height * scaleFactor; glScreenH = self.frame.size.height * scaleFactor;
@ -3030,6 +3034,21 @@ void QuitWithFatalError ( NSString *message)
S9xExit(); S9xExit();
} }
- (void)softwareReset
{
SNES9X_SoftReset();
SNES9X_Go();
[self resume];
}
- (void)hardwareReset
{
SNES9X_Reset();
SNES9X_Go();
[self resume];
}
- (BOOL)isRunning - (BOOL)isRunning
{ {
return running; return running;
@ -3172,6 +3191,7 @@ void QuitWithFatalError ( NSString *message)
- (BOOL)loadROM:(NSURL *)fileURL - (BOOL)loadROM:(NSURL *)fileURL
{ {
running = false; running = false;
frzselecting = false;
while (!Settings.StopEmulation) while (!Settings.StopEmulation)
{ {
@ -3183,6 +3203,12 @@ void QuitWithFatalError ( NSString *message)
SNES9X_Go(); SNES9X_Go();
s9xView.window.title = fileURL.lastPathComponent.stringByDeletingPathExtension; s9xView.window.title = fileURL.lastPathComponent.stringByDeletingPathExtension;
[s9xView.window makeKeyAndOrderFront:nil]; [s9xView.window makeKeyAndOrderFront:nil];
dispatch_async(dispatch_get_main_queue(), ^
{
[s9xView.window makeFirstResponder:s9xView];
});
[self start]; [self start];
return YES; return YES;
} }