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
|
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/>.
|
|
|
|
*/
|
|
|
|
|
2012-01-24 00:29:03 +01:00
|
|
|
#include <stdint.h>
|
2015-06-15 22:45:02 +02:00
|
|
|
#include <stddef.h>
|
2012-07-08 00:27:48 +03:00
|
|
|
|
2015-06-15 22:45:02 +02:00
|
|
|
#include <xtl.h>
|
2012-01-06 14:12:12 +01:00
|
|
|
#include <xbdm.h>
|
2015-09-20 15:39:59 +02:00
|
|
|
#include <xgraphics.h>
|
2012-07-08 21:42:26 +02:00
|
|
|
|
2014-10-22 01:59:46 +02:00
|
|
|
#include <file/file_path.h>
|
2015-06-15 22:45:02 +02:00
|
|
|
#ifndef IS_SALAMANDER
|
|
|
|
#include <file/file_list.h>
|
|
|
|
#endif
|
2015-01-17 05:47:33 +01:00
|
|
|
#include <retro_miscellaneous.h>
|
2013-01-09 01:35:46 +01:00
|
|
|
|
2015-06-15 22:45:02 +02:00
|
|
|
#include "platform_xdk.h"
|
|
|
|
#include "../../general.h"
|
|
|
|
|
2014-10-02 21:39:29 +02:00
|
|
|
static bool exit_spawn;
|
|
|
|
static bool exitspawn_start_game;
|
|
|
|
|
2015-01-03 23:39:32 +01:00
|
|
|
#ifdef _XBOX360
|
|
|
|
typedef struct _STRING
|
|
|
|
{
|
|
|
|
USHORT Length;
|
|
|
|
USHORT MaximumLength;
|
|
|
|
PCHAR Buffer;
|
|
|
|
} STRING, *PSTRING;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
VOID RtlInitAnsiString(PSTRING DestinationString, PCHAR SourceString);
|
|
|
|
HRESULT ObDeleteSymbolicLink(PSTRING SymbolicLinkName);
|
|
|
|
HRESULT ObCreateSymbolicLink(PSTRING SymbolicLinkName, PSTRING DeviceName);
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
HRESULT xbox_io_mount(const char* szDrive, char* szDevice)
|
|
|
|
{
|
|
|
|
STRING DeviceName, LinkName;
|
2015-01-08 15:59:28 +01:00
|
|
|
CHAR szDestinationDrive[PATH_MAX_LENGTH];
|
|
|
|
sprintf_s(szDestinationDrive, PATH_MAX_LENGTH, "\\??\\%s", szDrive);
|
2015-01-03 23:39:32 +01:00
|
|
|
RtlInitAnsiString(&DeviceName, szDevice);
|
|
|
|
RtlInitAnsiString(&LinkName, szDestinationDrive);
|
|
|
|
ObDeleteSymbolicLink(&LinkName);
|
|
|
|
return (HRESULT)ObCreateSymbolicLink(&LinkName, &DeviceName);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-01-09 05:24:31 +01:00
|
|
|
#ifdef _XBOX1
|
|
|
|
static HRESULT xbox_io_mount(char *szDrive, char *szDevice)
|
|
|
|
{
|
2014-05-31 18:34:06 +02:00
|
|
|
#ifndef IS_SALAMANDER
|
2015-06-12 23:38:46 +02:00
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
bool original_verbose = global->verbosity;
|
|
|
|
global->verbosity = true;
|
2014-05-31 18:34:06 +02:00
|
|
|
#endif
|
2015-06-12 23:38:46 +02:00
|
|
|
char szSourceDevice[48] = {0};
|
|
|
|
char szDestinationDrive[16] = {0};
|
2013-01-09 05:24:31 +01:00
|
|
|
|
2014-09-02 17:42:44 +02:00
|
|
|
snprintf(szSourceDevice, sizeof(szSourceDevice),
|
|
|
|
"\\Device\\%s", szDevice);
|
|
|
|
snprintf(szDestinationDrive, sizeof(szDestinationDrive),
|
|
|
|
"\\??\\%s", szDrive);
|
|
|
|
RARCH_LOG("xbox_io_mount() - source device: %s.\n",
|
|
|
|
szSourceDevice);
|
|
|
|
RARCH_LOG("xbox_io_mount() - destination drive: %s.\n",
|
|
|
|
szDestinationDrive);
|
2013-01-09 05:24:31 +01:00
|
|
|
|
|
|
|
STRING DeviceName =
|
|
|
|
{
|
|
|
|
strlen(szSourceDevice),
|
|
|
|
strlen(szSourceDevice) + 1,
|
|
|
|
szSourceDevice
|
|
|
|
};
|
|
|
|
|
|
|
|
STRING LinkName =
|
|
|
|
{
|
|
|
|
strlen(szDestinationDrive),
|
|
|
|
strlen(szDestinationDrive) + 1,
|
|
|
|
szDestinationDrive
|
|
|
|
};
|
|
|
|
|
|
|
|
IoCreateSymbolicLink(&LinkName, &DeviceName);
|
|
|
|
|
2014-05-31 18:34:06 +02:00
|
|
|
#ifndef IS_SALAMANDER
|
2015-03-21 04:43:18 +01:00
|
|
|
global->verbosity = original_verbose;
|
2014-05-31 18:34:06 +02:00
|
|
|
#endif
|
2013-01-09 05:24:31 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT xbox_io_unmount(char *szDrive)
|
|
|
|
{
|
2015-06-12 23:38:46 +02:00
|
|
|
char szDestinationDrive[16] = {0};
|
|
|
|
|
2014-09-02 17:42:44 +02:00
|
|
|
snprintf(szDestinationDrive, sizeof(szDestinationDrive),
|
|
|
|
"\\??\\%s", szDrive);
|
2013-01-09 05:24:31 +01:00
|
|
|
|
|
|
|
STRING LinkName =
|
|
|
|
{
|
|
|
|
strlen(szDestinationDrive),
|
|
|
|
strlen(szDestinationDrive) + 1,
|
|
|
|
szDestinationDrive
|
|
|
|
};
|
|
|
|
|
|
|
|
IoDeleteSymbolicLink(&LinkName);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-06-03 03:35:12 +02:00
|
|
|
static void frontend_xdk_get_environment_settings(int *argc, char *argv[],
|
|
|
|
void *args, void *params_data)
|
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
|
|
|
|
2013-08-10 20:59:10 +02:00
|
|
|
#ifndef IS_SALAMANDER
|
2015-06-12 23:38:46 +02:00
|
|
|
global_t *global = global_get_ptr();
|
2015-03-21 04:43:18 +01:00
|
|
|
bool original_verbose = global->verbosity;
|
2015-06-12 23:38:46 +02:00
|
|
|
|
2015-03-21 04:43:18 +01:00
|
|
|
global->verbosity = true;
|
2014-05-31 18:34:06 +02:00
|
|
|
#endif
|
2013-08-10 20:59:10 +02:00
|
|
|
|
2014-05-31 18:34:06 +02:00
|
|
|
#ifndef IS_SALAMANDER
|
2013-08-10 20:59:10 +02:00
|
|
|
#if defined(HAVE_LOGGER)
|
|
|
|
logger_init();
|
|
|
|
#elif defined(HAVE_FILE_LOGGER)
|
2015-03-21 04:43:18 +01:00
|
|
|
global->log_file = fopen("/retroarch-log.txt", "w");
|
2013-08-10 20:59:10 +02:00
|
|
|
#endif
|
|
|
|
#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;
|
2013-01-09 01:35:46 +01:00
|
|
|
DWORD volume_device_type;
|
2012-04-10 21:23:42 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2013-01-09 01:35:46 +01:00
|
|
|
XContentQueryVolumeDeviceType("GAME",&volume_device_type, NULL);
|
2012-04-10 21:23:42 +02:00
|
|
|
|
2013-01-09 01:35:46 +01:00
|
|
|
switch(volume_device_type)
|
2012-04-10 21:23:42 +02:00
|
|
|
{
|
|
|
|
case XCONTENTDEVICETYPE_HDD:
|
2012-07-28 17:48:52 +02:00
|
|
|
RARCH_LOG("RetroArch was launched from a content package on HDD.\n");
|
2013-03-11 07:13:11 +01:00
|
|
|
break;
|
|
|
|
case XCONTENTDEVICETYPE_MU:
|
|
|
|
RARCH_LOG("RetroArch was launched from a content package on USB or Memory Unit.\n");
|
|
|
|
break;
|
|
|
|
case XCONTENTDEVICETYPE_ODD:
|
|
|
|
RARCH_LOG("RetroArch was launched from a content package on Optical Disc Drive.\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RARCH_LOG("RetroArch was launched from a content package on an unknown device type.\n");
|
|
|
|
break;
|
2012-04-10 21:23:42 +02:00
|
|
|
}
|
|
|
|
}
|
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)
|
2015-07-27 17:18:10 +02:00
|
|
|
strlcpy(g_defaults.dir.core, "D:", sizeof(g_defaults.dir.core));
|
|
|
|
strlcpy(g_defaults.dir.core_info, "D:", sizeof(g_defaults.dir.core_info));
|
|
|
|
fill_pathname_join(g_defaults.path.config, g_defaults.dir.core,
|
|
|
|
"retroarch.cfg", sizeof(g_defaults.path.config));
|
|
|
|
fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.core,
|
|
|
|
"savestates", sizeof(g_defaults.dir.savestate));
|
|
|
|
fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.core,
|
|
|
|
"savefiles", sizeof(g_defaults.dir.sram));
|
|
|
|
fill_pathname_join(g_defaults.dir.system, g_defaults.dir.core,
|
|
|
|
"system", sizeof(g_defaults.dir.system));
|
|
|
|
fill_pathname_join(g_defaults.dir.screenshot, g_defaults.dir.core,
|
|
|
|
"screenshots", sizeof(g_defaults.dir.screenshot));
|
2012-07-25 21:46:22 +02:00
|
|
|
#elif defined(_XBOX360)
|
2015-07-27 17:18:10 +02:00
|
|
|
strlcpy(g_defaults.dir.core, "game:", sizeof(g_defaults.dir.core));
|
|
|
|
strlcpy(g_defaults.dir.core_info,
|
|
|
|
"game:", sizeof(g_defaults.dir.core_info));
|
|
|
|
strlcpy(g_defaults.path.config,
|
|
|
|
"game:\\retroarch.cfg", sizeof(g_defaults.path.config));
|
|
|
|
strlcpy(g_defaults.dir.screenshot,
|
|
|
|
"game:", sizeof(g_defaults.dir.screenshot));
|
|
|
|
strlcpy(g_defaults.dir.savestate,
|
|
|
|
"game:\\savestates", sizeof(g_defaults.dir.savestate));
|
|
|
|
strlcpy(g_defaults.dir.playlist,
|
|
|
|
"game:\\playlists", sizeof(g_defaults.dir.playlist));
|
|
|
|
strlcpy(g_defaults.dir.sram,
|
|
|
|
"game:\\savefiles", sizeof(g_defaults.dir.sram));
|
|
|
|
strlcpy(g_defaults.dir.system,
|
|
|
|
"game:\\system", sizeof(g_defaults.dir.system));
|
2012-07-08 16:43:50 +03:00
|
|
|
#endif
|
2014-05-31 18:34:06 +02:00
|
|
|
|
|
|
|
#ifndef IS_SALAMANDER
|
2015-01-17 05:47:33 +01:00
|
|
|
static char path[PATH_MAX_LENGTH];
|
2014-06-13 18:11:08 +02:00
|
|
|
*path = '\0';
|
2014-06-03 19:14:07 +02:00
|
|
|
#if defined(_XBOX1)
|
|
|
|
LAUNCH_DATA ptr;
|
|
|
|
DWORD launch_type;
|
|
|
|
|
|
|
|
if (XGetLaunchInfo(&launch_type, &ptr) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (launch_type == LDT_FROM_DEBUGGER_CMDLINE)
|
|
|
|
{
|
|
|
|
RARCH_LOG("Launched from commandline debugger.\n");
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char *extracted_path = (char*)&ptr.Data;
|
|
|
|
|
|
|
|
if (extracted_path && extracted_path[0] != '\0'
|
2014-09-02 17:42:44 +02:00
|
|
|
&& (strstr(extracted_path, "Pool") == NULL)
|
|
|
|
/* Hack. Unknown problem */)
|
2014-06-03 19:14:07 +02:00
|
|
|
{
|
|
|
|
strlcpy(path, extracted_path, sizeof(path));
|
|
|
|
RARCH_LOG("Auto-start game %s.\n", path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#elif defined(_XBOX360)
|
|
|
|
DWORD dwLaunchDataSize;
|
|
|
|
if (XGetLaunchDataSize(&dwLaunchDataSize) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
BYTE* pLaunchData = new BYTE[dwLaunchDataSize];
|
|
|
|
XGetLaunchData(pLaunchData, dwLaunchDataSize);
|
2015-01-03 23:47:26 +01:00
|
|
|
AURORA_LAUNCHDATA_EXECUTABLE* aurora = (AURORA_LAUNCHDATA_EXECUTABLE*)pLaunchData;
|
2015-01-03 23:39:32 +01:00
|
|
|
char* extracted_path = new char[dwLaunchDataSize];
|
|
|
|
memset(extracted_path, 0, dwLaunchDataSize);
|
2015-01-03 23:47:26 +01:00
|
|
|
if (aurora->ApplicationId == AURORA_LAUNCHDATA_APPID && aurora->FunctionId == AURORA_LAUNCHDATA_EXECUTABLE_FUNCID)
|
2015-01-03 23:39:32 +01:00
|
|
|
{
|
|
|
|
if (xbox_io_mount("aurora:", aurora->SystemPath) >= 0)
|
|
|
|
sprintf_s(extracted_path, dwLaunchDataSize, "aurora:%s%s", aurora->RelativePath, aurora->Exectutable);
|
|
|
|
else
|
|
|
|
RARCH_LOG("Failed to mount %s as aurora:.\n", aurora->SystemPath);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sprintf_s(extracted_path, dwLaunchDataSize, "%s", pLaunchData);
|
2014-06-03 19:14:07 +02:00
|
|
|
if (extracted_path && extracted_path[0] != '\0')
|
|
|
|
{
|
|
|
|
strlcpy(path, extracted_path, sizeof(path));
|
|
|
|
RARCH_LOG("Auto-start game %s.\n", path);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pLaunchData)
|
|
|
|
delete []pLaunchData;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (path && path[0] != '\0')
|
|
|
|
{
|
|
|
|
struct rarch_main_wrap *args = (struct rarch_main_wrap*)params_data;
|
|
|
|
|
|
|
|
if (args)
|
|
|
|
{
|
|
|
|
args->touched = true;
|
2014-07-28 19:55:28 +02:00
|
|
|
args->no_content = false;
|
2014-06-03 19:14:07 +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 19:14:07 +02:00
|
|
|
args->libretro_path = NULL;
|
|
|
|
|
|
|
|
RARCH_LOG("Auto-start game %s.\n", path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef IS_SALAMANDER
|
2014-10-21 08:13:50 +02:00
|
|
|
exit:
|
2015-03-21 04:43:18 +01:00
|
|
|
global->verbosity = original_verbose;
|
2014-05-31 18:34:06 +02:00
|
|
|
#endif
|
2012-02-04 13:33:19 +01:00
|
|
|
}
|
|
|
|
|
2014-05-17 14:56:12 +02:00
|
|
|
static void frontend_xdk_init(void *data)
|
2012-08-06 22:53:57 +02:00
|
|
|
{
|
2013-11-03 16:38:56 +01:00
|
|
|
(void)data;
|
2013-01-09 01:35:46 +01:00
|
|
|
#if defined(_XBOX1) && !defined(IS_SALAMANDER)
|
2012-08-06 22:53:57 +02:00
|
|
|
// Mount drives
|
|
|
|
xbox_io_mount("A:", "cdrom0");
|
2012-08-22 16:22:42 +02:00
|
|
|
xbox_io_mount("C:", "Harddisk0\\Partition0");
|
2012-08-06 22:53:57 +02:00
|
|
|
xbox_io_mount("E:", "Harddisk0\\Partition1");
|
|
|
|
xbox_io_mount("Z:", "Harddisk0\\Partition2");
|
|
|
|
xbox_io_mount("F:", "Harddisk0\\Partition6");
|
|
|
|
xbox_io_mount("G:", "Harddisk0\\Partition7");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-05-17 14:56:12 +02:00
|
|
|
static void frontend_xdk_exec(const char *path, bool should_load_game);
|
2013-07-27 21:38:38 +02:00
|
|
|
|
2014-10-02 21:39:29 +02:00
|
|
|
static void frontend_xdk_set_fork(bool exit, bool start_game)
|
|
|
|
{
|
|
|
|
exit_spawn = exit;
|
|
|
|
exitspawn_start_game = start_game;
|
|
|
|
}
|
|
|
|
|
2015-06-02 18:28:51 +02:00
|
|
|
static void frontend_xdk_exitspawn(char *s, size_t len)
|
2013-01-08 06:26:02 +01:00
|
|
|
{
|
2013-04-29 03:05:46 +02:00
|
|
|
bool should_load_game = false;
|
2014-06-05 06:45:31 +02:00
|
|
|
#ifndef IS_SALAMANDER
|
2014-10-02 21:39:29 +02:00
|
|
|
should_load_game = exitspawn_start_game;
|
|
|
|
|
|
|
|
if (!exit_spawn)
|
|
|
|
return;
|
2013-01-09 01:35:46 +01:00
|
|
|
#endif
|
2015-06-02 18:28:51 +02:00
|
|
|
frontend_xdk_exec(s, should_load_game);
|
2013-01-08 07:44:57 +01:00
|
|
|
}
|
2013-07-27 00:32:56 +02:00
|
|
|
|
2014-05-17 14:56:12 +02:00
|
|
|
static void frontend_xdk_exec(const char *path, bool should_load_game)
|
2013-07-27 03:59:01 +02:00
|
|
|
{
|
2014-05-31 18:34:06 +02:00
|
|
|
#ifndef IS_SALAMANDER
|
2015-03-21 04:43:18 +01:00
|
|
|
global_t *global = global_get_ptr();
|
|
|
|
bool original_verbose = global->verbosity;
|
|
|
|
global->verbosity = true;
|
2014-05-31 18:34:06 +02:00
|
|
|
#endif
|
2013-07-27 03:59:01 +02:00
|
|
|
(void)should_load_game;
|
|
|
|
|
|
|
|
RARCH_LOG("Attempt to load executable: [%s].\n", path);
|
|
|
|
#ifdef IS_SALAMANDER
|
2014-06-03 19:14:07 +02:00
|
|
|
if (path[0] != '\0')
|
|
|
|
XLaunchNewImage(path, NULL);
|
2013-07-27 03:59:01 +02:00
|
|
|
#else
|
|
|
|
#if defined(_XBOX1)
|
|
|
|
LAUNCH_DATA ptr;
|
|
|
|
memset(&ptr, 0, sizeof(ptr));
|
2015-06-12 23:38:46 +02:00
|
|
|
|
2015-03-21 04:43:18 +01:00
|
|
|
if (should_load_game && global->fullpath[0] != '\0')
|
|
|
|
snprintf((char*)ptr.Data, sizeof(ptr.Data), "%s", global->fullpath);
|
2014-06-03 19:14:07 +02:00
|
|
|
|
|
|
|
if (path[0] != '\0')
|
|
|
|
XLaunchNewImage(path, ptr.Data[0] != '\0' ? &ptr : NULL);
|
2013-07-27 03:59:01 +02:00
|
|
|
#elif defined(_XBOX360)
|
2015-06-12 23:38:46 +02:00
|
|
|
char game_path[1024] = {0};
|
|
|
|
|
2015-03-21 04:43:18 +01:00
|
|
|
if (should_load_game && global->fullpath[0] != '\0')
|
2013-07-27 03:59:01 +02:00
|
|
|
{
|
2015-03-21 04:43:18 +01:00
|
|
|
strlcpy(game_path, global->fullpath, sizeof(game_path));
|
2013-07-27 03:59:01 +02:00
|
|
|
XSetLaunchData(game_path, MAX_LAUNCH_DATA_SIZE);
|
|
|
|
}
|
2014-06-03 19:14:07 +02:00
|
|
|
|
|
|
|
if (path[0] != '\0')
|
|
|
|
XLaunchNewImage(path, NULL);
|
2013-07-27 03:59:01 +02:00
|
|
|
#endif
|
|
|
|
#endif
|
2014-05-31 18:34:06 +02:00
|
|
|
#ifndef IS_SALAMANDER
|
2015-03-21 04:43:18 +01:00
|
|
|
global->verbosity = original_verbose;
|
2014-05-31 18:34:06 +02:00
|
|
|
#endif
|
2013-07-27 03:59:01 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 22:20:33 +02:00
|
|
|
static int frontend_xdk_get_rating(void)
|
|
|
|
{
|
|
|
|
#if defined(_XBOX360)
|
|
|
|
return 11;
|
|
|
|
#elif defined(_XBOX1)
|
|
|
|
return 7;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-04-18 20:03:59 +02:00
|
|
|
enum frontend_architecture frontend_xdk_get_architecture(void)
|
|
|
|
{
|
|
|
|
#if defined(_XBOX360)
|
|
|
|
return FRONTEND_ARCH_PPC;
|
|
|
|
#elif defined(_XBOX1)
|
|
|
|
return FRONTEND_ARCH_X86;
|
|
|
|
#else
|
|
|
|
return FRONTEND_ARCH_NONE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-06-15 22:45:02 +02:00
|
|
|
static int frontend_xdk_parse_drive_list(void *data)
|
|
|
|
{
|
|
|
|
#ifndef IS_SALAMANDER
|
|
|
|
file_list_t *list = (file_list_t*)data;
|
|
|
|
|
|
|
|
#if defined(_XBOX1)
|
|
|
|
menu_list_push(list,
|
|
|
|
"C:", "", MENU_FILE_DIRECTORY, 0, 0);
|
|
|
|
menu_list_push(list,
|
|
|
|
"D:", "", MENU_FILE_DIRECTORY, 0, 0);
|
|
|
|
menu_list_push(list,
|
|
|
|
"E:", "", MENU_FILE_DIRECTORY, 0, 0);
|
|
|
|
menu_list_push(list,
|
|
|
|
"F:", "", MENU_FILE_DIRECTORY, 0, 0);
|
|
|
|
menu_list_push(list,
|
|
|
|
"G:", "", MENU_FILE_DIRECTORY, 0, 0);
|
|
|
|
#elif defined(_XBOX360)
|
|
|
|
menu_list_push(list,
|
|
|
|
"game:", "", MENU_FILE_DIRECTORY, 0, 0);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-27 03:44:28 +02:00
|
|
|
frontend_ctx_driver_t frontend_ctx_xdk = {
|
2015-04-18 20:03:59 +02:00
|
|
|
frontend_xdk_get_environment_settings,
|
|
|
|
frontend_xdk_init,
|
2013-07-27 16:36:55 +02:00
|
|
|
NULL, /* deinit */
|
2015-04-18 20:03:59 +02:00
|
|
|
frontend_xdk_exitspawn,
|
2014-06-03 19:21:49 +02:00
|
|
|
NULL, /* process_args */
|
2015-04-18 20:03:59 +02:00
|
|
|
frontend_xdk_exec,
|
|
|
|
frontend_xdk_set_fork,
|
2013-07-27 16:36:55 +02:00
|
|
|
NULL, /* 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_xdk_get_rating,
|
2014-10-17 03:55:16 +02:00
|
|
|
NULL, /* load_content */
|
2015-04-18 20:03:59 +02:00
|
|
|
frontend_xdk_get_architecture,
|
2015-04-18 13:56:26 +02:00
|
|
|
NULL, /* get_powerstate */
|
2015-06-15 22:45:02 +02:00
|
|
|
frontend_xdk_parse_drive_list,
|
2013-07-27 00:32:56 +02:00
|
|
|
"xdk",
|
|
|
|
};
|
2015-09-20 15:39:59 +02:00
|
|
|
|
|
|
|
#ifdef _XBOX360
|
|
|
|
struct XPR_HEADER
|
|
|
|
{
|
|
|
|
DWORD dwMagic;
|
|
|
|
DWORD dwHeaderSize;
|
|
|
|
DWORD dwDataSize;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define XPR0_MAGIC_VALUE 0x30525058
|
|
|
|
#define XPR1_MAGIC_VALUE 0x31525058
|
|
|
|
#define XPR2_MAGIC_VALUE 0x58505232
|
|
|
|
|
|
|
|
PackedResource::PackedResource()
|
|
|
|
{
|
|
|
|
m_pSysMemData = NULL;
|
|
|
|
m_dwSysMemDataSize = 0L;
|
|
|
|
m_pVidMemData = NULL;
|
|
|
|
m_dwVidMemDataSize = 0L;
|
|
|
|
m_pResourceTags = NULL;
|
|
|
|
m_dwNumResourceTags = 0L;
|
|
|
|
m_bInitialized = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PackedResource::~PackedResource()
|
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
void *PackedResource::GetData(const char *strName) const
|
|
|
|
{
|
|
|
|
if (m_pResourceTags == NULL || strName == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
#if defined(_XBOX1)
|
|
|
|
for (DWORD i=0; m_pResourceTags[i].strName; i++)
|
|
|
|
#elif defined(_XBOX360)
|
|
|
|
for (DWORD i = 0; i < m_dwNumResourceTags; i++)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
if (!strcasecmp(strName, m_pResourceTags[i].strName))
|
|
|
|
return &m_pSysMemData[m_pResourceTags[i].dwOffset];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INLINE void* AllocateContiguousMemory(DWORD Size, DWORD Alignment)
|
|
|
|
{
|
|
|
|
#if defined(_XBOX1)
|
|
|
|
return D3D_AllocContiguousMemory(Size, Alignment);
|
|
|
|
#elif defined(_XBOX360)
|
|
|
|
return XMemAlloc(Size, MAKE_XALLOC_ATTRIBUTES(0, 0, 0, 0, eXALLOCAllocatorId_GameMax,
|
|
|
|
Alignment, XALLOC_MEMPROTECT_WRITECOMBINE, 0, XALLOC_MEMTYPE_PHYSICAL));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static INLINE void FreeContiguousMemory(void* pData)
|
|
|
|
{
|
|
|
|
#if defined(_XBOX1)
|
|
|
|
return D3D_FreeContiguousMemory(pData);
|
|
|
|
#elif defined(_XBOX360)
|
|
|
|
return XMemFree(pData, MAKE_XALLOC_ATTRIBUTES(0, 0, 0, 0, eXALLOCAllocatorId_GameMax,
|
|
|
|
0, 0, 0, XALLOC_MEMTYPE_PHYSICAL));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _XBOX1
|
|
|
|
char g_strMediaPath[512] = "D:\\Media\\";
|
|
|
|
|
|
|
|
static HRESULT FindMediaFile(char *strPath, const char *strFilename, size_t strPathsize)
|
|
|
|
{
|
|
|
|
if(strFilename == NULL || strPath == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
strlcpy(strPath, strFilename, strPathsize);
|
|
|
|
|
|
|
|
if(strFilename[1] != ':')
|
|
|
|
snprintf(strPath, strPathsize, "%s%s", g_strMediaPath, strFilename);
|
|
|
|
|
|
|
|
HANDLE hFile = CreateFile(strPath, GENERIC_READ, FILE_SHARE_READ, NULL,
|
|
|
|
OPEN_EXISTING, 0, NULL);
|
|
|
|
|
|
|
|
if (hFile == INVALID_HANDLE_VALUE)
|
|
|
|
return 0x82000004;
|
|
|
|
|
|
|
|
CloseHandle(hFile);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_XBOX1)
|
|
|
|
HRESULT PackedResource::Create(const char *strFilename,
|
|
|
|
DWORD dwNumResourceTags, XBRESOURCE* pResourceTags)
|
|
|
|
#elif defined(_XBOX360)
|
|
|
|
HRESULT PackedResource::Create(const char *strFilename)
|
|
|
|
#endif
|
|
|
|
{
|
2015-09-28 16:20:26 +02:00
|
|
|
unsigned i;
|
2015-09-20 15:39:59 +02:00
|
|
|
HANDLE hFile;
|
|
|
|
DWORD dwNumBytesRead;
|
|
|
|
XPR_HEADER xprh;
|
|
|
|
bool retval;
|
|
|
|
#ifdef _XBOX1
|
|
|
|
BOOL bHasResourceOffsetsTable = FALSE;
|
|
|
|
char strResourcePath[512];
|
|
|
|
|
|
|
|
if (FAILED(FindMediaFile(strResourcePath, strFilename, sizeof(strResourcePath))))
|
|
|
|
return E_FAIL;
|
|
|
|
strFilename = strResourcePath;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
hFile = CreateFile(strFilename, GENERIC_READ, FILE_SHARE_READ, NULL,
|
|
|
|
OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
|
|
|
|
if (hFile == INVALID_HANDLE_VALUE)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
retval = ReadFile(hFile, &xprh, sizeof(XPR_HEADER), &dwNumBytesRead, NULL);
|
|
|
|
|
|
|
|
#if defined(_XBOX1)
|
|
|
|
if(xprh.dwMagic == XPR0_MAGIC_VALUE)
|
|
|
|
bHasResourceOffsetsTable = FALSE;
|
|
|
|
else if(xprh.dwMagic == XPR1_MAGIC_VALUE)
|
|
|
|
bHasResourceOffsetsTable = TRUE;
|
|
|
|
else
|
|
|
|
#elif defined(_XBOX360)
|
|
|
|
if(!retval)
|
|
|
|
{
|
|
|
|
CloseHandle(hFile);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xprh.dwMagic != XPR2_MAGIC_VALUE)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
CloseHandle(hFile);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compute memory requirements
|
|
|
|
#if defined(_XBOX1)
|
|
|
|
m_dwSysMemDataSize = xprh.dwHeaderSize - sizeof(XPR_HEADER);
|
|
|
|
m_dwVidMemDataSize = xprh.dwTotalSize - xprh.dwHeaderSize;
|
|
|
|
#elif defined(_XBOX360)
|
|
|
|
m_dwSysMemDataSize = xprh.dwHeaderSize;
|
|
|
|
m_dwVidMemDataSize = xprh.dwDataSize;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Allocate memory
|
|
|
|
m_pSysMemData = (BYTE*)malloc(m_dwSysMemDataSize);
|
|
|
|
if (m_pSysMemData == NULL)
|
|
|
|
{
|
|
|
|
m_dwSysMemDataSize = 0;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pVidMemData = (BYTE*)AllocateContiguousMemory(m_dwVidMemDataSize,
|
|
|
|
#if defined(_XBOX1)
|
|
|
|
D3DTEXTURE_ALIGNMENT
|
|
|
|
#elif defined(_XBOX360)
|
|
|
|
XALLOC_PHYSICAL_ALIGNMENT_4K
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
|
|
|
|
if(m_pVidMemData == NULL)
|
|
|
|
{
|
|
|
|
m_dwSysMemDataSize = 0;
|
|
|
|
m_dwVidMemDataSize = 0;
|
|
|
|
free(m_pSysMemData);
|
|
|
|
m_pSysMemData = NULL;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read in the data from the file
|
|
|
|
if( !ReadFile( hFile, m_pSysMemData, m_dwSysMemDataSize, &dwNumBytesRead, NULL) ||
|
|
|
|
!ReadFile( hFile, m_pVidMemData, m_dwVidMemDataSize, &dwNumBytesRead, NULL))
|
|
|
|
{
|
|
|
|
CloseHandle( hFile);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Done with the file
|
|
|
|
CloseHandle( hFile);
|
|
|
|
|
|
|
|
#ifdef _XBOX1
|
|
|
|
if (bHasResourceOffsetsTable)
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2015-09-28 16:20:26 +02:00
|
|
|
/* Extract resource table from the header data */
|
2015-09-20 15:39:59 +02:00
|
|
|
m_dwNumResourceTags = *(DWORD*)(m_pSysMemData + 0);
|
2015-09-28 16:20:26 +02:00
|
|
|
m_pResourceTags = (XBRESOURCE*)(m_pSysMemData + 4);
|
2015-09-20 15:39:59 +02:00
|
|
|
|
2015-09-28 16:20:26 +02:00
|
|
|
/* Patch up the resources */
|
|
|
|
|
|
|
|
for(i = 0; i < m_dwNumResourceTags; i++)
|
2015-09-20 15:39:59 +02:00
|
|
|
{
|
|
|
|
m_pResourceTags[i].strName = (char*)(m_pSysMemData + (DWORD)m_pResourceTags[i].strName);
|
|
|
|
#ifdef _XBOX360
|
|
|
|
if((m_pResourceTags[i].dwType & 0xffff0000) == (RESOURCETYPE_TEXTURE & 0xffff0000))
|
|
|
|
{
|
|
|
|
D3DTexture *pTexture = (D3DTexture*)&m_pSysMemData[m_pResourceTags[i].dwOffset];
|
|
|
|
XGOffsetBaseTextureAddress(pTexture, m_pVidMemData, m_pVidMemData);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _XBOX1
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _XBOX1
|
2015-09-28 16:20:26 +02:00
|
|
|
/* Use user-supplied number of resources and the resource tags */
|
2015-09-20 15:39:59 +02:00
|
|
|
if(dwNumResourceTags != 0 || pResourceTags != NULL)
|
|
|
|
{
|
|
|
|
m_pResourceTags = pResourceTags;
|
|
|
|
m_dwNumResourceTags = dwNumResourceTags;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_bInitialized = TRUE;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _XBOX360
|
|
|
|
void PackedResource::GetResourceTags(DWORD* pdwNumResourceTags,
|
|
|
|
XBRESOURCE** ppResourceTags)
|
|
|
|
{
|
|
|
|
if (pdwNumResourceTags)
|
|
|
|
(*pdwNumResourceTags) = m_dwNumResourceTags;
|
|
|
|
|
|
|
|
if (ppResourceTags)
|
|
|
|
(*ppResourceTags) = m_pResourceTags;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void PackedResource::Destroy()
|
|
|
|
{
|
|
|
|
free(m_pSysMemData);
|
|
|
|
m_pSysMemData = NULL;
|
|
|
|
m_dwSysMemDataSize = 0L;
|
|
|
|
|
|
|
|
if (m_pVidMemData != NULL)
|
|
|
|
FreeContiguousMemory(m_pVidMemData);
|
|
|
|
|
|
|
|
m_pVidMemData = NULL;
|
|
|
|
m_dwVidMemDataSize = 0L;
|
|
|
|
|
|
|
|
m_pResourceTags = NULL;
|
|
|
|
m_dwNumResourceTags = 0L;
|
|
|
|
|
|
|
|
m_bInitialized = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL PackedResource::Initialized() const
|
|
|
|
{
|
|
|
|
return m_bInitialized;
|
|
|
|
}
|