(Apple) Rewrite apple_run_core

This commit is contained in:
Twinaphex 2014-07-22 18:43:49 +02:00
parent 3f52a5558f
commit 624a983d8e
4 changed files with 12 additions and 15 deletions

View File

@ -165,10 +165,7 @@ static char** waiting_argv;
[cb addItemWithObjectValue:desc]; [cb addItemWithObjectValue:desc];
} }
if (waiting_argc) apple_run_core(waiting_argc, waiting_argv, nil, 0);
rarch_main(waiting_argc, waiting_argv);
else
apple_run_core(nil, 0);
waiting_argc = 0; waiting_argc = 0;
_wantReload = false; _wantReload = false;
@ -277,7 +274,7 @@ static char** waiting_argv;
_wantReload = g_extern.main_is_init; _wantReload = g_extern.main_is_init;
if (!g_extern.main_is_init) if (!g_extern.main_is_init)
apple_run_core(self.core, g_extern.fullpath); apple_run_core(0, NULL, self.core, g_extern.fullpath);
else else
g_extern.system.shutdown = true; g_extern.system.shutdown = true;
} }
@ -295,7 +292,7 @@ static char** waiting_argv;
[[NSApplication sharedApplication] terminate:nil]; [[NSApplication sharedApplication] terminate:nil];
if (_wantReload) if (_wantReload)
apple_run_core(self.core, g_extern.fullpath); apple_run_core(0, NULL, self.core, g_extern.fullpath);
else else
[[NSApplication sharedApplication] terminate:nil]; [[NSApplication sharedApplication] terminate:nil];

View File

@ -43,7 +43,7 @@ extern char** apple_argv;
extern id<RetroArch_Platform> apple_platform; extern id<RetroArch_Platform> apple_platform;
// main.m // main.m
extern void apple_run_core(NSString* core, const char* file); extern void apple_run_core(int argc, char **argv, NSString* core, const char* file);
extern void apple_start_iteration(void); extern void apple_start_iteration(void);
extern void apple_stop_iteration(void); extern void apple_stop_iteration(void);

View File

@ -27,11 +27,9 @@ void apple_rarch_exited(void)
[apple_platform unloadingCore]; [apple_platform unloadingCore];
} }
void apple_run_core(NSString* core, const char* file) void apple_run_core(int argc, char **argv, NSString* core, const char* file)
{ {
static char core_path[PATH_MAX], file_path[PATH_MAX], config_path[PATH_MAX]; static char core_path[PATH_MAX], file_path[PATH_MAX], config_path[PATH_MAX];
char **argv;
int argc;
[apple_platform loadingCore:core withFile:file]; [apple_platform loadingCore:core withFile:file];
@ -49,8 +47,10 @@ void apple_run_core(NSString* core, const char* file)
static const char* const argv_game[] = { "retroarch", "-c", config_path, "-L", core_path, file_path, 0 }; static const char* const argv_game[] = { "retroarch", "-c", config_path, "-L", core_path, file_path, 0 };
static const char* const argv_menu[] = { "retroarch", "-c", config_path, "--menu", 0 }; static const char* const argv_menu[] = { "retroarch", "-c", config_path, "--menu", 0 };
argc = (file && core) ? 6 : 4; if (argc == 0)
argv = (char**)((file && core) ? argv_game : argv_menu); argc = (file && core) ? 6 : 4;
if (!argv)
argv = (char**)((file && core) ? argv_game : argv_menu);
if (rarch_main(argc, argv)) if (rarch_main(argc, argv))
{ {

View File

@ -592,7 +592,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
action: ^(NSString* core) action: ^(NSString* core)
{ {
if (path) if (path)
apple_run_core(core, path.UTF8String); apple_run_core(0, NULL, core, path.UTF8String);
else else
{ {
weakSelf.core = core; weakSelf.core = core;
@ -617,7 +617,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
if (item && !item.isDirectory) if (item && !item.isDirectory)
{ {
if (weakSelf.core) if (weakSelf.core)
apple_run_core(weakSelf.core, item.path.UTF8String); apple_run_core(0, NULL, weakSelf.core, item.path.UTF8String);
else else
[weakSelf chooseCoreWithPath:item.path]; [weakSelf chooseCoreWithPath:item.path];
} }
@ -677,7 +677,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
for (i = 0; _history && i < content_history_size(_history); i ++) for (i = 0; _history && i < content_history_size(_history); i ++)
{ {
RAMenuItemBasic* item = [RAMenuItemBasic itemWithDescription:BOXSTRING(path_basename(content_history_get_path(weakSelf.history, i))) RAMenuItemBasic* item = [RAMenuItemBasic itemWithDescription:BOXSTRING(path_basename(content_history_get_path(weakSelf.history, i)))
action:^{ apple_run_core(BOXSTRING(content_history_get_core_path(weakSelf.history, i)), action:^{ apple_run_core(0, NULL, BOXSTRING(content_history_get_core_path(weakSelf.history, i)),
content_history_get_path(weakSelf.history, i)); } content_history_get_path(weakSelf.history, i)); }
detail:^{ return BOXSTRING(content_history_get_core_name(weakSelf.history, i)); }]; detail:^{ return BOXSTRING(content_history_get_core_name(weakSelf.history, i)); }];
[section addObject:item]; [section addObject:item];