Cocoa Port:

- Remember the emulation speed setting between app runs.
This commit is contained in:
rogerman 2013-11-22 19:36:14 +00:00
parent b85d168f9a
commit e52511502e
4 changed files with 35 additions and 18 deletions

View File

@ -114,6 +114,7 @@ class AudioSampleBlockGenerator;
@property (readonly) BOOL masterExecuteFlag;
@property (readonly) NSInteger executionState;
@property (readonly) CGFloat lastSetSpeedScalar;
@property (readonly) CGFloat speedScalar;
@property (assign) BOOL isWorking;
@ -205,14 +206,15 @@ class AudioSampleBlockGenerator;
- (void) cmdReset:(NSValue *)cmdAttrValue;
- (void) cmdToggleGPUState:(NSValue *)cmdAttrValue;
- (BOOL) handleLoadRom:(NSURL *)fileURL;
- (BOOL) handleLoadRomByURL:(NSURL *)fileURL;
- (BOOL) handleUnloadRom:(NSInteger)reasonID romToLoad:(NSURL *)romURL;
- (BOOL) loadRom:(NSURL *)romURL;
- (BOOL) loadRomByURL:(NSURL *)romURL asynchronous:(BOOL)willLoadAsync;
- (void) loadRomDidFinish:(NSNotification *)aNotification;
- (BOOL) unloadRom;
- (void) addOutputToCore:(CocoaDSOutput *)theOutput;
- (void) removeOutputFromCore:(CocoaDSOutput *)theOutput;
- (void) changeCoreSpeedWithDouble:(double)newSpeedScalar;
- (void) executeCore;
- (void) pauseCore;
- (void) restoreCoreState;

View File

@ -61,6 +61,7 @@
@dynamic masterExecuteFlag;
@dynamic executionState;
@synthesize lastSetSpeedScalar;
@dynamic speedScalar;
@synthesize isWorking;
@ -478,7 +479,7 @@
return;
}
[self handleLoadRom:selectedFile];
[self handleLoadRomByURL:selectedFile];
}
}
@ -775,9 +776,7 @@
else
{
const CGFloat newSpeedScalar = (CGFloat)[CocoaDSUtil getIBActionSenderTag:sender] / 100.0f;
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore setSpeedScalar:newSpeedScalar];
lastSetSpeedScalar = newSpeedScalar;
[self changeCoreSpeedWithDouble:newSpeedScalar];
}
}
@ -1286,11 +1285,11 @@
[cdsCore.cdsGPU setGpuStateFlags:flagBit];
}
- (BOOL) handleLoadRom:(NSURL *)fileURL
- (BOOL) handleLoadRomByURL:(NSURL *)fileURL
{
BOOL result = NO;
if ([self isRomLoading])
if (fileURL == nil || [self isRomLoading])
{
return result;
}
@ -1324,7 +1323,7 @@
}
else
{
result = [self loadRom:fileURL];
result = [self loadRomByURL:fileURL asynchronous:YES];
}
return result;
@ -1377,7 +1376,7 @@
return result;
}
- (BOOL) loadRom:(NSURL *)romURL
- (BOOL) loadRomByURL:(NSURL *)romURL asynchronous:(BOOL)willLoadAsync
{
BOOL result = NO;
@ -1409,7 +1408,16 @@
[romURL retain];
[newRom setSaveType:selectedRomSaveTypeID];
[newRom setWillStreamLoadData:[[NSUserDefaults standardUserDefaults] boolForKey:@"General_StreamLoadRomData"]];
[NSThread detachNewThreadSelector:@selector(loadDataOnThread:) toTarget:newRom withObject:romURL];
if (willLoadAsync)
{
[NSThread detachNewThreadSelector:@selector(loadDataOnThread:) toTarget:newRom withObject:romURL];
}
else
{
[newRom loadData:romURL];
}
[romURL release];
}
@ -1626,6 +1634,13 @@
[cdsCore removeOutput:theOutput];
}
- (void) changeCoreSpeedWithDouble:(double)newSpeedScalar
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore setSpeedScalar:newSpeedScalar];
lastSetSpeedScalar = newSpeedScalar;
}
- (void) executeCore
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
@ -1675,7 +1690,7 @@
[self setIsUserInterfaceBlockingExecution:NO];
[self setIsShowingFileMigrationDialog:NO];
[self loadRom:romURL];
[self loadRomByURL:romURL asynchronous:YES];
// We retained this when we initially put up the sheet, so we need to release it now.
[romURL release];
@ -1723,7 +1738,7 @@
[self didEndSaveStateSheet:sheet returnCode:returnCode contextInfo:contextInfo];
NSURL *romURL = (NSURL *)contextInfo;
[self handleLoadRom:romURL];
[self handleLoadRomByURL:romURL];
[romURL release];
}

View File

@ -97,7 +97,7 @@
NSString *fileKind = [CocoaDSFile fileKindByURL:fileURL];
if ([fileKind isEqualToString:@"ROM"])
{
result = [emuControl handleLoadRom:fileURL];
result = [emuControl handleLoadRomByURL:fileURL];
if ([emuControl isShowingSaveStateDialog] || [emuControl isShowingFileMigrationDialog])
{
// Just reply YES if a sheet is showing, even if the ROM hasn't actually been loaded yet.
@ -289,10 +289,7 @@
break;
}
if (autoloadRomURL != nil)
{
[emuControl handleLoadRom:autoloadRomURL];
}
[emuControl handleLoadRomByURL:autoloadRomURL];
}
// Present the file migration window to the user (if they haven't disabled it).
@ -335,10 +332,12 @@
- (void)applicationWillTerminate:(NSNotification *)notification
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)[emuControlController content];
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
// Save some settings to user defaults before app termination
[self saveDisplayWindowStates];
[[NSUserDefaults standardUserDefaults] setDouble:[emuControl lastSetSpeedScalar] forKey:@"CoreControl_SpeedScalar"];
[[NSUserDefaults standardUserDefaults] setBool:[cdsCore isSpeedLimitEnabled] forKey:@"CoreControl_EnableSpeedLimit"];
[[NSUserDefaults standardUserDefaults] setBool:[cdsCore isFrameSkipEnabled] forKey:@"CoreControl_EnableAutoFrameSkip"];
[[NSUserDefaults standardUserDefaults] setBool:[cdsCore isCheatingEnabled] forKey:@"CoreControl_EnableCheats"];
@ -487,6 +486,7 @@
[cdsCore setSlot1R4URL:(slot1R4Path != nil) ? [NSURL fileURLWithPath:slot1R4Path] : nil];
// Set the miscellaneous emulations settings per user preferences.
[emuControl changeCoreSpeedWithDouble:[[NSUserDefaults standardUserDefaults] doubleForKey:@"CoreControl_SpeedScalar"]];
[cdsCore setIsSpeedLimitEnabled:[[NSUserDefaults standardUserDefaults] boolForKey:@"CoreControl_EnableSpeedLimit"]];
[cdsCore setIsFrameSkipEnabled:[[NSUserDefaults standardUserDefaults] boolForKey:@"CoreControl_EnableAutoFrameSkip"]];
[cdsCore setIsCheatingEnabled:[[NSUserDefaults standardUserDefaults] boolForKey:@"CoreControl_EnableCheats"]];