(GX) work with new console code

This commit is contained in:
ToadKing 2013-01-07 23:48:21 -05:00
parent 7c3b9486b3
commit 1dc08b9a6d
7 changed files with 198 additions and 263 deletions

View File

@ -374,9 +374,7 @@ MAIN
#include "../../frontend/frontend_xdk.c"
#elif defined(XENON)
#include "../../frontend/frontend_xenon.c"
#elif defined(GEKKO)
#include "../../frontend/frontend_gx.c"
#elif defined(__CELLOS_LV2__)
#elif defined(__CELLOS_LV2__) || defined(GEKKO)
#include "../../frontend/frontend_console.c"
#elif defined(PSP)
#include "../../frontend/frontend_psp.c"

View File

@ -217,6 +217,9 @@ static void adjust_system_rates(void)
g_extern.system.force_nonblock = false;
const struct retro_system_timing *info = &g_extern.system.av_info.timing;
if (!info->fps || !info->sample_rate)
return;
float timing_skew = fabs(1.0f - info->fps / g_settings.video.refresh_rate);
if (timing_skew > 0.05f) // We don't want to adjust pitch too much. If we have extreme cases, just don't readjust at all.
{

View File

@ -19,10 +19,10 @@
#include <stddef.h>
#include <string.h>
#include "../console/rmenu/rmenu.h"
#if defined(__CELLOS_LV2__)
#include "frontend_ps3.c"
#elif defined(GEKKO)
#include "frontend_gx.c"
#endif
#undef main
@ -86,7 +86,9 @@ begin_loop:
{
driver.input->poll(NULL);
driver.video->set_aspect_ratio(driver.video_data, g_settings.video.aspect_ratio_idx);
audio_start_func();
while(rarch_main_iterate());
audio_stop_func();
}
else if (g_extern.console.rmenu.mode == MODE_INIT)
{
@ -119,6 +121,8 @@ begin_loop:
begin_shutdown:
config_save_file(g_extern.config_path);
system_deinit_save();
if(g_extern.main_is_init)
rarch_main_deinit();
@ -126,6 +130,14 @@ begin_shutdown:
driver.video->stop();
menu_free();
#ifdef HAVE_LOGGER
logger_shutdown();
#elif defined(HAVE_FILE_LOGGER)
if (g_extern.log_file)
fclose(g_extern.log_file);
g_extern.log_file = NULL;
#endif
system_deinit();
system_exitspawn();

View File

@ -15,8 +15,6 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#undef main
#include <stdbool.h>
#include "../driver.h"
#include "../general.h"
@ -62,6 +60,7 @@ enum
uint16_t menu_framebuf[400 * 240];
rgui_handle_t *rgui;
char input_path[1024];
#if defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER)
static devoptab_t dotab_stdout = {
@ -390,31 +389,6 @@ static void menu_free(void)
rgui_free(rgui);
}
static void get_environment_settings(void)
{
#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));
snprintf(g_extern.config_path, sizeof(g_extern.config_path), "%s/retroarch.cfg", default_paths.port_dir);
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));
}
#define MAKE_FILE(x) {\
if (!path_file_exists((x)))\
{\
@ -439,8 +413,33 @@ static void get_environment_settings(void)
}\
}
static void make_directories(void)
static void get_environment_settings(int argc, char *argv[])
{
(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));
snprintf(g_extern.config_path, sizeof(g_extern.config_path), "%s/retroarch.cfg", default_paths.port_dir);
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));
MAKE_DIR(default_paths.port_dir);
MAKE_DIR(default_paths.system_dir);
MAKE_DIR(default_paths.savestate_dir);
@ -450,9 +449,10 @@ static void make_directories(void)
MAKE_FILE(g_extern.config_path);
}
extern void __exception_setreload(int t);
int main(int argc, char *argv[])
static void system_init(void)
{
#ifdef HW_RVL
IOS_ReloadIOS(IOS_GetVersion());
@ -491,54 +491,22 @@ int main(int argc, char *argv[])
LWP_MutexInit(&gx_device_mutex, false);
LWP_CreateThread(&gx_device_thread, gx_devthread, NULL, NULL, 0, 66);
#endif
}
rarch_main_clear_state();
get_environment_settings();
make_directories();
config_set_defaults();
init_drivers_pre();
driver.input->init();
driver.video->start();
static void system_post_init(void)
{
gx_video_t *gx = (gx_video_t*)driver.video_data;
gx->menu_data = (uint32_t *) menu_framebuf;
rarch_settings_set_default();
rarch_input_set_controls_default(driver.input);
rarch_config_load();
#ifdef HAVE_LIBRETRO_MANAGEMENT
char core_exe_path[PATH_MAX];
char path_prefix[PATH_MAX];
const char *extension = default_paths.executable_extension;
snprintf(path_prefix, sizeof(path_prefix), "%s/", default_paths.core_dir);
snprintf(core_exe_path, sizeof(core_exe_path), "%sCORE%s", path_prefix, extension);
if (path_file_exists(core_exe_path))
{
if (rarch_libretro_core_install(core_exe_path, path_prefix, path_prefix,
g_extern.config_path, extension))
{
RARCH_LOG("New default libretro core saved to config file: %s.\n", g_settings.libretro);
config_save_file(g_extern.config_path);
}
}
#endif
char core_name[64];
rarch_console_name_from_id(core_name, sizeof(core_name));
char input_path[1024];
snprintf(input_path, sizeof(input_path), "%s/%s.cfg", default_paths.input_presets_dir, core_name);
config_read_keybinds(input_path);
init_libretro_sym();
driver.input->post_init();
menu_init();
gx->menu_data = (uint32_t *) menu_framebuf;
}
static void system_process_args(int argc, char *argv[])
{
if (argc > 2 && argv[1] != NULL && argv[2] != NULL)
{
char rom[PATH_MAX];
@ -556,69 +524,19 @@ int main(int argc, char *argv[])
}
else
g_extern.console.external_launch.support = EXTERN_LAUNCHER_SALAMANDER;
begin_loop:
if(g_extern.console.rmenu.mode == MODE_EMULATION)
{
driver.input->poll(NULL);
video_set_aspect_ratio_func(g_settings.video.aspect_ratio_idx);
audio_start_func();
while(rarch_main_iterate());
audio_stop_func();
}
else if (g_extern.console.rmenu.mode == MODE_INIT)
{
if(g_extern.main_is_init)
rarch_main_deinit();
struct rarch_main_wrap args = {0};
args.verbose = g_extern.verbose;
args.config_path = g_extern.config_path;
args.sram_path = g_extern.console.main_wrap.state.default_sram_dir.enable ? g_extern.console.main_wrap.paths.default_sram_dir : NULL,
args.state_path = g_extern.console.main_wrap.state.default_savestate_dir.enable ? g_extern.console.main_wrap.paths.default_savestate_dir : NULL,
args.rom_path = g_extern.file_state.rom_path;
args.libretro_path = g_settings.libretro;
int init_ret = rarch_main_init_wrap(&args);
if (init_ret == 0)
RARCH_LOG("rarch_main_init succeeded.\n");
else
RARCH_ERR("rarch_main_init failed.\n");
}
else if(g_extern.console.rmenu.mode == MODE_MENU)
rmenu_iterate();
else
goto begin_shutdown;
goto begin_loop;
begin_shutdown:
config_save_file(g_extern.config_path);
config_save_keybinds(input_path);
if(g_extern.main_is_init)
rarch_main_deinit();
driver.input->free(NULL);
driver.video->stop();
menu_free();
#ifdef HAVE_LOGGER
logger_shutdown();
#elif defined(HAVE_FILE_LOGGER)
if (g_extern.log_file)
fclose(g_extern.log_file);
g_extern.log_file = NULL;
#endif
if(g_extern.console.external_launch.enable)
rarch_console_exec(g_settings.libretro);
exit(0);
}
static void system_deinit_save(void)
{
config_save_keybinds(input_path);
}
static void system_deinit(void)
{
}
static void system_exitspawn(void)
{
if(g_extern.console.external_launch.enable)
rarch_console_exec(g_settings.libretro);
}

View File

@ -55,6 +55,9 @@ static void dma_callback(void)
static void *gx_audio_init(const char *device, unsigned rate, unsigned latency)
{
if (g_audio)
return g_audio;
AUDIO_Init(NULL);
AUDIO_RegisterDMACallback(dma_callback);

View File

@ -282,13 +282,11 @@ static void gx_input_poll(void *data)
{
uint32_t type = 0;
uint32_t down = 0;
uint64_t *state_cur = NULL;
uint64_t *state_cur = &pad_state[port];
#ifdef HW_RVL
if (WPAD_Probe(port, &type) != WPAD_ERR_NONE)
continue;
state_cur = &pad_state[port];
if (WPAD_Probe(port, &type) == WPAD_ERR_NONE)
{
WPADData *wpaddata = WPAD_Data(port);
down = wpaddata->btns_h;
@ -388,11 +386,12 @@ static void gx_input_poll(void *data)
if (abs(y) > JOYSTICK_THRESHOLD)
*state_cur |= y > 0 ? GX_NUNCHUK_UP : GX_NUNCHUK_DOWN;
}
}
#endif
if (!(SI_GetType(port) & SI_TYPE_GC))
continue;
if (SI_GetType(port) & SI_TYPE_GC)
{
down = PAD_ButtonsHeld(port);
*state_cur |= (down & PAD_BUTTON_A) ? GX_GC_A : 0;
@ -430,6 +429,7 @@ static void gx_input_poll(void *data)
if ((*state_cur & (GX_GC_LSTICK_UP | GX_GC_RSTICK_UP | GX_GC_L_TRIGGER | GX_GC_R_TRIGGER)) == (GX_GC_LSTICK_UP | GX_GC_RSTICK_UP | GX_GC_L_TRIGGER | GX_GC_R_TRIGGER))
*state_cur |= GX_WIIMOTE_HOME;
}
}
uint64_t *lifecycle_state = &g_extern.lifecycle_state;
uint64_t *pad_p1 = &pad_state[0];

View File

@ -1023,4 +1023,5 @@ const video_driver_t video_gx = {
.stop = gx_stop,
.restart = gx_restart,
.apply_state_changes = gx_apply_state_changes,
.set_aspect_ratio = gx_set_aspect_ratio
};