minor code tweaks.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@85949 e17a0e51-4ae3-4d35-97c3-1a29b211df97
This commit is contained in:
parent
0fd6f9301c
commit
09b52df12a
|
@ -8,7 +8,7 @@
|
|||
@class ConfigurationController;
|
||||
@class CheatController;
|
||||
|
||||
void ShowHelpAndExit(FILE* output, int exitCode) __dead2;
|
||||
void ShowHelpAndExit(FILE* output, int exitCode);
|
||||
void CloseEmuLog();
|
||||
|
||||
@interface PcsxrController : NSObject <NSApplicationDelegate>
|
||||
|
|
|
@ -38,13 +38,17 @@ NSString *saveStatePath;
|
|||
void ShowHelpAndExit(FILE* output, int exitCode)
|
||||
{
|
||||
fprintf(output, HELPSTR);
|
||||
exit(exitCode);
|
||||
if (!NSApp) {
|
||||
exit(exitCode);
|
||||
} else {
|
||||
[NSApp stop:nil];
|
||||
}
|
||||
}
|
||||
|
||||
@interface PcsxrController ()
|
||||
@property (readwrite) BOOL endAtEmuClose;
|
||||
@property (readwrite) BOOL sleepInBackground;
|
||||
@property (readwrite) BOOL wasPausedBeforeBGSwitch;
|
||||
@property BOOL sleepInBackground;
|
||||
@property BOOL wasPausedBeforeBGSwitch;
|
||||
@property (arcstrong) NSMutableArray *skipFiles;
|
||||
@end
|
||||
|
||||
|
@ -344,15 +348,16 @@ void ShowHelpAndExit(FILE* output, int exitCode)
|
|||
CloseEmuLog();
|
||||
}
|
||||
|
||||
static void ParseErrorStr(NSString *errStr) __dead2;
|
||||
static void ParseErrorStr(NSString *errStr)
|
||||
{
|
||||
#if 1
|
||||
SysMessage("Parsing error: %s\n\nPlease check the command line options and try again.\n\nPCSXR will now quit.\n", [errStr UTF8String]);
|
||||
#else
|
||||
NSLog(@"%@", errStr);
|
||||
NSString *logStr = [NSString stringWithFormat:@"Parse error: %@", errStr];
|
||||
|
||||
SysPrintf("%s\n", [logStr UTF8String]);
|
||||
if (!Config.PsxOut) {
|
||||
//make sure this comes out on the console.
|
||||
NSLog(@"%@", logStr);
|
||||
}
|
||||
NSRunCriticalAlertPanel(@"Parsing error", @"%@\n\nPlease check the command line options and try again.\n\nPCSXR will now quit.", nil, nil, nil, errStr);
|
||||
#endif
|
||||
ShowHelpAndExit(stderr, EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -443,7 +448,12 @@ otherblock();\
|
|||
//This block/argument does not need to be sorted
|
||||
dispatch_block_t emuCloseAtEnd = ^{
|
||||
hasParsedAnArgument = YES;
|
||||
self.endAtEmuClose = YES;
|
||||
dispatch_block_t runtimeBlock = ^{
|
||||
self.endAtEmuClose = YES;
|
||||
};
|
||||
LaunchArg *larg = [[LaunchArg alloc] initWithLaunchOrder:LaunchArgPreRun block:runtimeBlock argument:kPCSXRArgumentExitAtClose];
|
||||
[larg addToDictionary:argDict];
|
||||
RELEASEOBJ(larg);
|
||||
};
|
||||
|
||||
dispatch_block_t isoBlock = ^{
|
||||
|
@ -499,7 +509,7 @@ otherblock();\
|
|||
if ([progArgs count] <= ++i) {
|
||||
ParseErrorStr(@"Not enough arguments.");
|
||||
}
|
||||
NSString *path = [progArgs objectAtIndex:i];
|
||||
NSString *path = [[progArgs objectAtIndex:i] stringByExpandingTildeInPath];
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:path])
|
||||
{
|
||||
ParseErrorStr([NSString stringWithFormat:@"The file \"%@\" does not exist.", path]);
|
||||
|
@ -528,9 +538,10 @@ otherblock();\
|
|||
//As there doesn't seem to be a Cocoa/Objective-C method like this...
|
||||
NSString *unknownString = CFBridgingRelease(CFStringCreateByCombiningStrings(kCFAllocatorDefault, BRIDGE(CFArrayRef, unknownOptions), CFSTR(" ")));
|
||||
|
||||
SysPrintf("The following options weren't recognized by PCSX-R: %s. This may be due to extra arguments passed by the OS or debugger.", [unknownString UTF8String]);
|
||||
SysPrintf("The following options weren't recognized by PCSX-R: %s. This may be due to extra arguments passed by the OS or debugger.\n", [unknownString UTF8String]);
|
||||
}
|
||||
#endif
|
||||
unknownOptions = nil;
|
||||
if (!isLaunchable && hasParsedAnArgument) {
|
||||
NSMutableArray *mutProgArgs = [NSMutableArray arrayWithArray:progArgs];
|
||||
NSString *appRawPath = RETAINOBJ([mutProgArgs objectAtIndex:0]);
|
||||
|
@ -539,7 +550,7 @@ otherblock();\
|
|||
NSString *arg = CFBridgingRelease(CFStringCreateByCombiningStrings(kCFAllocatorDefault, BRIDGE(CFArrayRef, mutProgArgs), CFSTR(" ")));
|
||||
NSString *recognizedArgs = CFBridgingRelease(CFStringCreateByCombiningStrings(kCFAllocatorDefault, BRIDGE(CFArrayRef, [argDict allKeys]), CFSTR(" ")));
|
||||
|
||||
NSString *tmpStr = [NSString stringWithFormat:@"A launch command wasn't found in the command line and an argument that PCSX-R recognizes was: %@.\nThe following command line arguments were passed with the application launch file at %@: %@.\n\nThe valid launch commands are %@, %@, and %@.", recognizedArgs, appRawPath, arg, kPCSXRArgumentISO, kPCSXRArgumentCDROM, kPCSXRArgumentBIOS];
|
||||
NSString *tmpStr = [NSString stringWithFormat:@"A launch command wasn't found in the command line and one or more arguments that PCSX-R recognizes were: %@.\nThe following command line arguments were passed with the application launch file at %@: %@.\n\nThe valid launch commands are %@, %@, and %@.", recognizedArgs, appRawPath, arg, kPCSXRArgumentISO, kPCSXRArgumentCDROM, kPCSXRArgumentBIOS];
|
||||
RELEASEOBJ(appRawPath);
|
||||
ParseErrorStr(tmpStr);
|
||||
} else if (hasParsedAnArgument){
|
||||
|
|
|
@ -101,7 +101,7 @@ static inline void ClearMemcardData(char *to, int dsti, char *str)
|
|||
i = 0;
|
||||
while (i < MAX_MEMCARD_BLOCKS) {
|
||||
x = 1;
|
||||
McdBlock memBlock, tmpBlock;
|
||||
McdBlock memBlock;
|
||||
GetMcdBlockInfo(carNum, i + 1, &memBlock);
|
||||
|
||||
if ([PcsxrMemoryObject memFlagsFromBlockFlags:memBlock.Flags] == memFlagFree) {
|
||||
|
@ -110,6 +110,7 @@ static inline void ClearMemcardData(char *to, int dsti, char *str)
|
|||
continue;
|
||||
}
|
||||
do {
|
||||
McdBlock tmpBlock;
|
||||
GetMcdBlockInfo(carNum, i + x + 1, &tmpBlock);
|
||||
if ((tmpBlock.Flags & 0x3) == 0x3) {
|
||||
x++;
|
||||
|
@ -120,9 +121,11 @@ static inline void ClearMemcardData(char *to, int dsti, char *str)
|
|||
break;
|
||||
}
|
||||
} while (i + x - 1 < MAX_MEMCARD_BLOCKS);
|
||||
PcsxrMemoryObject *obj = [[PcsxrMemoryObject alloc] initWithMcdBlock:&memBlock startingIndex:i size:x];
|
||||
[tmpMemArray addObject:obj];
|
||||
RELEASEOBJ(obj);
|
||||
@autoreleasepool {
|
||||
PcsxrMemoryObject *obj = [[PcsxrMemoryObject alloc] initWithMcdBlock:&memBlock startingIndex:i size:x];
|
||||
[tmpMemArray addObject:obj];
|
||||
RELEASEOBJ(obj);
|
||||
}
|
||||
i += x;
|
||||
}
|
||||
self.rawArray = [NSArray arrayWithArray:tmpMemArray];
|
||||
|
|
|
@ -167,7 +167,10 @@ static NSString *MemLabelEndLink;
|
|||
self.sjisName = [NSString stringWithCString:infoBlock->sTitle encoding:NSShiftJISStringEncoding];
|
||||
|
||||
if ([englishName isEqualToString:sjisName]) {
|
||||
SysPrintf("English name and sjis name are the same: %s. Replacing the sjis string with the English string.\n", [englishName UTF8String]);
|
||||
#if 0
|
||||
if (![englishName isEqualToString:@""])
|
||||
SysPrintf("English name and sjis name are the same: %s. Replacing the sjis string with the English string.\n", [englishName UTF8String]);
|
||||
#endif
|
||||
self.sjisName = self.englishName;
|
||||
}
|
||||
@autoreleasepool {
|
||||
|
|
|
@ -110,7 +110,7 @@ int SysInit() {
|
|||
|
||||
IOReturn success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, CFSTR("PSX Emu Running"), &powerAssertion);
|
||||
if (success != kIOReturnSuccess) {
|
||||
SysPrintf("Unable to stop sleep, error code %d", success);
|
||||
SysPrintf("Unable to stop sleep, error code %d\n", success);
|
||||
}
|
||||
|
||||
attachHotkeys();
|
||||
|
@ -139,24 +139,34 @@ static NSDateFormatter* debugDateFormatter()
|
|||
|
||||
void SysPrintf(const char *fmt, ...) {
|
||||
va_list list;
|
||||
char msg[512];
|
||||
char *msg = calloc(sizeof(char), 512);
|
||||
|
||||
va_start(list, fmt);
|
||||
vsprintf(msg, fmt, list);
|
||||
vsnprintf(msg, 512, fmt, list);
|
||||
va_end(list);
|
||||
|
||||
if (Config.PsxOut) printf ("%s", msg);
|
||||
|
||||
dispatch_block_t printfBlock = ^{
|
||||
if (Config.PsxOut) printf ("%s", msg);
|
||||
#ifdef EMU_LOG
|
||||
#ifndef LOG_STDOUT
|
||||
fprintf(emuLog, "%s %s: %s",[[debugDateFormatter() stringFromDate:[NSDate date]] UTF8String],
|
||||
[[[NSBundle mainBundle]objectForInfoDictionaryKey:@"CFBundleName"] UTF8String], msg);
|
||||
fprintf(emuLog, "%s %s: %s",[[debugDateFormatter() stringFromDate:[NSDate date]] UTF8String],
|
||||
[[[NSBundle mainBundle]objectForInfoDictionaryKey:@"CFBundleName"] UTF8String], msg);
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
if ([NSThread isMainThread]) {
|
||||
printfBlock();
|
||||
} else {
|
||||
dispatch_sync(dispatch_get_main_queue(), printfBlock);
|
||||
}
|
||||
free(msg);
|
||||
}
|
||||
|
||||
void SysMessage(const char *fmt, ...) {
|
||||
va_list list;
|
||||
|
||||
|
||||
NSString *locFmtString = NSLocalizedString(@(fmt), nil);
|
||||
|
||||
va_start(list, fmt);
|
||||
|
@ -165,7 +175,10 @@ void SysMessage(const char *fmt, ...) {
|
|||
|
||||
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:msg forKey:NSLocalizedFailureReasonErrorKey];
|
||||
RELEASEOBJ(msg);
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
|
||||
|
||||
dispatch_block_t sysBlock = ^{
|
||||
if (Config.PsxOut) printf ("%s", [msg UTF8String]);
|
||||
#ifdef EMU_LOG
|
||||
#ifndef LOG_STDOUT
|
||||
fprintf(emuLog, "%s %s: %s",[[debugDateFormatter() stringFromDate:[NSDate date]] UTF8String],
|
||||
|
@ -173,7 +186,13 @@ void SysMessage(const char *fmt, ...) {
|
|||
#endif
|
||||
#endif
|
||||
[NSApp presentError:[NSError errorWithDomain:@"Unknown Domain" code:-1 userInfo:userInfo]];
|
||||
});
|
||||
};
|
||||
|
||||
if ([NSThread isMainThread]) {
|
||||
sysBlock();
|
||||
} else {
|
||||
dispatch_sync(dispatch_get_main_queue(), sysBlock);
|
||||
}
|
||||
}
|
||||
|
||||
void *SysLoadLibrary(const char *lib) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user