From de177f894f7220a08892c76359e27001b5e5915a Mon Sep 17 00:00:00 2001 From: CrystalCT Date: Tue, 22 Mar 2022 09:56:54 +0100 Subject: [PATCH] PS3/PSL1GHT Build fix --- audio/softsynth/mt32/File.cpp | 4 +++ audio/softsynth/mt32/ROMInfo.cpp | 4 +++ audio/softsynth/mt32/Synth.h | 4 +++ audio/softsynth/mt32/mmath.h | 4 +++ backends/fs/libretro/libretro-fs.h | 12 ++++++- backends/platform/libretro/build/Makefile | 32 +++++++++++++++---- .../libretro/deps/freetype/src/base/ftinit.c | 3 ++ .../platform/libretro/deps/libfaad/config.h | 2 ++ .../libretro-common/file/retro_dirent.c | 16 +++++----- .../libretro-common/file/retro_stat.c | 12 +++---- .../include/retro_miscellaneous.h | 6 ++-- backends/platform/libretro/libretro.cpp | 21 ++++++++++-- backends/platform/libretro/libretro.h | 2 +- backends/platform/libretro/libretro_os.cpp | 5 +-- backends/platform/libretro/os.h | 2 +- common/scummsys.h | 2 +- engines/bladerunner/ui/vk.cpp | 8 +++++ engines/glk/hugo/heparse.cpp | 4 +++ engines/illusions/bbdou/bbdou_bubble.cpp | 4 +++ engines/illusions/pathfinder.cpp | 4 +++ engines/mutationofjb/gamedata.h | 4 +++ engines/pink/objects/actions/action_text.cpp | 4 +++ engines/pink/objects/walk/walk_mgr.cpp | 4 +++ 23 files changed, 132 insertions(+), 31 deletions(-) diff --git a/audio/softsynth/mt32/File.cpp b/audio/softsynth/mt32/File.cpp index a5967b4f34c7..b2c48e7069ff 100644 --- a/audio/softsynth/mt32/File.cpp +++ b/audio/softsynth/mt32/File.cpp @@ -22,6 +22,10 @@ #include "File.h" #include "sha1/sha1.h" +#ifdef __PS3__ +using namespace std; +#endif + namespace MT32Emu { AbstractFile::AbstractFile() : sha1DigestCalculated(false) { diff --git a/audio/softsynth/mt32/ROMInfo.cpp b/audio/softsynth/mt32/ROMInfo.cpp index 8c813a4e69b2..4b9d712777bd 100644 --- a/audio/softsynth/mt32/ROMInfo.cpp +++ b/audio/softsynth/mt32/ROMInfo.cpp @@ -21,6 +21,10 @@ #include "ROMInfo.h" +#ifdef __PS3__ +using namespace std; +#endif + namespace MT32Emu { static const ROMInfo *getKnownROMInfoFromList(Bit32u index) { diff --git a/audio/softsynth/mt32/Synth.h b/audio/softsynth/mt32/Synth.h index 54417d5b44e7..1279274e9b2a 100644 --- a/audio/softsynth/mt32/Synth.h +++ b/audio/softsynth/mt32/Synth.h @@ -26,6 +26,10 @@ #include "Types.h" #include "Enumerations.h" +#ifdef __PS3__ +using namespace std; +#endif + namespace MT32Emu { class Analog; diff --git a/audio/softsynth/mt32/mmath.h b/audio/softsynth/mt32/mmath.h index 9a9e642ba109..176b59909b81 100644 --- a/audio/softsynth/mt32/mmath.h +++ b/audio/softsynth/mt32/mmath.h @@ -20,6 +20,10 @@ #include +#ifdef __PS3__ +using namespace std; +#endif + namespace MT32Emu { // Mathematical constants diff --git a/backends/fs/libretro/libretro-fs.h b/backends/fs/libretro/libretro-fs.h index 2c5999f942d7..8b16b5a73051 100644 --- a/backends/fs/libretro/libretro-fs.h +++ b/backends/fs/libretro/libretro-fs.h @@ -30,7 +30,9 @@ #endif #include -#ifdef PLAYSTATION3 +#if defined(__PS3__) && !defined(__PSL1GHT__) +#include +#include #define FORBIDDEN_SYMBOL_ALLOW_ALL #define F_OK 0 /* test for existence of file */ #define W_OK 0x02 /* test for write permission */ @@ -88,7 +90,15 @@ class LibRetroFilesystemNode : public AbstractFSNode { */ LibRetroFilesystemNode(const Common::String &path); +#if defined(__PS3__) && !defined(__PSL1GHT__) + virtual bool exists() const { + CellFsStat entry; + cellFsStat(_path.c_str(), &entry); + return access(_path.c_str(), F_OK) == 0 || (entry.st_mode & S_IFDIR) != 0; + } +#else virtual bool exists() const { return access(_path.c_str(), F_OK) == 0; } +#endif virtual Common::String getDisplayName() const { return _displayName; } virtual Common::String getName() const { return _displayName; } virtual Common::String getPath() const { return _path; } diff --git a/backends/platform/libretro/build/Makefile b/backends/platform/libretro/build/Makefile index 25d141eb551e..bcefa13a1b51 100644 --- a/backends/platform/libretro/build/Makefile +++ b/backends/platform/libretro/build/Makefile @@ -182,14 +182,22 @@ else ifeq ($(platform), genode) AR = $(shell pkg-config genode-base --variable=ar) rcs RANLIB = genode-x86-ranlib -# PS3 -else ifeq ($(platform), ps3) +# Lightweight PS3 Homebrew SDK +else ifneq (,$(filter $(platform), ps3 psl1ght)) TARGET := $(TARGET_NAME)_libretro_$(platform).a - CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe - CXX = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-g++.exe - AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe rcs - DEFINES += -DPLAYSTATION3 - STATIC_LINKING=1 + CC = $(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) rcs + AR_NOPAR = $(PS3DEV)/ppu/bin/ppu-$(COMMONLV)ar$(EXE_EXT) + DEFINES += -DPLAYSTATION3 -DWORDS_BIGENDIAN=1 -DMSB_FIRST -D__ppc__ -DNO_GETENV -D__PS3__ + STATIC_LINKING=1 + ifeq ($(platform), psl1ght) + PLATFORM_DEFINES += -D__PSL1GHT__ + endif + ifneq (,$(findstring MINGW32,$(shell uname -a))) + PS3MINGW32 := 1 + endif + LITE := 1 # Nintendo Wii else ifeq ($(platform), wii) @@ -561,6 +569,16 @@ $(TARGET): $(OBJS) libdeps.a $(MKDIR) libtemp cp $+ libtemp/ $(AR) -M < ctr.mri +else ifeq ($(PS3MINGW32), 1) +$(TARGET): $(OBJS) libdeps.a + $(HIDE)echo Linking $@... + $(HIDE)$(AR) $@ $(shell find ../ -maxdepth 1 -mindepth 1 -name '*.o') + $(HIDE)$(AR_NOPAR) q $@ $(shell find ../ -maxdepth 2 -mindepth 2 -name '*.o') + $(HIDE)$(AR_NOPAR) q $@ $(shell find ../ -maxdepth 3 -mindepth 3 -name '*.o') + $(HIDE)$(AR_NOPAR) q $@ $(shell find ../ -maxdepth 4 -mindepth 4 -name '*.o') + $(HIDE)$(AR_NOPAR) q $@ $(shell find ../ -maxdepth 5 -mindepth 5 -name '*.o') + $(HIDE)$(AR_NOPAR) q $@ $(shell find ../ -maxdepth 6 -mindepth 6 -name '*.o') + $(HIDE)$(AR_NOPAR) q $@ $(shell find ../ -maxdepth 7 -mindepth 7 -name '*.o') else ifeq ($(STATIC_LINKING), 1) $(TARGET): $(OBJS) libdeps.a @echo Linking $@... diff --git a/backends/platform/libretro/deps/freetype/src/base/ftinit.c b/backends/platform/libretro/deps/freetype/src/base/ftinit.c index 02ef938d5eaf..a602546f35db 100644 --- a/backends/platform/libretro/deps/freetype/src/base/ftinit.c +++ b/backends/platform/libretro/deps/freetype/src/base/ftinit.c @@ -44,6 +44,9 @@ #include FT_MODULE_H #include "basepic.h" +#ifdef __PS3__ +#define getenv(x) NULL +#endif /*************************************************************************/ /* */ diff --git a/backends/platform/libretro/deps/libfaad/config.h b/backends/platform/libretro/deps/libfaad/config.h index 4e4113560b5c..c3bb9f2120ee 100644 --- a/backends/platform/libretro/deps/libfaad/config.h +++ b/backends/platform/libretro/deps/libfaad/config.h @@ -52,7 +52,9 @@ #undef HAVE_STRCHR /* Define to 1 if you have the header file. */ +#ifndef __PS3__ #define HAVE_STRINGS_H 1 +#endif /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 diff --git a/backends/platform/libretro/libretro-common/file/retro_dirent.c b/backends/platform/libretro/libretro-common/file/retro_dirent.c index beba10bdd83c..84282ee157b9 100644 --- a/backends/platform/libretro/libretro-common/file/retro_dirent.c +++ b/backends/platform/libretro/libretro-common/file/retro_dirent.c @@ -49,7 +49,7 @@ # include #endif -#ifdef __CELLOS_LV2__ +#if defined(__PS3__) && !defined(__PSL1GHT__) #include #endif @@ -65,7 +65,7 @@ struct RDIR #elif defined(VITA) || defined(PSP) SceUID directory; SceIoDirent entry; -#elif defined(__CELLOS_LV2__) +#elif defined(__PS3__) && !defined(__PSL1GHT__) CellFsErrno error; int directory; CellFsDirent entry; @@ -90,7 +90,7 @@ struct RDIR *retro_opendir(const char *name) rdir->directory = FindFirstFile(path_buf, &rdir->entry); #elif defined(VITA) || defined(PSP) rdir->directory = sceIoDopen(name); -#elif defined(__CELLOS_LV2__) +#elif defined(__PS3__) && !defined(__PSL1GHT__) rdir->error = cellFsOpendir(name, &rdir->directory); #else rdir->directory = opendir(name); @@ -107,7 +107,7 @@ bool retro_dirent_error(struct RDIR *rdir) return (rdir->directory == INVALID_HANDLE_VALUE); #elif defined(VITA) || defined(PSP) return (rdir->directory < 0); -#elif defined(__CELLOS_LV2__) +#elif defined(__PS3__) && !defined(__PSL1GHT__) return (rdir->error != CELL_FS_SUCCEEDED); #else return !(rdir->directory); @@ -120,7 +120,7 @@ int retro_readdir(struct RDIR *rdir) return (FindNextFile(rdir->directory, &rdir->entry) != 0); #elif defined(VITA) || defined(PSP) return (sceIoDread(rdir->directory, &rdir->entry) > 0); -#elif defined(__CELLOS_LV2__) +#elif defined(__PS3__) && !defined(__PSL1GHT__) uint64_t nread; rdir->error = cellFsReaddir(rdir->directory, &rdir->entry, &nread); return (nread != 0); @@ -133,7 +133,7 @@ const char *retro_dirent_get_name(struct RDIR *rdir) { #if defined(_WIN32) return rdir->entry.cFileName; -#elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__) +#elif defined(VITA) || defined(PSP) || defined(__PS3__) return rdir->entry.d_name; #else return rdir->entry->d_name; @@ -163,7 +163,7 @@ bool retro_dirent_is_dir(struct RDIR *rdir, const char *path) #elif defined(VITA) return PSP2_S_ISDIR(entry->d_stat.st_mode); #endif -#elif defined(__CELLOS_LV2__) +#elif defined(__PS3__) && !defined(__PSL1GHT__) CellFsDirent *entry = (CellFsDirent*)&rdir->entry; return (entry->d_type == CELL_FS_TYPE_DIRECTORY); #elif defined(DT_DIR) @@ -190,7 +190,7 @@ void retro_closedir(struct RDIR *rdir) FindClose(rdir->directory); #elif defined(VITA) || defined(PSP) sceIoDclose(rdir->directory); -#elif defined(__CELLOS_LV2__) +#elif defined(__PS3__) && !defined(__PSL1GHT__) rdir->error = cellFsClosedir(rdir->directory); #else if (rdir->directory) diff --git a/backends/platform/libretro/libretro-common/file/retro_stat.c b/backends/platform/libretro/libretro-common/file/retro_stat.c index 8b20555d73d5..0a01d8b8bded 100644 --- a/backends/platform/libretro/libretro-common/file/retro_stat.c +++ b/backends/platform/libretro/libretro-common/file/retro_stat.c @@ -57,7 +57,7 @@ #include #endif -#if defined(__CELLOS_LV2__) +#if defined(__PS3__) && !defined(__PSL1GHT__) #include #endif @@ -65,7 +65,7 @@ #define FIO_S_ISDIR PSP2_S_ISDIR #endif -#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) +#if (defined(__PS3__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP) #include /* stat() is defined here */ #endif @@ -95,7 +95,7 @@ static bool path_stat(const char *path, enum stat_mode mode, int32_t *size) } free(tmp); -#elif defined(__CELLOS_LV2__) +#elif defined(__PS3__) && !defined(__PSL1GHT__) CellFsStat buf; if (cellFsStat(path, &buf) < 0) return false; @@ -124,7 +124,7 @@ static bool path_stat(const char *path, enum stat_mode mode, int32_t *size) case IS_DIRECTORY: #if defined(VITA) || defined(PSP) return FIO_S_ISDIR(buf.st_mode); -#elif defined(__CELLOS_LV2__) +#elif defined(__PS3__) && !defined(__PSL1GHT__) return ((buf.st_mode & S_IFMT) == S_IFDIR); #elif defined(_WIN32) return (file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); @@ -132,7 +132,7 @@ static bool path_stat(const char *path, enum stat_mode mode, int32_t *size) return S_ISDIR(buf.st_mode); #endif case IS_CHARACTER_SPECIAL: -#if defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__) || defined(_WIN32) +#if defined(VITA) || defined(PSP) || defined(__PS3__) || defined(_WIN32) return false; #else return S_ISCHR(buf.st_mode); @@ -144,7 +144,7 @@ static bool path_stat(const char *path, enum stat_mode mode, int32_t *size) return false; } -#if !defined(WIIU) && !defined(_3DS) +#if !defined(WIIU) && !defined(_3DS) && !defined(__PS3__) /** * path_is_directory: * @path : path diff --git a/backends/platform/libretro/libretro-common/include/retro_miscellaneous.h b/backends/platform/libretro/libretro-common/include/retro_miscellaneous.h index e53e248766c2..8f8076304db9 100644 --- a/backends/platform/libretro/libretro-common/include/retro_miscellaneous.h +++ b/backends/platform/libretro/libretro-common/include/retro_miscellaneous.h @@ -26,8 +26,10 @@ #include #include -#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) +#if defined(__PS3__) && !defined(__PSL1GHT__) #include +#define fseeko fseek +#define ftello ftell #elif defined(XENON) #include