summaryrefslogtreecommitdiff
path: root/macosx/PcsxController.m
diff options
context:
space:
mode:
authorSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2009-06-11 09:22:11 +0000
committerSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2009-06-11 09:22:11 +0000
commit115f535248b36a4a08bbb570e6fc971d3c40e654 (patch)
tree40ec39212d9ba18581b5bd99971807bb660f4491 /macosx/PcsxController.m
parent1ca5686e1587d754f8f97c369b717679c95876a1 (diff)
downloadpcsxr-115f535248b36a4a08bbb570e6fc971d3c40e654.tar.gz
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@23682 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/PcsxController.m')
-rw-r--r--macosx/PcsxController.m88
1 files changed, 53 insertions, 35 deletions
diff --git a/macosx/PcsxController.m b/macosx/PcsxController.m
index b1502761..3d12ee66 100644
--- a/macosx/PcsxController.m
+++ b/macosx/PcsxController.m
@@ -21,29 +21,44 @@ NSString *saveStatePath;
NSRange rdiskRange;
BOOL wasPaused = [EmuThread pauseSafe];
-
+
/* close connection to current cd */
if ([EmuThread active])
CDR_close();
-
- if (CDR_getDriveLetter() != nil) {
- deviceName = [NSMutableString stringWithCString:CDR_getDriveLetter()];
-
- // delete the 'r' in 'rdisk'
- rdiskRange = [deviceName rangeOfString:@"rdisk"];
- if (rdiskRange.length != 0) {
- rdiskRange.length = 1;
- [deviceName deleteCharactersInRange:rdiskRange];
+
+ // switch to another ISO if using internal image reader, otherwise eject the CD
+ if (cdrfilename[0] != '\0') {
+ NSOpenPanel* openDlg = [NSOpenPanel openPanel];
+
+ [openDlg setCanChooseFiles:YES];
+ [openDlg setCanChooseDirectories:NO];
+
+ if ([openDlg runModalForDirectory:nil file:nil] == NSOKButton) {
+ NSArray* files = [openDlg filenames];
+ strcpy(cdrfilename, (const char *)[[files objectAtIndex:0] UTF8String]);
+ }
+
+ cdOpenCase = time(NULL) + 2;
+ } else {
+ if (CDR_getDriveLetter() != nil) {
+ deviceName = [NSMutableString stringWithCString:CDR_getDriveLetter()];
+
+ // delete the 'r' in 'rdisk'
+ rdiskRange = [deviceName rangeOfString:@"rdisk"];
+ if (rdiskRange.length != 0) {
+ rdiskRange.length = 1;
+ [deviceName deleteCharactersInRange:rdiskRange];
+ }
+ // execute hdiutil to eject the device
+ ejectTask = [NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:[NSArray arrayWithObjects:@"eject", deviceName, nil]];
+ [ejectTask waitUntilExit];
}
- // execute hdiutil to eject the device
- ejectTask = [NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:[NSArray arrayWithObjects:@"eject", deviceName, nil]];
- [ejectTask waitUntilExit];
}
-
+
/* and open new cd */
if ([EmuThread active])
CDR_open();
-
+
if (!wasPaused) {
[EmuThread resume];
}
@@ -90,14 +105,22 @@ NSString *saveStatePath;
- (IBAction)runCD:(id)sender
{
-// LoadCdBios = 0;
+ cdrfilename[0] = '\0';
[EmuThread run];
}
-- (IBAction)runBios:(id)sender
+- (IBAction)runIso:(id)sender
{
-// LoadCdBios = 1;
- [EmuThread run];
+ NSOpenPanel* openDlg = [NSOpenPanel openPanel];
+
+ [openDlg setCanChooseFiles:YES];
+ [openDlg setCanChooseDirectories:NO];
+
+ if ([openDlg runModalForDirectory:nil file:nil] == NSOKButton) {
+ NSArray* files = [openDlg filenames];
+ strcpy(cdrfilename, (const char *)[[files objectAtIndex:0] UTF8String]);
+ [EmuThread run];
+ }
}
- (IBAction)runExe:(id)sender
@@ -123,26 +146,26 @@ NSString *saveStatePath;
GPU_keypressed(GPU_FULLSCREEN_KEY);
}
-
- (BOOL)validateMenuItem:(id <NSMenuItem>)menuItem
{
if ([menuItem action] == @selector(pause:)) {
[menuItem setState:([EmuThread isPaused] ? NSOnState : NSOffState)];
- } else if ([menuItem action] == @selector(runBios:)) {
- return [PcsxController biosAvailable];
}
if ([menuItem action] == @selector(reset:) || [menuItem action] == @selector(pause:) ||
[menuItem action] == @selector(ejectCD:) || [menuItem action] == @selector(freeze:) ||
[menuItem action] == @selector(fullscreen:))
return [EmuThread active];
-
+
+ if ([menuItem action] == @selector(runCD:) || [menuItem action] == @selector(runIso:))
+ return ![EmuThread active];
+
if ([menuItem action] == @selector(defrost:)) {
if (![EmuThread active])
return NO;
-
+
NSString *path = [NSString stringWithFormat:@"%@/%s-%3.3d.pcsxstate", saveStatePath, CdromId, [menuItem tag]];
- return (CheckState([path fileSystemRepresentation]) == 0);
+ return (CheckState((char *)[path fileSystemRepresentation]) == 0);
}
return YES;
@@ -151,7 +174,7 @@ NSString *saveStatePath;
- (void)applicationWillResignActive:(NSNotification *)aNotification
{
wasPausedBeforeBGSwitch = [EmuThread isPaused];
-
+
if (sleepInBackground) {
[EmuThread pause];
}
@@ -170,12 +193,12 @@ NSString *saveStatePath;
if (![pluginList configured] /*!Config.Gpu[0] || !Config.Spu[0] || !Config.Pad1[0] || !Config.Cdr[0]*/) {
// configure plugins
[self preferences:nil];
-
+
NSRunCriticalAlertPanel(NSLocalizedString(@"Missing plugins!", nil),
NSLocalizedString(@"Pcsx is missing one or more critical plugins. You will need to install these in order to play games.", nil),
nil, nil, nil);
}
-
+
if (![PcsxController biosAvailable]) {
NSRunInformationalAlertPanel(NSLocalizedString(@"Missing BIOS!", nil),
NSLocalizedString(@"Pcsx wasn't able to locate any Playstation BIOS ROM files. This means that it will run in BIOS simulation mode which is less stable and compatible than using a real Playstation BIOS.\n"
@@ -237,7 +260,7 @@ NSString *saveStatePath;
if (str != nil) strncpy(Config.Bios, str, 255);
else strcpy(Config.Bios, "HLE");
}
-
+
// FIXME: hack
strcpy(Config.Net, "Disabled");
}
@@ -356,11 +379,6 @@ NSString *saveStatePath;
str = [path fileSystemRepresentation];
if (str != nil) strncpy(Config.PluginsDir, str, 255);
- // set font location
-// path = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/GONZN16X.TLF"];
-// str = [path fileSystemRepresentation];
-// if (str != nil) strncpy(Config.BiosFont, str, 255);
-
// locate a bios
biosList = [[NSMutableArray alloc] init];
NSFileManager *manager = [NSFileManager defaultManager];
@@ -370,7 +388,7 @@ NSString *saveStatePath;
for (i=0; i<[bioses count]; i++) {
NSString *file = [bioses objectAtIndex:i];
NSDictionary *attrib = [manager fileAttributesAtPath:[NSString stringWithFormat:@"%s%@", Config.BiosDir, file] traverseLink:YES];
-
+
if ([[attrib fileType] isEqualToString:NSFileTypeRegular]) {
unsigned long long size = [attrib fileSize];
if (([attrib fileSize] % (256*1024)) == 0 && size > 0) {