/** * main_entry: * * Main function of RetroArch. * * If HAVE_MAIN is not defined, will contain main loop and will not * be exited from until we exit the program. Otherwise, will * just do initialization. * * Returns: varies per platform. **/ int rarch_main(int argc, char *argv[], void *data) { void *args = (void*)data; #ifndef HAVE_MAIN int ret = 0; #endif rarch_ctl(RARCH_CTL_PREINIT, NULL); frontend_driver_init_first(args); rarch_ctl(RARCH_CTL_INIT, NULL); if (frontend_driver_is_inited()) { content_ctx_info_t info; info.argc = argc; info.argv = argv; info.args = args; info.environ_get = frontend_driver_environment_get_ptr(); if (!task_push_content_load_default( NULL, NULL, &info, CORE_TYPE_PLAIN, CONTENT_MODE_LOAD_FROM_CLI, NULL, NULL)) return 0; } ui_companion_driver_init_first(); #ifndef HAVE_MAIN do { unsigned sleep_ms = 0; ret = runloop_iterate(&sleep_ms); if (ret == 1 && sleep_ms > 0) retro_sleep(sleep_ms); task_queue_ctl(TASK_QUEUE_CTL_CHECK, NULL); }while(ret != -1); main_exit(args); #endif return 0; }
static int zarch_zui_load_content(zui_t *zui, unsigned i) { content_ctx_info_t content_info = {0}; task_push_content_load_default(zui->pick_cores[i].path, zui->pick_content, &content_info, CORE_TYPE_PLAIN, CONTENT_MODE_LOAD_CONTENT_WITH_NEW_CORE_FROM_MENU, NULL, NULL); zarch_layout = LAY_HOME; return 0; }
/* Loads dummy core instead of exiting RetroArch completely. * Aborts core shutdown if invoked. */ static int runloop_iterate_time_to_exit_load_dummy(void) { content_ctx_info_t content_info = {0}; if (!task_push_content_load_default( NULL, NULL, &content_info, CORE_TYPE_DUMMY, CONTENT_MODE_LOAD_NOTHING_WITH_DUMMY_CORE, NULL, NULL)) return -1; runloop_ctl(RUNLOOP_CTL_UNSET_SHUTDOWN, NULL); runloop_ctl(RUNLOOP_CTL_UNSET_CORE_SHUTDOWN, NULL); return 1; }
LRESULT win32_menu_loop(HWND owner, WPARAM wparam) { WPARAM mode = wparam & 0xffff; enum event_command cmd = CMD_EVENT_NONE; bool do_wm_close = false; settings_t *settings = config_get_ptr(); switch (mode) { case ID_M_LOAD_CORE: case ID_M_LOAD_CONTENT: { char win32_file[PATH_MAX_LENGTH] = {0}; const char *extensions = NULL; const char *title = NULL; const char *initial_dir = NULL; switch (mode) { case ID_M_LOAD_CORE: extensions = "Libretro core (.dll)\0*.dll\0All Files\0*.*\0"; title = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_LIST); initial_dir = settings->directory.libretro; break; case ID_M_LOAD_CONTENT: extensions = "All Files\0*.*\0"; title = msg_hash_to_str( MENU_ENUM_LABEL_VALUE_LOAD_CONTENT_LIST); initial_dir = settings->directory.menu_content; break; } if (!win32_browser(owner, win32_file, extensions, title, initial_dir)) break; switch (mode) { case ID_M_LOAD_CORE: runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, win32_file); cmd = CMD_EVENT_LOAD_CORE; break; case ID_M_LOAD_CONTENT: { content_ctx_info_t content_info = {0}; path_set(RARCH_PATH_CONTENT, win32_file); do_wm_close = true; task_push_content_load_default( NULL, NULL, &content_info, CORE_TYPE_PLAIN, CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI, NULL, NULL); } break; } } break; case ID_M_RESET: cmd = CMD_EVENT_RESET; break; case ID_M_MUTE_TOGGLE: cmd = CMD_EVENT_AUDIO_MUTE_TOGGLE; break; case ID_M_MENU_TOGGLE: cmd = CMD_EVENT_MENU_TOGGLE; break; case ID_M_PAUSE_TOGGLE: cmd = CMD_EVENT_PAUSE_TOGGLE; break; case ID_M_LOAD_STATE: cmd = CMD_EVENT_LOAD_STATE; break; case ID_M_SAVE_STATE: cmd = CMD_EVENT_SAVE_STATE; break; case ID_M_DISK_CYCLE: cmd = CMD_EVENT_DISK_EJECT_TOGGLE; break; case ID_M_DISK_NEXT: cmd = CMD_EVENT_DISK_NEXT; break; case ID_M_DISK_PREV: cmd = CMD_EVENT_DISK_PREV; break; case ID_M_FULL_SCREEN: cmd = CMD_EVENT_FULLSCREEN_TOGGLE; break; #ifndef _XBOX case ID_M_SHADER_PARAMETERS: shader_dlg_show(owner); break; #endif case ID_M_MOUSE_GRAB: cmd = CMD_EVENT_GRAB_MOUSE_TOGGLE; break; case ID_M_TAKE_SCREENSHOT: cmd = CMD_EVENT_TAKE_SCREENSHOT; break; case ID_M_QUIT: do_wm_close = true; break; default: if (mode >= ID_M_WINDOW_SCALE_1X && mode <= ID_M_WINDOW_SCALE_10X) { unsigned idx = (mode - (ID_M_WINDOW_SCALE_1X-1)); runloop_ctl(RUNLOOP_CTL_SET_WINDOWED_SCALE, &idx); cmd = CMD_EVENT_RESIZE_WINDOWED_SCALE; } else if (mode == ID_M_STATE_INDEX_AUTO) { signed idx = -1; settings->state_slot = idx; } else if (mode >= (ID_M_STATE_INDEX_AUTO+1) && mode <= (ID_M_STATE_INDEX_AUTO+10)) { signed idx = (mode - (ID_M_STATE_INDEX_AUTO+1)); settings->state_slot = idx; } break; } if (cmd != CMD_EVENT_NONE) command_event(cmd, NULL); if (do_wm_close) PostMessage(owner, WM_CLOSE, 0, 0); return 0L; }
/* Get the count of the files dropped */ static int win32_drag_query_file(HWND hwnd, WPARAM wparam) { char szFilename[1024]; szFilename[0] = '\0'; if (DragQueryFile((HDROP)wparam, 0xFFFFFFFF, NULL, 0)) { /*poll list of current cores */ size_t list_size; content_ctx_info_t content_info = {0}; core_info_list_t *core_info_list = NULL; const core_info_t *core_info = NULL; DragQueryFile((HDROP)wparam, 0, szFilename, sizeof(szFilename)); core_info_get_list(&core_info_list); if (!core_info_list) return 0; core_info_list_get_supported_cores(core_info_list, (const char*)szFilename, &core_info, &list_size); if (!list_size) return 0; path_set(RARCH_PATH_CONTENT, szFilename); if (!path_is_empty(RARCH_PATH_CONTENT)) { unsigned i; core_info_t *current_core = NULL; core_info_get_current_core(¤t_core); /*we already have path for libretro core */ for (i = 0; i < list_size; i++) { const core_info_t *info = (const core_info_t*)&core_info[i]; if(!string_is_equal(info->systemname, current_core->systemname)) break; if(string_is_equal(path_get(RARCH_PATH_CORE), info->path)) { /* Our previous core supports the current rom */ content_ctx_info_t content_info = {0}; task_push_content_load_default( NULL, NULL, &content_info, CORE_TYPE_PLAIN, CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI, NULL, NULL); return 0; } } } /* Poll for cores for current rom since none exist. */ if(list_size ==1) { /*pick core that only exists and is bound to work. Ish. */ const core_info_t *info = (const core_info_t*)&core_info[0]; if (info) task_push_content_load_default( info->path, NULL, &content_info, CORE_TYPE_PLAIN, CONTENT_MODE_LOAD_CONTENT_WITH_NEW_CORE_FROM_COMPANION_UI, NULL, NULL); } else { /* Pick one core that could be compatible, ew */ if(DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_PICKCORE), hwnd,PickCoreProc,(LPARAM)NULL)==IDOK) { task_push_content_load_default( NULL, NULL, &content_info, CORE_TYPE_PLAIN, CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI, NULL, NULL); } } } return 0; }
/* Time to exit out of the main loop? * Reasons for exiting: * a) Shutdown environment callback was invoked. * b) Quit key was pressed. * c) Frame count exceeds or equals maximum amount of frames to run. * d) Video driver no longer alive. * e) End of BSV movie and BSV EOF exit is true. (TODO/FIXME - explain better) */ static INLINE int runloop_iterate_time_to_exit(bool quit_key_pressed) { settings_t *settings = config_get_ptr(); bool time_to_exit = runloop_shutdown_initiated; time_to_exit = time_to_exit || quit_key_pressed; time_to_exit = time_to_exit || !video_driver_is_alive(); time_to_exit = time_to_exit || bsv_movie_ctl(BSV_MOVIE_CTL_END_EOF, NULL); time_to_exit = time_to_exit || (runloop_max_frames && (*(video_driver_get_frame_count_ptr()) >= runloop_max_frames)); time_to_exit = time_to_exit || runloop_exec; if (!time_to_exit) return 1; #ifdef HAVE_MENU if (!runloop_is_quit_confirm()) { if (settings && settings->confirm_on_exit) { if (menu_dialog_is_active()) return 1; if (content_is_inited()) { if(menu_display_toggle_get_reason() != MENU_TOGGLE_REASON_USER) menu_display_toggle_set_reason(MENU_TOGGLE_REASON_MESSAGE); rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); } menu_dialog_show_message(MENU_DIALOG_QUIT_CONFIRM, MENU_ENUM_LABEL_CONFIRM_ON_EXIT); return 1; } } #endif if (runloop_exec) runloop_exec = false; if (runloop_core_shutdown_initiated && settings && settings->load_dummy_on_core_shutdown) { content_ctx_info_t content_info = {0}; if (!task_push_content_load_default( NULL, NULL, &content_info, CORE_TYPE_DUMMY, CONTENT_MODE_LOAD_NOTHING_WITH_DUMMY_CORE, NULL, NULL)) return -1; /* Loads dummy core instead of exiting RetroArch completely. * Aborts core shutdown if invoked. */ runloop_shutdown_initiated = false; runloop_core_shutdown_initiated = false; return 1; } /* Quits out of RetroArch main loop. */ return -1; }