diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 778b601445..d38a1ac0db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -168,13 +168,13 @@ jobs: extra: libretro cc: gcc cxx: g++ - args: ./b.sh --libretro + args: make -C libretro -f Makefile -j2 id: gcc-libretro - os: ubuntu-latest extra: libretro cc: clang cxx: clang++ - args: ./b.sh --libretro + args: make -C libretro -f Makefile -j2 id: clang-libretro - os: macos-latest diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 4dc3974761..cf83bb7dcf 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -112,8 +112,6 @@ void InitVROnAndroid(void* vm, void* activity, int version, const char* name) { java.AppVersion = version; strcpy(java.AppName, name); VR_Init(java, useVulkan); - - __DisplaySetFramerate(72); } #endif @@ -429,6 +427,7 @@ bool StartVRRender() { } // Set customizations + __DisplaySetFramerate(g_Config.bForce72Hz ? 72 : 60); VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF); VR_SetConfig(VR_CONFIG_CAMERA_DISTANCE, g_Config.fCameraDistance * 1000); VR_SetConfig(VR_CONFIG_CAMERA_HEIGHT, g_Config.fCameraHeight * 1000); @@ -506,22 +505,7 @@ bool Is2DVRObject(float* projMatrix, bool ortho) { return identity; } -void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) { - - // Update project matrices - float* dst[] = {leftEye, rightEye}; - VRMatrix enums[] = {VR_PROJECTION_MATRIX_LEFT_EYE, VR_PROJECTION_MATRIX_RIGHT_EYE}; - for (int index = 0; index < 2; index++) { - ovrMatrix4f hmdProjection = VR_GetMatrix(enums[index]); - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - if ((hmdProjection.M[i][j] > 0) != (projMatrix[i * 4 + j] > 0)) { - hmdProjection.M[i][j] *= -1.0f; - } - } - } - memcpy(dst[index], hmdProjection.M, 16 * sizeof(float)); - } +void UpdateVRParams(float* projMatrix) { // Set mirroring of axes if (!VR_GetConfig(VR_CONFIG_MIRROR_UPDATED)) { @@ -559,6 +543,22 @@ void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) { VR_SetConfig(VR_CONFIG_6DOF_SCALE, (int)(scale * 1000000)); } +void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) { + float* dst[] = {leftEye, rightEye}; + VRMatrix enums[] = {VR_PROJECTION_MATRIX_LEFT_EYE, VR_PROJECTION_MATRIX_RIGHT_EYE}; + for (int index = 0; index < 2; index++) { + ovrMatrix4f hmdProjection = VR_GetMatrix(enums[index]); + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + if ((hmdProjection.M[i][j] > 0) != (projMatrix[i * 4 + j] > 0)) { + hmdProjection.M[i][j] *= -1.0f; + } + } + } + memcpy(dst[index], hmdProjection.M, 16 * sizeof(float)); + } +} + void UpdateVRView(float* leftEye, float* rightEye) { float* dst[] = {leftEye, rightEye}; VRMatrix enums[] = {VR_VIEW_MATRIX_LEFT_EYE, VR_VIEW_MATRIX_RIGHT_EYE}; diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index 440f27859d..e926b9957a 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -42,6 +42,7 @@ int GetVRPassesCount(); bool IsMultiviewSupported(); bool IsFlatVRScene(); bool Is2DVRObject(float* projMatrix, bool ortho); +void UpdateVRParams(float* projMatrix); void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye); void UpdateVRView(float* leftEye, float* rightEye); @@ -70,6 +71,7 @@ inline int GetVRPassesCount() { return 1; } inline bool IsMultiviewSupported() { return false; } inline bool IsFlatVRScene() { return true; } inline bool Is2DVRObject(float* projMatrix, bool ortho) { return false; } +inline void UpdateVRParams(float* projMatrix) {} inline void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) {} inline void UpdateVRView(float* leftEye, float* rightEye) {} diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 3d4cce0222..c91d2f045f 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -306,7 +306,13 @@ bool VR_InitFrame( engine_t* engine ) { float nearPlane = (float)vrConfig[VR_CONFIG_FOV_SCALE] / 200.0f; vrMatrix[matrix] = ovrMatrix4f_CreateProjectionFov(fov.angleLeft, fov.angleRight, fov.angleUp, fov.angleDown, nearPlane, 0.0f ); } else if ((matrix == VR_VIEW_MATRIX_LEFT_EYE) || (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) { + bool flatScreen = false; XrPosef invView = invViewTransform[0]; + int vrMode = vrConfig[VR_CONFIG_MODE]; + if ((vrMode == VR_MODE_MONO_SCREEN) || (vrMode == VR_MODE_STEREO_SCREEN)) { + invView = XrPosef_Identity(); + flatScreen = true; + } // get axis mirroring configuration float mx = vrConfig[VR_CONFIG_MIRROR_PITCH] ? -1 : 1; @@ -333,7 +339,7 @@ bool VR_InitFrame( engine_t* engine ) { vrMatrix[matrix] = ovrMatrix4f_CreateFromQuaternion(&invView.orientation); float scale = (float)VR_GetConfig(VR_CONFIG_6DOF_SCALE) * 0.000001f; - if (vrConfig[VR_CONFIG_6DOF_ENABLED]) { + if (!flatScreen && vrConfig[VR_CONFIG_6DOF_ENABLED]) { vrMatrix[matrix].M[0][3] -= hmdposition.x * (vrConfig[VR_CONFIG_MIRROR_AXIS_X] ? -1.0f : 1.0f) * scale; vrMatrix[matrix].M[1][3] -= hmdposition.y * (vrConfig[VR_CONFIG_MIRROR_AXIS_Y] ? -1.0f : 1.0f) * scale; vrMatrix[matrix].M[2][3] -= hmdposition.z * (vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f) * scale; diff --git a/Core/Config.cpp b/Core/Config.cpp index e3aa3a5707..b8d1408144 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1209,6 +1209,7 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VREnable6DoF", &g_Config.bEnable6DoF, true), ConfigSetting("VREnableStereo", &g_Config.bEnableStereo, false), ConfigSetting("VREnableMotions", &g_Config.bEnableMotions, true), + ConfigSetting("VRbForce72Hz", &g_Config.bForce72Hz, true), ConfigSetting("VRCameraDistance", &g_Config.fCameraDistance, 0.0f), ConfigSetting("VRCameraHeight", &g_Config.fCameraHeight, 0.0f), ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f), diff --git a/Core/Config.h b/Core/Config.h index 4f212646d3..1de62adf27 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -464,6 +464,7 @@ public: bool bEnable6DoF; bool bEnableStereo; bool bEnableMotions; + bool bForce72Hz; float fCameraDistance; float fCameraHeight; float fCameraSide; diff --git a/Core/MIPS/IR/IRCompALU.cpp b/Core/MIPS/IR/IRCompALU.cpp index 62d813f3b2..e8fe1c46b6 100644 --- a/Core/MIPS/IR/IRCompALU.cpp +++ b/Core/MIPS/IR/IRCompALU.cpp @@ -118,7 +118,7 @@ void IRFrontend::Comp_RType3(MIPSOpcode op) { MIPSGPReg rd = _RD; // noop, won't write to ZERO. - if (rd == 0) + if (rd == MIPS_REG_ZERO) return; switch (op & 63) { @@ -298,7 +298,7 @@ void IRFrontend::Comp_Allegrex2(MIPSOpcode op) { MIPSGPReg rd = _RD; // Don't change $zr. - if (rd == 0) + if (rd == MIPS_REG_ZERO) return; switch (op & 0x3ff) { diff --git a/Core/MIPS/IR/IRCompFPU.cpp b/Core/MIPS/IR/IRCompFPU.cpp index c0aac3f3f1..cf6b4faa75 100644 --- a/Core/MIPS/IR/IRCompFPU.cpp +++ b/Core/MIPS/IR/IRCompFPU.cpp @@ -118,7 +118,7 @@ void IRFrontend::Comp_FPUComp(MIPSOpcode op) { break; case 3: // ueq, ngl (equal, unordered) mode = IRFpCompareMode::EqualUnordered; - return; + break; case 4: // olt, lt (less than, ordered) mode = IRFpCompareMode::LessOrdered; break; diff --git a/Core/MIPS/IR/IRCompVFPU.cpp b/Core/MIPS/IR/IRCompVFPU.cpp index 4694986cf7..74b0615547 100644 --- a/Core/MIPS/IR/IRCompVFPU.cpp +++ b/Core/MIPS/IR/IRCompVFPU.cpp @@ -117,8 +117,9 @@ namespace MIPSComp { int abs = (prefix >> (8 + i)) & 1; int negate = (prefix >> (16 + i)) & 1; int constants = (prefix >> (12 + i)) & 1; - if (regnum < n || abs || negate || constants) { - return false; + if (regnum >= n && !constants) { + if (abs || negate || regnum != i) + return false; } } @@ -464,6 +465,7 @@ namespace MIPSComp { init = Vec4Init::AllONE; break; default: + INVALIDOP; return; } ir.Write(IROp::Vec4Init, vec[0], (int)init); @@ -472,7 +474,7 @@ namespace MIPSComp { void IRFrontend::Comp_VHdp(MIPSOpcode op) { CONDITIONAL_DISABLE(VFPU_VEC); - if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || !IsPrefixWithinSize(js.prefixT, op)) { + if (js.HasUnknownPrefix() || js.HasSPrefix() || !IsPrefixWithinSize(js.prefixT, op)) { DISABLE; } @@ -754,8 +756,15 @@ namespace MIPSComp { void IRFrontend::Comp_VV2Op(MIPSOpcode op) { CONDITIONAL_DISABLE(VFPU_VEC); - if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || !IsPrefixWithinSize(js.prefixT, op)) - DISABLE; + int optype = (op >> 16) & 0x1f; + if (optype == 0) { + if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op)) + DISABLE; + } else { + // Many of these apply the D prefix strangely or override parts of the S prefix. + if (!js.HasNoPrefix()) + DISABLE; + } // Vector unary operation // d[N] = OP(s[N]) (see below) @@ -763,7 +772,6 @@ namespace MIPSComp { int vs = _VS; int vd = _VD; - int optype = (op >> 16) & 0x1f; if (optype >= 16 && !js.HasNoPrefix()) { DISABLE; } else if ((optype == 1 || optype == 2) && js.HasSPrefix()) { @@ -1458,7 +1466,7 @@ namespace MIPSComp { void IRFrontend::Comp_VDet(MIPSOpcode op) { CONDITIONAL_DISABLE(VFPU_VEC); - if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || (js.prefixT & 0x000CFCF0) != 0x000E0) { + if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || js.HasTPrefix()) { DISABLE; } @@ -1903,7 +1911,7 @@ namespace MIPSComp { void IRFrontend::Comp_Vsgn(MIPSOpcode op) { CONDITIONAL_DISABLE(VFPU_VEC); - if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || !IsPrefixWithinSize(js.prefixT, op)) { + if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || js.HasTPrefix()) { DISABLE; } @@ -1999,7 +2007,7 @@ namespace MIPSComp { void IRFrontend::Comp_Vbfy(MIPSOpcode op) { CONDITIONAL_DISABLE(VFPU_VEC); - if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || js.HasTPrefix()) { + if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || js.HasTPrefix() || (js.prefixS & VFPU_NEGATE(1, 1, 1, 1)) != 0) { DISABLE; } diff --git a/Core/MIPS/IR/IRInterpreter.cpp b/Core/MIPS/IR/IRInterpreter.cpp index 27b0ba0ca3..da1e643888 100644 --- a/Core/MIPS/IR/IRInterpreter.cpp +++ b/Core/MIPS/IR/IRInterpreter.cpp @@ -881,17 +881,23 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst, int count) { break; } case IRFpCompareMode::EqualOrdered: - case IRFpCompareMode::EqualUnordered: mips->fpcond = mips->f[inst->src1] == mips->f[inst->src2]; break; + case IRFpCompareMode::EqualUnordered: + mips->fpcond = mips->f[inst->src1] == mips->f[inst->src2] || my_isnan(mips->f[inst->src1]) || my_isnan(mips->f[inst->src2]); + break; case IRFpCompareMode::LessEqualOrdered: - case IRFpCompareMode::LessEqualUnordered: mips->fpcond = mips->f[inst->src1] <= mips->f[inst->src2]; break; + case IRFpCompareMode::LessEqualUnordered: + mips->fpcond = !(mips->f[inst->src1] > mips->f[inst->src2]); + break; case IRFpCompareMode::LessOrdered: - case IRFpCompareMode::LessUnordered: mips->fpcond = mips->f[inst->src1] < mips->f[inst->src2]; break; + case IRFpCompareMode::LessUnordered: + mips->fpcond = !(mips->f[inst->src1] >= mips->f[inst->src2]); + break; } break; diff --git a/Core/MIPS/MIPSIntVFPU.cpp b/Core/MIPS/MIPSIntVFPU.cpp index bc1120921e..1b2c8d60ec 100644 --- a/Core/MIPS/MIPSIntVFPU.cpp +++ b/Core/MIPS/MIPSIntVFPU.cpp @@ -1629,8 +1629,9 @@ namespace MIPSInt d[cosineLane] = cosine; } - // D prefix works, just not for x. - currentMIPS->vfpuCtrl[VFPU_CTRL_DPREFIX] &= 0xFFEFC; + // D prefix works, just not for the cosine lane. + uint32_t dprefixRemove = (3 << cosineLane) | (1 << (8 + cosineLane)); + currentMIPS->vfpuCtrl[VFPU_CTRL_DPREFIX] &= 0xFFFFF ^ dprefixRemove; ApplyPrefixD(d, sz); WriteVector(d, sz, vd); PC += 4; diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index fb6b436661..dcd413ff2b 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -21,6 +21,11 @@ #include #include #include +#ifdef SHARED_LIBZIP +#include +#else +#include "ext/libzip/zip.h" +#endif #include "ext/xxhash.h" @@ -44,9 +49,11 @@ #include "GPU/Common/TextureDecoder.h" static const std::string INI_FILENAME = "textures.ini"; +static const std::string ZIP_FILENAME = "textures.zip"; static const std::string NEW_TEXTURE_DIR = "new/"; static const int VERSION = 1; static const int MAX_MIP_LEVELS = 12; // 12 should be plenty, 8 is the max mip levels supported by the PSP. +static const double MAX_CACHE_SIZE = 4.0; TextureReplacer::TextureReplacer() { none_.initDone_ = true; @@ -54,6 +61,8 @@ TextureReplacer::TextureReplacer() { } TextureReplacer::~TextureReplacer() { + if (zip_) + zip_close(zip_); } void TextureReplacer::Init() { @@ -76,8 +85,11 @@ void TextureReplacer::NotifyConfigChanged() { File::CreateEmptyFile(newTextureDir / ".nomedia"); } - enabled_ = File::Exists(basePath_) && File::IsDirectory(basePath_); + enabled_ = File::IsDirectory(basePath_); } else if (wasEnabled) { + if (zip_) + zip_close(zip_); + zip_ = nullptr; Decimate(ReplacerDecimateMode::ALL); } @@ -86,6 +98,44 @@ void TextureReplacer::NotifyConfigChanged() { } } +static struct zip *ZipOpenPath(Path fileName) { + int error = 0; + if (fileName.Type() == PathType::CONTENT_URI) { + int fd = File::OpenFD(fileName, File::OPEN_READ); + return zip_fdopen(fd, 0, &error); + } + return zip_open(fileName.c_str(), 0, &error); +} + +static constexpr zip_uint64_t INVALID_ZIP_SIZE = 0xFFFFFFFFFFFFFFFFULL; +static zip_uint64_t ZipFileSize(zip *z, zip_int64_t i) { + zip_stat_t zstat; + if (zip_stat_index(z, i, 0, &zstat) != 0) + return INVALID_ZIP_SIZE; + if ((zstat.valid & ZIP_STAT_SIZE) == 0) + return INVALID_ZIP_SIZE; + return zstat.size; +} + +static bool LoadIniZip(IniFile &ini, zip *z, const std::string &filename) { + zip_int64_t i = zip_name_locate(z, filename.c_str(), ZIP_FL_NOCASE); + if (i < 0) + return false; + + std::string inistr; + zip_uint64_t sz = ZipFileSize(z, i); + if (sz == INVALID_ZIP_SIZE) + return false; + inistr.resize(sz); + + zip_file_t *zf = zip_fopen_index(z, i, 0); + inistr.resize(zip_fread(zf, &inistr[0], inistr.size())); + zip_fclose(zf); + + std::stringstream sstream(inistr); + return ini.Load(sstream); +} + bool TextureReplacer::LoadIni() { // TODO: Use crc32c? hash_ = ReplacedTextureHash::QUICK; @@ -101,10 +151,32 @@ bool TextureReplacer::LoadIni() { // Prevents dumping the mipmaps. ignoreMipmap_ = false; - if (File::Exists(basePath_ / INI_FILENAME)) { - IniFile ini; - ini.LoadFromVFS((basePath_ / INI_FILENAME).ToString()); + if (zip_) + zip_close(zip_); + zip_ = nullptr; + IniFile ini; + bool iniLoaded = false; + + // First, check for textures.zip, which is used to reduce IO. + zip *z = ZipOpenPath(basePath_ / ZIP_FILENAME); + if (z) { + iniLoaded = LoadIniZip(ini, z, INI_FILENAME); + // Require the zip have textures.ini to use it. + if (iniLoaded) { + iniLoaded = true; + zip_ = z; + } else { + zip_close(z); + z = nullptr; + } + } + + if (!iniLoaded) { + iniLoaded = ini.LoadFromVFS((basePath_ / INI_FILENAME).ToString()); + } + + if (iniLoaded) { if (!LoadIniValues(ini)) { return false; } @@ -113,10 +185,17 @@ bool TextureReplacer::LoadIni() { std::string overrideFilename; if (ini.GetOrCreateSection("games")->Get(gameID_.c_str(), &overrideFilename, "")) { if (!overrideFilename.empty() && overrideFilename != INI_FILENAME) { - INFO_LOG(G3D, "Loading extra texture ini: %s", overrideFilename.c_str()); IniFile overrideIni; - overrideIni.LoadFromVFS((basePath_ / overrideFilename).ToString()); + if (zip_) + iniLoaded = LoadIniZip(overrideIni, zip_, overrideFilename); + else + iniLoaded = overrideIni.LoadFromVFS((basePath_ / overrideFilename).ToString()); + if (!iniLoaded) { + ERROR_LOG(G3D, "Failed to load extra texture ini: %s", overrideFilename.c_str()); + return false; + } + INFO_LOG(G3D, "Loading extra texture ini: %s", overrideFilename.c_str()); if (!LoadIniValues(overrideIni, true)) { return false; } @@ -410,7 +489,7 @@ void TextureReplacer::PopulateReplacement(ReplacedTexture *result, u64 cachekey, for (int i = 0; i < MAX_MIP_LEVELS; ++i) { const std::string hashfile = LookupHashFile(cachekey, hash, i); const Path filename = basePath_ / hashfile; - if (hashfile.empty() || !File::Exists(filename)) { + if (hashfile.empty()) { // Out of valid mip levels. Bail out. break; } @@ -418,7 +497,16 @@ void TextureReplacer::PopulateReplacement(ReplacedTexture *result, u64 cachekey, ReplacedTextureLevel level; level.fmt = Draw::DataFormat::R8G8B8A8_UNORM; level.file = filename; - bool good = PopulateLevel(level); + + bool good; + bool logError = hashfile != HashName(cachekey, hash, i) + ".png"; + if (zip_) { + level.z = zip_; + level.zi = zip_name_locate(zip_, hashfile.c_str(), ZIP_FL_NOCASE); + good = PopulateLevelFromZip(level, !logError); + } else { + good = PopulateLevelFromPath(level, !logError); + } // We pad files that have been hashrange'd so they are the same texture size. level.w = (level.w * w) / newW; @@ -439,6 +527,12 @@ void TextureReplacer::PopulateReplacement(ReplacedTexture *result, u64 cachekey, break; } + // Populate the level data pointers for each level. + result->levelData_.resize(result->levels_.size()); + for (size_t i = 0; i < result->levels_.size(); ++i) { + result->levelData_[i] = &levelCache_[result->levels_[i]]; + } + result->prepareDone_ = true; } @@ -448,12 +542,7 @@ enum class ReplacedImageType { INVALID, }; -static ReplacedImageType Identify(FILE *fp) { - uint8_t magic[4]; - if (fread(magic, 1, 4, fp) != 4) - return ReplacedImageType::INVALID; - rewind(fp); - +static ReplacedImageType Identify(const uint8_t magic[4]) { if (strncmp((const char *)magic, "ZIMG", 4) == 0) return ReplacedImageType::ZIM; if (magic[0] == 0x89 && strncmp((const char *)&magic[1], "PNG", 3) == 0) @@ -461,12 +550,30 @@ static ReplacedImageType Identify(FILE *fp) { return ReplacedImageType::INVALID; } -bool TextureReplacer::PopulateLevel(ReplacedTextureLevel &level) { +static ReplacedImageType Identify(FILE *fp) { + uint8_t magic[4]; + if (fread(magic, 1, 4, fp) != 4) + return ReplacedImageType::INVALID; + rewind(fp); + + return Identify(magic); +} + +static ReplacedImageType Identify(zip_file_t *zf) { + uint8_t magic[4]; + if (zip_fread(zf, magic, 4) != 4) + return ReplacedImageType::INVALID; + + return Identify(magic); +} + +bool TextureReplacer::PopulateLevelFromPath(ReplacedTextureLevel &level, bool ignoreError) { bool good = false; FILE *fp = File::OpenCFile(level.file, "rb"); if (!fp) { - ERROR_LOG(G3D, "Error opening replacement texture file '%s'", level.file.c_str()); + if (!ignoreError) + ERROR_LOG(G3D, "Error opening replacement texture file '%s'", level.file.c_str()); return false; } @@ -499,6 +606,62 @@ bool TextureReplacer::PopulateLevel(ReplacedTextureLevel &level) { return good; } +bool TextureReplacer::PopulateLevelFromZip(ReplacedTextureLevel &level, bool ignoreError) { + bool good = false; + + if (!level.z || level.zi < 0) { + if (!ignoreError) + ERROR_LOG(G3D, "Error opening replacement texture file '%s' in textures.zip", level.file.c_str()); + return false; + } + + zip_file_t *zf = zip_fopen_index(level.z, level.zi, 0); + if (!zf) + return false; + + auto imageType = Identify(zf); + zip_fclose(zf); + + zf = zip_fopen_index(level.z, level.zi, 0); + if (imageType == ReplacedImageType::ZIM) { + uint32_t ignore = 0; + good = zip_fread(zf, &ignore, 4) == 4; + good = good && zip_fread(zf, &level.w, 4) == 4; + good = good && zip_fread(zf, &level.h, 4) == 4; + int flags; + if (good && zip_fread(zf, &flags, 4) == 4) { + good = (flags & ZIM_FORMAT_MASK) == ZIM_RGBA8888; + } + } else if (imageType == ReplacedImageType::PNG) { + png_image png = {}; + png.version = PNG_IMAGE_VERSION; + + // TODO: Use some way to stream data into libpng. Better than the IO lookups on Android... + zip_uint64_t zsize = ZipFileSize(level.z, level.zi); + std::string pngdata; + if (zsize != INVALID_ZIP_SIZE) + pngdata.resize(zsize); + if (!pngdata.empty()) { + pngdata.resize(zip_fread(zf, &pngdata[0], pngdata.size())); + } + + if (png_image_begin_read_from_memory(&png, &pngdata[0], pngdata.size())) { + // We pad files that have been hashrange'd so they are the same texture size. + level.w = png.width; + level.h = png.height; + good = true; + } else { + ERROR_LOG(G3D, "Could not load texture replacement info: %s - %s (zip)", level.file.ToVisualString().c_str(), png.message); + } + png_image_free(&png); + } else { + ERROR_LOG(G3D, "Could not load texture replacement info: %s - unsupported format (zip)", level.file.ToVisualString().c_str()); + } + zip_fclose(zf); + + return good; +} + static bool WriteTextureToPNG(png_imagep image, const Path &filename, int convert_to_8bit, const void *buffer, png_int_32 row_stride, const void *colormap) { FILE *fp = File::OpenCFile(filename, "wb"); if (!fp) { @@ -673,15 +836,32 @@ void TextureReplacer::NotifyTextureDecoded(const ReplacedTextureDecodeInfo &repl void TextureReplacer::Decimate(ReplacerDecimateMode mode) { // Allow replacements to be cached for a long time, although they're large. double age = 1800.0; - if (mode == ReplacerDecimateMode::FORCE_PRESSURE) + if (mode == ReplacerDecimateMode::FORCE_PRESSURE) { age = 90.0; - else if (mode == ReplacerDecimateMode::ALL) + } else if (mode == ReplacerDecimateMode::ALL) { age = 0.0; + } else if (lastTextureCacheSizeGB_ > 1.0) { + double pressure = std::min(MAX_CACHE_SIZE, lastTextureCacheSizeGB_) / MAX_CACHE_SIZE; + // Get more aggressive the closer we are to the max. + age = 90.0 + (1.0 - pressure) * 1710.0; + } const double threshold = time_now_d() - age; for (auto &item : cache_) { item.second.PurgeIfOlder(threshold); } + + size_t totalSize = 0; + for (auto &item : levelCache_) { + std::lock_guard guard(item.second.lock); + totalSize += item.second.data.size(); + } + + double totalSizeGB = totalSize / (1024.0 * 1024.0 * 1024.0); + if (totalSizeGB >= 1.0) { + WARN_LOG(G3D, "Decimated replacements older than %fs, currently using %f GB of RAM", age, totalSizeGB); + } + lastTextureCacheSizeGB_ = totalSizeGB; } template @@ -821,8 +1001,11 @@ bool ReplacedTexture::IsReady(double budget) { } // Loaded already, or not yet on a thread? - if (initDone_ && !levelData_.empty()) + if (initDone_ && !levelData_.empty()) { + for (auto &l : levelData_) + l->lastUsed = lastUsed_; return true; + } // Let's not even start a new texture if we're already behind. if (budget < 0.0) return false; @@ -856,7 +1039,6 @@ void ReplacedTexture::Prepare() { return; } - levelData_.resize(levels_.size()); for (int i = 0; i < (int)levels_.size(); ++i) { if (cancelPrepare_) break; @@ -870,39 +1052,87 @@ void ReplacedTexture::Prepare() { void ReplacedTexture::PrepareData(int level) { _assert_msg_((size_t)level < levels_.size(), "Invalid miplevel"); + _assert_msg_(levelData_[level] != nullptr, "Level cache not set for miplevel"); + + // We must lock around access to levelData_ in case two textures try to load it at once. + std::lock_guard guard(levelData_[level]->lock); const ReplacedTextureLevel &info = levels_[level]; - std::vector &out = levelData_[level]; + std::vector &out = levelData_[level]->data; - FILE *fp = File::OpenCFile(info.file, "rb"); - if (!fp) { - // Leaving the data sized at zero means failure. + // Already populated from cache. + if (!out.empty()) return; - } - auto imageType = Identify(fp); - if (imageType == ReplacedImageType::ZIM) { - size_t zimSize = File::GetFileSize(fp); - std::unique_ptr zim(new uint8_t[zimSize]); - if (!zim) { - ERROR_LOG(G3D, "Failed to allocate memory for texture replacement"); - fclose(fp); + FILE *fp = nullptr; + zip_file_t *zf = nullptr; + ReplacedImageType imageType; + if (info.z) { + zf = zip_fopen_index(info.z, info.zi, 0); + if (!zf) + return; + + imageType = Identify(zf); + // Can't assume we can seek. Reopen. + zip_fclose(zf); + zf = zip_fopen_index(info.z, info.zi, 0); + } else { + fp = File::OpenCFile(info.file, "rb"); + if (!fp) { + // Leaving the data sized at zero means failure. return; } - if (fread(&zim[0], 1, zimSize, fp) != zimSize) { - ERROR_LOG(G3D, "Could not load texture replacement: %s - failed to read ZIM", info.file.c_str()); + imageType = Identify(fp); + } + + auto cleanup = [&] { + if (zf) + zip_fclose(zf); + if (fp) fclose(fp); + }; + + if (imageType == ReplacedImageType::ZIM) { + size_t zimSize; + if (fp) { + zimSize = File::GetFileSize(fp); + } else if (zf) { + zip_uint64_t zsize = ZipFileSize(info.z, info.zi); + zimSize = zsize == INVALID_ZIP_SIZE ? 0 : (size_t)zsize; + } else { + _assert_(false); + } + std::unique_ptr zim(new uint8_t[zimSize]); + if (!zim) { + ERROR_LOG(G3D, "Failed to allocate memory for texture replacement"); + cleanup(); return; } + if (fp) { + if (fread(&zim[0], 1, zimSize, fp) != zimSize) { + ERROR_LOG(G3D, "Could not load texture replacement: %s - failed to read ZIM", info.file.c_str()); + cleanup(); + return; + } + } else if (zf) { + if (zip_fread(zf, &zim[0], zimSize) != zimSize) { + ERROR_LOG(G3D, "Could not load texture replacement: %s - failed to read ZIM (zip)", info.file.c_str()); + cleanup(); + return; + } + } else { + _assert_(false); + } + int w, h, f; uint8_t *image; if (LoadZIMPtr(&zim[0], zimSize, &w, &h, &f, &image)) { if (w > info.w || h > info.h) { ERROR_LOG(G3D, "Texture replacement changed since header read: %s", info.file.c_str()); - fclose(fp); + cleanup(); return; } @@ -925,14 +1155,33 @@ void ReplacedTexture::PrepareData(int level) { png_image png = {}; png.version = PNG_IMAGE_VERSION; - if (!png_image_begin_read_from_stdio(&png, fp)) { - ERROR_LOG(G3D, "Could not load texture replacement info: %s - %s", info.file.c_str(), png.message); - fclose(fp); - return; + // Needs to survive for a little while, used for zip only. + std::string pngdata; + if (fp) { + if (!png_image_begin_read_from_stdio(&png, fp)) { + ERROR_LOG(G3D, "Could not load texture replacement info: %s - %s", info.file.c_str(), png.message); + cleanup(); + return; + } + } else if (zf) { + zip_uint64_t zsize = ZipFileSize(info.z, info.zi); + if (zsize != INVALID_ZIP_SIZE) + pngdata.resize(zsize); + if (!pngdata.empty()) { + pngdata.resize(zip_fread(zf, &pngdata[0], pngdata.size())); + } + + if (!png_image_begin_read_from_memory(&png, &pngdata[0], pngdata.size())) { + ERROR_LOG(G3D, "Could not load texture replacement info: %s - %s (zip)", info.file.c_str(), png.message); + cleanup(); + return; + } + } else { + _assert_(false); } if (png.width > (uint32_t)info.w || png.height > (uint32_t)info.h) { ERROR_LOG(G3D, "Texture replacement changed since header read: %s", info.file.c_str()); - fclose(fp); + cleanup(); return; } @@ -949,7 +1198,7 @@ void ReplacedTexture::PrepareData(int level) { out.resize(info.w * info.h * 4); if (!png_image_finish_read(&png, nullptr, &out[0], info.w * 4, nullptr)) { ERROR_LOG(G3D, "Could not load texture replacement: %s - %s", info.file.c_str(), png.message); - fclose(fp); + cleanup(); out.resize(0); return; } @@ -964,13 +1213,23 @@ void ReplacedTexture::PrepareData(int level) { } } - fclose(fp); + cleanup(); } void ReplacedTexture::PurgeIfOlder(double t) { - if (lastUsed_ < t && (!threadWaitable_ || threadWaitable_->WaitFor(0.0))) { - levelData_.clear(); - initDone_ = false; + if (threadWaitable_ && !threadWaitable_->WaitFor(0.0)) + return; + if (lastUsed_ >= t) + return; + + for (auto &l : levelData_) { + if (l->lastUsed < t) { + // We have to lock since multiple textures might reference this same data. + std::lock_guard guard(l->lock); + l->data.clear(); + // This means we have to reload. If we never purge any, there's no need. + initDone_ = false; + } } } @@ -993,8 +1252,13 @@ bool ReplacedTexture::Load(int level, void *out, int rowPitch) { if (levelData_.empty()) return false; + _assert_msg_(levelData_[level] != nullptr, "Level cache not set for miplevel"); + + // We probably could avoid this lock, but better to play it safe. + std::lock_guard guard(levelData_[level]->lock); + const ReplacedTextureLevel &info = levels_[level]; - const std::vector &data = levelData_[level]; + const std::vector &data = levelData_[level]->data; if (data.empty()) return false; diff --git a/Core/TextureReplacer.h b/Core/TextureReplacer.h index b32d31a7d3..4fb5bf5224 100644 --- a/Core/TextureReplacer.h +++ b/Core/TextureReplacer.h @@ -17,11 +17,13 @@ #pragma once +#include "ppsspp_config.h" #include #include #include #include +#include "Common/CommonFuncs.h" #include "Common/CommonTypes.h" #include "Common/MemoryUtil.h" #include "Common/File/Path.h" @@ -35,6 +37,7 @@ class TextureCacheCommon; class TextureReplacer; class ReplacedTextureTask; class LimitedWaitable; +struct zip; // These must match the constants in TextureCacheCommon. enum class ReplacedTextureAlpha { @@ -54,6 +57,38 @@ struct ReplacedTextureLevel { int h; Draw::DataFormat fmt; // NOTE: Right now, the only supported format is Draw::DataFormat::R8G8B8A8_UNORM. Path file; + // Can be ignored for hashing/equal, since file has all uniqueness. + // To be able to reload, we need to be able to reopen, unfortunate we can't use zip_file_t. + zip *z = nullptr; + int64_t zi = -1; + + bool operator ==(const ReplacedTextureLevel &other) const { + if (w != other.w || h != other.h || fmt != other.fmt) + return false; + return file == other.file; + } +}; + +namespace std { + template <> + struct hash { + std::size_t operator()(const ReplacedTextureLevel &k) const { +#if PPSSPP_ARCH(64BIT) + uint64_t v = (uint64_t)k.w | ((uint64_t)k.h << 32); + v = __rotl64(v ^ (uint64_t)k.fmt, 13); +#else + uint32_t v = k.w ^ (uint32_t)k.fmt; + v = __rotl(__rotl(v, 13) ^ k.h, 13); +#endif + return v ^ hash()(k.file.ToString()); + } + }; +} + +struct ReplacedLevelCache { + std::mutex lock; + std::vector data; + double lastUsed = 0.0; }; struct ReplacementCacheKey { @@ -169,7 +204,7 @@ protected: void PurgeIfOlder(double t); std::vector levels_; - std::vector> levelData_; + std::vector levelData_; ReplacedTextureAlpha alphaStatus_ = ReplacedTextureAlpha::UNKNOWN; double lastUsed_ = 0.0; LimitedWaitable *threadWaitable_ = nullptr; @@ -240,7 +275,8 @@ protected: std::string LookupHashFile(u64 cachekey, u32 hash, int level); std::string HashName(u64 cachekey, u32 hash, int level); void PopulateReplacement(ReplacedTexture *result, u64 cachekey, u32 hash, int w, int h); - bool PopulateLevel(ReplacedTextureLevel &level); + bool PopulateLevelFromPath(ReplacedTextureLevel &level, bool ignoreError); + bool PopulateLevelFromZip(ReplacedTextureLevel &level, bool ignoreError); bool enabled_ = false; bool allowVideo_ = false; @@ -248,10 +284,13 @@ protected: bool reduceHash_ = false; float reduceHashSize = 1.0; // default value with reduceHash to false float reduceHashGlobalValue = 0.5; // Global value for textures dump pngs of all sizes, 0.5 by default but can be set in textures.ini + double lastTextureCacheSizeGB_ = 0.0; bool ignoreMipmap_ = false; std::string gameID_; Path basePath_; ReplacedTextureHash hash_ = ReplacedTextureHash::QUICK; + zip *zip_ = nullptr; + typedef std::pair WidthHeightPair; std::unordered_map hashranges_; std::unordered_map reducehashranges_; @@ -261,4 +300,5 @@ protected: ReplacedTexture none_; std::unordered_map cache_; std::unordered_map> savedCache_; + std::unordered_map levelCache_; }; diff --git a/Core/Util/GameManager.cpp b/Core/Util/GameManager.cpp index e808f07b6c..63952a5d81 100644 --- a/Core/Util/GameManager.cpp +++ b/Core/Util/GameManager.cpp @@ -325,6 +325,9 @@ bool GameManager::InstallGame(Path url, Path fileName, bool deleteAfter) { if (DetectTexturePackDest(z, info.textureIniIndex, dest)) { INFO_LOG(HLE, "Installing '%s' into '%s'", fileName.c_str(), dest.c_str()); File::CreateFullPath(dest); + // Install as a zip file if textures.ini is in the root. Performs better on Android. + if (info.stripChars == 0) + return InstallMemstickZip(z, fileName, dest / "textures.zip", info, deleteAfter); File::CreateEmptyFile(dest / ".nomedia"); return InstallMemstickGame(z, fileName, dest, info, true, deleteAfter); } else { @@ -617,6 +620,60 @@ bail: return false; } +bool GameManager::InstallMemstickZip(struct zip *z, const Path &zipfile, const Path &dest, const ZipFileInfo &info, bool deleteAfter) { + size_t allBytes = 0; + size_t bytesCopied = 0; + + auto sy = GetI18NCategory("System"); + + // We don't need the zip anymore, as we're going to copy it as-is. + zip_close(z); + z = nullptr; + + // Not using File::Copy() so we can report progress. + FILE *inf = File::OpenCFile(zipfile, "rb"); + if (!inf) + return false; + + allBytes = (size_t)File::GetFileSize(inf); + FILE *outf = File::OpenCFile(dest, "wb"); + if (!outf) { + SetInstallError(sy->T("Storage full")); + fclose(inf); + return false; + } + + const size_t blockSize = 1024 * 128; + u8 *buffer = new u8[blockSize]; + while (bytesCopied < allBytes) { + size_t readSize = std::min(blockSize, allBytes - bytesCopied); + if (fread(buffer, readSize, 1, inf) != 1) + break; + if (fwrite(buffer, readSize, 1, outf) != 1) + break; + bytesCopied += readSize; + installProgress_ = (float)allBytes / (float)allBytes; + } + + delete[] buffer; + fclose(inf); + fclose(outf); + + if (bytesCopied < allBytes) { + File::Delete(dest); + SetInstallError(sy->T("Storage full")); + return false; + } + + installProgress_ = 1.0f; + if (deleteAfter) { + File::Delete(zipfile); + } + InstallDone(); + ResetInstallError(); + return true; +} + bool GameManager::InstallZippedISO(struct zip *z, int isoFileIndex, const Path &zipfile, bool deleteAfter) { // Let's place the output file in the currently selected Games directory. diff --git a/Core/Util/GameManager.h b/Core/Util/GameManager.h index df74af2fd7..f7fc8ff7b5 100644 --- a/Core/Util/GameManager.h +++ b/Core/Util/GameManager.h @@ -79,6 +79,7 @@ public: private: bool InstallGame(Path url, Path tempFileName, bool deleteAfter); bool InstallMemstickGame(struct zip *z, const Path &zipFile, const Path &dest, const ZipFileInfo &info, bool allowRoot, bool deleteAfter); + bool InstallMemstickZip(struct zip *z, const Path &zipFile, const Path &dest, const ZipFileInfo &info, bool deleteAfter); bool InstallZippedISO(struct zip *z, int isoFileIndex, const Path &zipfile, bool deleteAfter); bool InstallRawISO(const Path &zipFile, const std::string &originalName, bool deleteAfter); void InstallDone(); diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index 586afdca0f..1438cbb6f5 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -58,7 +58,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu if (compat.shaderLanguage == GLSL_VULKAN) { WRITE(p, "\n"); - WRITE(p, "layout (std140, set = 0, binding = 3) uniform baseVars {\n%s};\n", ub_baseStr); + WRITE(p, "layout (std140, set = 1, binding = 3) uniform baseVars {\n%s};\n", ub_baseStr); } else if (compat.shaderLanguage == HLSL_D3D11) { WRITE(p, "cbuffer base : register(b0) {\n%s};\n", ub_baseStr); } diff --git a/GPU/Debugger/Playback.cpp b/GPU/Debugger/Playback.cpp index eb3f9fa2bc..03472ba834 100644 --- a/GPU/Debugger/Playback.cpp +++ b/GPU/Debugger/Playback.cpp @@ -46,6 +46,7 @@ namespace GPURecord { static std::string lastExecFilename; +static uint32_t lastExecVersion; static std::vector lastExecCommands; static std::vector lastExecPushbuf; static std::mutex executeLock; @@ -761,6 +762,7 @@ static void ReplayStop() { lastExecFilename.clear(); lastExecCommands.clear(); lastExecPushbuf.clear(); + lastExecVersion = 0; } bool RunMountedReplay(const std::string &filename) { @@ -769,7 +771,7 @@ bool RunMountedReplay(const std::string &filename) { std::lock_guard guard(executeLock); Core_ListenStopRequest(&ReplayStop); - uint32_t version = 0; + uint32_t version = lastExecVersion; if (lastExecFilename != filename) { PROFILE_THIS_SCOPE("ReplayLoad"); u32 fp = pspFileSystem.OpenFile(filename, FILEACCESS_READ); @@ -812,6 +814,7 @@ bool RunMountedReplay(const std::string &filename) { } lastExecFilename = filename; + lastExecVersion = version; } DumpExecute executor(lastExecPushbuf, lastExecCommands, version); diff --git a/GPU/Debugger/Record.cpp b/GPU/Debugger/Record.cpp index 6058546b0f..97ed107470 100644 --- a/GPU/Debugger/Record.cpp +++ b/GPU/Debugger/Record.cpp @@ -60,11 +60,13 @@ static std::vector commands; static std::vector lastRegisters; static std::vector lastTextures; static std::set lastRenderTargets; +static std::vector lastVRAM; enum class DirtyVRAMFlag : uint8_t { CLEAN = 0, - DIRTY = 1, - DRAWN = 2, + UNKNOWN = 1, + DIRTY = 2, + DRAWN = 3, }; static constexpr uint32_t DIRTY_VRAM_SHIFT = 8; static constexpr uint32_t DIRTY_VRAM_ROUND = (1 << DIRTY_VRAM_SHIFT) - 1; @@ -106,8 +108,15 @@ static Path GenRecordingFilename() { } static void DirtyAllVRAM(DirtyVRAMFlag flag) { - for (uint32_t i = 0; i < DIRTY_VRAM_SIZE; ++i) - dirtyVRAM[i] = flag; + if (flag == DirtyVRAMFlag::UNKNOWN) { + for (uint32_t i = 0; i < DIRTY_VRAM_SIZE; ++i) { + if (dirtyVRAM[i] == DirtyVRAMFlag::CLEAN) + dirtyVRAM[i] = DirtyVRAMFlag::UNKNOWN; + } + } else { + for (uint32_t i = 0; i < DIRTY_VRAM_SIZE; ++i) + dirtyVRAM[i] = flag; + } } static void DirtyVRAM(u32 start, u32 sz, DirtyVRAMFlag flag) { @@ -123,10 +132,10 @@ static void DirtyVRAM(u32 start, u32 sz, DirtyVRAMFlag flag) { } static void DirtyDrawnVRAM() { - int w = std::max(gstate.getScissorX2(), gstate.getRegionX2()) + 1; - int h = std::max(gstate.getScissorY2(), gstate.getRegionY2()) + 1; + int w = std::min(gstate.getScissorX2(), gstate.getRegionX2()) + 1; + int h = std::min(gstate.getScissorY2(), gstate.getRegionY2()) + 1; - bool drawZ = gstate.isDepthWriteEnabled() && gstate.isDepthTestEnabled(); + bool drawZ = !gstate.isModeClear() && gstate.isDepthWriteEnabled() && gstate.isDepthTestEnabled(); bool clearZ = gstate.isModeClear() && gstate.isClearModeDepthMask(); if (drawZ || clearZ) { int bytes = 2 * gstate.DepthBufStride() * h; @@ -155,6 +164,7 @@ static void BeginRecording() { pushbuf.resize(pushbuf.size() + sz); gstate.Save((u32_le *)(pushbuf.data() + ptr)); commands.push_back({CommandType::INIT, sz, ptr}); + lastVRAM.resize(2 * 1024 * 1024); // Also save the initial CLUT. GPUDebugBuffer clut; @@ -325,6 +335,7 @@ static u32 GetTargetFlags(u32 addr, u32 sizeInRAM) { addr &= 0x041FFFFF; const bool isTarget = lastRenderTargets.find(addr) != lastRenderTargets.end(); + bool isUnknownVRAM = false; bool isDirtyVRAM = false; bool isDrawnVRAM = false; uint32_t start = (addr >> DIRTY_VRAM_SHIFT) & DIRTY_VRAM_MASK; @@ -333,16 +344,25 @@ static u32 GetTargetFlags(u32 addr, u32 sizeInRAM) { bool endEven = ((addr + sizeInRAM) & DIRTY_VRAM_ROUND) == 0; for (uint32_t i = 0; i < blocks; ++i) { DirtyVRAMFlag flag = dirtyVRAM[start + i]; + isUnknownVRAM = (isUnknownVRAM || flag == DirtyVRAMFlag::UNKNOWN) && flag != DirtyVRAMFlag::DIRTY && flag != DirtyVRAMFlag::DRAWN; isDirtyVRAM = isDirtyVRAM || flag != DirtyVRAMFlag::CLEAN; isDrawnVRAM = isDrawnVRAM || flag == DirtyVRAMFlag::DRAWN; // Mark the VRAM clean now that it's been copied to VRAM. - if (flag == DirtyVRAMFlag::DIRTY) { + if (flag == DirtyVRAMFlag::UNKNOWN || flag == DirtyVRAMFlag::DIRTY) { if ((i > 0 || startEven) && (i < blocks || endEven)) dirtyVRAM[start + i] = DirtyVRAMFlag::CLEAN; } } + if (isUnknownVRAM && isDirtyVRAM) { + // This means it's only UNKNOWN/CLEAN and not known to be actually dirty. + // Let's check our shadow copy of what we last sent for this VRAM. + int diff = memcmp(&lastVRAM[addr & 0x001FFFFF], Memory::GetPointerUnchecked(addr), sizeInRAM); + if (diff == 0) + isDirtyVRAM = false; + } + // The isTarget flag is mostly used for replay of dumps on a PSP. u32 flags = isTarget ? 1 : 0; // The unchangedVRAM flag tells us we can skip recopying. @@ -376,13 +396,16 @@ static void EmitTextureData(int level, u32 texaddr) { u32 pad; }; - u32 flags = GetTargetFlags(texaddr, sizeInRAM); + u32 flags = GetTargetFlags(texaddr, bytes); FramebufData framebuf{ texaddr, bufw, flags }; framebufData.resize(sizeof(framebuf) + bytes); memcpy(&framebufData[0], &framebuf, sizeof(framebuf)); memcpy(&framebufData[sizeof(framebuf)], p, bytes); p = &framebufData[0]; + if ((flags & 2) == 0) + memcpy(&lastVRAM[texaddr & 0x001FFFFF], Memory::GetPointerUnchecked(texaddr), bytes); + // Okay, now we'll just emit this instead. type = CommandType((int)CommandType::FRAMEBUF0 + level); bytes += (u32)sizeof(framebuf); @@ -418,11 +441,12 @@ static void FlushPrimState(int vcount) { lastRenderTargets.insert(PSP_GetVidMemBase() | gstate.getDepthBufRawAddress()); // We re-flush textures always in case the game changed them... kinda expensive. - // TODO: Dirty textures on transfer/stall/etc. somehow? - // TODO: Or maybe de-dup by validating if it has changed? + bool textureEnabled = gstate.isTextureMapEnabled() || gstate.isAntiAliasEnabled(); + // Play it safe and allow texture coords to emit data too. + bool textureCoords = (gstate.vertType & GE_VTYPE_TC_MASK) != 0; for (int level = 0; level < 8; ++level) { u32 texaddr = gstate.getTextureAddress(level); - if (texaddr) { + if (texaddr && (textureEnabled || textureCoords)) { EmitTextureData(level, texaddr); } } @@ -508,6 +532,9 @@ static void EmitClut(u32 op) { pushbuf.resize(pushbuf.size() + sizeof(data)); memcpy(pushbuf.data() + cmd.ptr, &data, sizeof(data)); commands.push_back(cmd); + + if ((flags & 2) == 0) + memcpy(&lastVRAM[addr & 0x001FFFFF], Memory::GetPointerUnchecked(addr), bytes); } EmitCommandWithRAM(CommandType::CLUT, Memory::GetPointerUnchecked(addr), bytes, 16); } @@ -558,6 +585,7 @@ static void FinishRecording() { Path filename = WriteRecording(); commands.clear(); pushbuf.clear(); + lastVRAM.clear(); NOTICE_LOG(SYSTEM, "Recording finished"); active = false; @@ -655,8 +683,9 @@ void NotifyMemcpy(u32 dest, u32 src, u32 sz) { sz = Memory::ValidSize(dest, sz); if (sz != 0) { - EmitCommandWithRAM(CommandType::MEMCPYDATA, Memory::GetPointer(dest), sz, 1); - DirtyVRAM(dest, sz, DirtyVRAMFlag::DIRTY); + EmitCommandWithRAM(CommandType::MEMCPYDATA, Memory::GetPointerUnchecked(dest), sz, 1); + memcpy(&lastVRAM[dest & 0x001FFFFF], Memory::GetPointerUnchecked(dest), sz); + DirtyVRAM(dest, sz, DirtyVRAMFlag::CLEAN); } } } @@ -682,20 +711,14 @@ void NotifyMemset(u32 dest, int v, u32 sz) { pushbuf.resize(pushbuf.size() + sizeof(data)); memcpy(pushbuf.data() + cmd.ptr, &data, sizeof(data)); commands.push_back(cmd); - DirtyVRAM(dest, sz, DirtyVRAMFlag::DIRTY); + memset(&lastVRAM[dest & 0x001FFFFF], v, sz); + DirtyVRAM(dest, sz, DirtyVRAMFlag::CLEAN); } } void NotifyUpload(u32 dest, u32 sz) { - if (!active) { - return; - } - - if (Memory::IsVRAMAddress(dest)) { - // This also checks the edram translation value. - NotifyMemcpy(dest, dest, sz); - DirtyVRAM(dest, sz, DirtyVRAMFlag::DIRTY); - } + // This also checks the edram translation value and dirties VRAM. + NotifyMemcpy(dest, dest, sz); } static bool HasDrawCommands() { @@ -790,7 +813,7 @@ void NotifyCPU() { return; } - DirtyAllVRAM(DirtyVRAMFlag::DIRTY); + DirtyAllVRAM(DirtyVRAMFlag::UNKNOWN); } }; diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index e4a6350de1..118c8c3fed 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -411,6 +411,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu } else { UpdateVRProjection(gstate.projMatrix, leftEyeMatrix.m, rightEyeMatrix.m); } + UpdateVRParams(gstate.projMatrix); FlipProjMatrix(leftEyeMatrix, useBufferedRendering); FlipProjMatrix(rightEyeMatrix, useBufferedRendering); @@ -542,7 +543,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu float rightEyeView[16]; ConvertMatrix4x3To4x4Transposed(leftEyeView, gstate.viewMatrix); ConvertMatrix4x3To4x4Transposed(rightEyeView, gstate.viewMatrix); - if (!flatScreen && !is2D) { + if (!is2D) { UpdateVRView(leftEyeView, rightEyeView); } render_->SetUniformM4x4Stereo("u_view", &u_view, leftEyeView, rightEyeView); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index a3195adfc5..e46311870b 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1161,8 +1161,8 @@ void GameSettingsScreen::CreateViews() { vrSettings->Add(new CheckBox(&g_Config.bEnableVR, vr->T("Virtual reality"))); CheckBox *vr6DoF = vrSettings->Add(new CheckBox(&g_Config.bEnable6DoF, vr->T("6DoF movement"))); vr6DoF->SetEnabledPtr(&g_Config.bEnableVR); - CheckBox *vrStereo = vrSettings->Add(new CheckBox(&g_Config.bEnableStereo, vr->T("Stereoscopic vision (Experimental)"))); - vrStereo->SetEnabledPtr(&g_Config.bEnableVR); + vrSettings->Add(new CheckBox(&g_Config.bEnableStereo, vr->T("Stereoscopic vision (Experimental)"))); + vrSettings->Add(new CheckBox(&g_Config.bForce72Hz, vr->T("Force 72Hz update"))); vrSettings->Add(new ItemHeader(vr->T("VR camera"))); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraDistance, -10.0f, 10.0f, vr->T("Camera distance adjust"), 1.0f, screenManager(), "")); diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java index 5de8a70b77..8727f39dc3 100644 --- a/android/src/org/ppsspp/ppsspp/NativeActivity.java +++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java @@ -1235,6 +1235,12 @@ public abstract class NativeActivity extends Activity { // The return value is sent to C++ via seqID. public void inputBox(final String seqID, final String title, String defaultText, String defaultAction) { + // Workaround for issue #13363 to fix Split/Second game start + if (isVRDevice()) { + NativeApp.sendInputBox(seqID, false, defaultText); + return; + } + final FrameLayout fl = new FrameLayout(this); final EditText input = new EditText(this); input.setGravity(Gravity.CENTER); diff --git a/assets/compatvr.ini b/assets/compatvr.ini index 79b1c04678..430fb80e47 100644 --- a/assets/compatvr.ini +++ b/assets/compatvr.ini @@ -1120,6 +1120,12 @@ ULJM05162 = 1.0 ULJM05599 = 1.0 ULUS10076 = 1.0 +# Split/Second +NPJH50371 = 10.0 +ULES01402 = 10.0 +ULJM05812 = 10.0 +ULUS10513 = 10.0 + # Spot the Differences! NPEZ00107 = 1.0 NPEZ00108 = 1.0 diff --git a/ext/libzip/config.h b/ext/libzip/config.h index a5d26ea015..77c373b611 100644 --- a/ext/libzip/config.h +++ b/ext/libzip/config.h @@ -27,11 +27,11 @@ #endif #ifndef MS_UWP #define HAVE_FILENO -#define HAVE_FSEEKO -#define HAVE_FTELLO #define HAVE_GETPROGNAME #endif #ifndef _WIN32 +#define HAVE_FSEEKO +#define HAVE_FTELLO #define HAVE_LOCALTIME_R #define HAVE_MKSTEMP 1 #endif diff --git a/libretro/Makefile.common b/libretro/Makefile.common index cd9f7f04d7..7d858e0129 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -37,133 +37,131 @@ INCFLAGS += \ -I$(EXTDIR)/xxhash \ -I$(EXTDIR)/glew -ifeq ($(PLATFORM_EXT), android) - INCFLAGS += -I$(EXTDIR)/libzip - SOURCES_C += \ - $(EXTDIR)/libzip/zip_add.c \ - $(EXTDIR)/libzip/zip_add_dir.c \ - $(EXTDIR)/libzip/zip_add_entry.c \ - $(EXTDIR)/libzip/zip_algorithm_deflate.c \ - $(EXTDIR)/libzip/zip_buffer.c \ - $(EXTDIR)/libzip/zip_close.c \ - $(EXTDIR)/libzip/zip_delete.c \ - $(EXTDIR)/libzip/zip_dir_add.c \ - $(EXTDIR)/libzip/zip_dirent.c \ - $(EXTDIR)/libzip/zip_discard.c \ - $(EXTDIR)/libzip/zip_entry.c \ - $(EXTDIR)/libzip/zip_error.c \ - $(EXTDIR)/libzip/zip_error_clear.c \ - $(EXTDIR)/libzip/zip_error_get.c \ - $(EXTDIR)/libzip/zip_error_get_sys_type.c \ - $(EXTDIR)/libzip/zip_error_strerror.c \ - $(EXTDIR)/libzip/zip_error_to_str.c \ - $(EXTDIR)/libzip/zip_extra_field.c \ - $(EXTDIR)/libzip/zip_extra_field_api.c \ - $(EXTDIR)/libzip/zip_fclose.c \ - $(EXTDIR)/libzip/zip_fdopen.c \ - $(EXTDIR)/libzip/zip_file_add.c \ - $(EXTDIR)/libzip/zip_file_error_clear.c \ - $(EXTDIR)/libzip/zip_file_error_get.c \ - $(EXTDIR)/libzip/zip_file_get_comment.c \ - $(EXTDIR)/libzip/zip_file_get_external_attributes.c \ - $(EXTDIR)/libzip/zip_file_get_offset.c \ - $(EXTDIR)/libzip/zip_file_rename.c \ - $(EXTDIR)/libzip/zip_file_replace.c \ - $(EXTDIR)/libzip/zip_file_set_comment.c \ - $(EXTDIR)/libzip/zip_file_set_encryption.c \ - $(EXTDIR)/libzip/zip_file_set_external_attributes.c \ - $(EXTDIR)/libzip/zip_file_set_mtime.c \ - $(EXTDIR)/libzip/zip_file_strerror.c \ - $(EXTDIR)/libzip/zip_fopen.c \ - $(EXTDIR)/libzip/zip_fopen_encrypted.c \ - $(EXTDIR)/libzip/zip_fopen_index.c \ - $(EXTDIR)/libzip/zip_fopen_index_encrypted.c \ - $(EXTDIR)/libzip/zip_fread.c \ - $(EXTDIR)/libzip/zip_fseek.c \ - $(EXTDIR)/libzip/zip_ftell.c \ - $(EXTDIR)/libzip/zip_get_archive_comment.c \ - $(EXTDIR)/libzip/zip_get_archive_flag.c \ - $(EXTDIR)/libzip/zip_get_encryption_implementation.c \ - $(EXTDIR)/libzip/zip_get_file_comment.c \ - $(EXTDIR)/libzip/zip_get_name.c \ - $(EXTDIR)/libzip/zip_get_num_entries.c \ - $(EXTDIR)/libzip/zip_get_num_files.c \ - $(EXTDIR)/libzip/zip_hash.c \ - $(EXTDIR)/libzip/zip_io_util.c \ - $(EXTDIR)/libzip/zip_libzip_version.c \ - $(EXTDIR)/libzip/zip_memdup.c \ - $(EXTDIR)/libzip/zip_name_locate.c \ - $(EXTDIR)/libzip/zip_new.c \ - $(EXTDIR)/libzip/zip_open.c \ - $(EXTDIR)/libzip/zip_pkware.c \ - $(EXTDIR)/libzip/zip_progress.c \ - $(EXTDIR)/libzip/zip_rename.c \ - $(EXTDIR)/libzip/zip_replace.c \ - $(EXTDIR)/libzip/zip_set_archive_comment.c \ - $(EXTDIR)/libzip/zip_set_archive_flag.c \ - $(EXTDIR)/libzip/zip_set_default_password.c \ - $(EXTDIR)/libzip/zip_set_file_comment.c \ - $(EXTDIR)/libzip/zip_set_file_compression.c \ - $(EXTDIR)/libzip/zip_set_name.c \ - $(EXTDIR)/libzip/zip_source_accept_empty.c \ - $(EXTDIR)/libzip/zip_source_begin_write.c \ - $(EXTDIR)/libzip/zip_source_begin_write_cloning.c \ - $(EXTDIR)/libzip/zip_source_buffer.c \ - $(EXTDIR)/libzip/zip_source_call.c \ - $(EXTDIR)/libzip/zip_source_close.c \ - $(EXTDIR)/libzip/zip_source_commit_write.c \ - $(EXTDIR)/libzip/zip_source_compress.c \ - $(EXTDIR)/libzip/zip_source_crc.c \ - $(EXTDIR)/libzip/zip_source_error.c \ - $(EXTDIR)/libzip/zip_source_file_common.c \ - $(EXTDIR)/libzip/zip_source_file_stdio.c \ - $(EXTDIR)/libzip/zip_source_free.c \ - $(EXTDIR)/libzip/zip_source_function.c \ - $(EXTDIR)/libzip/zip_source_get_file_attributes.c \ - $(EXTDIR)/libzip/zip_source_is_deleted.c \ - $(EXTDIR)/libzip/zip_source_layered.c \ - $(EXTDIR)/libzip/zip_source_open.c \ - $(EXTDIR)/libzip/zip_source_pkware_decode.c \ - $(EXTDIR)/libzip/zip_source_pkware_encode.c \ - $(EXTDIR)/libzip/zip_source_read.c \ - $(EXTDIR)/libzip/zip_source_remove.c \ - $(EXTDIR)/libzip/zip_source_rollback_write.c \ - $(EXTDIR)/libzip/zip_source_seek.c \ - $(EXTDIR)/libzip/zip_source_seek_write.c \ - $(EXTDIR)/libzip/zip_source_stat.c \ - $(EXTDIR)/libzip/zip_source_supports.c \ - $(EXTDIR)/libzip/zip_source_tell.c \ - $(EXTDIR)/libzip/zip_source_tell_write.c \ - $(EXTDIR)/libzip/zip_source_window.c \ - $(EXTDIR)/libzip/zip_source_write.c \ - $(EXTDIR)/libzip/zip_source_zip.c \ - $(EXTDIR)/libzip/zip_source_zip_new.c \ - $(EXTDIR)/libzip/zip_stat.c \ - $(EXTDIR)/libzip/zip_stat_index.c \ - $(EXTDIR)/libzip/zip_stat_init.c \ - $(EXTDIR)/libzip/zip_strerror.c \ - $(EXTDIR)/libzip/zip_string.c \ - $(EXTDIR)/libzip/zip_unchange.c \ - $(EXTDIR)/libzip/zip_unchange_all.c \ - $(EXTDIR)/libzip/zip_unchange_archive.c \ - $(EXTDIR)/libzip/zip_unchange_data.c \ - $(EXTDIR)/libzip/zip_utf-8.c \ - $(EXTDIR)/libzip/zip_err_str.c +INCFLAGS += -I$(EXTDIR)/libzip +SOURCES_C += \ + $(EXTDIR)/libzip/zip_add.c \ + $(EXTDIR)/libzip/zip_add_dir.c \ + $(EXTDIR)/libzip/zip_add_entry.c \ + $(EXTDIR)/libzip/zip_algorithm_deflate.c \ + $(EXTDIR)/libzip/zip_buffer.c \ + $(EXTDIR)/libzip/zip_close.c \ + $(EXTDIR)/libzip/zip_delete.c \ + $(EXTDIR)/libzip/zip_dir_add.c \ + $(EXTDIR)/libzip/zip_dirent.c \ + $(EXTDIR)/libzip/zip_discard.c \ + $(EXTDIR)/libzip/zip_entry.c \ + $(EXTDIR)/libzip/zip_error.c \ + $(EXTDIR)/libzip/zip_error_clear.c \ + $(EXTDIR)/libzip/zip_error_get.c \ + $(EXTDIR)/libzip/zip_error_get_sys_type.c \ + $(EXTDIR)/libzip/zip_error_strerror.c \ + $(EXTDIR)/libzip/zip_error_to_str.c \ + $(EXTDIR)/libzip/zip_extra_field.c \ + $(EXTDIR)/libzip/zip_extra_field_api.c \ + $(EXTDIR)/libzip/zip_fclose.c \ + $(EXTDIR)/libzip/zip_fdopen.c \ + $(EXTDIR)/libzip/zip_file_add.c \ + $(EXTDIR)/libzip/zip_file_error_clear.c \ + $(EXTDIR)/libzip/zip_file_error_get.c \ + $(EXTDIR)/libzip/zip_file_get_comment.c \ + $(EXTDIR)/libzip/zip_file_get_external_attributes.c \ + $(EXTDIR)/libzip/zip_file_get_offset.c \ + $(EXTDIR)/libzip/zip_file_rename.c \ + $(EXTDIR)/libzip/zip_file_replace.c \ + $(EXTDIR)/libzip/zip_file_set_comment.c \ + $(EXTDIR)/libzip/zip_file_set_encryption.c \ + $(EXTDIR)/libzip/zip_file_set_external_attributes.c \ + $(EXTDIR)/libzip/zip_file_set_mtime.c \ + $(EXTDIR)/libzip/zip_file_strerror.c \ + $(EXTDIR)/libzip/zip_fopen.c \ + $(EXTDIR)/libzip/zip_fopen_encrypted.c \ + $(EXTDIR)/libzip/zip_fopen_index.c \ + $(EXTDIR)/libzip/zip_fopen_index_encrypted.c \ + $(EXTDIR)/libzip/zip_fread.c \ + $(EXTDIR)/libzip/zip_fseek.c \ + $(EXTDIR)/libzip/zip_ftell.c \ + $(EXTDIR)/libzip/zip_get_archive_comment.c \ + $(EXTDIR)/libzip/zip_get_archive_flag.c \ + $(EXTDIR)/libzip/zip_get_encryption_implementation.c \ + $(EXTDIR)/libzip/zip_get_file_comment.c \ + $(EXTDIR)/libzip/zip_get_name.c \ + $(EXTDIR)/libzip/zip_get_num_entries.c \ + $(EXTDIR)/libzip/zip_get_num_files.c \ + $(EXTDIR)/libzip/zip_hash.c \ + $(EXTDIR)/libzip/zip_io_util.c \ + $(EXTDIR)/libzip/zip_libzip_version.c \ + $(EXTDIR)/libzip/zip_memdup.c \ + $(EXTDIR)/libzip/zip_name_locate.c \ + $(EXTDIR)/libzip/zip_new.c \ + $(EXTDIR)/libzip/zip_open.c \ + $(EXTDIR)/libzip/zip_pkware.c \ + $(EXTDIR)/libzip/zip_progress.c \ + $(EXTDIR)/libzip/zip_rename.c \ + $(EXTDIR)/libzip/zip_replace.c \ + $(EXTDIR)/libzip/zip_set_archive_comment.c \ + $(EXTDIR)/libzip/zip_set_archive_flag.c \ + $(EXTDIR)/libzip/zip_set_default_password.c \ + $(EXTDIR)/libzip/zip_set_file_comment.c \ + $(EXTDIR)/libzip/zip_set_file_compression.c \ + $(EXTDIR)/libzip/zip_set_name.c \ + $(EXTDIR)/libzip/zip_source_accept_empty.c \ + $(EXTDIR)/libzip/zip_source_begin_write.c \ + $(EXTDIR)/libzip/zip_source_begin_write_cloning.c \ + $(EXTDIR)/libzip/zip_source_buffer.c \ + $(EXTDIR)/libzip/zip_source_call.c \ + $(EXTDIR)/libzip/zip_source_close.c \ + $(EXTDIR)/libzip/zip_source_commit_write.c \ + $(EXTDIR)/libzip/zip_source_compress.c \ + $(EXTDIR)/libzip/zip_source_crc.c \ + $(EXTDIR)/libzip/zip_source_error.c \ + $(EXTDIR)/libzip/zip_source_file_common.c \ + $(EXTDIR)/libzip/zip_source_file_stdio.c \ + $(EXTDIR)/libzip/zip_source_free.c \ + $(EXTDIR)/libzip/zip_source_function.c \ + $(EXTDIR)/libzip/zip_source_get_file_attributes.c \ + $(EXTDIR)/libzip/zip_source_is_deleted.c \ + $(EXTDIR)/libzip/zip_source_layered.c \ + $(EXTDIR)/libzip/zip_source_open.c \ + $(EXTDIR)/libzip/zip_source_pkware_decode.c \ + $(EXTDIR)/libzip/zip_source_pkware_encode.c \ + $(EXTDIR)/libzip/zip_source_read.c \ + $(EXTDIR)/libzip/zip_source_remove.c \ + $(EXTDIR)/libzip/zip_source_rollback_write.c \ + $(EXTDIR)/libzip/zip_source_seek.c \ + $(EXTDIR)/libzip/zip_source_seek_write.c \ + $(EXTDIR)/libzip/zip_source_stat.c \ + $(EXTDIR)/libzip/zip_source_supports.c \ + $(EXTDIR)/libzip/zip_source_tell.c \ + $(EXTDIR)/libzip/zip_source_tell_write.c \ + $(EXTDIR)/libzip/zip_source_window.c \ + $(EXTDIR)/libzip/zip_source_write.c \ + $(EXTDIR)/libzip/zip_source_zip.c \ + $(EXTDIR)/libzip/zip_source_zip_new.c \ + $(EXTDIR)/libzip/zip_stat.c \ + $(EXTDIR)/libzip/zip_stat_index.c \ + $(EXTDIR)/libzip/zip_stat_init.c \ + $(EXTDIR)/libzip/zip_strerror.c \ + $(EXTDIR)/libzip/zip_string.c \ + $(EXTDIR)/libzip/zip_unchange.c \ + $(EXTDIR)/libzip/zip_unchange_all.c \ + $(EXTDIR)/libzip/zip_unchange_archive.c \ + $(EXTDIR)/libzip/zip_unchange_data.c \ + $(EXTDIR)/libzip/zip_utf-8.c \ + $(EXTDIR)/libzip/zip_err_str.c - ifeq ($(PLATFORM_EXT), win32) - SOURCES_C += \ - $(EXTDIR)/libzip/zip_source_file_win32.c \ - $(EXTDIR)/libzip/zip_source_file_win32_named.c \ - $(EXTDIR)/libzip/zip_source_file_win32_utf16.c \ - $(EXTDIR)/libzip/zip_source_file_win32_utf8.c \ - $(EXTDIR)/libzip/zip_source_file_win32_ansi.c \ - $(EXTDIR)/libzip/zip_random_win32.c - else - SOURCES_C += \ - $(EXTDIR)/libzip/zip_mkstempm.c \ - $(EXTDIR)/libzip/zip_source_file_stdio_named.c \ - $(EXTDIR)/libzip/zip_random_unix.c - endif +ifeq ($(PLATFORM_EXT), win32) + SOURCES_C += \ + $(EXTDIR)/libzip/zip_source_file_win32.c \ + $(EXTDIR)/libzip/zip_source_file_win32_named.c \ + $(EXTDIR)/libzip/zip_source_file_win32_utf16.c \ + $(EXTDIR)/libzip/zip_source_file_win32_utf8.c \ + $(EXTDIR)/libzip/zip_source_file_win32_ansi.c \ + $(EXTDIR)/libzip/zip_random_win32.c +else + SOURCES_C += \ + $(EXTDIR)/libzip/zip_mkstempm.c \ + $(EXTDIR)/libzip/zip_source_file_stdio_named.c \ + $(EXTDIR)/libzip/zip_random_unix.c endif SOURCES_C += $(LIBRETRODIR)/ext/glew/glew.c diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 9b4a20bd97..3716f1989e 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -45,6 +45,7 @@ #include "libretro/libretro.h" #include "libretro/LibretroGraphicsContext.h" +#include "libretro/libretro_core_options.h" #if PPSSPP_PLATFORM(ANDROID) #include @@ -81,6 +82,10 @@ #define VSYNC_SWAP_INTERVAL_RUN_SPEED_THRESHOLD 5.0f static bool libretro_supports_bitmasks = false; +static bool libretro_supports_option_categories = false; +static bool show_ip_address_options = true; +static bool show_upnp_port_option = true; +static bool show_detect_frame_rate_option = true; static std::string changeProAdhocServer; namespace Libretro @@ -428,239 +433,72 @@ class PrintfLogger : public LogListener }; static PrintfLogger *printfLogger; -template class RetroOption -{ - public: - RetroOption(const char *id, const char *name, std::initializer_list> list) : id_(id), name_(name), list_(list.begin(), list.end()) {} - RetroOption(const char *id, const char *name, std::initializer_list list) : id_(id), name_(name) { - for (auto option : list) - list_.push_back({ option, (T)list_.size() }); - } - RetroOption(const char *id, const char *name, T first, std::initializer_list list) : id_(id), name_(name) { - for (auto option : list) - list_.push_back({ option, first + (int)list_.size() }); - } - RetroOption(const char *id, const char *name, T first, int count, int step = 1) : id_(id), name_(name) { - for (T i = first; i < first + count; i += step) - list_.push_back({ std::to_string(i), i }); - } - RetroOption(const char *id, const char *name, bool initial) : id_(id), name_(name) { - list_.push_back({ initial ? "enabled" : "disabled", initial }); - list_.push_back({ !initial ? "enabled" : "disabled", !initial }); - } - - retro_variable GetOptions() - { - if (options_.empty()) - { - options_ = name_; - options_.push_back(';'); - for (auto &option : list_) - { - if (option.first == list_.begin()->first) - options_ += std::string(" ") + option.first; - else - options_ += std::string("|") + option.first; - } - } - return { id_, options_.c_str() }; - } - - bool Update(T *dest) - { - retro_variable var{ id_ }; - T val = list_.front().second; - - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - for (auto option : list_) - { - if (option.first == var.value) - { - val = option.second; - break; - } - } - } - - if (*dest != val) - { - *dest = val; - return true; - } - - return false; - } - - void Show(bool show) - { - struct retro_core_option_display optionDisplay{id_, show}; - environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &optionDisplay); - } - - void Set(const char *val) - { - struct retro_variable var{id_, val}; - environ_cb(RETRO_ENVIRONMENT_SET_VARIABLE, &var); - } - - private: - const char *id_; - const char *name_; - std::string options_; - std::vector> list_; -}; - -#define MAC_INITIALIZER_LIST \ -{ \ - {"0", "0"}, \ - {"1", "1"}, \ - {"2", "2"}, \ - {"3", "3"}, \ - {"4", "4"}, \ - {"5", "5"}, \ - {"6", "6"}, \ - {"7", "7"}, \ - {"8", "8"}, \ - {"9", "9"}, \ - {"a", "a"}, \ - {"b", "b"}, \ - {"c", "c"}, \ - {"d", "d"}, \ - {"e", "e"}, \ - {"f", "f"} \ -} - -static RetroOption ppsspp_cpu_core("ppsspp_cpu_core", "CPU Core", { { "JIT", CPUCore::JIT }, { "IR JIT", CPUCore::IR_JIT }, { "Interpreter", CPUCore::INTERPRETER } }); -static RetroOption ppsspp_locked_cpu_speed("ppsspp_locked_cpu_speed", "Locked CPU Speed", { { "off", 0 }, { "222MHz", 222 }, { "266MHz", 266 }, { "333MHz", 333 } }); -static RetroOption ppsspp_language("ppsspp_language", "Language", { { "Automatic", -1 }, { "English", PSP_SYSTEMPARAM_LANGUAGE_ENGLISH }, { "Japanese", PSP_SYSTEMPARAM_LANGUAGE_JAPANESE }, { "French", PSP_SYSTEMPARAM_LANGUAGE_FRENCH }, { "Spanish", PSP_SYSTEMPARAM_LANGUAGE_SPANISH }, { "German", PSP_SYSTEMPARAM_LANGUAGE_GERMAN }, { "Italian", PSP_SYSTEMPARAM_LANGUAGE_ITALIAN }, { "Dutch", PSP_SYSTEMPARAM_LANGUAGE_DUTCH }, { "Portuguese", PSP_SYSTEMPARAM_LANGUAGE_PORTUGUESE }, { "Russian", PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN }, { "Korean", PSP_SYSTEMPARAM_LANGUAGE_KOREAN }, { "Chinese Traditional", PSP_SYSTEMPARAM_LANGUAGE_CHINESE_TRADITIONAL }, { "Chinese Simplified", PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED } }); -static RetroOption ppsspp_rendering_mode("ppsspp_rendering_mode", "Rendering Mode", { { "Buffered", FB_BUFFERED_MODE }, { "Skip Buffer Effects", FB_NON_BUFFERED_MODE } }); -static RetroOption ppsspp_auto_frameskip("ppsspp_auto_frameskip", "Auto Frameskip", false); -static RetroOption ppsspp_frameskip("ppsspp_frameskip", "Frameskip", { "Off", "1", "2", "3", "4", "5", "6", "7", "8" }); -static RetroOption ppsspp_frameskiptype("ppsspp_frameskiptype", "Frameskip Type", { {"Number of frames", 0}, {"Percent of FPS", 1} }); -static RetroOption ppsspp_internal_resolution("ppsspp_internal_resolution", "Internal Resolution (Restart)", 1, { "480x272", "960x544", "1440x816", "1920x1088", "2400x1360", "2880x1632", "3360x1904", "3840x2176", "4320x2448", "4800x2720" }); -static RetroOption ppsspp_button_preference("ppsspp_button_preference", "Confirmation Button", { { "Cross", PSP_SYSTEMPARAM_BUTTON_CROSS }, { "Circle", PSP_SYSTEMPARAM_BUTTON_CIRCLE } }); -static RetroOption ppsspp_fast_memory("ppsspp_fast_memory", "Fast Memory (Speedhack)", true); -static RetroOption ppsspp_block_transfer_gpu("ppsspp_block_transfer_gpu", "Block Transfer GPU", true); -static RetroOption ppsspp_inflight_frames("ppsspp_inflight_frames", "Buffered frames (Slower, less lag, restart)", { { "Up to 2", 2 }, { "Up to 1", 1 }, { "No buffer", 0 }, }); -static RetroOption ppsspp_texture_scaling_level("ppsspp_texture_scaling_level", "Texture Scaling Level", { { "Off", 1 }, { "2x", 2 }, { "3x", 3 }, { "4x", 4 }, { "5x", 5 } }); -static RetroOption ppsspp_texture_scaling_type("ppsspp_texture_scaling_type", "Texture Scaling Type", { { "xbrz", TextureScalerCommon::XBRZ }, { "hybrid", TextureScalerCommon::HYBRID }, { "bicubic", TextureScalerCommon::BICUBIC }, { "hybrid_bicubic", TextureScalerCommon::HYBRID_BICUBIC } }); -static RetroOption ppsspp_texture_shader("ppsspp_texture_shader", "Texture Shader (Vulkan only, overrides Texture Scaling Type)", { {"Off", "Off"}, {"2xBRZ", "Tex2xBRZ"}, {"4xBRZ", "Tex4xBRZ"}, {"MMPX", "TexMMPX"} }); -static RetroOption ppsspp_texture_filtering("ppsspp_texture_filtering", "Texture Filtering", { { "Auto", 1 }, { "Nearest", 2 }, { "Linear", 3 }, {"Auto max quality", 4}}); -static RetroOption ppsspp_texture_anisotropic_filtering("ppsspp_texture_anisotropic_filtering", "Anisotropic Filtering", { "off", "2x", "4x", "8x", "16x" }); -static RetroOption ppsspp_lower_resolution_for_effects("ppsspp_lower_resolution_for_effects", "Lower resolution for effects", { {"Off", 0}, {"Safe", 1}, {"Balanced", 2}, {"Aggressive", 3} }); -static RetroOption ppsspp_texture_deposterize("ppsspp_texture_deposterize", "Texture Deposterize", false); -static RetroOption ppsspp_texture_replacement("ppsspp_texture_replacement", "Texture Replacement", false); -static RetroOption ppsspp_gpu_hardware_transform("ppsspp_gpu_hardware_transform", "GPU Hardware T&L", true); -static RetroOption ppsspp_vertex_cache("ppsspp_vertex_cache", "Vertex Cache (Speedhack)", false); -static RetroOption ppsspp_cheats("ppsspp_cheats", "Internal Cheats Support", false); -static RetroOption ppsspp_io_timing_method("ppsspp_io_timing_method", "IO Timing Method", { { "Fast", IOTimingMethods::IOTIMING_FAST }, { "Host", IOTimingMethods::IOTIMING_HOST }, { "Simulate UMD delays", IOTimingMethods::IOTIMING_REALISTIC } }); -static RetroOption ppsspp_frame_duplication("ppsspp_frame_duplication", "Duplicate Frames in 30 Hz Games", false); -static RetroOption ppsspp_detect_vsync_swap_interval("ppsspp_detect_vsync_swap_interval", "Detect Frame Rate Changes (Notify Frontend)", false); -static RetroOption ppsspp_software_skinning("ppsspp_software_skinning", "Software Skinning", true); -static RetroOption ppsspp_ignore_bad_memory_access("ppsspp_ignore_bad_memory_access", "Ignore bad memory accesses", true); -static RetroOption ppsspp_lazy_texture_caching("ppsspp_lazy_texture_caching", "Lazy texture caching (Speedup)", false); -static RetroOption ppsspp_retain_changed_textures("ppsspp_retain_changed_textures", "Retain changed textures (Speedup, mem hog)", false); -static RetroOption ppsspp_force_lag_sync("ppsspp_force_lag_sync", "Force real clock sync (Slower, less lag)", false); -static RetroOption ppsspp_spline_quality("ppsspp_spline_quality", "Spline/Bezier curves quality", { {"Low", 0}, {"Medium", 1}, {"High", 2} }); -static RetroOption ppsspp_enable_wlan("ppsspp_enable_wlan", "Enable Networking/WLAN (beta, may break games)", false); -static RetroOption ppsspp_change_mac_address[] = { - {"ppsspp_change_mac_address01", "MAC address Pt 1: X-:--:--:--:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address02", "MAC address Pt 2: -X:--:--:--:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address03", "MAC address Pt 3: --:X-:--:--:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address04", "MAC address Pt 4: --:-X:--:--:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address05", "MAC address Pt 5: --:--:X-:--:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address06", "MAC address Pt 6: --:--:-X:--:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address07", "MAC address Pt 7: --:--:--:X-:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address08", "MAC address Pt 8: --:--:--:-X:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address09", "MAC address Pt 9: --:--:--:--:X-:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address10", "MAC address Pt 10: --:--:--:--:-X:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address11", "MAC address Pt 11: --:--:--:--:--:X-", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address12", "MAC address Pt 12: --:--:--:--:--:-X", MAC_INITIALIZER_LIST} -}; -static RetroOption ppsspp_wlan_channel("ppsspp_wlan_channel", "WLAN channel", {{"Auto", 0}, {"1", 1}, {"6", 6}, {"11", 11}} ); -static RetroOption ppsspp_enable_builtin_pro_ad_hoc_server("ppsspp_enable_builtin_pro_ad_hoc_server", "Enable built-in PRO ad hoc server", false); -static RetroOption ppsspp_change_pro_ad_hoc_server_address("ppsspp_change_pro_ad_hoc_server_address", "Change PRO ad hoc server IP address (localhost = multiple instances)", { - {"socom.cc", "socom.cc"}, - {"psp.gameplayer.club", "psp.gameplayer.club"}, - {"myneighborsushicat.com", "myneighborsushicat.com"}, - {"localhost", "localhost"}, - {"IP address", "IP address"} -}); -static RetroOption ppsspp_pro_ad_hoc_ipv4[] = { - {"ppsspp_pro_ad_hoc_server_address01", "PRO ad hoc server IP address Pt 1: x--.---.---.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address02", "PRO ad hoc server IP address Pt 2: -x-.---.---.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address03", "PRO ad hoc server IP address Pt 3: --x.---.---.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address04", "PRO ad hoc server IP address Pt 4: ---.x--.---.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address05", "PRO ad hoc server IP address Pt 5: ---.-x-.---.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address06", "PRO ad hoc server IP address Pt 6: ---.--x.---.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address07", "PRO ad hoc server IP address Pt 7: ---.---.x--.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address08", "PRO ad hoc server IP address Pt 8: ---.---.-x-.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address09", "PRO ad hoc server IP address Pt 9: ---.---.--x.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address10", "PRO ad hoc server IP address Pt 10: ---.---.---.x-- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address11", "PRO ad hoc server IP address Pt 11: ---.---.---.-x- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address12", "PRO ad hoc server IP address Pt 12: ---.---.---.--x ", 0, 10, 1} -}; -static RetroOption ppsspp_enable_upnp("ppsspp_enable_upnp", "Enable UPnP (need a few seconds to detect)", false); -static RetroOption ppsspp_upnp_use_original_port("ppsspp_upnp_use_original_port", "UPnP use original port (enabled = PSP compatibility)", true); -static RetroOption ppsspp_port_offset("ppsspp_port_offset", "Port offset (0 = PSP compatibility)", 0, 65001, 1000); -static RetroOption ppsspp_minimum_timeout("ppsspp_minimum timeout", "Minimum timeout (override in ms, 0 = default))", 0, 5001, 100); -static RetroOption ppsspp_forced_first_connect("ppsspp_forced_first_connect", "Forced first connect (faster connect)", false); - static bool set_variable_visibility(void) { + struct retro_core_option_display option_display; + struct retro_variable var; bool updated = false; - if (ppsspp_change_pro_ad_hoc_server_address.Update(&changeProAdhocServer)) - updated = true; + // Show/hide IP address options + bool show_ip_address_options_prev = show_ip_address_options; + show_ip_address_options = true; - if (changeProAdhocServer == "IP address") + var.key = "ppsspp_change_pro_ad_hoc_server_address"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && strcmp(var.value, "IP address")) + show_ip_address_options = false; + + if (show_ip_address_options != show_ip_address_options_prev) { - g_Config.proAdhocServer = ""; - for (int i = 0;;) + option_display.visible = show_ip_address_options; + for (int i = 0; i < 12; i++) { - int addressPt = 0; - ppsspp_pro_ad_hoc_ipv4[i].Show(true); - ppsspp_pro_ad_hoc_ipv4[i].Update(&addressPt); - g_Config.proAdhocServer += static_cast('0' + addressPt); - - if (++i == 12) - break; - - if (i % 3 == 0) - g_Config.proAdhocServer += '.'; + char key[64] = {0}; + option_display.key = key; + snprintf(key, sizeof(key), "ppsspp_pro_ad_hoc_server_address%02d", i + 1); + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); } - } - else - { - g_Config.proAdhocServer = changeProAdhocServer; - - for (int i = 0; i < 12; ++i) - ppsspp_pro_ad_hoc_ipv4[i].Show(false); - } - - if (ppsspp_enable_upnp.Update(&g_Config.bEnableUPnP)) updated = true; + } - ppsspp_upnp_use_original_port.Show(g_Config.bEnableUPnP); + // Show/hide 'UPnP Use Original Port' option + bool show_upnp_port_option_prev = show_upnp_port_option; + show_upnp_port_option = true; - bool detectVsyncSwapIntervalOptShownLast = detectVsyncSwapIntervalOptShown; - bool autoFrameSkip = false; - int frameSkip = 0; - bool renderDuplicateFrames = false; + var.key = "ppsspp_enable_upnp"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && !strcmp(var.value, "disabled")) + show_upnp_port_option = false; - ppsspp_auto_frameskip.Update(&autoFrameSkip); - ppsspp_frameskip.Update(&frameSkip); - ppsspp_frame_duplication.Update(&renderDuplicateFrames); - - detectVsyncSwapIntervalOptShown = - !autoFrameSkip && - (frameSkip == 0) && - !renderDuplicateFrames; - - if (detectVsyncSwapIntervalOptShown != detectVsyncSwapIntervalOptShownLast) + if (show_upnp_port_option != show_upnp_port_option_prev) { - ppsspp_detect_vsync_swap_interval.Show(detectVsyncSwapIntervalOptShown); + option_display.visible = show_upnp_port_option; + option_display.key = "ppsspp_upnp_use_original_port"; + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); + updated = true; + } + + // Show/hide 'Detect Frame Rate Changes' option + bool show_detect_frame_rate_option_prev = show_detect_frame_rate_option; + int frameskip = 0; + bool auto_frameskip = false; + bool dupe_frames = false; + show_detect_frame_rate_option = true; + + var.key = "ppsspp_frameskip"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && strcmp(var.value, "disabled")) + frameskip = atoi(var.value); + var.key = "ppsspp_auto_frameskip"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && !strcmp(var.value, "enabled")) + auto_frameskip = true; + var.key = "ppsspp_frame_duplication"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && !strcmp(var.value, "enabled")) + dupe_frames = true; + + show_detect_frame_rate_option = (frameskip == 0) && !auto_frameskip && !dupe_frames; + if (show_detect_frame_rate_option != show_detect_frame_rate_option_prev) + { + option_display.visible = show_detect_frame_rate_option; + option_display.key = "ppsspp_detect_vsync_swap_interval"; + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); updated = true; } @@ -671,59 +509,10 @@ void retro_set_environment(retro_environment_t cb) { environ_cb = cb; + libretro_set_core_options(environ_cb, &libretro_supports_option_categories); struct retro_core_options_update_display_callback update_display_cb; update_display_cb.callback = set_variable_visibility; environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_UPDATE_DISPLAY_CALLBACK, &update_display_cb); - - std::vector vars; - vars.push_back(ppsspp_internal_resolution.GetOptions()); - vars.push_back(ppsspp_cpu_core.GetOptions()); - vars.push_back(ppsspp_locked_cpu_speed.GetOptions()); - vars.push_back(ppsspp_language.GetOptions()); - vars.push_back(ppsspp_button_preference.GetOptions()); - vars.push_back(ppsspp_rendering_mode.GetOptions()); - vars.push_back(ppsspp_gpu_hardware_transform.GetOptions()); - vars.push_back(ppsspp_texture_anisotropic_filtering.GetOptions()); - vars.push_back(ppsspp_spline_quality.GetOptions()); - vars.push_back(ppsspp_auto_frameskip.GetOptions()); - vars.push_back(ppsspp_frameskip.GetOptions()); - vars.push_back(ppsspp_frameskiptype.GetOptions()); - vars.push_back(ppsspp_frame_duplication.GetOptions()); - vars.push_back(ppsspp_detect_vsync_swap_interval.GetOptions()); - vars.push_back(ppsspp_vertex_cache.GetOptions()); - vars.push_back(ppsspp_fast_memory.GetOptions()); - vars.push_back(ppsspp_block_transfer_gpu.GetOptions()); - vars.push_back(ppsspp_inflight_frames.GetOptions()); - vars.push_back(ppsspp_software_skinning.GetOptions()); - vars.push_back(ppsspp_lazy_texture_caching.GetOptions()); - vars.push_back(ppsspp_retain_changed_textures.GetOptions()); - vars.push_back(ppsspp_force_lag_sync.GetOptions()); - vars.push_back(ppsspp_lower_resolution_for_effects.GetOptions()); - vars.push_back(ppsspp_texture_scaling_level.GetOptions()); - vars.push_back(ppsspp_texture_scaling_type.GetOptions()); - vars.push_back(ppsspp_texture_shader.GetOptions()); - vars.push_back(ppsspp_texture_filtering.GetOptions()); - vars.push_back(ppsspp_texture_deposterize.GetOptions()); - vars.push_back(ppsspp_texture_replacement.GetOptions()); - vars.push_back(ppsspp_io_timing_method.GetOptions()); - vars.push_back(ppsspp_ignore_bad_memory_access.GetOptions()); - vars.push_back(ppsspp_cheats.GetOptions()); - vars.push_back(ppsspp_enable_wlan.GetOptions()); - for (int i = 0; i < 12; ++i) - vars.push_back(ppsspp_change_mac_address[i].GetOptions()); - vars.push_back(ppsspp_wlan_channel.GetOptions()); - vars.push_back(ppsspp_enable_builtin_pro_ad_hoc_server.GetOptions()); - vars.push_back(ppsspp_change_pro_ad_hoc_server_address.GetOptions()); - for (int i = 0; i < 12; ++i) - vars.push_back(ppsspp_pro_ad_hoc_ipv4[i].GetOptions()); - vars.push_back(ppsspp_enable_upnp.GetOptions()); - vars.push_back(ppsspp_upnp_use_original_port.GetOptions()); - vars.push_back(ppsspp_port_offset.GetOptions()); - vars.push_back(ppsspp_minimum_timeout.GetOptions()); - vars.push_back(ppsspp_forced_first_connect.GetOptions()); - vars.push_back({}); - - environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void *)vars.data()); } static int get_language_auto(void) @@ -803,46 +592,522 @@ static void check_variables(CoreParameter &coreParam) && !updated) return; - ppsspp_button_preference.Update(&g_Config.iButtonPreference); - ppsspp_fast_memory.Update(&g_Config.bFastMemory); - ppsspp_vertex_cache.Update(&g_Config.bVertexCache); - ppsspp_gpu_hardware_transform.Update(&g_Config.bHardwareTransform); - ppsspp_frameskip.Update(&g_Config.iFrameSkip); - ppsspp_frameskiptype.Update(&g_Config.iFrameSkipType); - ppsspp_auto_frameskip.Update(&g_Config.bAutoFrameSkip); - ppsspp_block_transfer_gpu.Update(&g_Config.bBlockTransferGPU); - ppsspp_texture_filtering.Update(&g_Config.iTexFiltering); - ppsspp_texture_anisotropic_filtering.Update(&g_Config.iAnisotropyLevel); - ppsspp_texture_deposterize.Update(&g_Config.bTexDeposterize); - ppsspp_texture_replacement.Update(&g_Config.bReplaceTextures); - ppsspp_cheats.Update(&g_Config.bEnableCheats); - ppsspp_locked_cpu_speed.Update(&g_Config.iLockedCPUSpeed); - ppsspp_rendering_mode.Update(&g_Config.iRenderingMode); - ppsspp_cpu_core.Update((CPUCore *)&g_Config.iCpuCore); - ppsspp_io_timing_method.Update((IOTimingMethods *)&g_Config.iIOTimingMethod); - ppsspp_lower_resolution_for_effects.Update(&g_Config.iBloomHack); - ppsspp_frame_duplication.Update(&g_Config.bRenderDuplicateFrames); - ppsspp_detect_vsync_swap_interval.Update(&detectVsyncSwapInterval); - ppsspp_software_skinning.Update(&g_Config.bSoftwareSkinning); - ppsspp_ignore_bad_memory_access.Update(&g_Config.bIgnoreBadMemAccess); - ppsspp_lazy_texture_caching.Update(&g_Config.bTextureBackoffCache); - ppsspp_retain_changed_textures.Update(&g_Config.bTextureSecondaryCache); - ppsspp_force_lag_sync.Update(&g_Config.bForceLagSync); - ppsspp_spline_quality.Update(&g_Config.iSplineBezierQuality); - ppsspp_inflight_frames.Update(&g_Config.iInflightFrames); - const bool do_scaling_type_update = ppsspp_texture_scaling_type.Update(&g_Config.iTexScalingType); - const bool do_scaling_level_update = ppsspp_texture_scaling_level.Update(&g_Config.iTexScalingLevel); - const bool do_texture_shader_update = ppsspp_texture_shader.Update(&g_Config.sTextureShaderName); + struct retro_variable var = {0}; + std::string sTextureShaderName_prev; + int iInternalResolution_prev; + int iTexScalingType_prev; + int iTexScalingLevel_prev; - g_Config.bTexHardwareScaling = "Off" != g_Config.sTextureShaderName; + var.key = "ppsspp_language"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "Automatic")) + g_Config.iLanguage = -1; + else if (!strcmp(var.value, "English")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH; + else if (!strcmp(var.value, "Japanese")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_JAPANESE; + else if (!strcmp(var.value, "French")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_FRENCH; + else if (!strcmp(var.value, "Spanish")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_SPANISH; + else if (!strcmp(var.value, "German")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_GERMAN; + else if (!strcmp(var.value, "Italian")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_ITALIAN; + else if (!strcmp(var.value, "Dutch")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_DUTCH; + else if (!strcmp(var.value, "Portuguese")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_PORTUGUESE; + else if (!strcmp(var.value, "Russian")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN; + else if (!strcmp(var.value, "Korean")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_KOREAN; + else if (!strcmp(var.value, "Chinese Traditional")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_TRADITIONAL; + else if (!strcmp(var.value, "Chinese Simplified")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED; + } - if (gpu && (do_scaling_type_update || do_scaling_level_update || do_texture_shader_update)) + var.key = "ppsspp_cpu_core"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "JIT")) + g_Config.iCpuCore = (int)CPUCore::JIT; + else if (!strcmp(var.value, "IR JIT")) + g_Config.iCpuCore = (int)CPUCore::IR_JIT; + else if (!strcmp(var.value, "Interpreter")) + g_Config.iCpuCore = (int)CPUCore::INTERPRETER; + } + + var.key = "ppsspp_fast_memory"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bFastMemory = false; + else + g_Config.bFastMemory = true; + } + + var.key = "ppsspp_ignore_bad_memory_access"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bIgnoreBadMemAccess = false; + else + g_Config.bIgnoreBadMemAccess = true; + } + + var.key = "ppsspp_io_timing_method"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "Fast")) + g_Config.iIOTimingMethod = IOTIMING_FAST; + else if (!strcmp(var.value, "Host")) + g_Config.iIOTimingMethod = IOTIMING_HOST; + else if (!strcmp(var.value, "Simulate UMD delays")) + g_Config.iIOTimingMethod = IOTIMING_REALISTIC; + } + + var.key = "ppsspp_force_lag_sync"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bForceLagSync = false; + else + g_Config.bForceLagSync = true; + } + + var.key = "ppsspp_locked_cpu_speed"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + g_Config.iLockedCPUSpeed = atoi(var.value); + + var.key = "ppsspp_cache_iso"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bCacheFullIsoInRam = false; + else + g_Config.bCacheFullIsoInRam = true; + } + + var.key = "ppsspp_cheats"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bEnableCheats = false; + else + g_Config.bEnableCheats = true; + } + + var.key = "ppsspp_psp_model"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "psp_1000")) + g_Config.iPSPModel = PSP_MODEL_FAT; + else if (!strcmp(var.value, "psp_2000_3000")) + g_Config.iPSPModel = PSP_MODEL_SLIM; + } + + var.key = "ppsspp_button_preference"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "Cross")) + g_Config.iButtonPreference = PSP_SYSTEMPARAM_BUTTON_CROSS; + else if (!strcmp(var.value, "Circle")) + g_Config.iButtonPreference = PSP_SYSTEMPARAM_BUTTON_CIRCLE; + } + + var.key = "ppsspp_internal_resolution"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + iInternalResolution_prev = g_Config.iInternalResolution; + + if (!strcmp(var.value, "480x272")) + g_Config.iInternalResolution = 1; + else if (!strcmp(var.value, "960x544")) + g_Config.iInternalResolution = 2; + else if (!strcmp(var.value, "1440x816")) + g_Config.iInternalResolution = 3; + else if (!strcmp(var.value, "1920x1088")) + g_Config.iInternalResolution = 4; + else if (!strcmp(var.value, "2400x1360")) + g_Config.iInternalResolution = 5; + else if (!strcmp(var.value, "2880x1632")) + g_Config.iInternalResolution = 6; + else if (!strcmp(var.value, "3360x1904")) + g_Config.iInternalResolution = 7; + else if (!strcmp(var.value, "3840x2176")) + g_Config.iInternalResolution = 8; + else if (!strcmp(var.value, "4320x2448")) + g_Config.iInternalResolution = 9; + else if (!strcmp(var.value, "4800x2720")) + g_Config.iInternalResolution = 10; + } + + var.key = "ppsspp_rendering_mode"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "Buffered")) + g_Config.iRenderingMode = FB_BUFFERED_MODE; + else if (!strcmp(var.value, "Skip Buffer Effects")) + g_Config.iRenderingMode = FB_NON_BUFFERED_MODE; + } + + var.key = "ppsspp_block_transfer_gpu"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bBlockTransferGPU = false; + else + g_Config.bBlockTransferGPU = true; + } + + var.key = "ppsspp_frameskip"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + g_Config.iFrameSkip = atoi(var.value); + + var.key = "ppsspp_frameskiptype"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "Number of frames")) + g_Config.iFrameSkipType = 0; + else if (!strcmp(var.value, "Percent of FPS")) + g_Config.iFrameSkipType = 1; + } + + var.key = "ppsspp_auto_frameskip"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bAutoFrameSkip = false; + else + g_Config.bAutoFrameSkip = true; + } + + var.key = "ppsspp_frame_duplication"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bRenderDuplicateFrames = false; + else + g_Config.bRenderDuplicateFrames = true; + } + + var.key = "ppsspp_detect_vsync_swap_interval"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + detectVsyncSwapInterval = false; + else + detectVsyncSwapInterval = true; + } + + var.key = "ppsspp_inflight_frames"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "No buffer")) + g_Config.iInflightFrames = 0; + else if (!strcmp(var.value, "Up to 1")) + g_Config.iInflightFrames = 1; + else if (!strcmp(var.value, "Up to 2")) + g_Config.iInflightFrames = 2; + } + + var.key = "ppsspp_gpu_hardware_transform"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bHardwareTransform = false; + else + g_Config.bHardwareTransform = true; + } + + var.key = "ppsspp_software_skinning"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bSoftwareSkinning = false; + else + g_Config.bSoftwareSkinning = true; + } + + var.key = "ppsspp_vertex_cache"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bVertexCache = false; + else + g_Config.bVertexCache = true; + } + + var.key = "ppsspp_lazy_texture_caching"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bTextureBackoffCache = false; + else + g_Config.bTextureBackoffCache = true; + } + + var.key = "ppsspp_retain_changed_textures"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bTextureSecondaryCache = false; + else + g_Config.bTextureSecondaryCache = true; + } + + var.key = "ppsspp_spline_quality"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "Low")) + g_Config.iSplineBezierQuality = 0; + else if (!strcmp(var.value, "Medium")) + g_Config.iSplineBezierQuality = 1; + else if (!strcmp(var.value, "High")) + g_Config.iSplineBezierQuality = 2; + } + + var.key = "ppsspp_hardware_tesselation"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bHardwareTessellation = false; + else + g_Config.bHardwareTessellation = true; + } + + var.key = "ppsspp_lower_resolution_for_effects"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.iBloomHack = 0; + else if (!strcmp(var.value, "Safe")) + g_Config.iBloomHack = 1; + else if (!strcmp(var.value, "Balanced")) + g_Config.iBloomHack = 2; + else if (!strcmp(var.value, "Aggressive")) + g_Config.iBloomHack = 3; + } + + var.key = "ppsspp_texture_scaling_type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + iTexScalingType_prev = g_Config.iTexScalingType; + + if (!strcmp(var.value, "xbrz")) + g_Config.iTexScalingType = TextureScalerCommon::XBRZ; + else if (!strcmp(var.value, "hybrid")) + g_Config.iTexScalingType = TextureScalerCommon::HYBRID; + else if (!strcmp(var.value, "bicubic")) + g_Config.iTexScalingType = TextureScalerCommon::BICUBIC; + else if (!strcmp(var.value, "hybrid_bicubic")) + g_Config.iTexScalingType = TextureScalerCommon::HYBRID_BICUBIC; + } + + var.key = "ppsspp_texture_scaling_level"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + iTexScalingLevel_prev = g_Config.iTexScalingLevel; + + if (!strcmp(var.value, "disabled")) + g_Config.iTexScalingLevel = 1; + else if (!strcmp(var.value, "2x")) + g_Config.iTexScalingLevel = 2; + else if (!strcmp(var.value, "3x")) + g_Config.iTexScalingLevel = 3; + else if (!strcmp(var.value, "4x")) + g_Config.iTexScalingLevel = 4; + else if (!strcmp(var.value, "5x")) + g_Config.iTexScalingLevel = 5; + } + + var.key = "ppsspp_texture_deposterize"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bTexDeposterize = false; + else + g_Config.bTexDeposterize = true; + } + + var.key = "ppsspp_texture_shader"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + sTextureShaderName_prev = g_Config.sTextureShaderName; + + if (!strcmp(var.value, "disabled")) + g_Config.sTextureShaderName = "Off"; + else if (!strcmp(var.value, "2xBRZ")) + g_Config.sTextureShaderName = "Tex2xBRZ"; + else if (!strcmp(var.value, "4xBRZ")) + g_Config.sTextureShaderName = "Tex4xBRZ"; + else if (!strcmp(var.value, "MMPX")) + g_Config.sTextureShaderName = "TexMMPX"; + } + + var.key = "ppsspp_texture_anisotropic_filtering"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.iAnisotropyLevel = 0; + else if (!strcmp(var.value, "2x")) + g_Config.iAnisotropyLevel = 1; + else if (!strcmp(var.value, "4x")) + g_Config.iAnisotropyLevel = 2; + else if (!strcmp(var.value, "8x")) + g_Config.iAnisotropyLevel = 3; + else if (!strcmp(var.value, "16x")) + g_Config.iAnisotropyLevel = 4; + } + + var.key = "ppsspp_texture_filtering"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "Auto")) + g_Config.iTexFiltering = 1; + else if (!strcmp(var.value, "Nearest")) + g_Config.iTexFiltering = 2; + else if (!strcmp(var.value, "Linear")) + g_Config.iTexFiltering = 3; + else if (!strcmp(var.value, "Auto max quality")) + g_Config.iTexFiltering = 4; + } + + var.key = "ppsspp_texture_replacement"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bReplaceTextures = false; + else + g_Config.bReplaceTextures = true; + } + + var.key = "ppsspp_enable_wlan"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bEnableWlan = false; + else + g_Config.bEnableWlan = true; + } + + var.key = "ppsspp_wlan_channel"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + g_Config.iWlanAdhocChannel = atoi(var.value); + + var.key = "ppsspp_enable_builtin_pro_ad_hoc_server"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bEnableAdhocServer = false; + else + g_Config.bEnableAdhocServer = true; + } + + var.key = "ppsspp_change_pro_ad_hoc_server_address"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + changeProAdhocServer = var.value; + + var.key = "ppsspp_enable_upnp"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bEnableUPnP = false; + else + g_Config.bEnableUPnP = true; + } + + var.key = "ppsspp_upnp_use_original_port"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bUPnPUseOriginalPort = false; + else + g_Config.bUPnPUseOriginalPort = true; + } + + var.key = "ppsspp_port_offset"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + g_Config.iPortOffset = atoi(var.value); + + var.key = "ppsspp_minimum_timeout"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + g_Config.iMinTimeout = atoi(var.value); + + var.key = "ppsspp_forced_first_connect"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bForcedFirstConnect = false; + else + g_Config.bForcedFirstConnect = true; + } + + std::string ppsspp_change_mac_address[12]; + int ppsspp_pro_ad_hoc_ipv4[12]; + char key[64] = {0}; + var.key = key; + g_Config.sMACAddress = ""; + g_Config.proAdhocServer = ""; + for (int i = 0; i < 12; i++) + { + snprintf(key, sizeof(key), "ppsspp_change_mac_address%02d", i + 1); + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + ppsspp_change_mac_address[i] = var.value; + + if (i && i % 2 == 0) + g_Config.sMACAddress += ":"; + + g_Config.sMACAddress += ppsspp_change_mac_address[i]; + } + + snprintf(key, sizeof(key), "ppsspp_pro_ad_hoc_server_address%02d", i + 1); + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + ppsspp_pro_ad_hoc_ipv4[i] = atoi(var.value); + } + + if (g_Config.sMACAddress == "00:00:00:00:00:00") + { + g_Config.sMACAddress = CreateRandMAC(); + + for (int i = 0; i < 12; i++) + { + snprintf(key, sizeof(key), "ppsspp_change_mac_address%02d", i + 1); + std::string digit = {g_Config.sMACAddress[i + i / 2]}; + var.value = digit.c_str(); + environ_cb(RETRO_ENVIRONMENT_SET_VARIABLE, &var); + } + } + + if (changeProAdhocServer == "IP address") + { + g_Config.proAdhocServer = ""; + for (int i = 0; i < 12; i++) + { + if (i && i % 3 == 0) + g_Config.proAdhocServer += '.'; + + int addressPt = ppsspp_pro_ad_hoc_ipv4[i]; + g_Config.proAdhocServer += static_cast('0' + addressPt); + } + } + else + g_Config.proAdhocServer = changeProAdhocServer; + + g_Config.bTexHardwareScaling = g_Config.sTextureShaderName != "Off"; + + if (gpu && (g_Config.iTexScalingType != iTexScalingType_prev + || g_Config.iTexScalingLevel != iTexScalingLevel_prev + || g_Config.sTextureShaderName != sTextureShaderName_prev)) { gpu->ClearCacheNextFrame(); gpu->Resized(); } - ppsspp_language.Update(&g_Config.iLanguage); if (g_Config.iLanguage < 0) g_Config.iLanguage = get_language_auto(); @@ -864,7 +1129,7 @@ static void check_variables(CoreParameter &coreParam) updateAvInfo = true; } - if (ppsspp_internal_resolution.Update(&g_Config.iInternalResolution) && !PSP_IsInited()) + if (g_Config.iInternalResolution != iInternalResolution_prev && !PSP_IsInited()) { coreParam.pixelWidth = coreParam.renderWidth = g_Config.iInternalResolution * 480; coreParam.pixelHeight = coreParam.renderHeight = g_Config.iInternalResolution * 272; @@ -889,40 +1154,6 @@ static void check_variables(CoreParameter &coreParam) bool isFastForwarding = environ_cb(RETRO_ENVIRONMENT_GET_FASTFORWARDING, &isFastForwarding); coreParam.fastForward = isFastForwarding; - ppsspp_enable_wlan.Update(&g_Config.bEnableWlan); - ppsspp_wlan_channel.Update(&g_Config.iWlanAdhocChannel); - ppsspp_enable_builtin_pro_ad_hoc_server.Update(&g_Config.bEnableAdhocServer); - - ppsspp_upnp_use_original_port.Update(&g_Config.bUPnPUseOriginalPort); - ppsspp_port_offset.Update(&g_Config.iPortOffset); - ppsspp_minimum_timeout.Update(&g_Config.iMinTimeout); - ppsspp_forced_first_connect.Update(&g_Config.bForcedFirstConnect); - - g_Config.sMACAddress = ""; - for (int i = 0; i < 12;) - { - std::string digit; - ppsspp_change_mac_address[i].Update(&digit); - g_Config.sMACAddress += digit; - - if (++i == 12) - break; - - if (i % 2 == 0) - g_Config.sMACAddress += ":"; - } - - if (g_Config.sMACAddress == "00:00:00:00:00:00") - { - g_Config.sMACAddress = CreateRandMAC(); - - for (int i = 0; i < 12; ++i) - { - std::string digit = {g_Config.sMACAddress[i + i / 2]}; - ppsspp_change_mac_address[i].Set(digit.c_str()); - } - } - set_variable_visibility(); } @@ -1018,6 +1249,7 @@ void retro_deinit(void) host = nullptr; libretro_supports_bitmasks = false; + libretro_supports_option_categories = false; VsyncSwapIntervalReset(); AudioBufferDeinit(); diff --git a/libretro/libretro.h b/libretro/libretro.h index 2f17483701..bb114aed35 100644 --- a/libretro/libretro.h +++ b/libretro/libretro.h @@ -283,6 +283,12 @@ enum retro_language RETRO_LANGUAGE_HEBREW = 21, RETRO_LANGUAGE_ASTURIAN = 22, RETRO_LANGUAGE_FINNISH = 23, + RETRO_LANGUAGE_INDONESIAN = 24, + RETRO_LANGUAGE_SWEDISH = 25, + RETRO_LANGUAGE_UKRAINIAN = 26, + RETRO_LANGUAGE_CZECH = 27, + RETRO_LANGUAGE_CATALAN_VALENCIA = 28, + RETRO_LANGUAGE_CATALAN = 29, RETRO_LANGUAGE_LAST, /* Ensure sizeof(enum) == sizeof(int) */ @@ -1753,6 +1759,12 @@ enum retro_mod * the frontend is attempting to call retro_run(). */ +#define RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT (72 | RETRO_ENVIRONMENT_EXPERIMENTAL) + /* int * -- + * Tells the core about the context the frontend is asking for savestate. + * (see enum retro_savestate_context) + */ + /* VFS functionality */ /* File paths: @@ -2990,6 +3002,35 @@ enum retro_pixel_format RETRO_PIXEL_FORMAT_UNKNOWN = INT_MAX }; +enum retro_savestate_context +{ + /* Standard savestate written to disk. */ + RETRO_SAVESTATE_CONTEXT_NORMAL = 0, + + /* Savestate where you are guaranteed that the same instance will load the save state. + * You can store internal pointers to code or data. + * It's still a full serialization and deserialization, and could be loaded or saved at any time. + * It won't be written to disk or sent over the network. + */ + RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_INSTANCE = 1, + + /* Savestate where you are guaranteed that the same emulator binary will load that savestate. + * You can skip anything that would slow down saving or loading state but you can not store internal pointers. + * It won't be written to disk or sent over the network. + * Example: "Second Instance" runahead + */ + RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_BINARY = 2, + + /* Savestate used within a rollback netplay feature. + * You should skip anything that would unnecessarily increase bandwidth usage. + * It won't be written to disk but it will be sent over the network. + */ + RETRO_SAVESTATE_CONTEXT_ROLLBACK_NETPLAY = 3, + + /* Ensure sizeof() == sizeof(int). */ + RETRO_SAVESTATE_CONTEXT_UNKNOWN = INT_MAX +}; + struct retro_message { const char *msg; /* Message to be displayed. */ @@ -3461,6 +3502,10 @@ struct retro_core_option_definition const char *default_value; }; +#ifdef __PS3__ +#undef local +#endif + struct retro_core_options_intl { /* Pointer to an array of retro_core_option_definition structs diff --git a/libretro/libretro_core_options.h b/libretro/libretro_core_options.h new file mode 100644 index 0000000000..78cab61d7d --- /dev/null +++ b/libretro/libretro_core_options.h @@ -0,0 +1,1359 @@ +#ifndef LIBRETRO_CORE_OPTIONS_H__ +#define LIBRETRO_CORE_OPTIONS_H__ + +#include +#include + +#include "libretro.h" +#include "retro_inline.h" + +#ifndef HAVE_NO_LANGEXTRA +#include "libretro_core_options_intl.h" +#endif + +#define BOOL_OPTIONS \ +{ \ + { "disabled", NULL }, \ + { "enabled", NULL }, \ + { NULL, NULL }, \ +} + +#define MAC_ADDRESS_OPTIONS \ +{ \ + { "0", NULL }, \ + { "1", NULL }, \ + { "2", NULL }, \ + { "3", NULL }, \ + { "4", NULL }, \ + { "5", NULL }, \ + { "6", NULL }, \ + { "7", NULL }, \ + { "8", NULL }, \ + { "9", NULL }, \ + { "a", NULL }, \ + { "b", NULL }, \ + { "c", NULL }, \ + { "d", NULL }, \ + { "e", NULL }, \ + { "f", NULL }, \ + { NULL, NULL }, \ +} + +#define IP_ADDRESS_OPTIONS \ +{ \ + { "0", NULL }, \ + { "1", NULL }, \ + { "2", NULL }, \ + { "3", NULL }, \ + { "4", NULL }, \ + { "5", NULL }, \ + { "6", NULL }, \ + { "7", NULL }, \ + { "8", NULL }, \ + { "9", NULL }, \ + { NULL, NULL }, \ +} + +/* + ******************************** + * VERSION: 2.0 + ******************************** + * + * - 2.0: Add support for core options v2 interface + * - 1.3: Move translations to libretro_core_options_intl.h + * - libretro_core_options_intl.h includes BOM and utf-8 + * fix for MSVC 2010-2013 + * - Added HAVE_NO_LANGEXTRA flag to disable translations + * on platforms/compilers without BOM support + * - 1.2: Use core options v1 interface when + * RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION is >= 1 + * (previously required RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION == 1) + * - 1.1: Support generation of core options v0 retro_core_option_value + * arrays containing options with a single value + * - 1.0: First commit +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + ******************************** + * Core Option Definitions + ******************************** +*/ + +/* RETRO_LANGUAGE_ENGLISH */ + +/* Default language: + * - All other languages must include the same keys and values + * - Will be used as a fallback in the event that frontend language + * is not available + * - Will be used as a fallback for any missing entries in + * frontend language definition */ + +struct retro_core_option_v2_category option_cats_us[] = { + { + "system", + "System", + "Configure system options." + }, + { + "video", + "Video", + "Configure video options." + }, + { + "network", + "Network", + "Configure network options." + }, + { NULL, NULL, NULL }, +}; + +struct retro_core_option_v2_definition option_defs_us[] = { + { + "ppsspp_language", + "Language", + NULL, + "Choose language, 'Automatic' will use the frontend language.", + NULL, + "system", + { + { "Automatic", NULL }, + { "English", NULL }, + { "Japanese", NULL }, + { "French", NULL }, + { "Spanish", NULL }, + { "German", NULL }, + { "Italian", NULL }, + { "Dutch", NULL }, + { "Portuguese", NULL }, + { "Russian", NULL }, + { "Korean", NULL }, + { "Chinese Traditional", NULL }, + { "Chinese Simplified", NULL }, + { NULL, NULL }, + }, + "Automatic" + }, + { + "ppsspp_cpu_core", + "CPU Core", + NULL, + NULL, + NULL, + "system", + { + { "JIT", "Dynarec (JIT)" }, + { "IR JIT", "IR Interpreter" }, + { "Interpreter", NULL }, + { NULL, NULL }, + }, + "JIT" + }, + { + "ppsspp_fast_memory", + "Fast Memory", + NULL, + NULL, + NULL, + "system", + BOOL_OPTIONS, + "enabled" + }, + { + "ppsspp_ignore_bad_memory_access", + "Ignore Bad Memory Accesses", + NULL, + NULL, + NULL, + "system", + BOOL_OPTIONS, + "enabled" + }, + { + "ppsspp_io_timing_method", + "I/O Timing Method", + NULL, + NULL, + NULL, + "system", + { + { "Fast", NULL }, + { "Host", NULL }, + { "Simulate UMD delays", NULL }, + { NULL, NULL }, + }, + "Fast" + }, + { + "ppsspp_force_lag_sync", + "Force Real Clock Sync (Slower, less lag)", + NULL, + NULL, + NULL, + "system", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_locked_cpu_speed", + "Locked CPU Speed", + NULL, + NULL, + NULL, + "system", + { + { "disabled", NULL }, + { "222MHz", NULL }, + { "266MHz", NULL }, + { "333MHz", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "ppsspp_cache_iso", + "Cache Full ISO in RAM", + NULL, + NULL, + NULL, + "system", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_cheats", + "Internal Cheats Support", + NULL, + NULL, + NULL, + "system", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_psp_model", + "PSP Model", + NULL, + NULL, + NULL, + "system", + { + { "psp_1000", "PSP-1000" }, + { "psp_2000_3000", "PSP-2000/3000" }, + { NULL, NULL }, + }, + "psp_2000_3000" + }, + { + "ppsspp_button_preference", + "Confirmation Button", + NULL, + NULL, + NULL, + "system", + { + { "Cross", NULL }, + { "Circle", NULL }, + { NULL, NULL }, + }, + "Cross" + }, + { + "ppsspp_internal_resolution", + "Internal Resolution (Restart)", + NULL, + NULL, + NULL, + "video", + { + { "480x272", NULL }, + { "960x544", NULL }, + { "1440x816", NULL }, + { "1920x1088", NULL }, + { "2400x1360", NULL }, + { "2880x1632", NULL }, + { "3360x1904", NULL }, + { "3840x2176", NULL }, + { "4320x2448", NULL }, + { "4800x2720", NULL }, + { NULL, NULL }, + }, + "480x272" + }, + { + "ppsspp_rendering_mode", + "Rendering Mode", + NULL, + "'Skip Buffer Effects' is faster, but nothing may draw in some games.", + NULL, + "video", + { + { "Buffered", NULL }, + { "Skip Buffer Effects", NULL }, + { NULL, NULL }, + }, + "Buffered" + }, + { + "ppsspp_block_transfer_gpu", + "Block Transfer GPU", + NULL, + "Some games require this to be enabled for correct graphics.", + NULL, + "video", + BOOL_OPTIONS, + "enabled" + }, + { + "ppsspp_frameskip", + "Frameskip", + NULL, + NULL, + NULL, + "video", + { + { "disabled", NULL }, + { "1", NULL }, + { "2", NULL }, + { "3", NULL }, + { "4", NULL }, + { "5", NULL }, + { "6", NULL }, + { "7", NULL }, + { "8", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "ppsspp_frameskiptype", + "Frameskip Type", + NULL, + NULL, + NULL, + "video", + { + { "Number of frames", NULL }, + { "Percent of FPS", NULL }, + { NULL, NULL }, + }, + "Number of frames" + }, + { + "ppsspp_auto_frameskip", + "Auto Frameskip", + NULL, + NULL, + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_frame_duplication", + "Duplicate Frames in 30 Hz Games", + NULL, + "Can make framerate smoother in games that run at lower framerates.", + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_detect_vsync_swap_interval", + "Detect Frame Rate Changes (Notify frontend)", + NULL, + NULL, + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_inflight_frames", + "Buffered Frames (GL/Vulkan only, slower, less lag, restart)", + NULL, + NULL, + NULL, + "video", + { + { "No buffer", NULL }, + { "Up to 1", NULL }, + { "Up to 2", NULL }, + { NULL, NULL }, + }, + "Up to 2" + }, + { + "ppsspp_gpu_hardware_transform", + "Hardware Transform", + NULL, + NULL, + NULL, + "video", + BOOL_OPTIONS, + "enabled" + }, + { + "ppsspp_software_skinning", + "Software Skinning", + NULL, + "Combine skinned model draws on the CPU, faster in most games.", + NULL, + "video", + BOOL_OPTIONS, + "enabled" + }, + { + "ppsspp_vertex_cache", + "Vertex Cache", + NULL, + "Faster, but may cause temporary flicker.", + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_lazy_texture_caching", + "Lazy Texture Caching (Speedup)", + NULL, + "Faster, but can cause text problems in a few games.", + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_retain_changed_textures", + "Retain Changed Textures (Speedup, mem hog)", + NULL, + "Makes many games slower, but some games a lot faster.", + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_spline_quality", + "Spline/Bezier Curves Quality", + NULL, + "Only used by some games, controls smoothness of curves.", + NULL, + "video", + { + { "Low", NULL }, + { "Medium", NULL }, + { "High", NULL }, + { NULL, NULL }, + }, + "High" + }, + { + "ppsspp_hardware_tesselation", + "Hardware Tesselation", + NULL, + "Uses hardware to make curves.", + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_lower_resolution_for_effects", + "Lower Resolution for Effects", + NULL, + NULL, + NULL, + "video", + { + { "disabled", NULL }, + { "Safe", NULL }, + { "Balanced", NULL }, + { "Aggressive", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "ppsspp_texture_scaling_type", + "Texture Scaling Type", + NULL, + NULL, + NULL, + "video", + { + { "xbrz", "xBRZ" }, + { "hybrid", "Hybrid" }, + { "bicubic", "Bicubic" }, + { "hybrid_bicubic", "Hybrid + Bicubic" }, + { NULL, NULL }, + }, + "xbrz" + }, + { + "ppsspp_texture_scaling_level", + "Texture Scaling Level", + NULL, + "CPU heavy, some scaling may be delayed to avoid stutter.", + NULL, + "video", + { + { "disabled", NULL }, + { "2x", NULL }, + { "3x", NULL }, + { "4x", NULL }, + { "5x", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "ppsspp_texture_deposterize", + "Texture Deposterize", + NULL, + "Fixes visual banding glitches in upscaled textures.", + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_texture_shader", + "Texture Shader (Vulkan only, overrides 'Texture Scaling Type')", + NULL, + NULL, + NULL, + "video", + { + { "disabled", NULL }, + { "2xBRZ", "Tex2xBRZ" }, + { "4xBRZ", "Tex4xBRZ" }, + { "MMPX", "TexMMPX" }, + { NULL, NULL }, + }, + "disabled" + }, + { + "ppsspp_texture_anisotropic_filtering", + "Anisotropic Filtering", + NULL, + NULL, + NULL, + "video", + { + { "disabled", NULL }, + { "2x", NULL }, + { "4x", NULL }, + { "8x", NULL }, + { "16x", NULL }, + { NULL, NULL }, + }, + "16x" + }, + { + "ppsspp_texture_filtering", + "Texture Filtering", + NULL, + NULL, + NULL, + "video", + { + { "Auto", NULL }, + { "Nearest", NULL }, + { "Linear", NULL }, + { "Auto max quality", NULL }, + { NULL, NULL }, + }, + "Auto" + }, + { + "ppsspp_texture_replacement", + "Texture Replacement", + NULL, + NULL, + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_enable_wlan", + "Enable Networking/WLAN (Beta, may break games)", + NULL, + NULL, + NULL, + "network", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_change_mac_address01", + "MAC Address Pt 1: X-:--:--:--:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address02", + "MAC Address Pt 2: -X:--:--:--:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address03", + "MAC Address Pt 3: --:X-:--:--:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address04", + "MAC Address Pt 4: --:-X:--:--:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address05", + "MAC Address Pt 5: --:--:X-:--:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address06", + "MAC Address Pt 6: --:--:-X:--:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address07", + "MAC Address Pt 7: --:--:--:X-:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address08", + "MAC Address Pt 8: --:--:--:-X:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address09", + "MAC Address Pt 9: --:--:--:--:X-:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address10", + "MAC Address Pt 10: --:--:--:--:-X:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address11", + "MAC Address Pt 11: --:--:--:--:--:X-", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address12", + "MAC Address Pt 12: --:--:--:--:--:-X", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_wlan_channel", + "WLAN Channel", + NULL, + NULL, + NULL, + "network", + { + { "Auto", NULL }, + { "1", NULL }, + { "6", NULL }, + { "11", NULL }, + { NULL, NULL }, + }, + "Auto" + }, + { + "ppsspp_enable_builtin_pro_ad_hoc_server", + "Enable Built-in PRO Ad Hoc Server", + NULL, + NULL, + NULL, + "network", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_change_pro_ad_hoc_server_address", + "Change PRO Ad Hoc Server IP Address ('localhost' = multiple instances)", + NULL, + NULL, + NULL, + "network", + { + { "socom.cc", NULL }, + { "psp.gameplayer.club", NULL }, + { "myneighborsushicat.com", NULL }, + { "localhost", NULL }, + { "IP address", NULL }, + { NULL, NULL }, + }, + "socom.cc" + }, + { + "ppsspp_pro_ad_hoc_server_address01", + "PRO Ad Hoc Server IP Address Pt 1: x--.---.---.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address02", + "PRO Ad Hoc Server IP Address Pt 2: -x-.---.---.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address03", + "PRO Ad Hoc Server IP Address Pt 3: --x.---.---.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address04", + "PRO Ad Hoc Server IP Address Pt 4: ---.x--.---.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address05", + "PRO Ad Hoc Server IP Address Pt 5: ---.-x-.---.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address06", + "PRO Ad Hoc Server IP Address Pt 6: ---.--x.---.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address07", + "PRO Ad Hoc Server IP Address Pt 7: ---.---.x--.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address08", + "PRO Ad Hoc Server IP Address Pt 8: ---.---.-x-.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address09", + "PRO Ad Hoc Server IP Address Pt 9: ---.---.--x.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address10", + "PRO Ad Hoc Server IP Address Pt 10: ---.---.---.x--", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address11", + "PRO Ad Hoc Server IP Address Pt 11: ---.---.---.-x-", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address12", + "PRO Ad Hoc Server IP Address Pt 12: ---.---.---.--x", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_enable_upnp", + "Enable UPnP (Need a few seconds to detect)", + NULL, + NULL, + NULL, + "network", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_upnp_use_original_port", + "UPnP Use Original Port ('ON' = PSP compatibility)", + NULL, + NULL, + NULL, + "network", + BOOL_OPTIONS, + "enabled" + }, + { + "ppsspp_port_offset", + "Port Offset ('0' = PSP compatibility)", + NULL, + NULL, + NULL, + "network", + { + { "0", NULL }, + { "1000", NULL }, + { "2000", NULL }, + { "3000", NULL }, + { "4000", NULL }, + { "5000", NULL }, + { "6000", NULL }, + { "7000", NULL }, + { "8000", NULL }, + { "9000", NULL }, + { "10000", NULL }, + { "11000", NULL }, + { "12000", NULL }, + { "13000", NULL }, + { "14000", NULL }, + { "15000", NULL }, + { "16000", NULL }, + { "17000", NULL }, + { "18000", NULL }, + { "19000", NULL }, + { "20000", NULL }, + { "31000", NULL }, + { "32000", NULL }, + { "33000", NULL }, + { "34000", NULL }, + { "35000", NULL }, + { "36000", NULL }, + { "37000", NULL }, + { "38000", NULL }, + { "39000", NULL }, + { "40000", NULL }, + { "41000", NULL }, + { "42000", NULL }, + { "43000", NULL }, + { "44000", NULL }, + { "45000", NULL }, + { "46000", NULL }, + { "47000", NULL }, + { "48000", NULL }, + { "49000", NULL }, + { "50000", NULL }, + { "51000", NULL }, + { "52000", NULL }, + { "53000", NULL }, + { "54000", NULL }, + { "55000", NULL }, + { "56000", NULL }, + { "57000", NULL }, + { "58000", NULL }, + { "59000", NULL }, + { "60000", NULL }, + { "61000", NULL }, + { "62000", NULL }, + { "63000", NULL }, + { "64000", NULL }, + { "65000", NULL }, + { NULL, NULL }, + }, + "0" + }, + { + "ppsspp_minimum_timeout", + "Minimum Timeout (Override in ms, '0' = default)", + NULL, + NULL, + NULL, + "network", + { + { "0", NULL }, + { "100", NULL }, + { "200", NULL }, + { "300", NULL }, + { "400", NULL }, + { "500", NULL }, + { "600", NULL }, + { "700", NULL }, + { "800", NULL }, + { "900", NULL }, + { "1000", NULL }, + { "1100", NULL }, + { "1200", NULL }, + { "1300", NULL }, + { "1400", NULL }, + { "1500", NULL }, + { "1600", NULL }, + { "1700", NULL }, + { "1800", NULL }, + { "1900", NULL }, + { "2000", NULL }, + { "3100", NULL }, + { "3200", NULL }, + { "3300", NULL }, + { "3400", NULL }, + { "3500", NULL }, + { "3600", NULL }, + { "3700", NULL }, + { "3800", NULL }, + { "3900", NULL }, + { "4000", NULL }, + { "4100", NULL }, + { "4200", NULL }, + { "4300", NULL }, + { "4400", NULL }, + { "4500", NULL }, + { "4600", NULL }, + { "4700", NULL }, + { "4800", NULL }, + { "4900", NULL }, + { "5000", NULL }, + { NULL, NULL }, + }, + "0" + }, + { + "ppsspp_forced_first_connect", + "Forced First Connect (Faster connect)", + NULL, + NULL, + NULL, + "network", + BOOL_OPTIONS, + "disabled" + }, + { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL }, +}; + +struct retro_core_options_v2 options_us = { + option_cats_us, + option_defs_us +}; + +/* + ******************************** + * Language Mapping + ******************************** +*/ + +#ifndef HAVE_NO_LANGEXTRA +struct retro_core_options_v2 *options_intl[RETRO_LANGUAGE_LAST] = { + &options_us, /* RETRO_LANGUAGE_ENGLISH */ + NULL, /* RETRO_LANGUAGE_JAPANESE */ + NULL, /* RETRO_LANGUAGE_FRENCH */ + NULL, /* RETRO_LANGUAGE_SPANISH */ + NULL, /* RETRO_LANGUAGE_GERMAN */ + NULL, /* RETRO_LANGUAGE_ITALIAN */ + NULL, /* RETRO_LANGUAGE_DUTCH */ + NULL, /* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */ + NULL, /* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */ + NULL, /* RETRO_LANGUAGE_RUSSIAN */ + NULL, /* RETRO_LANGUAGE_KOREAN */ + NULL, /* RETRO_LANGUAGE_CHINESE_TRADITIONAL */ + NULL, /* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */ + NULL, /* RETRO_LANGUAGE_ESPERANTO */ + NULL, /* RETRO_LANGUAGE_POLISH */ + NULL, /* RETRO_LANGUAGE_VIETNAMESE */ + NULL, /* RETRO_LANGUAGE_ARABIC */ + NULL, /* RETRO_LANGUAGE_GREEK */ + NULL, /* RETRO_LANGUAGE_TURKISH */ + NULL, /* RETRO_LANGUAGE_SLOVAK */ + NULL, /* RETRO_LANGUAGE_PERSIAN */ + NULL, /* RETRO_LANGUAGE_HEBREW */ + NULL, /* RETRO_LANGUAGE_ASTURIAN */ + NULL, /* RETRO_LANGUAGE_FINNISH */ + NULL, /* RETRO_LANGUAGE_INDONESIAN */ + NULL, /* RETRO_LANGUAGE_SWEDISH */ + NULL, /* RETRO_LANGUAGE_UKRAINIAN */ + NULL, /* RETRO_LANGUAGE_CZECH */ +}; +#endif + +/* + ******************************** + * Functions + ******************************** +*/ + +/* Handles configuration/setting of core options. + * Should be called as early as possible - ideally inside + * retro_set_environment(), and no later than retro_load_game() + * > We place the function body in the header to avoid the + * necessity of adding more .c files (i.e. want this to + * be as painless as possible for core devs) + */ + +static INLINE void libretro_set_core_options(retro_environment_t environ_cb, + bool *categories_supported) +{ + unsigned version = 0; +#ifndef HAVE_NO_LANGEXTRA + unsigned language = 0; +#endif + + if (!environ_cb || !categories_supported) + return; + + *categories_supported = false; + + if (!environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version)) + version = 0; + + if (version >= 2) + { +#ifndef HAVE_NO_LANGEXTRA + struct retro_core_options_v2_intl core_options_intl; + + core_options_intl.us = &options_us; + core_options_intl.local = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) && + (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH)) + core_options_intl.local = options_intl[language]; + + *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL, + &core_options_intl); +#else + *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2, + &options_us); +#endif + } + else + { + size_t i, j; + size_t option_index = 0; + size_t num_options = 0; + struct retro_core_option_definition + *option_v1_defs_us = NULL; +#ifndef HAVE_NO_LANGEXTRA + size_t num_options_intl = 0; + struct retro_core_option_v2_definition + *option_defs_intl = NULL; + struct retro_core_option_definition + *option_v1_defs_intl = NULL; + struct retro_core_options_intl + core_options_v1_intl; +#endif + struct retro_variable *variables = NULL; + char **values_buf = NULL; + + /* Determine total number of options */ + while (true) + { + if (option_defs_us[num_options].key) + num_options++; + else + break; + } + + if (version >= 1) + { + /* Allocate US array */ + option_v1_defs_us = (struct retro_core_option_definition *) + calloc(num_options + 1, sizeof(struct retro_core_option_definition)); + + /* Copy parameters from option_defs_us array */ + for (i = 0; i < num_options; i++) + { + struct retro_core_option_v2_definition *option_def_us = &option_defs_us[i]; + struct retro_core_option_value *option_values = option_def_us->values; + struct retro_core_option_definition *option_v1_def_us = &option_v1_defs_us[i]; + struct retro_core_option_value *option_v1_values = option_v1_def_us->values; + + option_v1_def_us->key = option_def_us->key; + option_v1_def_us->desc = option_def_us->desc; + option_v1_def_us->info = option_def_us->info; + option_v1_def_us->default_value = option_def_us->default_value; + + /* Values must be copied individually... */ + while (option_values->value) + { + option_v1_values->value = option_values->value; + option_v1_values->label = option_values->label; + + option_values++; + option_v1_values++; + } + } + +#ifndef HAVE_NO_LANGEXTRA + if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) && + (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH) && + options_intl[language]) + option_defs_intl = options_intl[language]->definitions; + + if (option_defs_intl) + { + /* Determine number of intl options */ + while (true) + { + if (option_defs_intl[num_options_intl].key) + num_options_intl++; + else + break; + } + + /* Allocate intl array */ + option_v1_defs_intl = (struct retro_core_option_definition *) + calloc(num_options_intl + 1, sizeof(struct retro_core_option_definition)); + + /* Copy parameters from option_defs_intl array */ + for (i = 0; i < num_options_intl; i++) + { + struct retro_core_option_v2_definition *option_def_intl = &option_defs_intl[i]; + struct retro_core_option_value *option_values = option_def_intl->values; + struct retro_core_option_definition *option_v1_def_intl = &option_v1_defs_intl[i]; + struct retro_core_option_value *option_v1_values = option_v1_def_intl->values; + + option_v1_def_intl->key = option_def_intl->key; + option_v1_def_intl->desc = option_def_intl->desc; + option_v1_def_intl->info = option_def_intl->info; + option_v1_def_intl->default_value = option_def_intl->default_value; + + /* Values must be copied individually... */ + while (option_values->value) + { + option_v1_values->value = option_values->value; + option_v1_values->label = option_values->label; + + option_values++; + option_v1_values++; + } + } + } + + core_options_v1_intl.us = option_v1_defs_us; + core_options_v1_intl.local = option_v1_defs_intl; + + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_v1_intl); +#else + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, option_v1_defs_us); +#endif + } + else + { + /* Allocate arrays */ + variables = (struct retro_variable *)calloc(num_options + 1, + sizeof(struct retro_variable)); + values_buf = (char **)calloc(num_options, sizeof(char *)); + + if (!variables || !values_buf) + goto error; + + /* Copy parameters from option_defs_us array */ + for (i = 0; i < num_options; i++) + { + const char *key = option_defs_us[i].key; + const char *desc = option_defs_us[i].desc; + const char *default_value = option_defs_us[i].default_value; + struct retro_core_option_value *values = option_defs_us[i].values; + size_t buf_len = 3; + size_t default_index = 0; + + values_buf[i] = NULL; + + if (desc) + { + size_t num_values = 0; + + /* Determine number of values */ + while (true) + { + if (values[num_values].value) + { + /* Check if this is the default value */ + if (default_value) + if (strcmp(values[num_values].value, default_value) == 0) + default_index = num_values; + + buf_len += strlen(values[num_values].value); + num_values++; + } + else + break; + } + + /* Build values string */ + if (num_values > 0) + { + buf_len += num_values - 1; + buf_len += strlen(desc); + + values_buf[i] = (char *)calloc(buf_len, sizeof(char)); + if (!values_buf[i]) + goto error; + + strcpy(values_buf[i], desc); + strcat(values_buf[i], "; "); + + /* Default value goes first */ + strcat(values_buf[i], values[default_index].value); + + /* Add remaining values */ + for (j = 0; j < num_values; j++) + { + if (j != default_index) + { + strcat(values_buf[i], "|"); + strcat(values_buf[i], values[j].value); + } + } + } + } + + variables[option_index].key = key; + variables[option_index].value = values_buf[i]; + option_index++; + } + + /* Set variables */ + environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables); + } + +error: + /* Clean up */ + + if (option_v1_defs_us) + { + free(option_v1_defs_us); + option_v1_defs_us = NULL; + } + +#ifndef HAVE_NO_LANGEXTRA + if (option_v1_defs_intl) + { + free(option_v1_defs_intl); + option_v1_defs_intl = NULL; + } +#endif + + if (values_buf) + { + for (i = 0; i < num_options; i++) + { + if (values_buf[i]) + { + free(values_buf[i]); + values_buf[i] = NULL; + } + } + + free(values_buf); + values_buf = NULL; + } + + if (variables) + { + free(variables); + variables = NULL; + } + } +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libretro/libretro_core_options_intl.h b/libretro/libretro_core_options_intl.h new file mode 100644 index 0000000000..b2649b6b5e --- /dev/null +++ b/libretro/libretro_core_options_intl.h @@ -0,0 +1,91 @@ +#ifndef LIBRETRO_CORE_OPTIONS_INTL_H__ +#define LIBRETRO_CORE_OPTIONS_INTL_H__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1500 && _MSC_VER < 1900) +/* https://support.microsoft.com/en-us/kb/980263 */ +#pragma execution_character_set("utf-8") +#pragma warning(disable:4566) +#endif + +#include "libretro.h" + +/* + ******************************** + * VERSION: 2.0 + ******************************** + * + * - 2.0: Add support for core options v2 interface + * - 1.3: Move translations to libretro_core_options_intl.h + * - libretro_core_options_intl.h includes BOM and utf-8 + * fix for MSVC 2010-2013 + * - Added HAVE_NO_LANGEXTRA flag to disable translations + * on platforms/compilers without BOM support + * - 1.2: Use core options v1 interface when + * RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION is >= 1 + * (previously required RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION == 1) + * - 1.1: Support generation of core options v0 retro_core_option_value + * arrays containing options with a single value + * - 1.0: First commit +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + ******************************** + * Core Option Definitions + ******************************** +*/ + +/* RETRO_LANGUAGE_JAPANESE */ + +/* RETRO_LANGUAGE_FRENCH */ + +/* RETRO_LANGUAGE_SPANISH */ + +/* RETRO_LANGUAGE_GERMAN */ + +/* RETRO_LANGUAGE_ITALIAN */ + +/* RETRO_LANGUAGE_DUTCH */ + +/* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */ + +/* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */ + +/* RETRO_LANGUAGE_RUSSIAN */ + +/* RETRO_LANGUAGE_KOREAN */ + +/* RETRO_LANGUAGE_CHINESE_TRADITIONAL */ + +/* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */ + +/* RETRO_LANGUAGE_ESPERANTO */ + +/* RETRO_LANGUAGE_POLISH */ + +/* RETRO_LANGUAGE_VIETNAMESE */ + +/* RETRO_LANGUAGE_ARABIC */ + +/* RETRO_LANGUAGE_GREEK */ + +/* RETRO_LANGUAGE_TURKISH */ + +/* RETRO_LANGUAGE_SLOVAK */ + +/* RETRO_LANGUAGE_PERSIAN */ + +/* RETRO_LANGUAGE_HEBREW */ + +/* RETRO_LANGUAGE_ASTURIAN */ + +/* RETRO_LANGUAGE_FINNISH */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libretro/retro_inline.h b/libretro/retro_inline.h new file mode 100644 index 0000000000..b27d6dd6d4 --- /dev/null +++ b/libretro/retro_inline.h @@ -0,0 +1,39 @@ +/* Copyright (C) 2010-2020 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (retro_inline.h). + * --------------------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __LIBRETRO_SDK_INLINE_H +#define __LIBRETRO_SDK_INLINE_H + +#ifndef INLINE + +#if defined(_WIN32) || defined(__INTEL_COMPILER) +#define INLINE __inline +#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L +#define INLINE inline +#elif defined(__GNUC__) +#define INLINE __inline__ +#else +#define INLINE +#endif + +#endif +#endif