diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-06-22 21:25:16 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-06-22 21:25:16 +0000 |
| commit | d30baffb38d2ee1de16f45a78d42d99e780c3df7 (patch) | |
| tree | 42b03c45adf98a9aeb0b82d9d5095e170bc3eb83 | |
| parent | b6b2beab4846d5579514aed399d7eab56d6d02f0 (diff) | |
| download | pcsxr-d30baffb38d2ee1de16f45a78d42d99e780c3df7.tar.gz | |
Minor spacing changes.
Enable logging in the debug build.
Warn if we are passed multiple memory cards of the same type from the command line.
Add a common method to set up the emulation thread.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@85489 e17a0e51-4ae3-4d35-97c3-1a29b211df97
| -rwxr-xr-x | macosx/EmuThread.m | 34 | ||||
| -rwxr-xr-x | macosx/PcsxrController.m | 37 |
2 files changed, 41 insertions, 30 deletions
diff --git a/macosx/EmuThread.m b/macosx/EmuThread.m index 2f8c5d62..01d574d1 100755 --- a/macosx/EmuThread.m +++ b/macosx/EmuThread.m @@ -30,13 +30,13 @@ static pthread_mutex_t eventMutex; #define EMUEVENT_RESET (1<<1) #define EMUEVENT_STOP (1<<2) -static NSString * const ThreadInfo = @"PSX Emu Background thread"; - @implementation EmuThread -- (void)EmuThreadRun:(id)anObject +- (void)setUpThread { - [[NSThread currentThread] setName:ThreadInfo]; + NSAssert(![[NSThread currentThread] isEqual:[NSThread mainThread]], @"This function should not be run on the main thread!"); + + [[NSThread currentThread] setName:@"PSX Emu Background thread"]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(emuWindowDidClose:) @@ -52,6 +52,11 @@ static NSString * const ThreadInfo = @"PSX Emu Background thread"; // we shouldn't change the priority, since we might depend on subthreads //[NSThread setThreadPriority:1.0-((1.0-[NSThread threadPriority])/4.0)]; +} + +- (void)EmuThreadRun:(id)anObject +{ + [self setUpThread]; // Do processing here if (OpenPlugins() == -1) @@ -87,23 +92,8 @@ done: - (void)EmuThreadRunBios:(id)anObject { - [[NSThread currentThread] setName:ThreadInfo]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emuWindowDidClose:) - name:@"emuWindowDidClose" object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emuWindowWantPause:) - name:@"emuWindowWantPause" object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(emuWindowWantResume:) - name:@"emuWindowWantResume" object:nil]; - - // we shouldn't change the priority, since we might depend on subthreads - //[NSThread setThreadPriority:1.0-((1.0-[NSThread threadPriority])/4.0)]; - + [self setUpThread]; + // Do processing here if (OpenPlugins() == -1) goto done; @@ -122,7 +112,7 @@ done: - (void)dealloc { // remove all registered observers - [[NSNotificationCenter defaultCenter] removeObserver:self name:nil object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; SUPERDEALLOC; } diff --git a/macosx/PcsxrController.m b/macosx/PcsxrController.m index 9bf3900f..4bb4a565 100755 --- a/macosx/PcsxrController.m +++ b/macosx/PcsxrController.m @@ -43,11 +43,14 @@ void ShowHelpAndExit(FILE* output, int exitCode) @property (readwrite) BOOL endAtEmuClose; @property (readwrite) BOOL sleepInBackground; @property (readwrite) BOOL wasPausedBeforeBGSwitch; +@property (retain) NSMutableArray *skipFiles; @end @implementation PcsxrController @synthesize recentItems; +@synthesize skipFiles; + - (BOOL)endAtEmuClose { return PSXflags.endAtEmuClose; @@ -338,8 +341,14 @@ void ShowHelpAndExit(FILE* output, int exitCode) - (void)applicationDidFinishLaunching:(NSNotification *)notification { - RELEASEOBJ(skipFiles); - skipFiles = nil; + self.skipFiles = nil; + BOOL enableLogging = NO; +#ifdef DEBUG + enableLogging = YES; + //Just in case it didn't get set. + Config.PsxOut = TRUE; +#endif + [[NSUserDefaults standardUserDefaults] setBool:enableLogging forKey:@"ConsoleOutput"]; } static void ParseErrorStr(NSString *errStr) __dead2; @@ -390,15 +399,17 @@ otherblock();\ } self.sleepInBackground = [[NSUserDefaults standardUserDefaults] boolForKey:@"PauseInBackground"]; - NSProcessInfo *procInfo = [NSProcessInfo processInfo]; - NSArray *progArgs = [procInfo arguments]; + + NSArray *progArgs = [[NSProcessInfo processInfo] arguments]; if ([progArgs count] > 1 && ![[progArgs objectAtIndex:1] hasPrefix:@"-psn"]) { - skipFiles = [[NSMutableArray alloc] init]; + self.skipFiles = [NSMutableArray array]; + BOOL isLaunchable = NO; NSString *runtimeStr = nil; + + __block short memcardHandled = 0; __block dispatch_block_t runtimeBlock = NULL; __block BOOL hasParsedAnArgument = NO; - __block NSString *(^FileTestBlock)() = NULL; NSMutableArray *unknownOptions = [NSMutableArray array]; @@ -432,6 +443,11 @@ otherblock();\ void (^mcdBlock)(int mcdNumber) = ^(int mcdnumber){ hasParsedAnArgument = YES; + if (memcardHandled & (1 << mcdnumber)) { + NSLog(@"Memory card %i has already been defined. The latest one passed will be used.", mcdnumber); + } else { + memcardHandled |= (1 << mcdnumber); + } NSString *path = FileTestBlock(); LoadMcd(mcdnumber, (char*)[path fileSystemRepresentation]); }; @@ -584,7 +600,12 @@ otherblock();\ char *str = (char *)[[prefStringKeys objectForKey:defaultKey] pointerValue]; if (str) { - [defaults setObject:[NSString stringWithCString:str encoding:NSUTF8StringEncoding] forKey:defaultKey]; + NSString *tmpNSStr = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:str length:strlen(str)]; + if (!tmpNSStr) { + tmpNSStr = [NSString stringWithCString:str encoding:NSUTF8StringEncoding]; + } + + [defaults setObject:tmpNSStr forKey:defaultKey]; return; } @@ -749,7 +770,7 @@ otherblock();\ NSError *err = nil; NSString *utiFile = [[NSWorkspace sharedWorkspace] typeOfFile:filename error:&err]; if (err) { - NSRunAlertPanel(NSLocalizedString(@"Error opening file", nil), [NSString stringWithFormat:NSLocalizedString(@"Unable to open %@: %@", nil), [filename lastPathComponent], [err localizedFailureReason]], nil, nil, nil); + NSRunAlertPanel(NSLocalizedString(@"Error opening file", nil), NSLocalizedString(@"Unable to open %@: %@", nil), nil, nil, nil, [filename lastPathComponent], err); return NO; } static NSArray *handlers = nil; |
