301 lines
8.4 KiB
C
Raw Normal View History

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-01-05 22:47:34 +01:00
#include <stddef.h>
#include <stdint.h>
#include <string>
#ifdef _XBOX360
#include <xfilecache.h>
#include "../../360/frontend-xdk/menu.h"
#endif
2012-01-06 14:12:12 +01:00
#include <xbdm.h>
#ifdef _XBOX
#if defined(_XBOX1)
#include "../../xbox1/xdk_d3d8.h"
#elif defined(_XBOX360)
#include "../../360/xdk_d3d9.h"
#endif
#endif
#include "../../console/retroarch_console.h"
#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
static void set_default_settings (void)
{
//g_settings
g_settings.rewind_enable = false;
strlcpy(g_settings.video.cg_shader_path, default_paths.shader_file, sizeof(g_settings.video.cg_shader_path));
2012-05-06 18:53:43 +02:00
g_settings.video.fbo_scale_x = 2.0f;
g_settings.video.fbo_scale_y = 2.0f;
g_settings.video.render_to_texture = true;
strlcpy(g_settings.video.second_pass_shader, default_paths.shader_file, sizeof(g_settings.video.second_pass_shader));
2012-05-07 17:27:14 +02:00
g_settings.video.second_pass_smooth = true;
g_settings.video.smooth = true;
g_settings.video.vsync = true;
2012-07-10 17:39:26 +02:00
strlcpy(g_settings.cheat_database, "game:", sizeof(g_settings.cheat_database));
g_settings.video.aspect_ratio = -1.0f;
rarch_input_set_controls_default();
//g_console
g_console.block_config_read = true;
2012-05-07 17:27:14 +02:00
g_console.frame_advance_enable = false;
g_console.emulator_initialized = 0;
2012-05-07 17:27:14 +02:00
g_console.gamma_correction_enable = true;
g_console.initialize_rarch_enable = false;
2012-05-07 05:34:41 +02:00
g_console.fbo_enabled = true;
g_console.mode_switch = MODE_MENU;
g_console.screen_orientation = ORIENTATION_NORMAL;
g_console.throttle_enable = true;
g_console.aspect_ratio_index = 0;
strlcpy(g_console.default_rom_startup_dir, "game:", sizeof(g_console.default_rom_startup_dir));
g_console.viewports.custom_vp.width = 0;
g_console.viewports.custom_vp.height = 0;
g_console.viewports.custom_vp.x = 0;
g_console.viewports.custom_vp.y = 0;
g_console.color_format = 0;
g_console.info_msg_enable = true;
//g_extern
g_extern.state_slot = 0;
g_extern.audio_data.mute = 0;
g_extern.verbose = true;
}
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;
(void)ret;
#ifdef HAVE_HDD_CACHE_PARTITION
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");
}
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");
}
XFlushUtilityDrive();
#endif
#ifdef _XBOX360
// detect install environment
unsigned long license_mask;
if (XContentGetLicenseMask(&license_mask, NULL) != ERROR_SUCCESS)
{
2012-04-21 23:13:50 +02:00
printf("RetroArch was launched as a standalone DVD, or using DVD emulation, or from the development area of the HDD.\n");
}
else
{
XContentQueryVolumeDeviceType("GAME",&g_console.volume_device_type, NULL);
switch(g_console.volume_device_type)
{
case XCONTENTDEVICETYPE_HDD:
2012-04-21 23:13:50 +02:00
printf("RetroArch was launched from a content package on HDD.\n");
break;
case XCONTENTDEVICETYPE_MU:
2012-04-21 23:13:50 +02:00
printf("RetroArch was launched from a content package on USB or Memory Unit.\n");
break;
case XCONTENTDEVICETYPE_ODD:
2012-04-21 23:13:50 +02:00
printf("RetroArch was launched from a content package on Optical Disc Drive.\n");
break;
default:
2012-04-21 23:13:50 +02:00
printf("RetroArch was launched from a content package on an unknown device type.\n");
break;
}
}
#endif
strlcpy(default_paths.shader_file, "game:\\media\\shaders\\stock.cg", sizeof(default_paths.shader_file));
2012-07-08 16:43:50 +03:00
#ifdef _XBOX1
/* FIXME: Hardcoded */
strlcpy(default_paths.config_file, "D:\\retroarch.cfg", sizeof(default_paths.config_file));
2012-07-11 04:08:36 +02:00
strlcpy(g_settings.system_directory, "D:\\system\\", sizeof(g_settings.system_directory));
2012-07-08 16:43:50 +03:00
#else
strlcpy(default_paths.config_file, "game:\\retroarch.cfg", sizeof(default_paths.config_file));
2012-07-11 04:08:36 +02:00
strlcpy(g_settings.system_directory, "game:\\system\\", sizeof(g_settings.system_directory));
2012-07-08 16:43:50 +03:00
#endif
2012-02-04 13:33:19 +01:00
}
static void configure_libretro(const char *path_prefix, const char * extension)
2012-02-04 13:33:19 +01:00
{
2012-06-29 00:38:26 +02:00
char full_path[1024];
snprintf(full_path, sizeof(full_path), "%sCORE%s", path_prefix, extension);
bool find_libretro_file = rarch_configure_libretro_core(full_path, path_prefix, path_prefix,
default_paths.config_file, extension);
set_default_settings();
rarch_config_load(default_paths.config_file, path_prefix, extension, find_libretro_file);
init_libretro_sym();
}
2012-07-08 00:34:11 +03:00
#ifdef _XBOX1
#include "../../xbox1/RetroLaunch/Global.h"
#include "../../xbox1/RetroLaunch/IniFile.h"
#include "../../xbox1/RetroLaunch/IoSupport.h"
#include "../../xbox1/RetroLaunch/Input.h"
#include "../../xbox1/RetroLaunch/Debug.h"
#include "../../xbox1/RetroLaunch/Font.h"
#include "../../xbox1/RetroLaunch/MenuManager.h"
#include "../../xbox1/RetroLaunch/RomList.h"
bool g_bExit = false;
static void menu_init(void)
{
2012-07-23 15:42:31 +02:00
g_debug.Print("Starting RetroLaunch\n");
2012-07-23 15:42:31 +02:00
// Set file cache size
XSetFileCacheSize(8 * 1024 * 1024);
2012-07-23 15:42:31 +02:00
// Mount drives
g_IOSupport.Mount("A:", "cdrom0");
g_IOSupport.Mount("E:", "Harddisk0\\Partition1");
g_IOSupport.Mount("Z:", "Harddisk0\\Partition2");
g_IOSupport.Mount("F:", "Harddisk0\\Partition6");
g_IOSupport.Mount("G:", "Harddisk0\\Partition7");
// Get RetroArch's native d3d device
2012-07-23 15:42:31 +02:00
// Parse ini file for settings
g_iniFile.CheckForIniEntry();
2012-07-23 15:42:31 +02:00
// Load the rom list if it isn't already loaded
if (!g_romList.IsLoaded()) {
g_romList.Load();
}
2012-07-23 15:42:31 +02:00
// Init input here
g_input.Create();
2012-07-23 15:42:31 +02:00
// Load the font here
g_font.Create();
2012-07-23 15:42:31 +02:00
// Build menu here (Menu state -> Main Menu)
g_menuManager.Create();
g_console.mode_switch = MODE_MENU;
}
2012-07-08 00:34:11 +03:00
static void menu_free(void) {}
static void menu_loop(void)
{
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
2012-07-23 15:42:31 +02:00
//rarch_console_load_game("D:\\ssf2x.gba");
// Loop the app
2012-07-23 15:42:31 +02:00
while (!g_bExit)
{
d3d->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET,
D3DCOLOR_XRGB(0, 0, 0),
1.0f, 0);
d3d->d3d_render_device->BeginScene();
d3d->d3d_render_device->SetFlickerFilter(g_iniFile.m_currentIniEntry.dwFlickerFilter);
d3d->d3d_render_device->SetSoftDisplayFilter(g_iniFile.m_currentIniEntry.bSoftDisplayFilter);
2012-07-23 15:42:31 +02:00
g_input.GetInput();
g_menuManager.Update();
d3d->d3d_render_device->EndScene();
d3d->d3d_render_device->Present(NULL, NULL, NULL, NULL);
2012-07-23 15:42:31 +02:00
}
}
2012-07-08 00:34:11 +03:00
#endif
int main(int argc, char *argv[])
{
2012-07-11 04:08:36 +02:00
rarch_main_clear_state();
get_environment_settings();
config_set_defaults();
#ifdef _XBOX1
configure_libretro("D:\\", ".xbe");
#else
configure_libretro("game:\\", ".xex");
#endif
#if defined(HAVE_D3D8) || defined(HAVE_D3D9)
2012-07-07 20:15:06 +03:00
video_xdk_d3d.start();
#else
video_null.start();
#endif
input_xinput.init();
2012-04-21 23:25:32 +02:00
rarch_input_set_default_keybind_names_for_emulator();
menu_init();
begin_loop:
if(g_console.mode_switch == MODE_EMULATION)
{
bool repeat = false;
input_xinput.poll(NULL);
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
do{
2012-04-21 23:25:32 +02:00
repeat = rarch_main_iterate();
}while(repeat && !g_console.frame_advance_enable);
}
else if(g_console.mode_switch == MODE_MENU)
{
menu_loop();
rarch_startup(default_paths.config_file);
}
else
goto begin_shutdown;
goto begin_loop;
begin_shutdown:
if(path_file_exists(default_paths.config_file))
rarch_config_save(default_paths.config_file);
menu_free();
#if defined(HAVE_D3D8) || defined(HAVE_D3D9)
2012-07-07 20:15:06 +03:00
video_xdk_d3d.stop();
#else
video_null.stop();
#endif
input_xinput.free(NULL);
2012-04-21 23:25:32 +02:00
rarch_exec();
return 0;
}