2015-09-26 14:01:16 +00:00
|
|
|
// Copyright (c) 2013- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2020-08-10 02:20:07 +00:00
|
|
|
#include <cstring>
|
2020-10-03 22:25:21 +00:00
|
|
|
|
2022-11-06 13:36:51 +00:00
|
|
|
#include "Common/Log.h"
|
2020-10-03 22:25:21 +00:00
|
|
|
#include "Common/Data/Format/IniFile.h"
|
2022-07-04 21:48:48 +00:00
|
|
|
#include "Common/StringUtils.h"
|
2015-09-26 14:01:16 +00:00
|
|
|
#include "Core/Compatibility.h"
|
2022-07-04 21:48:48 +00:00
|
|
|
#include "Core/Config.h"
|
2015-09-26 14:01:16 +00:00
|
|
|
#include "Core/System.h"
|
|
|
|
|
|
|
|
void Compatibility::Load(const std::string &gameID) {
|
|
|
|
Clear();
|
|
|
|
|
2022-07-04 21:48:48 +00:00
|
|
|
// Allow ignoring compat settings by name (regardless of game ID.)
|
|
|
|
std::vector<std::string> ignored;
|
|
|
|
SplitString(g_Config.sIgnoreCompatSettings, ',', ignored);
|
|
|
|
ignored_ = std::set<std::string>(ignored.begin(), ignored.end());
|
|
|
|
// If ALL, don't process any compat flags.
|
|
|
|
if (ignored_.find("ALL") != ignored_.end())
|
|
|
|
return;
|
|
|
|
|
2016-01-16 10:24:04 +00:00
|
|
|
{
|
|
|
|
IniFile compat;
|
|
|
|
// This loads from assets.
|
|
|
|
if (compat.LoadFromVFS("compat.ini")) {
|
|
|
|
CheckSettings(compat, gameID);
|
|
|
|
}
|
2015-09-26 14:01:16 +00:00
|
|
|
}
|
|
|
|
|
2022-10-22 14:16:23 +00:00
|
|
|
{
|
|
|
|
IniFile compat2;
|
|
|
|
// This one is user-editable. Need to load it after the system one.
|
|
|
|
Path path = GetSysDirectory(DIRECTORY_SYSTEM) / "compat.ini";
|
|
|
|
if (compat2.Load(path.ToString())) {
|
|
|
|
CheckSettings(compat2, gameID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-12 16:46:04 +00:00
|
|
|
{
|
|
|
|
IniFile compat;
|
|
|
|
// This loads from assets.
|
|
|
|
if (compat.LoadFromVFS("compatvr.ini")) {
|
2022-10-22 14:16:23 +00:00
|
|
|
CheckVRSettings(compat, gameID);
|
2022-09-12 16:46:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-16 10:24:04 +00:00
|
|
|
{
|
|
|
|
IniFile compat2;
|
|
|
|
// This one is user-editable. Need to load it after the system one.
|
2022-10-22 14:16:23 +00:00
|
|
|
Path path = GetSysDirectory(DIRECTORY_SYSTEM) / "compatvr.ini";
|
2021-05-05 23:31:38 +00:00
|
|
|
if (compat2.Load(path.ToString())) {
|
2022-10-22 14:16:23 +00:00
|
|
|
CheckVRSettings(compat2, gameID);
|
2016-01-16 10:24:04 +00:00
|
|
|
}
|
2015-09-26 14:01:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Compatibility::Clear() {
|
|
|
|
memset(&flags_, 0, sizeof(flags_));
|
2022-09-12 16:46:04 +00:00
|
|
|
memset(&vrCompat_, 0, sizeof(vrCompat_));
|
2015-09-26 14:01:16 +00:00
|
|
|
}
|
|
|
|
|
2016-01-16 10:24:04 +00:00
|
|
|
void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) {
|
2017-01-28 09:04:50 +00:00
|
|
|
CheckSetting(iniFile, gameID, "VertexDepthRounding", &flags_.VertexDepthRounding);
|
|
|
|
CheckSetting(iniFile, gameID, "PixelDepthRounding", &flags_.PixelDepthRounding);
|
|
|
|
CheckSetting(iniFile, gameID, "DepthRangeHack", &flags_.DepthRangeHack);
|
|
|
|
CheckSetting(iniFile, gameID, "ClearToRAM", &flags_.ClearToRAM);
|
2017-01-28 23:10:50 +00:00
|
|
|
CheckSetting(iniFile, gameID, "Force04154000Download", &flags_.Force04154000Download);
|
2017-02-03 14:30:22 +00:00
|
|
|
CheckSetting(iniFile, gameID, "DrawSyncEatCycles", &flags_.DrawSyncEatCycles);
|
2017-02-14 15:56:53 +00:00
|
|
|
CheckSetting(iniFile, gameID, "FakeMipmapChange", &flags_.FakeMipmapChange);
|
2017-03-14 09:36:51 +00:00
|
|
|
CheckSetting(iniFile, gameID, "RequireBufferedRendering", &flags_.RequireBufferedRendering);
|
2017-03-21 07:23:31 +00:00
|
|
|
CheckSetting(iniFile, gameID, "RequireBlockTransfer", &flags_.RequireBlockTransfer);
|
2017-12-17 12:14:06 +00:00
|
|
|
CheckSetting(iniFile, gameID, "RequireDefaultCPUClock", &flags_.RequireDefaultCPUClock);
|
2017-11-21 10:56:42 +00:00
|
|
|
CheckSetting(iniFile, gameID, "DisableAccurateDepth", &flags_.DisableAccurateDepth);
|
2018-04-13 15:32:36 +00:00
|
|
|
CheckSetting(iniFile, gameID, "MGS2AcidHack", &flags_.MGS2AcidHack);
|
2018-04-13 16:05:04 +00:00
|
|
|
CheckSetting(iniFile, gameID, "SonicRivalsHack", &flags_.SonicRivalsHack);
|
2018-11-04 23:28:01 +00:00
|
|
|
CheckSetting(iniFile, gameID, "BlockTransferAllowCreateFB", &flags_.BlockTransferAllowCreateFB);
|
2020-10-10 21:48:37 +00:00
|
|
|
CheckSetting(iniFile, gameID, "IntraVRAMBlockTransferAllowCreateFB", &flags_.IntraVRAMBlockTransferAllowCreateFB);
|
2018-11-27 14:45:51 +00:00
|
|
|
CheckSetting(iniFile, gameID, "YugiohSaveFix", &flags_.YugiohSaveFix);
|
2019-02-06 09:45:12 +00:00
|
|
|
CheckSetting(iniFile, gameID, "ForceUMDDelay", &flags_.ForceUMDDelay);
|
2019-02-06 09:54:03 +00:00
|
|
|
CheckSetting(iniFile, gameID, "ForceMax60FPS", &flags_.ForceMax60FPS);
|
2022-07-03 22:58:48 +00:00
|
|
|
CheckSetting(iniFile, gameID, "GoWFramerateHack60", &flags_.GoWFramerateHack60);
|
|
|
|
CheckSetting(iniFile, gameID, "GoWFramerateHack30", &flags_.GoWFramerateHack30);
|
2019-03-01 09:55:43 +00:00
|
|
|
CheckSetting(iniFile, gameID, "JitInvalidationHack", &flags_.JitInvalidationHack);
|
2019-08-01 16:38:40 +00:00
|
|
|
CheckSetting(iniFile, gameID, "HideISOFiles", &flags_.HideISOFiles);
|
2019-08-05 04:37:33 +00:00
|
|
|
CheckSetting(iniFile, gameID, "MoreAccurateVMMUL", &flags_.MoreAccurateVMMUL);
|
2019-10-22 19:38:14 +00:00
|
|
|
CheckSetting(iniFile, gameID, "ForceSoftwareRenderer", &flags_.ForceSoftwareRenderer);
|
2019-10-23 22:10:39 +00:00
|
|
|
CheckSetting(iniFile, gameID, "DarkStalkersPresentHack", &flags_.DarkStalkersPresentHack);
|
2020-10-05 18:26:04 +00:00
|
|
|
CheckSetting(iniFile, gameID, "ReportSmallMemstick", &flags_.ReportSmallMemstick);
|
2020-10-20 05:42:49 +00:00
|
|
|
CheckSetting(iniFile, gameID, "MemstickFixedFree", &flags_.MemstickFixedFree);
|
2020-10-11 08:19:06 +00:00
|
|
|
CheckSetting(iniFile, gameID, "DateLimited", &flags_.DateLimited);
|
2020-11-27 22:34:02 +00:00
|
|
|
CheckSetting(iniFile, gameID, "ShaderColorBitmask", &flags_.ShaderColorBitmask);
|
2020-12-20 11:59:44 +00:00
|
|
|
CheckSetting(iniFile, gameID, "DisableFirstFrameReadback", &flags_.DisableFirstFrameReadback);
|
2021-02-09 15:11:59 +00:00
|
|
|
CheckSetting(iniFile, gameID, "MpegAvcWarmUp", &flags_.MpegAvcWarmUp);
|
2022-04-24 18:53:09 +00:00
|
|
|
CheckSetting(iniFile, gameID, "BlueToAlpha", &flags_.BlueToAlpha);
|
2022-06-10 22:20:35 +00:00
|
|
|
CheckSetting(iniFile, gameID, "CenteredLines", &flags_.CenteredLines);
|
2022-04-16 21:47:05 +00:00
|
|
|
CheckSetting(iniFile, gameID, "MaliDepthStencilBugWorkaround", &flags_.MaliDepthStencilBugWorkaround);
|
2022-07-14 21:17:32 +00:00
|
|
|
CheckSetting(iniFile, gameID, "ZZT3SelectHack", &flags_.ZZT3SelectHack);
|
2022-07-15 09:43:49 +00:00
|
|
|
CheckSetting(iniFile, gameID, "AllowLargeFBTextureOffsets", &flags_.AllowLargeFBTextureOffsets);
|
2022-08-14 06:54:06 +00:00
|
|
|
CheckSetting(iniFile, gameID, "AtracLoopHack", &flags_.AtracLoopHack);
|
2022-08-18 22:34:02 +00:00
|
|
|
CheckSetting(iniFile, gameID, "DeswizzleDepth", &flags_.DeswizzleDepth);
|
2022-08-30 17:36:08 +00:00
|
|
|
CheckSetting(iniFile, gameID, "SplitFramebufferMargin", &flags_.SplitFramebufferMargin);
|
2022-09-04 21:42:35 +00:00
|
|
|
CheckSetting(iniFile, gameID, "ForceLowerResolutionForEffectsOn", &flags_.ForceLowerResolutionForEffectsOn);
|
2022-09-11 08:26:01 +00:00
|
|
|
CheckSetting(iniFile, gameID, "AllowDownloadCLUT", &flags_.AllowDownloadCLUT);
|
2022-09-26 18:47:55 +00:00
|
|
|
CheckSetting(iniFile, gameID, "NearestFilteringOnFramebufferCreate", &flags_.NearestFilteringOnFramebufferCreate);
|
2022-11-06 16:28:50 +00:00
|
|
|
CheckSetting(iniFile, gameID, "SecondaryTextureCache", &flags_.SecondaryTextureCache);
|
2022-11-13 22:16:09 +00:00
|
|
|
CheckSetting(iniFile, gameID, "EnglishOrJapaneseOnly", &flags_.EnglishOrJapaneseOnly);
|
2016-01-16 10:24:04 +00:00
|
|
|
}
|
|
|
|
|
2022-10-22 14:16:23 +00:00
|
|
|
void Compatibility::CheckVRSettings(IniFile &iniFile, const std::string &gameID) {
|
2022-11-09 18:25:08 +00:00
|
|
|
CheckSetting(iniFile, gameID, "IdentityViewHack", &vrCompat_.IdentityViewHack);
|
2022-10-22 14:16:23 +00:00
|
|
|
CheckSetting(iniFile, gameID, "Skyplane", &vrCompat_.Skyplane);
|
|
|
|
CheckSetting(iniFile, gameID, "UnitsPerMeter", &vrCompat_.UnitsPerMeter);
|
2022-11-06 13:36:51 +00:00
|
|
|
|
|
|
|
NOTICE_LOG(G3D, "UnitsPerMeter for %s: %f", gameID.c_str(), vrCompat_.UnitsPerMeter);
|
2022-10-22 14:16:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-28 09:04:50 +00:00
|
|
|
void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, bool *flag) {
|
2022-07-06 13:54:15 +00:00
|
|
|
if (ignored_.find(option) == ignored_.end()) {
|
2022-07-04 21:48:48 +00:00
|
|
|
iniFile.Get(option, gameID.c_str(), flag, *flag);
|
2022-09-04 09:43:17 +00:00
|
|
|
|
|
|
|
// Shortcut for debugging, sometimes useful to globally enable compat flags.
|
|
|
|
bool all = false;
|
|
|
|
iniFile.Get(option, "ALL", &all, false);
|
|
|
|
*flag |= all;
|
2022-07-04 21:48:48 +00:00
|
|
|
}
|
2015-09-26 14:01:16 +00:00
|
|
|
}
|
2022-09-12 16:46:04 +00:00
|
|
|
|
|
|
|
void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, float *flag) {
|
|
|
|
std::string value;
|
|
|
|
iniFile.Get(option, gameID.c_str(), &value, "0");
|
|
|
|
*flag = stof(value);
|
|
|
|
}
|