(PS3) Salamander merged into platform_ps3.c

This commit is contained in:
twinaphex 2013-01-09 00:54:46 +01:00
parent 0cd26b3623
commit e1985b8bfd
3 changed files with 138 additions and 254 deletions

View File

@ -18,8 +18,8 @@ endif
STRIP = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-strip.exe STRIP = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-strip.exe
PPU_CFLAGS += -I. -D__CELLOS_LV2__ -DIS_SALAMANDER -DRARCH_CONSOLE PPU_CFLAGS += -I. -D__CELLOS_LV2__ -DIS_SALAMANDER -DRARCH_CONSOLE -DHAVE_SYSUTILS -DHAVE_SYSMODULES -DHAVE_RARCH_EXEC
PPU_SRCS = frontend/salamander/salamander_ps3.c console/rarch_console_exec.c console/rarch_console_libretro_mgmt.c file_path.c compat/compat.c conf/config_file.c PPU_SRCS = frontend/frontend_console.c console/rarch_console_exec.c console/rarch_console_libretro_mgmt.c file_path.c compat/compat.c conf/config_file.c
ifeq ($(HAVE_LOGGER), 1) ifeq ($(HAVE_LOGGER), 1)
PPU_CFLAGS += -DHAVE_LOGGER -Iconsole/logger PPU_CFLAGS += -DHAVE_LOGGER -Iconsole/logger

View File

@ -21,7 +21,7 @@
#include "../../ps3/sdk_defines.h" #include "../../ps3/sdk_defines.h"
#include "../../ps3/ps3_input.h" #include "../../ps3/ps3_input.h"
#include "../console/rarch_console.h" #include "../../console/rarch_console.h"
#ifdef HAVE_RARCH_EXEC #ifdef HAVE_RARCH_EXEC
#include "../../console/rarch_console_exec.h" #include "../../console/rarch_console_exec.h"
@ -47,15 +47,117 @@
static uint8_t np_pool[NP_POOL_SIZE]; static uint8_t np_pool[NP_POOL_SIZE];
#endif #endif
//TODO - not sure if stack size needs to be lower for Salamander
#ifdef IS_SALAMANDER
SYS_PROCESS_PARAM(1001, 0x100000)
#else
SYS_PROCESS_PARAM(1001, 0x200000) SYS_PROCESS_PARAM(1001, 0x200000)
#endif
#undef main #undef main
#ifdef IS_SALAMANDER
#include <netex/net.h>
#include <np.h>
#include <np/drm.h>
#include <cell/pad.h>
#include <cell/sysmodule.h>
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[PATH_MAX];
rarch_manage_libretro_set_first_file(first_file, sizeof(first_file), default_paths.core_dir, "SELF");
if(first_file)
{
snprintf(default_paths.libretro_path, sizeof(default_paths.libretro_path),
"%s/%s", default_paths.core_dir, first_file);
RARCH_LOG("libretro_path now set to: %s.\n", default_paths.libretro_path);
}
else
RARCH_ERR("Failed last fallback - RetroArch Salamander will exit.\n");
}
static void salamander_init_settings(void)
{
CellPadData pad_data;
cellPadInit(7);
cellPadGetData(0, &pad_data);
if(pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE)
{
//override path, boot first executable in cores directory
RARCH_LOG("Fallback - Will boot first executable in RetroArch cores/ directory.\n");
find_and_set_first_file();
}
else
{
//normal executable loading path
char tmp_str[PATH_MAX];
bool config_file_exists = false;
if(path_file_exists(default_paths.config_path))
config_file_exists = true;
//try to find CORE executable
char core_executable[1024];
snprintf(core_executable, sizeof(core_executable), "%s/CORE.SELF", 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);
}
}
}
cellPadEnd();
}
#endif
#ifdef HAVE_SYSUTILS #ifdef HAVE_SYSUTILS
static void callback_sysutil_exit(uint64_t status, uint64_t param, void *userdata) static void callback_sysutil_exit(uint64_t status, uint64_t param, void *userdata)
{ {
(void) param; (void)param;
(void) userdata; (void)userdata;
(void)status;
#ifndef IS_SALAMANDER
#ifdef HAVE_OSKUTIL #ifdef HAVE_OSKUTIL
oskutil_params *osk = &g_extern.console.misc.oskutil_handle; oskutil_params *osk = &g_extern.console.misc.oskutil_handle;
#endif #endif
@ -77,6 +179,7 @@ static void callback_sysutil_exit(uint64_t status, uint64_t param, void *userdat
break; break;
#endif #endif
} }
#endif
} }
#endif #endif
@ -99,7 +202,9 @@ void menu_free (void)
static void get_environment_settings(int argc, char *argv[]) static void get_environment_settings(int argc, char *argv[])
{ {
#ifndef IS_SALAMANDER
g_extern.verbose = true; g_extern.verbose = true;
#endif
int ret; int ret;
unsigned int get_type; unsigned int get_type;
@ -132,10 +237,12 @@ static void get_environment_settings(int argc, char *argv[])
} }
else else
#endif #endif
#ifndef IS_SALAMANDER
{ {
g_extern.console.external_launch.support = EXTERN_LAUNCHER_SALAMANDER; g_extern.console.external_launch.support = EXTERN_LAUNCHER_SALAMANDER;
RARCH_WARN("Not started from multiMAN, auto-game start disabled.\n"); RARCH_WARN("Not started from multiMAN, auto-game start disabled.\n");
} }
#endif
memset(&size, 0x00, sizeof(CellGameContentSize)); memset(&size, 0x00, sizeof(CellGameContentSize));
@ -207,11 +314,18 @@ static void get_environment_settings(int argc, char *argv[])
snprintf(default_paths.shader_file, sizeof(default_paths.shader_file), "%s/shaders/stock.cg", default_paths.core_dir); snprintf(default_paths.shader_file, sizeof(default_paths.shader_file), "%s/shaders/stock.cg", default_paths.core_dir);
snprintf(default_paths.menu_shader_file, sizeof(default_paths.menu_shader_file), "%s/shaders/Borders/Menu/border-only-rarch.cg", default_paths.core_dir); snprintf(default_paths.menu_shader_file, sizeof(default_paths.menu_shader_file), "%s/shaders/Borders/Menu/border-only-rarch.cg", default_paths.core_dir);
#endif #endif
#ifdef IS_SALAMANDER
snprintf(default_paths.config_path, sizeof(default_paths.config_path), "%s/retroarch.cfg", default_paths.port_dir);
#else
snprintf(g_extern.config_path, sizeof(g_extern.config_path), "%s/retroarch.cfg", default_paths.port_dir); snprintf(g_extern.config_path, sizeof(g_extern.config_path), "%s/retroarch.cfg", default_paths.port_dir);
#endif
snprintf(default_paths.salamander_file, sizeof(default_paths.salamander_file), "EBOOT.BIN"); snprintf(default_paths.salamander_file, sizeof(default_paths.salamander_file), "EBOOT.BIN");
} }
#ifndef IS_SALAMANDER
g_extern.verbose = false; g_extern.verbose = false;
#endif
} }
static void system_init(void) static void system_init(void)
@ -233,10 +347,14 @@ static void system_init(void)
cellSysmoduleLoadModule(CELL_SYSMODULE_FS); cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
#ifndef __PSL1GHT__ #ifndef __PSL1GHT__
cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_GAME); cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_GAME);
#endif
#ifndef IS_SALAMANDER
#ifndef __PSL1GHT__
cellSysmoduleLoadModule(CELL_SYSMODULE_AVCONF_EXT); cellSysmoduleLoadModule(CELL_SYSMODULE_AVCONF_EXT);
#endif #endif
cellSysmoduleLoadModule(CELL_SYSMODULE_PNGDEC); cellSysmoduleLoadModule(CELL_SYSMODULE_PNGDEC);
cellSysmoduleLoadModule(CELL_SYSMODULE_JPGDEC); cellSysmoduleLoadModule(CELL_SYSMODULE_JPGDEC);
#endif
cellSysmoduleLoadModule(CELL_SYSMODULE_NET); cellSysmoduleLoadModule(CELL_SYSMODULE_NET);
cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_NP); cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_NP);
#endif #endif
@ -304,6 +422,8 @@ static void system_process_args(int argc, char *argv[])
static void system_deinit(void) static void system_deinit(void)
{ {
#ifndef IS_SALAMANDER
#ifdef HAVE_OSKUTIL #ifdef HAVE_OSKUTIL
oskutil_params *osk = &g_extern.console.misc.oskutil_handle; oskutil_params *osk = &g_extern.console.misc.oskutil_handle;
@ -349,6 +469,8 @@ static void system_deinit(void)
RARCH_ERR("System cache partition could not be cleared on exit.\n"); RARCH_ERR("System cache partition could not be cleared on exit.\n");
} }
#endif #endif
#endif
} }
static void system_deinit_save(void) static void system_deinit_save(void)
@ -358,7 +480,18 @@ static void system_deinit_save(void)
static void system_exitspawn(void) static void system_exitspawn(void)
{ {
#ifdef HAVE_RARCH_EXEC #ifdef HAVE_RARCH_EXEC
#ifdef IS_SALAMANDER
rarch_console_exec(default_paths.libretro_path);
cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME);
cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
cellSysmoduleLoadModule(CELL_SYSMODULE_IO);
#else
if(g_extern.console.external_launch.enable) if(g_extern.console.external_launch.enable)
rarch_console_exec(g_extern.console.external_launch.launch_app); rarch_console_exec(g_extern.console.external_launch.launch_app);
#endif #endif
#endif
} }

View File

@ -1,249 +0,0 @@
/* RetroArch - A frontend for libretro.
* RetroArch Salamander - A frontend for managing some pre-launch tasks.
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
* Copyright (C) 2011-2013 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* 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.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include <cell/pad.h>
#include <cell/sysmodule.h>
#include <sysutil/sysutil_gamecontent.h>
#include <sys/process.h>
#include <netex/net.h>
#include <np.h>
#include <np/drm.h>
#include <dirent.h>
#include "../../compat/strl.h"
#include "../../conf/config_file.h"
#define NP_POOL_SIZE (128*1024)
#ifndef PATH_MAX
#define PATH_MAX 512
#endif
#include "../../console/rarch_console.h"
#include "../../console/rarch_console_exec.h"
#include "../../console/rarch_console_libretro_mgmt.h"
#include "../../retroarch_logger.h"
#include "../../file.h"
static uint8_t np_pool[NP_POOL_SIZE];
SYS_PROCESS_PARAM(1001, 0x100000)
char libretro_path[PATH_MAX];
char config_path[PATH_MAX];
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[PATH_MAX];
rarch_manage_libretro_set_first_file(first_file, sizeof(first_file), default_paths.core_dir, "SELF");
if(first_file)
{
snprintf(libretro_path, sizeof(libretro_path), "%s/%s", default_paths.core_dir, first_file);
RARCH_LOG("libretro_path now set to: %s.\n", libretro_path);
}
else
RARCH_ERR("Failed last fallback - RetroArch Salamander will exit.\n");
}
static void init_settings(void)
{
char tmp_str[PATH_MAX];
bool config_file_exists = false;
if(path_file_exists(config_path))
config_file_exists = true;
//try to find CORE executable
char core_executable[1024];
snprintf(core_executable, sizeof(core_executable), "%s/CORE.SELF", default_paths.core_dir);
if(path_file_exists(core_executable))
{
//Start CORE executable
snprintf(libretro_path, sizeof(libretro_path), core_executable);
RARCH_LOG("Start [%s].\n", libretro_path);
}
else
{
if(config_file_exists)
{
config_file_t * conf = config_file_new(config_path);
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
config_file_free(conf);
snprintf(libretro_path, sizeof(libretro_path), tmp_str);
}
if(!config_file_exists || !strcmp(libretro_path, ""))
{
find_and_set_first_file();
}
else
{
RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path);
}
if (!config_file_exists)
{
config_file_t *new_conf = config_file_new(NULL);
config_set_string(new_conf, "libretro_path", libretro_path);
config_file_write(new_conf, config_path);
config_file_free(new_conf);
}
}
}
static void get_environment_settings (void)
{
unsigned int get_type;
unsigned int get_attributes;
CellGameContentSize size;
char dirName[CELL_GAME_DIRNAME_SIZE];
char contentInfoPath[PATH_MAX];
memset(&size, 0x00, sizeof(CellGameContentSize));
int ret = cellGameBootCheck(&get_type, &get_attributes, &size, dirName);
if(ret < 0)
{
RARCH_ERR("cellGameBootCheck() Error: 0x%x.\n", ret);
}
else
{
RARCH_LOG("cellGameBootCheck() OK.\n");
RARCH_LOG("Directory name: [%s].\n", dirName);
RARCH_LOG(" HDD Free Size (in KB) = [%d] Size (in KB) = [%d] System Size (in KB) = [%d].\n", size.hddFreeSizeKB, size.sizeKB, size.sysSizeKB);
switch(get_type)
{
case CELL_GAME_GAMETYPE_DISC:
RARCH_LOG("RetroArch was launched on Optical Disc Drive.\n");
break;
case CELL_GAME_GAMETYPE_HDD:
RARCH_LOG("RetroArch was launched on HDD.\n");
break;
}
if((get_attributes & CELL_GAME_ATTRIBUTE_APP_HOME) == CELL_GAME_ATTRIBUTE_APP_HOME)
RARCH_LOG("RetroArch was launched from host machine (APP_HOME).\n");
ret = cellGameContentPermit(contentInfoPath, default_paths.port_dir);
if(ret < 0)
{
RARCH_ERR("cellGameContentPermit() Error: 0x%x\n", ret);
}
else
{
RARCH_LOG("cellGameContentPermit() OK.\n");
RARCH_LOG("contentInfoPath : [%s].\n", contentInfoPath);
RARCH_LOG("usrDirPath : [%s].\n", default_paths.port_dir);
}
#ifdef HAVE_HDD_CACHE_PARTITION
snprintf(default_paths.cache_dir, sizeof(default_paths.cache_dir), "/dev_hdd1/");
#endif
snprintf(default_paths.core_dir, sizeof(default_paths.core_dir), "%s/cores", default_paths.port_dir);
snprintf(default_paths.executable_extension, sizeof(default_paths.executable_extension), ".SELF");
snprintf(default_paths.savestate_dir, sizeof(default_paths.savestate_dir), "%s/savestates", default_paths.core_dir);
snprintf(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.core_dir);
snprintf(default_paths.system_dir, sizeof(default_paths.system_dir), "%s/system", default_paths.core_dir);
/* now we fill in all the variables */
snprintf(default_paths.border_file, sizeof(default_paths.border_file), "%s/borders/Centered-1080p/mega-man-2.png", default_paths.core_dir);
snprintf(default_paths.menu_border_file, sizeof(default_paths.menu_border_file), "%s/borders/Menu/main-menu.png", default_paths.core_dir);
snprintf(default_paths.cgp_dir, sizeof(default_paths.cgp_dir), "%s/presets", default_paths.core_dir);
snprintf(default_paths.input_presets_dir, sizeof(default_paths.input_presets_dir), "%s/input", default_paths.cgp_dir);
snprintf(default_paths.border_dir, sizeof(default_paths.border_dir), "%s/borders", default_paths.core_dir);
snprintf(config_path, sizeof(config_path), "%s/retroarch.cfg", default_paths.port_dir);
snprintf(default_paths.salamander_file, sizeof(default_paths.salamander_file), "EBOOT.BIN");
}
}
//dummy - just to avoid the emitted warnings
static void callback_sysutil_exit(uint64_t status, uint64_t param, void *userdata)
{
(void) param;
(void) userdata;
(void) status;
}
int main(int argc, char *argv[])
{
CellPadData pad_data;
cellSysutilRegisterCallback(0, callback_sysutil_exit, NULL);
cellSysmoduleLoadModule(CELL_SYSMODULE_IO);
cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_GAME);
cellSysmoduleLoadModule(CELL_SYSMODULE_NET);
cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_NP);
sys_net_initialize_network();
#ifdef HAVE_LOGGER
logger_init();
#endif
sceNpInit(NP_POOL_SIZE, np_pool);
get_environment_settings();
cellPadInit(7);
cellPadGetData(0, &pad_data);
if(pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE)
{
//override path, boot first executable in cores directory
RARCH_LOG("Fallback - Will boot first executable in RetroArch cores/ directory.\n");
find_and_set_first_file();
}
else
{
//normal executable loading path
init_settings();
}
cellPadEnd();
#ifdef HAVE_LOGGER
logger_shutdown();
#endif
rarch_console_exec(libretro_path);
cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME);
cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
cellSysmoduleLoadModule(CELL_SYSMODULE_IO);
return 1;
}