diff --git a/Makefile.common b/Makefile.common index 03838ff50d..10bbe7e71b 100644 --- a/Makefile.common +++ b/Makefile.common @@ -99,7 +99,6 @@ OBJ += frontend/frontend.o \ rarch_compr_file_path.o \ hash.o \ driver.o \ - general.o \ settings.o \ settings_list.o \ settings_data.o \ diff --git a/general.c b/general.c deleted file mode 100644 index d5e59ac494..0000000000 --- a/general.c +++ /dev/null @@ -1,153 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2015 - Daniel De Matteis - * Copyright (C) 2012-2015 - Michael Lelli - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#include "general.h" -#include "settings.h" -#include "retroarch.h" -#include "dynamic.h" -#include - -void rarch_playlist_load_content(content_playlist_t *playlist, - unsigned idx) -{ - const char *path = NULL; - const char *core_path = NULL; - - content_playlist_get_index(playlist, - idx, &path, &core_path, NULL); - - strlcpy(g_settings.libretro, core_path, sizeof(g_settings.libretro)); - - driver.menu->load_no_content = (path) ? false : true; - - rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)path); - - rarch_main_command(RARCH_CMD_LOAD_CORE); -} - -/* When selection is presented back, returns 0. - * If it can make a decision right now, returns -1. */ - -int rarch_defer_core(core_info_list_t *core_info, const char *dir, - const char *path, const char *menu_label, - char *deferred_path, size_t sizeof_deferred_path) -{ - char new_core_path[PATH_MAX_LENGTH]; - const core_info_t *info = NULL; - size_t supported = 0; - - fill_pathname_join(deferred_path, dir, path, sizeof_deferred_path); - -#ifdef HAVE_COMPRESSION - if (path_is_compressed_file(dir)) - { - /* In case of a compressed archive, we have to join with a hash */ - /* We are going to write at the position of dir: */ - rarch_assert(strlen(dir) < strlen(deferred_path)); - deferred_path[strlen(dir)] = '#'; - } -#endif - - if (core_info) - core_info_list_get_supported_cores(core_info, deferred_path, &info, - &supported); - - if (!strcmp(menu_label, "load_content")) - { - strlcpy(new_core_path, g_extern.core_info_current->path, sizeof(new_core_path)); - supported = 1; - } - else - { - strlcpy(new_core_path, info->path, sizeof(new_core_path)); - } - - /* Can make a decision right now. */ - if (supported == 1) - { - strlcpy(g_extern.fullpath, deferred_path, - sizeof(g_extern.fullpath)); - if (path_file_exists(new_core_path)) - strlcpy(g_settings.libretro, new_core_path, - sizeof(g_settings.libretro)); - return -1; - } - return 0; -} - -/* Quite intrusive and error prone. - * Likely to have lots of small bugs. - * Cleanly exit the main loop to ensure that all the tiny details - * get set properly. - * - * This should mitigate most of the smaller bugs. */ - -bool rarch_replace_config(const char *path) -{ - /* If config file to be replaced is the same as the - * current config file, exit. */ - if (!strcmp(path, g_extern.config_path)) - return false; - - if (g_settings.config_save_on_exit && *g_extern.config_path) - config_save_file(g_extern.config_path); - - strlcpy(g_extern.config_path, path, sizeof(g_extern.config_path)); - g_extern.block_config_read = false; - *g_settings.libretro = '\0'; /* Load core in new config. */ - - rarch_main_command(RARCH_CMD_PREPARE_DUMMY); - - return true; -} - -void rarch_update_system_info(struct retro_system_info *_info, - bool *load_no_content) -{ - const core_info_t *info = NULL; -#if defined(HAVE_DYNAMIC) - libretro_free_system_info(_info); - if (!(*g_settings.libretro)) - return; - - libretro_get_system_info(g_settings.libretro, _info, - load_no_content); -#endif - if (!g_extern.core_info) - return; - - if (!core_info_list_get_info(g_extern.core_info, - g_extern.core_info_current, g_settings.libretro)) - return; - - /* Keep track of info for the currently selected core. */ - info = (const core_info_t*)g_extern.core_info_current; - - if (!g_extern.verbosity) - return; - - RARCH_LOG("[Core Info]:\n"); - if (info->display_name) - RARCH_LOG("Display Name = %s\n", info->display_name); - if (info->supported_extensions) - RARCH_LOG("Supported Extensions = %s\n", - info->supported_extensions); - if (info->authors) - RARCH_LOG("Authors = %s\n", info->authors); - if (info->permissions) - RARCH_LOG("Permissions = %s\n", info->permissions); -} diff --git a/general.h b/general.h index 32b57f4ad8..1cefd36373 100644 --- a/general.h +++ b/general.h @@ -839,18 +839,6 @@ extern struct defaults g_defaults; /* Public functions. */ int rarch_main(int argc, char *argv[]); -bool rarch_replace_config(const char *path); - -void rarch_playlist_load_content(content_playlist_t *playlist, - unsigned index); - -int rarch_defer_core(core_info_list_t *data, - const char *dir, const char *path, const char *menu_label, - char *deferred_path, size_t sizeof_deferred_path); - -void rarch_update_system_info(struct retro_system_info *info, - bool *load_no_content); - #ifdef __cplusplus } #endif diff --git a/griffin/griffin.c b/griffin/griffin.c index 41f9f5fa94..9b27cfacfd 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -611,7 +611,6 @@ MAIN /*============================================================ RETROARCH ============================================================ */ -#include "../general.c" #include "../libretro_version_1.c" #include "../retroarch.c" #include "../runloop.c" diff --git a/retroarch.c b/retroarch.c index aeee1255af..e9a09b73b8 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2882,3 +2882,134 @@ void rarch_main_deinit(void) g_extern.main_is_init = false; } + +void rarch_playlist_load_content(content_playlist_t *playlist, + unsigned idx) +{ + const char *path = NULL; + const char *core_path = NULL; + + content_playlist_get_index(playlist, + idx, &path, &core_path, NULL); + + strlcpy(g_settings.libretro, core_path, sizeof(g_settings.libretro)); + + driver.menu->load_no_content = (path) ? false : true; + + rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)path); + + rarch_main_command(RARCH_CMD_LOAD_CORE); +} + +/* When selection is presented back, returns 0. + * If it can make a decision right now, returns -1. */ + +int rarch_defer_core(core_info_list_t *core_info, const char *dir, + const char *path, const char *menu_label, + char *deferred_path, size_t sizeof_deferred_path) +{ + char new_core_path[PATH_MAX_LENGTH]; + const core_info_t *info = NULL; + size_t supported = 0; + + fill_pathname_join(deferred_path, dir, path, sizeof_deferred_path); + +#ifdef HAVE_COMPRESSION + if (path_is_compressed_file(dir)) + { + /* In case of a compressed archive, we have to join with a hash */ + /* We are going to write at the position of dir: */ + rarch_assert(strlen(dir) < strlen(deferred_path)); + deferred_path[strlen(dir)] = '#'; + } +#endif + + if (core_info) + core_info_list_get_supported_cores(core_info, deferred_path, &info, + &supported); + + if (!strcmp(menu_label, "load_content")) + { + strlcpy(new_core_path, g_extern.core_info_current->path, sizeof(new_core_path)); + supported = 1; + } + else + { + strlcpy(new_core_path, info->path, sizeof(new_core_path)); + } + + /* Can make a decision right now. */ + if (supported == 1) + { + strlcpy(g_extern.fullpath, deferred_path, + sizeof(g_extern.fullpath)); + if (path_file_exists(new_core_path)) + strlcpy(g_settings.libretro, new_core_path, + sizeof(g_settings.libretro)); + return -1; + } + return 0; +} + +/* Quite intrusive and error prone. + * Likely to have lots of small bugs. + * Cleanly exit the main loop to ensure that all the tiny details + * get set properly. + * + * This should mitigate most of the smaller bugs. */ + +bool rarch_replace_config(const char *path) +{ + /* If config file to be replaced is the same as the + * current config file, exit. */ + if (!strcmp(path, g_extern.config_path)) + return false; + + if (g_settings.config_save_on_exit && *g_extern.config_path) + config_save_file(g_extern.config_path); + + strlcpy(g_extern.config_path, path, sizeof(g_extern.config_path)); + g_extern.block_config_read = false; + *g_settings.libretro = '\0'; /* Load core in new config. */ + + rarch_main_command(RARCH_CMD_PREPARE_DUMMY); + + return true; +} + +void rarch_update_system_info(struct retro_system_info *_info, + bool *load_no_content) +{ + const core_info_t *info = NULL; +#if defined(HAVE_DYNAMIC) + libretro_free_system_info(_info); + if (!(*g_settings.libretro)) + return; + + libretro_get_system_info(g_settings.libretro, _info, + load_no_content); +#endif + if (!g_extern.core_info) + return; + + if (!core_info_list_get_info(g_extern.core_info, + g_extern.core_info_current, g_settings.libretro)) + return; + + /* Keep track of info for the currently selected core. */ + info = (const core_info_t*)g_extern.core_info_current; + + if (!g_extern.verbosity) + return; + + RARCH_LOG("[Core Info]:\n"); + if (info->display_name) + RARCH_LOG("Display Name = %s\n", info->display_name); + if (info->supported_extensions) + RARCH_LOG("Supported Extensions = %s\n", + info->supported_extensions); + if (info->authors) + RARCH_LOG("Authors = %s\n", info->authors); + if (info->permissions) + RARCH_LOG("Permissions = %s\n", info->permissions); +} diff --git a/retroarch.h b/retroarch.h index 26ca224bac..6956118b45 100644 --- a/retroarch.h +++ b/retroarch.h @@ -47,6 +47,18 @@ void rarch_disk_control_append_image(const char *path); void rarch_recording_dump_frame(const void *data, unsigned width, unsigned height, size_t pitch); +bool rarch_replace_config(const char *path); + +void rarch_playlist_load_content(content_playlist_t *playlist, + unsigned index); + +int rarch_defer_core(core_info_list_t *data, + const char *dir, const char *path, const char *menu_label, + char *deferred_path, size_t sizeof_deferred_path); + +void rarch_update_system_info(struct retro_system_info *info, + bool *load_no_content); + #ifdef __cplusplus } #endif