2012-04-21 23:13:50 +02:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2012-01-08 01:08:18 +01:00
|
|
|
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2012 - Daniel De Matteis
|
2012-01-05 22:47:34 +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
|
2012-01-05 22:47:34 +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;
|
2012-01-05 22:47:34 +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.
|
2012-01-05 22:47:34 +01:00
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <xtl.h>
|
2012-07-08 00:27:48 +03:00
|
|
|
|
2012-01-05 22:47:34 +01:00
|
|
|
#include <stddef.h>
|
2012-01-24 00:29:03 +01:00
|
|
|
#include <stdint.h>
|
2012-01-23 05:10:23 +01:00
|
|
|
#include <string>
|
2012-07-08 00:27:48 +03:00
|
|
|
|
2012-07-23 18:52:58 +02:00
|
|
|
#include "../../xdk/menu_shared.h"
|
|
|
|
|
2012-07-08 00:27:48 +03:00
|
|
|
#ifdef _XBOX360
|
|
|
|
#include <xfilecache.h>
|
2012-07-16 05:13:30 +02:00
|
|
|
#include "../../360/frontend-xdk/menu.h"
|
2012-07-08 00:27:48 +03:00
|
|
|
#endif
|
|
|
|
|
2012-01-06 14:12:12 +01:00
|
|
|
#include <xbdm.h>
|
2012-07-08 21:42:26 +02:00
|
|
|
|
|
|
|
#ifdef _XBOX
|
|
|
|
#if defined(_XBOX1)
|
|
|
|
#include "../../xbox1/xdk_d3d8.h"
|
|
|
|
#elif defined(_XBOX360)
|
2012-07-16 05:13:30 +02:00
|
|
|
#include "../../360/xdk_d3d9.h"
|
2012-07-08 21:42:26 +02:00
|
|
|
#endif
|
|
|
|
#endif
|
2012-06-22 07:38:53 +02:00
|
|
|
|
2012-07-28 15:54:35 +02:00
|
|
|
#include "../../console/rarch_console.h"
|
2012-07-28 16:35:07 +02:00
|
|
|
#include "../../console/rarch_console_exec.h"
|
2012-07-28 16:42:57 +02:00
|
|
|
#include "../../console/rarch_console_libretro_mgmt.h"
|
2012-07-28 15:54:35 +02:00
|
|
|
#include "../../console/rarch_console_config.h"
|
2012-07-28 16:21:05 +02:00
|
|
|
#include "../../console/rarch_console_main_wrap.h"
|
2012-06-22 07:38:53 +02:00
|
|
|
#include "../../conf/config_file.h"
|
|
|
|
#include "../../conf/config_file_macros.h"
|
|
|
|
#include "../../file.h"
|
|
|
|
#include "../../general.h"
|
2012-01-05 22:47:34 +01:00
|
|
|
|
2012-04-21 23:25:32 +02:00
|
|
|
int rarch_main(int argc, char *argv[]);
|
2012-01-05 22:47:34 +01:00
|
|
|
|
|
|
|
#undef main
|
2012-01-22 01:43:54 +01:00
|
|
|
|
2012-02-04 13:33:19 +01:00
|
|
|
static void get_environment_settings (void)
|
2012-01-05 22:47:34 +01:00
|
|
|
{
|
2012-07-23 10:23:27 +02:00
|
|
|
HRESULT ret;
|
2012-07-23 16:38:29 +02:00
|
|
|
(void)ret;
|
2012-06-30 13:37:18 +02:00
|
|
|
#ifdef HAVE_HDD_CACHE_PARTITION
|
2012-04-10 21:23:42 +02:00
|
|
|
ret = XSetFileCacheSize(0x100000);
|
|
|
|
|
|
|
|
if(ret != TRUE)
|
|
|
|
{
|
2012-04-21 23:25:32 +02:00
|
|
|
RARCH_ERR("Couldn't change number of bytes reserved for file system cache.\n");
|
2012-04-10 21:23:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = XFileCacheInit(XFILECACHE_CLEAR_ALL, 0x100000, XFILECACHE_DEFAULT_THREAD, 0, 1);
|
|
|
|
|
|
|
|
if(ret != ERROR_SUCCESS)
|
|
|
|
{
|
2012-04-21 23:25:32 +02:00
|
|
|
RARCH_ERR("File cache could not be initialized.\n");
|
2012-04-10 21:23:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
XFlushUtilityDrive();
|
2012-06-30 13:37:18 +02:00
|
|
|
#endif
|
|
|
|
|
2012-07-08 00:27:48 +03:00
|
|
|
#ifdef _XBOX360
|
2012-04-10 21:23:42 +02:00
|
|
|
// detect install environment
|
|
|
|
unsigned long license_mask;
|
|
|
|
|
|
|
|
if (XContentGetLicenseMask(&license_mask, NULL) != ERROR_SUCCESS)
|
|
|
|
{
|
2012-07-28 17:48:52 +02:00
|
|
|
RARCH_LOG("RetroArch was launched as a standalone DVD, or using DVD emulation, or from the development area of the HDD.\n");
|
2012-04-10 21:23:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XContentQueryVolumeDeviceType("GAME",&g_console.volume_device_type, NULL);
|
|
|
|
|
|
|
|
switch(g_console.volume_device_type)
|
|
|
|
{
|
|
|
|
case XCONTENTDEVICETYPE_HDD:
|
2012-07-28 17:48:52 +02:00
|
|
|
RARCH_LOG("RetroArch was launched from a content package on HDD.\n");
|
2012-04-10 21:23:42 +02:00
|
|
|
break;
|
|
|
|
case XCONTENTDEVICETYPE_MU:
|
2012-07-28 17:48:52 +02:00
|
|
|
RARCH_LOG("RetroArch was launched from a content package on USB or Memory Unit.\n");
|
2012-04-10 21:23:42 +02:00
|
|
|
break;
|
|
|
|
case XCONTENTDEVICETYPE_ODD:
|
2012-07-28 17:48:52 +02:00
|
|
|
RARCH_LOG("RetroArch was launched from a content package on Optical Disc Drive.\n");
|
2012-04-10 21:23:42 +02:00
|
|
|
break;
|
|
|
|
default:
|
2012-07-28 17:48:52 +02:00
|
|
|
RARCH_LOG("RetroArch was launched from a content package on an unknown device type.\n");
|
2012-04-10 21:23:42 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-07-08 00:27:48 +03:00
|
|
|
#endif
|
2012-04-10 21:23:42 +02:00
|
|
|
|
2012-07-25 21:46:22 +02:00
|
|
|
#if defined(_XBOX1)
|
2012-07-08 16:43:50 +03:00
|
|
|
/* FIXME: Hardcoded */
|
2012-07-23 18:17:50 +02:00
|
|
|
strlcpy(default_paths.config_file, "D:\\retroarch.cfg", sizeof(default_paths.config_file));
|
2012-07-27 14:59:45 +02:00
|
|
|
strlcpy(default_paths.system_dir, "D:\\system\\", sizeof(default_paths.system_dir));
|
2012-07-24 09:57:34 +02:00
|
|
|
strlcpy(default_paths.filesystem_root_dir, "D:\\", sizeof(default_paths.filesystem_root_dir));
|
|
|
|
strlcpy(default_paths.executable_extension, ".xbe", sizeof(default_paths.executable_extension));
|
2012-07-25 21:46:22 +02:00
|
|
|
#elif defined(_XBOX360)
|
|
|
|
#ifdef HAVE_HDD_CACHE_PARTITION
|
|
|
|
strlcpy(default_paths.cache_dir, "cache:\\", sizeof(default_paths.cache_dir));
|
|
|
|
#endif
|
2012-07-24 09:57:34 +02:00
|
|
|
strlcpy(default_paths.filesystem_root_dir, "game:\\", sizeof(default_paths.filesystem_root_dir));
|
2012-07-23 18:52:58 +02:00
|
|
|
strlcpy(default_paths.shader_file, "game:\\media\\shaders\\stock.cg", sizeof(default_paths.shader_file));
|
2012-07-23 18:17:50 +02:00
|
|
|
strlcpy(default_paths.config_file, "game:\\retroarch.cfg", sizeof(default_paths.config_file));
|
2012-07-27 14:59:45 +02:00
|
|
|
strlcpy(default_paths.system_dir, "game:\\system\\", sizeof(default_paths.system_dir));
|
2012-07-24 09:57:34 +02:00
|
|
|
strlcpy(default_paths.executable_extension, ".xex", sizeof(default_paths.executable_extension));
|
2012-07-08 16:43:50 +03:00
|
|
|
#endif
|
2012-02-04 13:33:19 +01:00
|
|
|
}
|
|
|
|
|
2012-07-08 00:27:48 +03:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2012-07-11 04:08:36 +02:00
|
|
|
rarch_main_clear_state();
|
2012-07-08 00:27:48 +03:00
|
|
|
get_environment_settings();
|
|
|
|
|
|
|
|
config_set_defaults();
|
|
|
|
|
2012-07-25 21:02:01 +02:00
|
|
|
input_xinput.init();
|
2012-07-28 18:41:18 +02:00
|
|
|
|
|
|
|
const char *path_prefix = default_paths.filesystem_root_dir;
|
|
|
|
const char *extension = default_paths.executable_extension;
|
|
|
|
const input_driver_t *input = &input_xinput;
|
|
|
|
bool find_libretro_file = rarch_configure_libretro(input, path_prefix, extension);
|
|
|
|
|
|
|
|
rarch_settings_set_default(input);
|
|
|
|
rarch_config_load(default_paths.config_file, path_prefix, extension, find_libretro_file);
|
|
|
|
init_libretro_sym();
|
2012-03-12 22:39:29 +01:00
|
|
|
|
2012-07-27 15:46:15 +02:00
|
|
|
input_xinput.post_init();
|
|
|
|
|
2012-07-08 18:21:29 +03:00
|
|
|
#if defined(HAVE_D3D8) || defined(HAVE_D3D9)
|
2012-07-07 20:15:06 +03:00
|
|
|
video_xdk_d3d.start();
|
2012-07-08 18:21:29 +03:00
|
|
|
#else
|
|
|
|
video_null.start();
|
|
|
|
#endif
|
2012-03-12 22:39:29 +01:00
|
|
|
|
2012-04-10 21:23:42 +02:00
|
|
|
menu_init();
|
2012-01-24 00:29:03 +01:00
|
|
|
|
|
|
|
begin_loop:
|
2012-04-10 21:23:42 +02:00
|
|
|
if(g_console.mode_switch == MODE_EMULATION)
|
|
|
|
{
|
|
|
|
bool repeat = false;
|
|
|
|
|
2012-07-07 20:56:46 +03:00
|
|
|
input_xinput.poll(NULL);
|
2012-04-10 21:23:42 +02:00
|
|
|
|
2012-07-07 14:41:58 +02:00
|
|
|
rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height);
|
2012-05-22 20:15:27 +02:00
|
|
|
|
2012-04-10 21:23:42 +02:00
|
|
|
do{
|
2012-04-21 23:25:32 +02:00
|
|
|
repeat = rarch_main_iterate();
|
2012-04-10 21:23:42 +02:00
|
|
|
}while(repeat && !g_console.frame_advance_enable);
|
|
|
|
}
|
|
|
|
else if(g_console.mode_switch == MODE_MENU)
|
|
|
|
{
|
|
|
|
menu_loop();
|
2012-07-23 18:17:50 +02:00
|
|
|
rarch_startup(default_paths.config_file);
|
2012-04-10 21:23:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
goto begin_shutdown;
|
|
|
|
|
|
|
|
goto begin_loop;
|
2012-01-24 00:29:03 +01:00
|
|
|
|
|
|
|
begin_shutdown:
|
2012-07-23 18:17:50 +02:00
|
|
|
if(path_file_exists(default_paths.config_file))
|
|
|
|
rarch_config_save(default_paths.config_file);
|
2012-04-10 21:23:42 +02:00
|
|
|
|
2012-06-18 06:22:26 +02:00
|
|
|
menu_free();
|
2012-07-08 18:21:29 +03:00
|
|
|
#if defined(HAVE_D3D8) || defined(HAVE_D3D9)
|
2012-07-07 20:15:06 +03:00
|
|
|
video_xdk_d3d.stop();
|
2012-07-08 18:21:29 +03:00
|
|
|
#else
|
|
|
|
video_null.stop();
|
|
|
|
#endif
|
2012-07-07 20:56:46 +03:00
|
|
|
input_xinput.free(NULL);
|
2012-07-28 18:26:30 +02:00
|
|
|
|
|
|
|
if(g_console.return_to_launcher)
|
|
|
|
rarch_console_exec(g_console.launch_app_on_exit);
|
2012-04-10 21:23:42 +02:00
|
|
|
|
|
|
|
return 0;
|
2012-07-08 18:21:29 +03:00
|
|
|
}
|