diff --git a/Makefile b/Makefile index 758490e..1d701bb 100644 --- a/Makefile +++ b/Makefile @@ -171,13 +171,17 @@ else ifeq ($(platform), qnx) PLATFORM_DEFINES := -D__BLACKBERRY_QNX__ -fexceptions -marm -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp # Lightweight PS3 Homebrew SDK -else ifeq ($(platform), psl1ght) - TARGET := $(TARGET_NAME)_libretro_psl1ght.a - CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT) - CC_AS = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT) - CXX = $(PS3DEV)/ppu/bin/ppu-g++$(EXE_EXT) - AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT) - PLATFORM_DEFINES := +else ifneq (,$(filter $(platform), ps3 psl1ght)) + ifeq ($(platform), psl1ght) + PLATFORM_DEFINES := -D__PS3__ -D__PSLIGHT__ + else + PLATFORM_DEFINES := -D__PS3__ + endif + TARGET := $(TARGET_NAME)_libretro_$(platform).a + CC = $(PS3DEV)/ppu/bin/ppu-$(COMMONLV)gcc$(EXE_EXT) + CC_AS = $(PS3DEV)/ppu/bin/ppu-$(COMMONLV)gcc$(EXE_EXT) + CXX = $(PS3DEV)/ppu/bin/ppu-$(COMMONLV)g++$(EXE_EXT) + AR = $(PS3DEV)/ppu/bin/ppu-$(COMMONLV)ar$(EXE_EXT) STATIC_LINKING = 1 HAVE_COMPAT = 1 diff --git a/atari800/src/atari.c b/atari800/src/atari.c index f71bc4a..d099618 100644 --- a/atari800/src/atari.c +++ b/atari800/src/atari.c @@ -443,7 +443,9 @@ int Atari800_Initialise(int *argc, char *argv[]) #if defined(__LIBRETRO__) SYSROM_FindInDir(retro_system_directory, TRUE); #endif +#if !defined(__PS3__) && !defined(__PSL1GHT__) SYSROM_FindInDir(".", TRUE); /* current directory */ +#endif #if defined(unix) || defined(__unix__) || defined(__linux__) SYSROM_FindInDir("/usr/share/atari800", TRUE); #endif diff --git a/atari800/src/cfg.c b/atari800/src/cfg.c index 224c8ff..90b721a 100644 --- a/atari800/src/cfg.c +++ b/atari800/src/cfg.c @@ -64,6 +64,9 @@ #endif int CFG_save_on_exit = FALSE; +#if defined(__LIBRETRO__) +extern const char *retro_system_directory; +#endif /* If another default path config path is defined use it otherwise use the default one */ @@ -75,6 +78,10 @@ int CFG_save_on_exit = FALSE; #define SYSTEM_WIDE_CFG_FILE "/etc/atari800.cfg" #endif +#if defined (__PS3__) || defined(__PSL1GHT__) +#define DEFAULT_CFG_NAME "/atari800.cfg" +#endif + #ifdef WIIU #define DEFAULT_CFG_NAME "sd:/retroarch/cores/system/atari800.cfg" #define SYSTEM_WIDE_CFG_FILE "sd:/retroarch/cores/system/atari800.cfg" @@ -101,11 +108,16 @@ int CFG_LoadConfig(const char *alternate_config_filename) } /* else use the default config name under the HOME folder */ else { +#if !defined(__PS3__) && !defined(__PSL1GHT__) char *home = getenv("HOME"); if (home != NULL) Util_catpath(rtconfig_filename, home, DEFAULT_CFG_NAME); else strcpy(rtconfig_filename, DEFAULT_CFG_NAME); +#else + strcpy(rtconfig_filename, retro_system_directory); + strcat(rtconfig_filename, DEFAULT_CFG_NAME); +#endif } fp = fopen(fname, "r"); diff --git a/atari800/src/devices.h b/atari800/src/devices.h index 9c707d1..b24bef1 100644 --- a/atari800/src/devices.h +++ b/atari800/src/devices.h @@ -4,6 +4,12 @@ #include /* FILENAME_MAX */ #include "atari.h" /* UWORD */ +#if defined(__PS3__) && !defined(__PSL1GHT__) +#define S_IREAD S_IRUSR +#define S_IWRITE S_IWUSR +#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#endif + int Devices_Initialise(int *argc, char *argv[]); void Devices_Exit(void); int Devices_PatchOS(void); diff --git a/atari800/src/ide.c b/atari800/src/ide.c index 7ce2a7b..f8413d3 100644 --- a/atari800/src/ide.c +++ b/atari800/src/ide.c @@ -81,7 +81,7 @@ # define fseeko _fseek # define ftello _ftell # define PRId64 "lld" -#elif defined (__DJGPP__) +#elif defined (__DJGPP__) || defined(__PS3__) && !defined(__PSL1GHT__) # define fseeko fseek # define ftello ftell # define PRId64 "lld" diff --git a/atari800/src/ui_basic.c b/atari800/src/ui_basic.c index 708e648..baed0ad 100644 --- a/atari800/src/ui_basic.c +++ b/atari800/src/ui_basic.c @@ -44,6 +44,9 @@ #ifdef HAVE_WINDOWS_H #include #endif +#if defined(__PS3__) && !defined(__PSL1GHT__) +#include "devices.h" +#endif #include "antic.h" #include "atari.h" diff --git a/atari800/src/util.c b/atari800/src/util.c index 970cf32..0fbc6d8 100644 --- a/atari800/src/util.c +++ b/atari800/src/util.c @@ -57,6 +57,11 @@ #include #endif +#if defined(__PS3__) && !defined(__PSL1GHT__) +#include +#define usleep sys_timer_usleep +#endif + #include "atari.h" #include "platform.h" #include "util.h" diff --git a/libretro/config.h b/libretro/config.h index 589451f..b5be5e3 100644 --- a/libretro/config.h +++ b/libretro/config.h @@ -583,3 +583,33 @@ #undef HAVE_NANOSLEEP #endif + +#if defined(__PS3__) && !defined(__PSL1GHT__) +#undef HAVE_FSEEKO +#undef HAVE_GETCWD +#undef HAVE_NANOSLEEP +#undef HAVE_MKSTEMP +#undef HAVE_MKTEMP +#undef HAVE_SIGNAL +#undef HAVE_SIGNAL_H +#undef HAVE_SYSTEM +#undef HAVE_TMPFILE +#undef HAVE_TMPNAM +#undef HAVE_STRINGS_H +#include +#define O_RDONLY CELL_FS_O_RDONLY +#define O_WRONLY CELL_FS_O_WRONLY +#define O_CREAT CELL_FS_O_CREAT +#define O_TRUNC CELL_FS_O_TRUNC +#define O_RDWR CELL_FS_O_RDWR +#define sysFsStat cellFsStat +#define sysFSStat CellFsStat +#define sysFSDirent CellFsDirent +#define sysFsOpendir cellFsOpendir +#define sysFsReaddir cellFsReaddir +#define sysFSDirent CellFsDirent +#define sysFsClosedir cellFsClosedir +#define WORDS_BIGENDIAN 1 +#define FS_SUCCEEDED 0 +#define FS_TYPE_DIR 1 +#endif diff --git a/libretro/libretro-common/include/memmap.h b/libretro/libretro-common/include/memmap.h index ebbc307..8897877 100644 --- a/libretro/libretro-common/include/memmap.h +++ b/libretro/libretro-common/include/memmap.h @@ -26,7 +26,7 @@ #include #include -#if defined(PSP) || defined(PS2) || defined(GEKKO) || defined(VITA) || defined(_XBOX) || defined(_3DS) || defined(WIIU) || defined(SWITCH) || defined(HAVE_LIBNX) +#if defined(PSP) || defined(PS2) || defined(GEKKO) || defined(VITA) || defined(_XBOX) || defined(_3DS) || defined(WIIU) || defined(SWITCH) || defined(HAVE_LIBNX) || defined(__PS3__) || defined(__PSL1GHT__) /* No mman available */ #elif defined(_WIN32) && !defined(_XBOX) #include diff --git a/libretro/libretro-common/vfs/vfs_implementation.c b/libretro/libretro-common/vfs/vfs_implementation.c index 034d8f3..46259e6 100644 --- a/libretro/libretro-common/vfs/vfs_implementation.c +++ b/libretro/libretro-common/vfs/vfs_implementation.c @@ -909,6 +909,19 @@ int retro_vfs_stat_impl(const char *path, int32_t *size) orbisDclose(dir_ret); is_character_special = S_ISCHR(buf.st_mode); +#elif defined(__PSL1GHT__) || defined(__PS3__) + /* Lowlevel Lv2 */ + sysFSStat buf; + + if (!path || !*path) + return 0; + if (sysFsStat(path, &buf) < 0) + return 0; + + if (size) + *size = (int32_t)buf.st_size; + + is_dir = ((buf.st_mode & S_IFMT) == S_IFDIR); #elif defined(_WIN32) /* Windows */ DWORD file_info; @@ -1081,6 +1094,10 @@ struct libretro_vfs_implementation_dir #elif defined(VITA) || defined(PSP) SceUID directory; SceIoDirent entry; +#elif defined(__PSL1GHT__) || defined(__PS3__) + int error; + int directory; + sysFSDirent entry; #elif defined(ORBIS) int directory; struct dirent entry; @@ -1096,6 +1113,8 @@ static bool dirent_check_error(libretro_vfs_implementation_dir *rdir) return (rdir->directory == INVALID_HANDLE_VALUE); #elif defined(VITA) || defined(PSP) || defined(ORBIS) return (rdir->directory < 0); +#elif defined(__PSL1GHT__) || defined(__PS3__) + return (rdir->error != FS_SUCCEEDED); #else return !(rdir->directory); #endif @@ -1159,6 +1178,8 @@ libretro_vfs_implementation_dir *retro_vfs_opendir_impl( #elif defined(_3DS) rdir->directory = !string_is_empty(name) ? opendir(name) : NULL; rdir->entry = NULL; +#elif defined(__PSL1GHT__) || defined(__PS3__) + rdir->error = sysFsOpendir(name, &rdir->directory); #elif defined(ORBIS) rdir->directory = orbisDopen(name); #else @@ -1194,6 +1215,10 @@ bool retro_vfs_readdir_impl(libretro_vfs_implementation_dir *rdir) return (rdir->directory != INVALID_HANDLE_VALUE); #elif defined(VITA) || defined(PSP) return (sceIoDread(rdir->directory, &rdir->entry) > 0); +#elif defined(__PSL1GHT__) || defined(__PS3__) + uint64_t nread; + rdir->error = sysFsReaddir(rdir->directory, &rdir->entry, &nread); + return (nread != 0); #elif defined(ORBIS) return (orbisDread(rdir->directory, &rdir->entry) > 0); #else @@ -1214,7 +1239,7 @@ const char *retro_vfs_dirent_get_name_impl(libretro_vfs_implementation_dir *rdir if (name) free(name); return (char*)rdir->entry.cFileName; -#elif defined(VITA) || defined(PSP) || defined(ORBIS) +#elif defined(VITA) || defined(PSP) || defined(ORBIS) || defined(__PSL1GHT__) || defined(__PS3__) return rdir->entry.d_name; #else if (!rdir || !rdir->entry) @@ -1235,6 +1260,9 @@ bool retro_vfs_dirent_is_dir_impl(libretro_vfs_implementation_dir *rdir) #elif defined(VITA) return SCE_S_ISDIR(entry->d_stat.st_mode); #endif +#elif defined(__PSL1GHT__) || defined(__PS3__) + sysFSDirent* entry = (sysFSDirent*)&rdir->entry; + return (entry->d_type == FS_TYPE_DIR); #elif defined(ORBIS) const struct dirent *entry = &rdir->entry; if (entry->d_type == DT_DIR) @@ -1271,6 +1299,8 @@ int retro_vfs_closedir_impl(libretro_vfs_implementation_dir *rdir) FindClose(rdir->directory); #elif defined(VITA) || defined(PSP) sceIoDclose(rdir->directory); +#elif defined(__PSL1GHT__) || defined(__PS3__) + rdir->error = sysFsClosedir(rdir->directory); #elif defined(ORBIS) orbisDclose(rdir->directory); #else