2012-04-21 23:13:50 +02:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 01:50:59 +01:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 17:46:50 +01:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
|
|
* Copyright (C) 2012-2015 - Michael Lelli
|
2015-07-20 20:08:13 -05:00
|
|
|
*
|
2012-04-21 23:13:50 +02:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
2011-12-14 12:49:13 +01:00
|
|
|
* 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.
|
|
|
|
*
|
2012-04-21 23:13:50 +02:00
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
2011-12-14 12:49:13 +01:00
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
2012-04-21 23:31:57 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
2011-12-14 12:49:13 +01:00
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2011-12-14 16:01:16 +01:00
|
|
|
#include <stdlib.h>
|
2011-12-14 12:49:13 +01:00
|
|
|
#include <stddef.h>
|
2012-01-08 00:57:44 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2015-06-15 22:45:02 +02:00
|
|
|
#if defined(HW_RVL) && !defined(IS_SALAMANDER)
|
|
|
|
#include <ogc/mutex.h>
|
|
|
|
#include <ogc/cond.h>
|
2015-09-20 15:03:49 +02:00
|
|
|
#include "../../memory/wii/mem2_manager.h"
|
2015-06-15 22:45:02 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <boolean.h>
|
|
|
|
|
|
|
|
#include <file/file_path.h>
|
|
|
|
#ifndef IS_SALAMANDER
|
2016-03-20 14:53:54 +01:00
|
|
|
#include <lists/file_list.h>
|
2015-06-15 22:45:02 +02:00
|
|
|
#endif
|
2015-12-26 07:45:19 +01:00
|
|
|
#include <string/stdstring.h>
|
2015-06-15 22:45:02 +02:00
|
|
|
|
2015-11-29 01:57:16 +01:00
|
|
|
#include "../frontend_driver.h"
|
|
|
|
#include "../../defaults.h"
|
2015-06-15 22:45:02 +02:00
|
|
|
|
2012-08-07 05:27:27 +02:00
|
|
|
#ifdef HW_RVL
|
2012-08-22 15:56:20 -04:00
|
|
|
#include <ogc/ios.h>
|
2012-08-27 22:50:46 -04:00
|
|
|
#include <ogc/usbstorage.h>
|
|
|
|
#include <sdcard/wiisd_io.h>
|
2013-11-03 17:39:12 +01:00
|
|
|
extern void system_exec_wii(const char *path, bool should_load_game);
|
2012-08-07 05:27:27 +02:00
|
|
|
#endif
|
2011-12-14 14:52:58 +01:00
|
|
|
#include <sdcard/gcsd.h>
|
|
|
|
#include <fat.h>
|
2015-07-20 20:08:13 -05:00
|
|
|
#include <rthreads/rthreads.h>
|
2012-01-08 00:57:44 +01:00
|
|
|
|
2014-10-27 19:37:02 -05:00
|
|
|
#ifdef USBGECKO
|
|
|
|
#include <debug.h>
|
|
|
|
#endif
|
|
|
|
|
2016-02-12 16:58:59 -05:00
|
|
|
#if defined(HW_RVL) && ! defined(IS_SALAMANDER)
|
2016-02-05 18:34:28 +01:00
|
|
|
static enum frontend_fork gx_fork_mode = FRONTEND_FORK_NONE;
|
2016-02-03 14:42:40 +01:00
|
|
|
#endif
|
2014-10-03 17:01:56 +02:00
|
|
|
|
2014-06-05 06:12:41 +02:00
|
|
|
#ifndef IS_SALAMANDER
|
2013-01-09 00:10:19 +01:00
|
|
|
|
2012-08-27 22:50:46 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
GX_DEVICE_SD = 0,
|
|
|
|
GX_DEVICE_USB,
|
|
|
|
GX_DEVICE_END
|
|
|
|
};
|
|
|
|
|
2012-08-10 23:42:24 -04:00
|
|
|
#if defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER)
|
2012-08-10 22:49:12 -04:00
|
|
|
static devoptab_t dotab_stdout = {
|
|
|
|
"stdout", // device name
|
|
|
|
0, // size of file structure
|
|
|
|
NULL, // device open
|
|
|
|
NULL, // device close
|
|
|
|
NULL, // device write
|
|
|
|
NULL, // device read
|
|
|
|
NULL, // device seek
|
|
|
|
NULL, // device fstat
|
|
|
|
NULL, // device stat
|
|
|
|
NULL, // device link
|
|
|
|
NULL, // device unlink
|
|
|
|
NULL, // device chdir
|
|
|
|
NULL, // device rename
|
|
|
|
NULL, // device mkdir
|
|
|
|
0, // dirStateSize
|
|
|
|
NULL, // device diropen_r
|
|
|
|
NULL, // device dirreset_r
|
|
|
|
NULL, // device dirnext_r
|
|
|
|
NULL, // device dirclose_r
|
|
|
|
NULL, // device statvfs_r
|
|
|
|
NULL, // device ftrunctate_r
|
|
|
|
NULL, // device fsync_r
|
|
|
|
NULL, // deviceData;
|
|
|
|
};
|
2012-08-10 23:42:24 -04:00
|
|
|
#endif
|
2012-08-10 22:49:12 -04:00
|
|
|
|
2012-08-29 15:15:24 -04:00
|
|
|
#ifdef HW_RVL
|
|
|
|
static struct {
|
|
|
|
bool mounted;
|
|
|
|
const DISC_INTERFACE *interface;
|
|
|
|
const char *name;
|
|
|
|
} gx_devices[GX_DEVICE_END];
|
2015-04-11 23:37:00 +02:00
|
|
|
|
|
|
|
static slock_t *gx_device_mutex;
|
|
|
|
static slock_t *gx_device_cond_mutex;
|
|
|
|
static scond_t *gx_device_cond;
|
2015-07-20 20:08:13 -05:00
|
|
|
static sthread_t *gx_device_thread;
|
|
|
|
static volatile bool gx_stop_dev_thread;
|
2012-08-10 22:49:12 -04:00
|
|
|
|
2015-07-20 20:08:13 -05:00
|
|
|
static void gx_devthread(void *a)
|
2012-08-27 22:50:46 -04:00
|
|
|
{
|
2016-01-13 06:59:01 +01:00
|
|
|
unsigned i;
|
|
|
|
|
2015-07-20 20:08:13 -05:00
|
|
|
while (!gx_stop_dev_thread)
|
2012-08-27 22:50:46 -04:00
|
|
|
{
|
2015-04-11 23:37:00 +02:00
|
|
|
slock_lock(gx_device_mutex);
|
|
|
|
|
2016-01-13 06:59:01 +01:00
|
|
|
for (i = 0; i < GX_DEVICE_END; i++)
|
|
|
|
{
|
|
|
|
if (gx_devices[i].mounted)
|
|
|
|
{
|
|
|
|
if (!gx_devices[i].interface->isInserted())
|
|
|
|
{
|
2015-07-20 21:01:11 -05:00
|
|
|
char n[8];
|
2016-01-13 06:59:01 +01:00
|
|
|
|
|
|
|
gx_devices[i].mounted = false;
|
2015-07-20 21:01:11 -05:00
|
|
|
snprintf(n, sizeof(n), "%s:", gx_devices[i].name);
|
|
|
|
fatUnmount(n);
|
|
|
|
}
|
2012-08-27 22:50:46 -04:00
|
|
|
}
|
2016-01-13 06:59:01 +01:00
|
|
|
else if (gx_devices[i].interface->startup() && gx_devices[i].interface->isInserted())
|
|
|
|
gx_devices[i].mounted = fatMountSimple(gx_devices[i].name, gx_devices[i].interface);
|
2012-08-27 22:50:46 -04:00
|
|
|
}
|
2015-04-11 23:37:00 +02:00
|
|
|
|
|
|
|
slock_unlock(gx_device_mutex);
|
|
|
|
|
|
|
|
slock_lock(gx_device_cond_mutex);
|
|
|
|
scond_wait_timeout(gx_device_cond, gx_device_cond_mutex, 1000000);
|
|
|
|
slock_unlock(gx_device_cond_mutex);
|
2012-08-27 22:50:46 -04:00
|
|
|
}
|
|
|
|
}
|
2012-08-29 15:15:24 -04:00
|
|
|
#endif
|
|
|
|
|
2016-01-13 08:27:58 +01:00
|
|
|
#ifdef HAVE_LOGGER
|
2016-01-13 07:03:14 +01:00
|
|
|
static int gx_logger_net(struct _reent *r, int fd, const char *ptr, size_t len)
|
2012-08-29 15:15:24 -04:00
|
|
|
{
|
2016-01-13 07:03:14 +01:00
|
|
|
#ifdef HAVE_LOGGER
|
2012-08-29 15:15:24 -04:00
|
|
|
static char temp[4000];
|
2016-01-13 08:27:58 +01:00
|
|
|
size_t l = (len >= 4000) ? 3999 : len - 1;
|
2012-08-29 15:15:24 -04:00
|
|
|
memcpy(temp, ptr, l);
|
|
|
|
temp[l] = 0;
|
|
|
|
logger_send("%s", temp);
|
|
|
|
#elif defined(HAVE_FILE_LOGGER)
|
2015-11-23 15:45:02 +01:00
|
|
|
fwrite(ptr, 1, len, retro_main_log_file());
|
2016-01-13 07:03:14 +01:00
|
|
|
#endif
|
2012-08-29 15:15:24 -04:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-01-13 08:27:58 +01:00
|
|
|
#endif
|
|
|
|
|
2013-05-08 19:11:52 -04:00
|
|
|
#ifdef IS_SALAMANDER
|
2015-01-09 18:04:29 +01:00
|
|
|
extern char gx_rom_path[PATH_MAX_LENGTH];
|
2013-05-08 19:11:52 -04:00
|
|
|
#endif
|
|
|
|
|
2016-01-13 07:03:14 +01:00
|
|
|
static void frontend_gx_get_environment_settings(
|
|
|
|
int *argc, char *argv[],
|
2014-06-03 03:35:12 +02:00
|
|
|
void *args, void *params_data)
|
2012-08-21 00:28:38 -04:00
|
|
|
{
|
2013-08-10 20:59:10 +02:00
|
|
|
#ifndef IS_SALAMANDER
|
|
|
|
#if defined(HAVE_LOGGER)
|
|
|
|
logger_init();
|
|
|
|
#elif defined(HAVE_FILE_LOGGER)
|
2015-11-23 15:45:02 +01:00
|
|
|
retro_main_log_file_init("/retroarch-log.txt");
|
2013-08-10 20:59:10 +02:00
|
|
|
#endif
|
|
|
|
#endif
|
2013-01-07 23:48:21 -05:00
|
|
|
|
|
|
|
#ifdef HW_DOL
|
|
|
|
chdir("carda:/retroarch");
|
|
|
|
#endif
|
2015-07-27 17:18:10 +02:00
|
|
|
getcwd(g_defaults.dir.core, MAXPATHLEN);
|
|
|
|
char *last_slash = strrchr(g_defaults.dir.core, '/');
|
2013-01-07 23:48:21 -05:00
|
|
|
if (last_slash)
|
|
|
|
*last_slash = 0;
|
2015-07-27 17:18:10 +02:00
|
|
|
char *device_end = strchr(g_defaults.dir.core, '/');
|
2013-01-07 23:48:21 -05:00
|
|
|
if (device_end)
|
2015-07-27 17:18:10 +02:00
|
|
|
snprintf(g_defaults.dir.port, sizeof(g_defaults.dir.port),
|
|
|
|
"%.*s/retroarch", device_end - g_defaults.dir.core,
|
|
|
|
g_defaults.dir.core);
|
2013-01-07 23:48:21 -05:00
|
|
|
else
|
2015-07-27 17:18:10 +02:00
|
|
|
fill_pathname_join(g_defaults.dir.port, g_defaults.dir.port,
|
|
|
|
"retroarch", sizeof(g_defaults.dir.port));
|
|
|
|
fill_pathname_join(g_defaults.dir.overlay, g_defaults.dir.core,
|
|
|
|
"overlays", sizeof(g_defaults.dir.overlay));
|
|
|
|
fill_pathname_join(g_defaults.path.config, g_defaults.dir.port,
|
|
|
|
"retroarch.cfg", sizeof(g_defaults.path.config));
|
|
|
|
fill_pathname_join(g_defaults.dir.system, g_defaults.dir.port,
|
|
|
|
"system", sizeof(g_defaults.dir.system));
|
|
|
|
fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.port,
|
|
|
|
"savefiles", sizeof(g_defaults.dir.sram));
|
|
|
|
fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.port,
|
|
|
|
"savefiles", sizeof(g_defaults.dir.savestate));
|
|
|
|
fill_pathname_join(g_defaults.dir.playlist, g_defaults.dir.port,
|
|
|
|
"playlists", sizeof(g_defaults.dir.playlist));
|
2013-05-08 19:11:52 -04:00
|
|
|
|
|
|
|
#ifdef IS_SALAMANDER
|
2014-06-01 05:56:38 +02:00
|
|
|
if (*argc > 2 && argv[1] != NULL && argv[2] != NULL)
|
2013-11-12 14:58:43 +01:00
|
|
|
fill_pathname_join(gx_rom_path, argv[1], argv[2], sizeof(gx_rom_path));
|
2013-05-08 19:11:52 -04:00
|
|
|
else
|
|
|
|
gx_rom_path[0] = '\0';
|
2014-06-01 04:42:32 +02:00
|
|
|
#else
|
|
|
|
#ifdef HW_RVL
|
2015-07-20 20:08:13 -05:00
|
|
|
/* needed on Wii; loaders follow a dumb standard where the path and
|
2014-09-02 17:42:44 +02:00
|
|
|
* filename are separate in the argument list */
|
2014-06-01 05:56:38 +02:00
|
|
|
if (*argc > 2 && argv[1] != NULL && argv[2] != NULL)
|
2014-06-01 04:42:32 +02:00
|
|
|
{
|
2015-01-09 18:04:29 +01:00
|
|
|
static char path[PATH_MAX_LENGTH];
|
2014-06-13 18:11:08 +02:00
|
|
|
*path = '\0';
|
2014-06-03 04:49:01 +02:00
|
|
|
struct rarch_main_wrap *args = (struct rarch_main_wrap*)params_data;
|
|
|
|
|
2014-06-03 06:37:57 +02:00
|
|
|
if (args)
|
|
|
|
{
|
|
|
|
fill_pathname_join(path, argv[1], argv[2], sizeof(path));
|
|
|
|
|
|
|
|
args->touched = true;
|
2014-07-28 19:55:28 +02:00
|
|
|
args->no_content = false;
|
2014-06-03 06:37:57 +02:00
|
|
|
args->verbose = false;
|
|
|
|
args->config_path = NULL;
|
|
|
|
args->sram_path = NULL;
|
|
|
|
args->state_path = NULL;
|
2014-07-28 19:55:28 +02:00
|
|
|
args->content_path = path;
|
2014-06-03 06:37:57 +02:00
|
|
|
args->libretro_path = NULL;
|
|
|
|
}
|
2014-06-01 04:42:32 +02:00
|
|
|
}
|
|
|
|
#endif
|
2013-05-08 19:11:52 -04:00
|
|
|
#endif
|
2012-07-27 19:15:42 +02:00
|
|
|
}
|
|
|
|
|
2012-11-22 02:08:50 -05:00
|
|
|
extern void __exception_setreload(int t);
|
|
|
|
|
2014-05-17 14:56:12 +02:00
|
|
|
static void frontend_gx_init(void *data)
|
2011-12-14 12:49:13 +01:00
|
|
|
{
|
2013-11-03 16:38:56 +01:00
|
|
|
(void)data;
|
2012-06-29 19:10:41 -04:00
|
|
|
#ifdef HW_RVL
|
2013-05-28 22:20:36 -04:00
|
|
|
IOS_ReloadIOS(IOS_GetVersion());
|
2012-06-29 18:42:42 -04:00
|
|
|
L2Enhance();
|
2013-01-09 00:10:19 +01:00
|
|
|
#ifndef IS_SALAMANDER
|
2012-08-27 20:36:05 -04:00
|
|
|
gx_init_mem2();
|
2012-06-29 19:10:41 -04:00
|
|
|
#endif
|
2013-01-09 00:10:19 +01:00
|
|
|
#endif
|
2012-06-29 19:10:41 -04:00
|
|
|
|
2014-10-27 19:37:02 -05:00
|
|
|
#ifdef USBGECKO
|
|
|
|
DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
|
|
|
|
_break();
|
|
|
|
#endif
|
|
|
|
|
2014-05-31 16:27:27 -04:00
|
|
|
#if defined(DEBUG) && defined(IS_SALAMANDER)
|
2015-11-15 20:22:19 +01:00
|
|
|
VIInit();
|
2014-05-31 16:27:27 -04:00
|
|
|
GXRModeObj *rmode = VIDEO_GetPreferredMode(NULL);
|
|
|
|
void *xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
|
2014-09-02 17:42:44 +02:00
|
|
|
console_init(xfb, 20, 20, rmode->fbWidth,
|
|
|
|
rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ);
|
2015-11-15 20:22:19 +01:00
|
|
|
VIConfigure(rmode);
|
|
|
|
VISetNextFramebuffer(xfb);
|
|
|
|
VISetBlack(FALSE);
|
|
|
|
VIFlush();
|
|
|
|
VIWaitForRetrace();
|
|
|
|
VIWaitForRetrace();
|
2014-05-31 16:27:27 -04:00
|
|
|
#endif
|
|
|
|
|
2012-11-22 02:08:50 -05:00
|
|
|
#ifndef DEBUG
|
|
|
|
__exception_setreload(8);
|
|
|
|
#endif
|
|
|
|
|
2011-12-14 19:11:46 +01:00
|
|
|
fatInitDefault();
|
2012-07-27 19:15:42 +02:00
|
|
|
|
2012-07-27 17:51:36 -04:00
|
|
|
#ifdef HAVE_LOGGER
|
2012-08-10 22:49:12 -04:00
|
|
|
devoptab_list[STD_OUT] = &dotab_stdout;
|
|
|
|
devoptab_list[STD_ERR] = &dotab_stdout;
|
|
|
|
dotab_stdout.write_r = gx_logger_net;
|
2013-04-23 03:17:45 +02:00
|
|
|
#elif defined(HAVE_FILE_LOGGER) && !defined(IS_SALAMANDER)
|
2012-08-10 22:49:12 -04:00
|
|
|
devoptab_list[STD_OUT] = &dotab_stdout;
|
|
|
|
devoptab_list[STD_ERR] = &dotab_stdout;
|
|
|
|
dotab_stdout.write_r = gx_logger_file;
|
2012-04-13 22:54:30 +02:00
|
|
|
#endif
|
|
|
|
|
2013-01-09 00:10:19 +01:00
|
|
|
#if defined(HW_RVL) && !defined(IS_SALAMANDER)
|
2012-08-27 22:50:46 -04:00
|
|
|
gx_devices[GX_DEVICE_SD].interface = &__io_wiisd;
|
|
|
|
gx_devices[GX_DEVICE_SD].name = "sd";
|
2014-09-02 17:42:44 +02:00
|
|
|
gx_devices[GX_DEVICE_SD].mounted = fatMountSimple(
|
|
|
|
gx_devices[GX_DEVICE_SD].name,
|
|
|
|
gx_devices[GX_DEVICE_SD].interface);
|
2012-08-27 22:50:46 -04:00
|
|
|
gx_devices[GX_DEVICE_USB].interface = &__io_usbstorage;
|
|
|
|
gx_devices[GX_DEVICE_USB].name = "usb";
|
2014-09-02 17:42:44 +02:00
|
|
|
gx_devices[GX_DEVICE_USB].mounted = fatMountSimple(
|
|
|
|
gx_devices[GX_DEVICE_USB].name,
|
|
|
|
gx_devices[GX_DEVICE_USB].interface);
|
2014-06-04 18:54:40 +02:00
|
|
|
|
2015-04-11 23:37:00 +02:00
|
|
|
gx_device_cond_mutex = slock_new();
|
|
|
|
gx_device_cond = scond_new();
|
|
|
|
gx_device_mutex = slock_new();
|
2015-07-20 20:08:13 -05:00
|
|
|
gx_device_thread = sthread_create(gx_devthread, NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void frontend_gx_deinit(void *data)
|
|
|
|
{
|
|
|
|
(void)data;
|
|
|
|
|
|
|
|
#if defined(HW_RVL) && !defined(IS_SALAMANDER)
|
|
|
|
slock_lock(gx_device_cond_mutex);
|
|
|
|
gx_stop_dev_thread = true;
|
|
|
|
slock_unlock(gx_device_cond_mutex);
|
|
|
|
scond_signal(gx_device_cond);
|
|
|
|
sthread_join(gx_device_thread);
|
2012-08-27 22:50:46 -04:00
|
|
|
#endif
|
2013-01-07 23:48:21 -05:00
|
|
|
}
|
2012-08-27 22:50:46 -04:00
|
|
|
|
2016-01-13 07:01:29 +01:00
|
|
|
static void frontend_gx_exec(const char *path, bool should_load_game)
|
|
|
|
{
|
|
|
|
#ifdef HW_RVL
|
|
|
|
system_exec_wii(path, should_load_game);
|
|
|
|
#endif
|
|
|
|
}
|
2013-07-27 21:38:38 +02:00
|
|
|
|
2015-06-02 18:28:51 +02:00
|
|
|
static void frontend_gx_exitspawn(char *s, size_t len)
|
2013-01-09 00:10:19 +01:00
|
|
|
{
|
2014-06-05 06:12:41 +02:00
|
|
|
bool should_load_game = false;
|
2013-02-14 15:47:52 +01:00
|
|
|
#if defined(IS_SALAMANDER)
|
2015-12-26 07:45:19 +01:00
|
|
|
if (!string_is_empty(gx_rom_path))
|
2014-06-05 06:12:41 +02:00
|
|
|
should_load_game = true;
|
2013-02-14 15:47:52 +01:00
|
|
|
#elif defined(HW_RVL)
|
2016-02-03 15:38:28 +01:00
|
|
|
char salamander_basename[PATH_MAX_LENGTH];
|
2014-10-02 21:39:29 +02:00
|
|
|
|
2016-02-05 18:34:28 +01:00
|
|
|
if (gx_fork_mode == FRONTEND_FORK_NONE)
|
2014-10-02 21:39:29 +02:00
|
|
|
return;
|
2013-04-29 03:05:46 +02:00
|
|
|
|
2016-02-05 18:34:28 +01:00
|
|
|
switch (gx_fork_mode)
|
|
|
|
{
|
|
|
|
case FRONTEND_FORK_CORE_WITH_ARGS:
|
|
|
|
should_load_game = true;
|
|
|
|
break;
|
2016-02-06 18:18:17 +01:00
|
|
|
case FRONTEND_FORK_CORE:
|
|
|
|
/* fall-through */
|
2016-02-05 18:57:44 +01:00
|
|
|
case FRONTEND_FORK_RESTART:
|
2016-02-05 18:34:28 +01:00
|
|
|
{
|
|
|
|
char new_path[PATH_MAX_LENGTH];
|
|
|
|
char salamander_name[PATH_MAX_LENGTH];
|
|
|
|
|
|
|
|
if (frontend_driver_get_salamander_basename(salamander_name,
|
|
|
|
sizeof(salamander_name)))
|
|
|
|
{
|
|
|
|
fill_pathname_join(new_path, g_defaults.dir.core,
|
|
|
|
salamander_name, sizeof(new_path));
|
|
|
|
runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, new_path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FRONTEND_FORK_NONE:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-06-02 18:28:51 +02:00
|
|
|
frontend_gx_exec(s, should_load_game);
|
2016-02-03 15:38:28 +01:00
|
|
|
frontend_driver_get_salamander_basename(salamander_basename,
|
|
|
|
sizeof(salamander_basename));
|
2014-06-05 06:45:31 +02:00
|
|
|
|
2014-09-02 17:42:44 +02:00
|
|
|
/* FIXME/TODO - hack
|
2016-01-13 07:01:29 +01:00
|
|
|
* direct loading failed (out of memory),
|
|
|
|
* try to jump to Salamander,
|
2014-09-02 17:42:44 +02:00
|
|
|
* then load the correct core */
|
2015-07-27 17:18:10 +02:00
|
|
|
fill_pathname_join(s, g_defaults.dir.core,
|
2016-02-03 15:38:28 +01:00
|
|
|
salamander_basename, len);
|
2013-01-09 00:10:19 +01:00
|
|
|
#endif
|
2015-06-02 18:28:51 +02:00
|
|
|
frontend_gx_exec(s, should_load_game);
|
2013-01-09 00:10:19 +01:00
|
|
|
}
|
|
|
|
|
2014-07-28 00:18:05 +02:00
|
|
|
static void frontend_gx_process_args(int *argc, char *argv[])
|
2013-01-07 23:48:21 -05:00
|
|
|
{
|
2013-07-26 20:58:47 +02:00
|
|
|
#ifndef IS_SALAMANDER
|
2016-01-13 07:01:29 +01:00
|
|
|
char path[PATH_MAX_LENGTH];
|
2015-03-20 22:22:06 +01:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
2015-07-20 20:08:13 -05:00
|
|
|
/* A big hack: sometimes Salamander doesn't save the new core
|
2014-09-02 17:42:44 +02:00
|
|
|
* it loads on first boot, so we make sure
|
2015-03-20 22:22:06 +01:00
|
|
|
* settings->libretro is set here. */
|
|
|
|
if (!settings->libretro[0] && *argc >= 1 && strrchr(argv[0], '/'))
|
2013-08-24 23:08:40 +02:00
|
|
|
{
|
2013-08-25 11:07:06 +02:00
|
|
|
strlcpy(path, strrchr(argv[0], '/') + 1, sizeof(path));
|
2016-01-25 03:04:42 +01:00
|
|
|
if (path_file_exists(path))
|
|
|
|
runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, path);
|
2013-08-24 23:08:40 +02:00
|
|
|
}
|
2013-07-26 20:58:47 +02:00
|
|
|
#endif
|
2013-01-07 23:48:21 -05:00
|
|
|
}
|
2012-08-28 23:00:35 -04:00
|
|
|
|
2016-02-07 00:04:19 +01:00
|
|
|
#if defined(HW_RVL) && !defined(IS_SALAMANDER)
|
2016-02-04 17:46:50 +01:00
|
|
|
static bool frontend_gx_set_fork(enum frontend_fork fork_mode)
|
2014-10-02 21:39:29 +02:00
|
|
|
{
|
2016-02-04 17:46:50 +01:00
|
|
|
switch (fork_mode)
|
2016-01-13 11:16:03 +01:00
|
|
|
{
|
2016-02-04 17:46:50 +01:00
|
|
|
case FRONTEND_FORK_CORE:
|
2016-02-05 18:34:28 +01:00
|
|
|
RARCH_LOG("FRONTEND_FORK_CORE\n");
|
2016-02-06 18:18:17 +01:00
|
|
|
gx_fork_mode = fork_mode;
|
2016-02-04 17:46:50 +01:00
|
|
|
break;
|
|
|
|
case FRONTEND_FORK_CORE_WITH_ARGS:
|
2016-02-05 18:34:28 +01:00
|
|
|
RARCH_LOG("FRONTEND_FORK_CORE_WITH_ARGS\n");
|
|
|
|
gx_fork_mode = fork_mode;
|
2016-02-04 17:46:50 +01:00
|
|
|
break;
|
2016-02-05 18:57:44 +01:00
|
|
|
case FRONTEND_FORK_RESTART:
|
|
|
|
RARCH_LOG("FRONTEND_FORK_RESTART\n");
|
|
|
|
gx_fork_mode = fork_mode;
|
2016-02-07 00:04:19 +01:00
|
|
|
rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL);
|
2016-02-04 17:46:50 +01:00
|
|
|
break;
|
|
|
|
case FRONTEND_FORK_NONE:
|
2016-02-05 18:34:28 +01:00
|
|
|
default:
|
2016-02-04 17:46:50 +01:00
|
|
|
return false;
|
|
|
|
}
|
2016-01-13 08:43:08 +01:00
|
|
|
|
2016-02-04 17:08:09 +01:00
|
|
|
return true;
|
2014-10-02 21:39:29 +02:00
|
|
|
}
|
2016-02-03 12:31:29 +01:00
|
|
|
#endif
|
2014-10-02 21:39:29 +02:00
|
|
|
|
2014-05-16 22:20:33 +02:00
|
|
|
static int frontend_gx_get_rating(void)
|
|
|
|
{
|
|
|
|
#ifdef HW_RVL
|
|
|
|
return 8;
|
|
|
|
#else
|
|
|
|
return 6;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-04-18 20:03:59 +02:00
|
|
|
static enum frontend_architecture frontend_gx_get_architecture(void)
|
|
|
|
{
|
|
|
|
return FRONTEND_ARCH_PPC;
|
|
|
|
}
|
|
|
|
|
2015-06-15 22:45:02 +02:00
|
|
|
static int frontend_gx_parse_drive_list(void *data)
|
|
|
|
{
|
|
|
|
#ifndef IS_SALAMANDER
|
|
|
|
file_list_t *list = (file_list_t*)data;
|
|
|
|
#ifdef HW_RVL
|
2016-04-11 05:49:39 +02:00
|
|
|
menu_entries_add(list,
|
2015-06-15 22:45:02 +02:00
|
|
|
"sd:/", "", MENU_FILE_DIRECTORY, 0, 0);
|
2016-04-11 05:49:39 +02:00
|
|
|
menu_entries_add(list,
|
2015-06-15 22:45:02 +02:00
|
|
|
"usb:/", "", MENU_FILE_DIRECTORY, 0, 0);
|
|
|
|
#endif
|
2016-04-11 05:49:39 +02:00
|
|
|
menu_entries_add(list,
|
2015-06-15 22:45:02 +02:00
|
|
|
"carda:/", "", MENU_FILE_DIRECTORY, 0, 0);
|
2016-04-11 05:49:39 +02:00
|
|
|
menu_entries_add(list,
|
2015-06-15 22:45:02 +02:00
|
|
|
"cardb:/", "", MENU_FILE_DIRECTORY, 0, 0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-01-13 11:16:03 +01:00
|
|
|
static void frontend_gx_shutdown(bool unused)
|
|
|
|
{
|
|
|
|
#ifndef IS_SALAMANDER
|
|
|
|
exit(0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-07-27 03:44:28 +02:00
|
|
|
frontend_ctx_driver_t frontend_ctx_gx = {
|
2015-04-18 20:03:59 +02:00
|
|
|
frontend_gx_get_environment_settings,
|
|
|
|
frontend_gx_init,
|
2015-07-20 20:08:13 -05:00
|
|
|
frontend_gx_deinit,
|
2015-04-18 20:03:59 +02:00
|
|
|
frontend_gx_exitspawn,
|
|
|
|
frontend_gx_process_args,
|
|
|
|
frontend_gx_exec,
|
2016-02-07 00:04:19 +01:00
|
|
|
#if defined(HW_RVL) && !defined(IS_SALAMANDER)
|
2015-04-18 20:03:59 +02:00
|
|
|
frontend_gx_set_fork,
|
2016-02-03 12:31:29 +01:00
|
|
|
#else
|
|
|
|
NULL,
|
|
|
|
#endif
|
2016-01-13 11:16:03 +01:00
|
|
|
frontend_gx_shutdown,
|
2014-06-12 16:26:33 +02:00
|
|
|
NULL, /* get_name */
|
2015-04-07 22:48:46 +02:00
|
|
|
NULL, /* get_os */
|
2015-04-18 20:03:59 +02:00
|
|
|
frontend_gx_get_rating,
|
2014-10-17 03:55:16 +02:00
|
|
|
NULL, /* load_content */
|
2015-04-18 20:03:59 +02:00
|
|
|
frontend_gx_get_architecture,
|
2015-04-18 13:56:26 +02:00
|
|
|
NULL, /* get_powerstate */
|
2015-06-15 22:45:02 +02:00
|
|
|
frontend_gx_parse_drive_list,
|
2013-07-26 20:58:47 +02:00
|
|
|
"gx",
|
|
|
|
};
|