RetroArch/frontend/platform/platform_gx.c

646 lines
19 KiB
C
Raw Normal View History

2012-04-21 23:13:50 +02:00
/* RetroArch - A frontend for libretro.
2013-01-01 01:37:37 +01:00
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
* Copyright (C) 2011-2013 - Daniel De Matteis
2012-07-26 17:07:47 -04:00
* Copyright (C) 2012 - Michael Lelli
2011-12-14 12:49:13 +01: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/>.
*/
2012-01-08 00:57:44 +01:00
#include <stdbool.h>
#include "../../driver.h"
#include "../../general.h"
#include "../../libretro.h"
#include "platform_inl.h"
#include "../../console/rgui/rgui.h"
#ifndef IS_SALAMANDER
#include "../../gfx/fonts/bitmap.h"
#endif
#include "../../console/rarch_console.h"
#include "../../console/rarch_console_libretro_mgmt.h"
#include "../../console/rarch_console_input.h"
#include "../../console/rarch_console_settings.h"
#include "../../file.h"
2012-01-08 00:57:44 +01:00
#if defined(HW_RVL) && !defined(IS_SALAMANDER)
#include "../../wii/mem2_manager.h"
2012-09-01 04:20:30 +02:00
#endif
2012-08-27 20:36:05 -04:00
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>
#include <dirent.h>
#ifndef _DIRENT_HAVE_D_TYPE
2012-01-08 00:57:44 +01:00
#include <sys/stat.h>
#endif
2012-01-08 00:57:44 +01:00
#include <unistd.h>
#include <dirent.h>
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>
2012-08-07 05:27:27 +02:00
#endif
2011-12-14 14:52:58 +01:00
#include <sdcard/gcsd.h>
#include <fat.h>
2012-01-08 00:57:44 +01:00
#define MAKE_FILE(x) {\
if (!path_file_exists((x)))\
{\
RARCH_WARN("File \"%s\" does not exists, creating\n", (x));\
FILE *f = fopen((x), "wb");\
if (!f)\
{\
RARCH_ERR("Could not create file \"%s\"\n", (x));\
}\
fclose(f);\
}\
}
#define MAKE_DIR(x) {\
if (!path_is_directory((x)))\
{\
RARCH_WARN("Directory \"%s\" does not exists, creating\n", (x));\
if (mkdir((x), 0777) != 0)\
{\
RARCH_ERR("Could not create directory \"%s\"\n", (x));\
}\
}\
}
#ifdef IS_SALAMANDER
default_paths_t default_paths;
static void find_and_set_first_file(void)
{
//Last fallback - we'll need to start the first executable file
// we can find in the RetroArch cores directory
char first_file[512] = {0};
rarch_manage_libretro_set_first_file(first_file, sizeof(first_file),
default_paths.core_dir, "dol");
if(first_file[0])
strlcpy(default_paths.libretro_path, first_file, sizeof(default_paths.libretro_path));
else
RARCH_ERR("Failed last fallback - RetroArch Salamander will exit.\n");
}
static void salamander_init_settings(void)
{
char tmp_str[512] = {0};
bool config_file_exists;
if(!path_file_exists(default_paths.config_path))
{
FILE * f;
config_file_exists = false;
RARCH_ERR("Config file \"%s\" doesn't exist. Creating...\n", default_paths.config_path);
MAKE_DIR(default_paths.port_dir);
f = fopen(default_paths.config_path, "w");
fclose(f);
}
else
config_file_exists = true;
//try to find CORE executable
char core_executable[1024];
snprintf(core_executable, sizeof(core_executable), "%s/CORE.dol", default_paths.core_dir);
if(path_file_exists(core_executable))
{
//Start CORE executable
snprintf(default_paths.libretro_path, sizeof(default_paths.libretro_path), core_executable);
RARCH_LOG("Start [%s].\n", default_paths.libretro_path);
}
else
{
if(config_file_exists)
{
config_file_t * conf = config_file_new(default_paths.config_path);
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
config_file_free(conf);
snprintf(default_paths.libretro_path, sizeof(default_paths.libretro_path), tmp_str);
}
if(!config_file_exists || !strcmp(default_paths.libretro_path, ""))
find_and_set_first_file();
else
{
RARCH_LOG("Start [%s] found in retroarch.cfg.\n", default_paths.libretro_path);
}
if (!config_file_exists)
{
config_file_t *new_conf = config_file_new(NULL);
config_set_string(new_conf, "libretro_path", default_paths.libretro_path);
config_file_write(new_conf, default_paths.config_path);
config_file_free(new_conf);
}
}
}
#else
2012-08-27 22:50:46 -04:00
enum
{
GX_DEVICE_SD = 0,
GX_DEVICE_USB,
GX_DEVICE_END
};
uint16_t menu_framebuf[400 * 240];
2012-08-07 23:40:17 -04:00
rgui_handle_t *rgui;
2013-01-07 23:48:21 -05:00
char input_path[1024];
2012-01-08 00:57:44 +01:00
2012-08-10 23:42:24 -04:00
#if defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER)
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
#ifdef HW_RVL
static struct {
bool mounted;
const DISC_INTERFACE *interface;
const char *name;
} gx_devices[GX_DEVICE_END];
static mutex_t gx_device_mutex;
2012-08-27 22:50:46 -04:00
static void *gx_devthread(void *a)
{
while (1)
{
LWP_MutexLock(gx_device_mutex);
unsigned i;
for (i = 0; i < GX_DEVICE_END; i++)
{
if (gx_devices[i].mounted && !gx_devices[i].interface->isInserted())
{
gx_devices[i].mounted = false;
char n[8];
snprintf(n, sizeof(n), "%s:", gx_devices[i].name);
fatUnmount(n);
}
}
LWP_MutexUnlock(gx_device_mutex);
usleep(100000);
}
return NULL;
}
static int gx_get_device_from_path(const char *path)
{
if (strstr(path, "sd:") == path)
return GX_DEVICE_SD;
if (strstr(path, "usb:") == path)
return GX_DEVICE_USB;
return -1;
}
#endif
#ifdef HAVE_LOGGER
int gx_logger_net(struct _reent *r, int fd, const char *ptr, size_t len)
{
static char temp[4000];
size_t l = len >= 4000 ? 3999 : len;
memcpy(temp, ptr, l);
temp[l] = 0;
logger_send("%s", temp);
return len;
}
#elif defined(HAVE_FILE_LOGGER)
int gx_logger_file(struct _reent *r, int fd, const char *ptr, size_t len)
{
fwrite(ptr, 1, len, g_extern.log_file);
return len;
}
#endif
static const struct retro_keybind _gx_nav_binds[] = {
#ifdef HW_RVL
2012-08-06 22:00:35 +02:00
{ 0, 0, 0, GX_GC_UP | GX_GC_LSTICK_UP | GX_GC_RSTICK_UP | GX_CLASSIC_UP | GX_CLASSIC_LSTICK_UP | GX_CLASSIC_RSTICK_UP | GX_WIIMOTE_UP | GX_NUNCHUK_UP, 0 },
{ 0, 0, 0, GX_GC_DOWN | GX_GC_LSTICK_DOWN | GX_GC_RSTICK_DOWN | GX_CLASSIC_DOWN | GX_CLASSIC_LSTICK_DOWN | GX_CLASSIC_RSTICK_DOWN | GX_WIIMOTE_DOWN | GX_NUNCHUK_DOWN, 0 },
{ 0, 0, 0, GX_GC_LEFT | GX_GC_LSTICK_LEFT | GX_GC_RSTICK_LEFT | GX_CLASSIC_LEFT | GX_CLASSIC_LSTICK_LEFT | GX_CLASSIC_RSTICK_LEFT | GX_WIIMOTE_LEFT | GX_NUNCHUK_LEFT, 0 },
{ 0, 0, 0, GX_GC_RIGHT | GX_GC_LSTICK_RIGHT | GX_GC_RSTICK_RIGHT | GX_CLASSIC_RIGHT | GX_CLASSIC_LSTICK_RIGHT | GX_CLASSIC_RSTICK_RIGHT | GX_WIIMOTE_RIGHT | GX_NUNCHUK_RIGHT, 0 },
{ 0, 0, 0, GX_GC_A | GX_CLASSIC_A | GX_WIIMOTE_A | GX_WIIMOTE_2, 0 },
{ 0, 0, 0, GX_GC_B | GX_CLASSIC_B | GX_WIIMOTE_B | GX_WIIMOTE_1, 0 },
{ 0, 0, 0, GX_GC_START | GX_CLASSIC_PLUS | GX_WIIMOTE_PLUS, 0 },
{ 0, 0, 0, GX_GC_Z_TRIGGER | GX_CLASSIC_MINUS | GX_WIIMOTE_MINUS, 0 },
{ 0, 0, 0, GX_WIIMOTE_HOME | GX_CLASSIC_HOME, 0 },
#else
{ 0, 0, 0, GX_GC_UP | GX_GC_LSTICK_UP | GX_GC_RSTICK_UP, 0 },
{ 0, 0, 0, GX_GC_DOWN | GX_GC_LSTICK_DOWN | GX_GC_RSTICK_DOWN, 0 },
{ 0, 0, 0, GX_GC_LEFT | GX_GC_LSTICK_LEFT | GX_GC_RSTICK_LEFT, 0 },
{ 0, 0, 0, GX_GC_RIGHT | GX_GC_LSTICK_RIGHT | GX_GC_RSTICK_RIGHT, 0 },
{ 0, 0, 0, GX_GC_A, 0 },
{ 0, 0, 0, GX_GC_B, 0 },
{ 0, 0, 0, GX_GC_START, 0 },
{ 0, 0, 0, GX_GC_Z_TRIGGER, 0 },
{ 0, 0, 0, GX_WIIMOTE_HOME, 0 },
#endif
2012-08-20 19:47:04 -04:00
{ 0, 0, 0, GX_QUIT_KEY, 0 },
2012-07-26 17:07:47 -04:00
};
static const struct retro_keybind *gx_nav_binds[] = {
_gx_nav_binds
};
enum
{
2012-08-06 22:00:35 +02:00
GX_DEVICE_NAV_UP = 0,
GX_DEVICE_NAV_DOWN,
GX_DEVICE_NAV_LEFT,
GX_DEVICE_NAV_RIGHT,
GX_DEVICE_NAV_A,
GX_DEVICE_NAV_B,
GX_DEVICE_NAV_START,
GX_DEVICE_NAV_SELECT,
2012-08-20 19:47:04 -04:00
GX_DEVICE_NAV_MENU,
GX_DEVICE_NAV_QUIT,
2012-08-06 22:00:35 +02:00
GX_DEVICE_NAV_LAST
};
2012-05-06 04:04:33 +02:00
static bool folder_cb(const char *directory, rgui_file_enum_cb_t file_cb,
2012-01-08 00:57:44 +01:00
void *userdata, void *ctx)
{
bool core_chooser = (userdata) ? *(rgui_file_type_t *)userdata == RGUI_SETTINGS_CORE : false;
2012-01-08 00:57:44 +01:00
if (!*directory)
{
#ifdef HW_RVL
file_cb(ctx, "sd:", RGUI_FILE_DEVICE, 0);
file_cb(ctx, "usb:", RGUI_FILE_DEVICE, 0);
#endif
file_cb(ctx, "carda:", RGUI_FILE_DEVICE, 0);
file_cb(ctx, "cardb:", RGUI_FILE_DEVICE, 0);
return true;
}
#ifdef HW_RVL
2012-08-27 22:50:46 -04:00
LWP_MutexLock(gx_device_mutex);
int dev = gx_get_device_from_path(directory);
if (dev != -1 && !gx_devices[dev].mounted && gx_devices[dev].interface->isInserted())
fatMountSimple(gx_devices[dev].name, gx_devices[dev].interface);
LWP_MutexUnlock(gx_device_mutex);
#endif
2012-08-27 22:50:46 -04:00
char exts[256];
if (core_chooser)
strlcpy(exts, "dol|DOL", sizeof(exts));
else
strlcpy(exts, rarch_console_get_rom_ext(), sizeof(exts));
struct string_list *ext_list = string_split(exts, "|");
char _dir[PATH_MAX];
snprintf(_dir, sizeof(_dir), "%s/", directory);
DIR *dir = opendir(_dir);
2012-01-08 00:57:44 +01:00
if (!dir)
return false;
struct dirent *entry;
while ((entry = readdir(dir)))
{
char stat_path[PATH_MAX];
const char *file_ext = path_get_extension(entry->d_name);
2012-01-08 00:57:44 +01:00
snprintf(stat_path, sizeof(stat_path), "%s/%s", directory, entry->d_name);
bool is_dir;
#ifdef _DIRENT_HAVE_D_TYPE
is_dir = (entry->d_type == DT_DIR);
if (entry->d_type != DT_REG && !is_dir)
continue;
#else
2012-01-08 00:57:44 +01:00
struct stat st;
if (stat(stat_path, &st) < 0)
continue;
is_dir = S_ISDIR(st.st_mode);
if (!S_ISREG(st.st_mode) && !is_dir)
2012-01-08 00:57:44 +01:00
continue;
#endif
2012-01-08 00:57:44 +01:00
if (core_chooser && (is_dir || strcasecmp(entry->d_name, default_paths.salamander_file) == 0))
continue;
if (!is_dir && ext_list && !string_list_find_elem_prefix(ext_list, ".", file_ext))
continue;
2012-01-08 00:57:44 +01:00
file_cb(ctx,
entry->d_name,
is_dir ? RGUI_FILE_DIRECTORY : RGUI_FILE_PLAIN, 0);
2012-01-08 00:57:44 +01:00
}
closedir(dir);
string_list_free(ext_list);
2012-01-08 00:57:44 +01:00
return true;
}
static bool rmenu_iterate(void)
2012-01-08 00:57:44 +01:00
{
2013-01-06 17:40:27 +01:00
static uint16_t old_input_state = 0;
2013-01-06 18:47:36 -05:00
static bool initial_held = true;
2013-01-06 17:40:27 +01:00
static bool first_held = false;
2012-01-08 01:07:26 +01:00
2012-12-18 08:32:48 +01:00
g_extern.draw_menu = true;
driver.video->apply_state_changes();
2013-01-06 17:40:27 +01:00
g_extern.frame_count++;
2012-12-15 05:55:08 +01:00
2013-01-06 17:40:27 +01:00
uint16_t input_state = 0;
2012-01-08 00:57:44 +01:00
driver.input->poll(NULL);
2012-07-26 17:07:47 -04:00
2013-01-06 17:40:27 +01:00
for (unsigned i = 0; i < GX_DEVICE_NAV_LAST; i++)
input_state |= driver.input->input_state(NULL, gx_nav_binds, 0,
2013-01-06 17:40:27 +01:00
RETRO_DEVICE_JOYPAD, 0, i) ? (1ULL << i) : 0;
2012-01-08 00:57:44 +01:00
2013-01-06 17:40:27 +01:00
uint16_t trigger_state = input_state & ~old_input_state;
bool do_held = (input_state & ((1ULL << GX_DEVICE_NAV_UP) | (1ULL << GX_DEVICE_NAV_DOWN) | (1ULL << GX_DEVICE_NAV_LEFT) | (1ULL << GX_DEVICE_NAV_RIGHT))) && !(input_state & ((1ULL << GX_DEVICE_NAV_MENU) | (1ULL << GX_DEVICE_NAV_QUIT)));
2012-08-21 01:14:46 -04:00
2013-01-06 17:40:27 +01:00
if(do_held)
{
if(!first_held)
2012-08-21 01:14:46 -04:00
{
2013-01-06 17:40:27 +01:00
first_held = true;
g_extern.delay_timer[1] = g_extern.frame_count + (initial_held ? 15 : 7);
2012-08-21 01:14:46 -04:00
}
2013-01-06 17:40:27 +01:00
if (!(g_extern.frame_count < g_extern.delay_timer[1]))
2012-08-21 01:14:46 -04:00
{
first_held = false;
2013-01-06 17:40:27 +01:00
trigger_state = input_state; //second input frame set as current frame
2012-08-21 01:14:46 -04:00
}
2013-01-06 17:40:27 +01:00
initial_held = false;
}
else
{
first_held = false;
initial_held = true;
}
rgui_action_t action = RGUI_ACTION_NOOP;
// don't run anything first frame, only capture held inputs for old_input_state
if (trigger_state & (1ULL << GX_DEVICE_NAV_UP))
action = RGUI_ACTION_UP;
else if (trigger_state & (1ULL << GX_DEVICE_NAV_DOWN))
action = RGUI_ACTION_DOWN;
else if (trigger_state & (1ULL << GX_DEVICE_NAV_LEFT))
action = RGUI_ACTION_LEFT;
else if (trigger_state & (1ULL << GX_DEVICE_NAV_RIGHT))
action = RGUI_ACTION_RIGHT;
else if (trigger_state & (1ULL << GX_DEVICE_NAV_B))
action = RGUI_ACTION_CANCEL;
else if (trigger_state & (1ULL << GX_DEVICE_NAV_A))
action = RGUI_ACTION_OK;
else if (trigger_state & (1ULL << GX_DEVICE_NAV_START))
action = RGUI_ACTION_START;
else if (trigger_state & (1ULL << GX_DEVICE_NAV_SELECT))
action = RGUI_ACTION_SETTINGS;
rgui_iterate(rgui, action);
rarch_render_cached_frame();
old_input_state = input_state;
if (!(g_extern.frame_count < g_extern.delay_timer[0]))
2013-01-06 17:40:27 +01:00
{
bool rmenu_enable = ((trigger_state & (1ULL << GX_DEVICE_NAV_MENU)) && g_extern.main_is_init);
bool quit_key_pressed = (trigger_state & (1ULL << GX_DEVICE_NAV_QUIT));
2013-01-06 17:40:27 +01:00
switch(g_extern.console.rmenu.mode)
2012-01-08 00:57:44 +01:00
{
2013-01-06 17:40:27 +01:00
case MODE_EXIT:
case MODE_INIT:
case MODE_EMULATION:
break;
default:
2013-01-06 18:47:36 -05:00
g_extern.console.rmenu.mode = quit_key_pressed ? MODE_EXIT : rmenu_enable ? MODE_EMULATION : MODE_MENU;
2013-01-06 17:40:27 +01:00
break;
2012-07-26 17:07:47 -04:00
}
2013-01-06 17:40:27 +01:00
}
2012-08-07 23:40:17 -04:00
2013-01-06 17:40:27 +01:00
if (g_extern.console.rmenu.mode != MODE_MENU)
goto deinit;
2013-01-06 01:28:23 +01:00
2013-01-06 17:40:27 +01:00
return true;
2012-08-07 23:40:17 -04:00
2013-01-06 17:40:27 +01:00
deinit:
2013-01-08 00:35:49 +01:00
// set a timer delay so that we don't instantly switch back to the menu when
// press and holding QUIT in the emulation loop (lasts for 30 frame ticks)
2013-01-06 17:40:27 +01:00
if (!(g_extern.lifecycle_state & (1ULL << RARCH_FRAMEADVANCE)))
g_extern.delay_timer[0] = g_extern.frame_count + 30;
2013-01-08 00:35:49 +01:00
2012-12-18 08:32:48 +01:00
g_extern.draw_menu = false;
g_extern.console.rmenu.state.ingame_menu.enable = false;
2013-01-06 17:40:27 +01:00
return false;
2012-08-07 23:40:17 -04:00
}
static void menu_init(void)
{
rgui = rgui_init("",
menu_framebuf, RGUI_WIDTH * sizeof(uint16_t),
NULL /* _binary_console_font_bmp_start */, bitmap_bin, folder_cb, NULL);
2012-08-07 23:40:17 -04:00
g_extern.console.rmenu.mode = MODE_MENU;
rgui_iterate(rgui, RGUI_ACTION_REFRESH);
2012-08-07 23:40:17 -04:00
}
static void menu_free(void)
{
rgui_free(rgui);
2012-01-08 00:57:44 +01:00
}
2011-12-14 12:49:13 +01:00
#endif
2013-01-07 23:48:21 -05:00
static void get_environment_settings(int argc, char *argv[])
{
2013-01-07 23:48:21 -05:00
(void)argc;
(void)argv;
#ifdef HW_DOL
chdir("carda:/retroarch");
#endif
getcwd(default_paths.core_dir, MAXPATHLEN);
char *last_slash = strrchr(default_paths.core_dir, '/');
if (last_slash)
*last_slash = 0;
char *device_end = strchr(default_paths.core_dir, '/');
if (device_end)
snprintf(default_paths.port_dir, sizeof(default_paths.port_dir), "%.*s/retroarch", device_end - default_paths.core_dir, default_paths.core_dir);
else
strlcpy(default_paths.port_dir, "/retroarch", sizeof(default_paths.port_dir));
#ifdef IS_SALAMANDER
snprintf(default_paths.config_path, sizeof(default_paths.config_path), "%s/retroarch.cfg", default_paths.port_dir);
#else
2013-01-07 23:48:21 -05:00
snprintf(g_extern.config_path, sizeof(g_extern.config_path), "%s/retroarch.cfg", default_paths.port_dir);
#endif
2013-01-07 23:48:21 -05:00
snprintf(default_paths.system_dir, sizeof(default_paths.system_dir), "%s/system", default_paths.port_dir);
snprintf(default_paths.savestate_dir, sizeof(default_paths.savestate_dir), "%s/savestates", default_paths.port_dir);
strlcpy(default_paths.filesystem_root_dir, "/", sizeof(default_paths.filesystem_root_dir));
snprintf(default_paths.filebrowser_startup_dir, sizeof(default_paths.filebrowser_startup_dir), default_paths.filesystem_root_dir);
snprintf(default_paths.sram_dir, sizeof(default_paths.sram_dir), "%s/sram", default_paths.port_dir);
snprintf(default_paths.input_presets_dir, sizeof(default_paths.input_presets_dir), "%s/input", default_paths.port_dir);
strlcpy(default_paths.executable_extension, ".dol", sizeof(default_paths.executable_extension));
strlcpy(default_paths.salamander_file, "boot.dol", sizeof(default_paths.salamander_file));
#ifndef IS_SALAMANDER
MAKE_DIR(default_paths.port_dir);
MAKE_DIR(default_paths.system_dir);
MAKE_DIR(default_paths.savestate_dir);
MAKE_DIR(default_paths.sram_dir);
MAKE_DIR(default_paths.input_presets_dir);
MAKE_FILE(g_extern.config_path);
#endif
2012-07-27 19:15:42 +02:00
}
extern void __exception_setreload(int t);
2013-01-07 23:48:21 -05:00
static void system_init(void)
2011-12-14 12:49:13 +01:00
{
2012-06-29 19:10:41 -04:00
#ifdef HW_RVL
2012-08-22 15:56:20 -04:00
IOS_ReloadIOS(IOS_GetVersion());
2012-06-29 18:42:42 -04:00
L2Enhance();
#ifndef IS_SALAMANDER
2012-08-27 20:36:05 -04:00
gx_init_mem2();
2012-06-29 19:10:41 -04:00
#endif
#endif
2012-06-29 19:10:41 -04: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
inl_logger_init();
devoptab_list[STD_OUT] = &dotab_stdout;
devoptab_list[STD_ERR] = &dotab_stdout;
dotab_stdout.write_r = gx_logger_net;
#elif defined(HAVE_FILE_LOGGER)
inl_logger_init();
#ifndef IS_SALAMANDER
devoptab_list[STD_OUT] = &dotab_stdout;
devoptab_list[STD_ERR] = &dotab_stdout;
dotab_stdout.write_r = gx_logger_file;
#endif
#endif
#if defined(HW_RVL) && !defined(IS_SALAMANDER)
2012-08-27 22:50:46 -04:00
lwp_t gx_device_thread;
gx_devices[GX_DEVICE_SD].interface = &__io_wiisd;
gx_devices[GX_DEVICE_SD].name = "sd";
gx_devices[GX_DEVICE_SD].mounted = fatMountSimple(gx_devices[GX_DEVICE_SD].name, gx_devices[GX_DEVICE_SD].interface);
gx_devices[GX_DEVICE_USB].interface = &__io_usbstorage;
gx_devices[GX_DEVICE_USB].name = "usb";
gx_devices[GX_DEVICE_USB].mounted = fatMountSimple(gx_devices[GX_DEVICE_USB].name, gx_devices[GX_DEVICE_USB].interface);
LWP_MutexInit(&gx_device_mutex, false);
LWP_CreateThread(&gx_device_thread, gx_devthread, NULL, NULL, 0, 66);
#endif
2013-01-07 23:48:21 -05:00
}
2012-08-27 22:50:46 -04:00
static void system_exitspawn(void)
{
#ifdef IS_SALAMANDER
rarch_console_exec(default_paths.libretro_path);
#else
if(g_extern.console.external_launch.enable)
rarch_console_exec(g_settings.libretro);
#endif
}
static void system_deinit(void)
{
#if defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER)
inl_logger_deinit()
#endif
}
#ifndef IS_SALAMANDER
2013-01-07 23:48:21 -05:00
static void system_post_init(void)
{
2012-08-07 13:12:51 -04:00
gx_video_t *gx = (gx_video_t*)driver.video_data;
2012-08-21 00:51:00 -04:00
char core_name[64];
2013-01-07 23:48:21 -05:00
get_libretro_core_name(core_name, sizeof(core_name));
2012-08-21 00:51:00 -04:00
snprintf(input_path, sizeof(input_path), "%s/%s.cfg", default_paths.input_presets_dir, core_name);
config_read_keybinds(input_path);
2013-01-07 23:48:21 -05:00
gx->menu_data = (uint32_t *) menu_framebuf;
}
2012-07-27 19:15:42 +02:00
static void system_deinit_save(void)
{
config_save_keybinds(input_path);
}
2013-01-07 23:48:21 -05:00
static void system_process_args(int argc, char *argv[])
{
if (argc > 2 && argv[1] != NULL && argv[2] != NULL)
{
char rom[PATH_MAX];
g_extern.console.external_launch.support = EXTERN_LAUNCHER_CHANNEL;
snprintf(rom, sizeof(rom), "%s%s", argv[1], argv[2]);
g_extern.file_state.zip_extract_mode = ZIP_EXTRACT_TO_CURRENT_DIR_AND_LOAD_FIRST_FILE;
rarch_console_load_game_wrap(rom, g_extern.file_state.zip_extract_mode, S_DELAY_1);
rgui_iterate(rgui, RGUI_ACTION_MESSAGE);
2012-12-18 08:32:48 +01:00
g_extern.draw_menu = true;
rarch_render_cached_frame();
2012-12-18 08:32:48 +01:00
g_extern.draw_menu = false;
g_extern.console.rmenu.mode = MODE_INIT;
}
else
g_extern.console.external_launch.support = EXTERN_LAUNCHER_SALAMANDER;
2013-01-07 23:48:21 -05:00
}
#endif