2020-08-20 11:30:11 +00:00
|
|
|
#include "game_settings.h"
|
|
|
|
#include "common/assert.h"
|
|
|
|
#include "common/byte_stream.h"
|
|
|
|
#include "common/file_system.h"
|
|
|
|
#include "common/log.h"
|
|
|
|
#include "common/string.h"
|
|
|
|
#include "common/string_util.h"
|
2020-09-01 02:29:22 +00:00
|
|
|
#include "core/host_interface.h"
|
|
|
|
#include "core/settings.h"
|
2020-08-20 11:30:11 +00:00
|
|
|
#include <array>
|
|
|
|
#include <utility>
|
|
|
|
Log_SetChannel(GameSettings);
|
|
|
|
|
2020-11-27 05:42:22 +00:00
|
|
|
#ifndef LIBRETRO
|
2020-08-20 11:30:11 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#include "common/windows_headers.h"
|
|
|
|
#endif
|
|
|
|
#include "SimpleIni.h"
|
2020-11-27 05:42:22 +00:00
|
|
|
#endif
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
namespace GameSettings {
|
|
|
|
|
|
|
|
std::array<std::pair<const char*, const char*>, static_cast<u32>(Trait::Count)> s_trait_names = {{
|
2020-08-22 03:01:52 +00:00
|
|
|
{"ForceInterpreter", TRANSLATABLE("GameSettingsTrait", "Force Interpreter")},
|
|
|
|
{"ForceSoftwareRenderer", TRANSLATABLE("GameSettingsTrait", "Force Software Renderer")},
|
2020-08-29 11:53:52 +00:00
|
|
|
{"ForceInterlacing", TRANSLATABLE("GameSettingsTrait", "Force Interlacing")},
|
2020-08-22 03:01:52 +00:00
|
|
|
{"DisableTrueColor", TRANSLATABLE("GameSettingsTrait", "Disable True Color")},
|
|
|
|
{"DisableUpscaling", TRANSLATABLE("GameSettingsTrait", "Disable Upscaling")},
|
|
|
|
{"DisableScaledDithering", TRANSLATABLE("GameSettingsTrait", "Disable Scaled Dithering")},
|
2020-09-01 14:03:53 +00:00
|
|
|
{"DisableForceNTSCTimings", TRANSLATABLE("GameSettingsTrait", "Disallow Forcing NTSC Timings")},
|
2020-08-22 03:01:52 +00:00
|
|
|
{"DisableWidescreen", TRANSLATABLE("GameSettingsTrait", "Disable Widescreen")},
|
|
|
|
{"DisablePGXP", TRANSLATABLE("GameSettingsTrait", "Disable PGXP")},
|
|
|
|
{"DisablePGXPCulling", TRANSLATABLE("GameSettingsTrait", "Disable PGXP Culling")},
|
2020-09-14 08:20:42 +00:00
|
|
|
{"DisablePGXPTextureCorrection", TRANSLATABLE("GameSettingsTrait", "Disable PGXP Texture Correction")},
|
2020-12-22 15:11:51 +00:00
|
|
|
{"DisablePGXPDepthBuffer", TRANSLATABLE("GameSettingsTrait", "Disable PGXP Depth Buffer")},
|
2020-08-29 11:53:52 +00:00
|
|
|
{"ForcePGXPVertexCache", TRANSLATABLE("GameSettingsTrait", "Force PGXP Vertex Cache")},
|
|
|
|
{"ForcePGXPCPUMode", TRANSLATABLE("GameSettingsTrait", "Force PGXP CPU Mode")},
|
2020-12-11 08:59:40 +00:00
|
|
|
{"DisableAnalogModeForcing", TRANSLATABLE("GameSettingsTrait", "Disable Forcing Controller Analog Mode on Reset")},
|
2020-08-29 11:53:52 +00:00
|
|
|
{"ForceRecompilerMemoryExceptions", TRANSLATABLE("GameSettingsTrait", "Force Recompiler Memory Exceptions")},
|
2020-08-29 12:11:10 +00:00
|
|
|
{"ForceRecompilerICache", TRANSLATABLE("GameSettingsTrait", "Force Recompiler ICache")},
|
2020-08-20 11:30:11 +00:00
|
|
|
}};
|
|
|
|
|
|
|
|
const char* GetTraitName(Trait trait)
|
|
|
|
{
|
|
|
|
DebugAssert(trait < Trait::Count);
|
|
|
|
return s_trait_names[static_cast<u32>(trait)].first;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* GetTraitDisplayName(Trait trait)
|
|
|
|
{
|
|
|
|
DebugAssert(trait < Trait::Count);
|
|
|
|
return s_trait_names[static_cast<u32>(trait)].second;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
bool ReadOptionalFromStream(ByteStream* stream, std::optional<T>* dest)
|
|
|
|
{
|
|
|
|
bool has_value;
|
|
|
|
if (!stream->Read2(&has_value, sizeof(has_value)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!has_value)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
T value;
|
|
|
|
if (!stream->Read2(&value, sizeof(T)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
*dest = value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-09-01 14:00:48 +00:00
|
|
|
static bool ReadStringFromStream(ByteStream* stream, std::string* dest)
|
|
|
|
{
|
|
|
|
u32 size;
|
|
|
|
if (!stream->Read2(&size, sizeof(size)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
dest->resize(size);
|
|
|
|
if (!stream->Read2(dest->data(), size))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-08-20 11:30:11 +00:00
|
|
|
template<typename T>
|
|
|
|
bool WriteOptionalToStream(ByteStream* stream, const std::optional<T>& src)
|
|
|
|
{
|
|
|
|
const bool has_value = src.has_value();
|
|
|
|
if (!stream->Write2(&has_value, sizeof(has_value)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!has_value)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return stream->Write2(&src.value(), sizeof(T));
|
|
|
|
}
|
|
|
|
|
2020-09-01 14:00:48 +00:00
|
|
|
static bool WriteStringToStream(ByteStream* stream, const std::string& str)
|
|
|
|
{
|
|
|
|
const u32 size = static_cast<u32>(str.size());
|
|
|
|
return (stream->Write2(&size, sizeof(size)) && (size == 0 || stream->Write2(str.data(), size)));
|
|
|
|
}
|
|
|
|
|
2020-08-20 11:30:11 +00:00
|
|
|
bool Entry::LoadFromStream(ByteStream* stream)
|
|
|
|
{
|
|
|
|
constexpr u32 num_bytes = (static_cast<u32>(Trait::Count) + 7) / 8;
|
|
|
|
std::array<u8, num_bytes> bits;
|
|
|
|
|
2020-09-30 13:46:35 +00:00
|
|
|
if (!stream->Read2(bits.data(), num_bytes) || !ReadOptionalFromStream(stream, &cpu_overclock_numerator) ||
|
|
|
|
!ReadOptionalFromStream(stream, &cpu_overclock_denominator) ||
|
2020-10-04 14:17:12 +00:00
|
|
|
!ReadOptionalFromStream(stream, &cpu_overclock_enable) || !ReadOptionalFromStream(stream, &cdrom_read_speedup) ||
|
2020-09-30 13:46:35 +00:00
|
|
|
!ReadOptionalFromStream(stream, &display_active_start_offset) ||
|
2020-08-20 11:30:11 +00:00
|
|
|
!ReadOptionalFromStream(stream, &display_active_end_offset) ||
|
2020-12-03 12:31:21 +00:00
|
|
|
!ReadOptionalFromStream(stream, &display_line_start_offset) ||
|
|
|
|
!ReadOptionalFromStream(stream, &display_line_end_offset) ||
|
2020-10-29 13:59:48 +00:00
|
|
|
!ReadOptionalFromStream(stream, &dma_max_slice_ticks) || !ReadOptionalFromStream(stream, &dma_halt_ticks) ||
|
|
|
|
!ReadOptionalFromStream(stream, &gpu_fifo_size) || !ReadOptionalFromStream(stream, &gpu_max_run_ahead) ||
|
2020-12-22 15:11:51 +00:00
|
|
|
!ReadOptionalFromStream(stream, &gpu_pgxp_tolerance) ||
|
|
|
|
!ReadOptionalFromStream(stream, &gpu_pgxp_depth_threshold) ||
|
|
|
|
!ReadOptionalFromStream(stream, &display_crop_mode) || !ReadOptionalFromStream(stream, &display_aspect_ratio) ||
|
2020-09-01 14:00:48 +00:00
|
|
|
!ReadOptionalFromStream(stream, &display_linear_upscaling) ||
|
|
|
|
!ReadOptionalFromStream(stream, &display_integer_upscaling) ||
|
2020-09-26 05:21:17 +00:00
|
|
|
!ReadOptionalFromStream(stream, &display_force_4_3_for_24bit) ||
|
2020-11-26 14:34:25 +00:00
|
|
|
!ReadOptionalFromStream(stream, &gpu_resolution_scale) || !ReadOptionalFromStream(stream, &gpu_multisamples) ||
|
|
|
|
!ReadOptionalFromStream(stream, &gpu_per_sample_shading) || !ReadOptionalFromStream(stream, &gpu_true_color) ||
|
2020-09-01 14:00:48 +00:00
|
|
|
!ReadOptionalFromStream(stream, &gpu_scaled_dithering) ||
|
|
|
|
!ReadOptionalFromStream(stream, &gpu_force_ntsc_timings) ||
|
2020-09-14 08:06:45 +00:00
|
|
|
!ReadOptionalFromStream(stream, &gpu_texture_filter) || !ReadOptionalFromStream(stream, &gpu_widescreen_hack) ||
|
2020-12-22 15:11:51 +00:00
|
|
|
!ReadOptionalFromStream(stream, &gpu_pgxp) || !ReadOptionalFromStream(stream, &gpu_pgxp_depth_buffer) ||
|
|
|
|
!ReadOptionalFromStream(stream, &controller_1_type) || !ReadOptionalFromStream(stream, &controller_2_type) ||
|
|
|
|
!ReadOptionalFromStream(stream, &memory_card_1_type) || !ReadOptionalFromStream(stream, &memory_card_2_type) ||
|
2020-09-01 14:00:48 +00:00
|
|
|
!ReadStringFromStream(stream, &memory_card_1_shared_path) ||
|
2020-10-04 08:20:18 +00:00
|
|
|
!ReadStringFromStream(stream, &memory_card_2_shared_path) || !ReadStringFromStream(stream, &input_profile_name))
|
2020-08-20 11:30:11 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
traits.reset();
|
|
|
|
for (u32 i = 0; i < static_cast<int>(Trait::Count); i++)
|
|
|
|
{
|
|
|
|
if ((bits[i / 8] & (1u << (i % 8))) != 0)
|
|
|
|
AddTrait(static_cast<Trait>(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Entry::SaveToStream(ByteStream* stream) const
|
|
|
|
{
|
|
|
|
constexpr u32 num_bytes = (static_cast<u32>(Trait::Count) + 7) / 8;
|
|
|
|
std::array<u8, num_bytes> bits;
|
|
|
|
bits.fill(0);
|
|
|
|
for (u32 i = 0; i < static_cast<int>(Trait::Count); i++)
|
|
|
|
{
|
|
|
|
if (HasTrait(static_cast<Trait>(i)))
|
|
|
|
bits[i / 8] |= (1u << (i % 8));
|
|
|
|
}
|
|
|
|
|
2020-09-30 13:46:35 +00:00
|
|
|
return stream->Write2(bits.data(), num_bytes) && WriteOptionalToStream(stream, cpu_overclock_numerator) &&
|
|
|
|
WriteOptionalToStream(stream, cpu_overclock_denominator) &&
|
2020-10-04 14:17:12 +00:00
|
|
|
WriteOptionalToStream(stream, cpu_overclock_enable) && WriteOptionalToStream(stream, cdrom_read_speedup) &&
|
2020-09-30 13:46:35 +00:00
|
|
|
WriteOptionalToStream(stream, display_active_start_offset) &&
|
2020-10-29 13:59:48 +00:00
|
|
|
WriteOptionalToStream(stream, display_active_end_offset) &&
|
2020-12-03 12:31:21 +00:00
|
|
|
WriteOptionalToStream(stream, display_line_start_offset) &&
|
|
|
|
WriteOptionalToStream(stream, display_line_end_offset) && WriteOptionalToStream(stream, dma_max_slice_ticks) &&
|
|
|
|
WriteOptionalToStream(stream, dma_halt_ticks) && WriteOptionalToStream(stream, gpu_fifo_size) &&
|
|
|
|
WriteOptionalToStream(stream, gpu_max_run_ahead) && WriteOptionalToStream(stream, gpu_pgxp_tolerance) &&
|
2020-12-22 15:11:51 +00:00
|
|
|
WriteOptionalToStream(stream, gpu_pgxp_depth_threshold) && WriteOptionalToStream(stream, display_crop_mode) &&
|
|
|
|
WriteOptionalToStream(stream, display_aspect_ratio) &&
|
2020-09-01 14:00:48 +00:00
|
|
|
WriteOptionalToStream(stream, display_linear_upscaling) &&
|
|
|
|
WriteOptionalToStream(stream, display_integer_upscaling) &&
|
2020-09-26 05:21:17 +00:00
|
|
|
WriteOptionalToStream(stream, display_force_4_3_for_24bit) &&
|
2020-11-26 14:34:25 +00:00
|
|
|
WriteOptionalToStream(stream, gpu_resolution_scale) && WriteOptionalToStream(stream, gpu_multisamples) &&
|
|
|
|
WriteOptionalToStream(stream, gpu_per_sample_shading) && WriteOptionalToStream(stream, gpu_true_color) &&
|
2020-09-14 08:06:45 +00:00
|
|
|
WriteOptionalToStream(stream, gpu_scaled_dithering) && WriteOptionalToStream(stream, gpu_force_ntsc_timings) &&
|
|
|
|
WriteOptionalToStream(stream, gpu_texture_filter) && WriteOptionalToStream(stream, gpu_widescreen_hack) &&
|
2020-12-22 15:11:51 +00:00
|
|
|
WriteOptionalToStream(stream, gpu_pgxp) && WriteOptionalToStream(stream, gpu_pgxp_depth_buffer) &&
|
|
|
|
WriteOptionalToStream(stream, controller_1_type) && WriteOptionalToStream(stream, controller_2_type) &&
|
|
|
|
WriteOptionalToStream(stream, memory_card_1_type) && WriteOptionalToStream(stream, memory_card_2_type) &&
|
|
|
|
WriteStringToStream(stream, memory_card_1_shared_path) &&
|
2020-10-04 08:20:18 +00:00
|
|
|
WriteStringToStream(stream, memory_card_2_shared_path) && WriteStringToStream(stream, input_profile_name);
|
2020-08-20 11:30:11 +00:00
|
|
|
}
|
|
|
|
|
2020-11-27 05:42:22 +00:00
|
|
|
#ifndef LIBRETRO
|
|
|
|
|
2020-08-20 11:30:11 +00:00
|
|
|
static void ParseIniSection(Entry* entry, const char* section, const CSimpleIniA& ini)
|
|
|
|
{
|
|
|
|
for (u32 trait = 0; trait < static_cast<u32>(Trait::Count); trait++)
|
|
|
|
{
|
|
|
|
if (ini.GetBoolValue(section, s_trait_names[trait].first, false))
|
|
|
|
entry->AddTrait(static_cast<Trait>(trait));
|
|
|
|
}
|
|
|
|
|
2020-09-30 13:46:35 +00:00
|
|
|
const char* cvalue = ini.GetValue(section, "CPUOverclockNumerator", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->cpu_overclock_numerator = StringUtil::FromChars<u32>(cvalue);
|
|
|
|
cvalue = ini.GetValue(section, "CPUOverclockDenominator", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->cpu_overclock_denominator = StringUtil::FromChars<u32>(cvalue);
|
|
|
|
cvalue = ini.GetValue(section, "CPUOverclockEnable", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->cpu_overclock_enable = StringUtil::FromChars<bool>(cvalue);
|
|
|
|
|
2020-10-04 14:17:12 +00:00
|
|
|
cvalue = ini.GetValue(section, "CDROMReadSpeedup", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->cdrom_read_speedup = StringUtil::FromChars<u32>(cvalue);
|
|
|
|
|
2020-08-20 11:30:11 +00:00
|
|
|
long lvalue = ini.GetLongValue(section, "DisplayActiveStartOffset", 0);
|
|
|
|
if (lvalue != 0)
|
|
|
|
entry->display_active_start_offset = static_cast<s16>(lvalue);
|
|
|
|
lvalue = ini.GetLongValue(section, "DisplayActiveEndOffset", 0);
|
|
|
|
if (lvalue != 0)
|
2020-12-12 09:00:34 +00:00
|
|
|
entry->display_active_end_offset = static_cast<s16>(lvalue);
|
2020-12-03 12:31:21 +00:00
|
|
|
lvalue = ini.GetLongValue(section, "DisplayLineStartOffset", 0);
|
|
|
|
if (lvalue != 0)
|
|
|
|
entry->display_line_start_offset = static_cast<s8>(lvalue);
|
|
|
|
lvalue = ini.GetLongValue(section, "DisplayLineEndOffset", 0);
|
|
|
|
if (lvalue != 0)
|
2020-12-12 09:00:34 +00:00
|
|
|
entry->display_line_end_offset = static_cast<s8>(lvalue);
|
2020-10-29 13:59:48 +00:00
|
|
|
lvalue = ini.GetLongValue(section, "DMAMaxSliceTicks", 0);
|
|
|
|
if (lvalue > 0)
|
|
|
|
entry->dma_max_slice_ticks = static_cast<u32>(lvalue);
|
|
|
|
lvalue = ini.GetLongValue(section, "DMAHaltTicks", 0);
|
|
|
|
if (lvalue > 0)
|
|
|
|
entry->dma_halt_ticks = static_cast<u32>(lvalue);
|
|
|
|
lvalue = ini.GetLongValue(section, "GPUFIFOSize", 0);
|
|
|
|
if (lvalue > 0)
|
|
|
|
entry->gpu_fifo_size = static_cast<u32>(lvalue);
|
|
|
|
lvalue = ini.GetLongValue(section, "GPUMaxRunAhead", 0);
|
|
|
|
if (lvalue > 0)
|
|
|
|
entry->gpu_max_run_ahead = static_cast<u32>(lvalue);
|
2020-11-26 14:34:25 +00:00
|
|
|
float fvalue = static_cast<float>(ini.GetDoubleValue(section, "GPUPGXPTolerance", -1.0f));
|
|
|
|
if (fvalue >= 0.0f)
|
|
|
|
entry->gpu_pgxp_tolerance = fvalue;
|
2020-12-22 15:11:51 +00:00
|
|
|
fvalue = static_cast<float>(ini.GetDoubleValue(section, "GPUPGXPDepthThreshold", -1.0f));
|
|
|
|
if (fvalue > 0.0f)
|
|
|
|
entry->gpu_pgxp_depth_threshold = fvalue;
|
2020-08-20 11:30:11 +00:00
|
|
|
|
2020-09-30 13:46:35 +00:00
|
|
|
cvalue = ini.GetValue(section, "DisplayCropMode", nullptr);
|
2020-08-20 11:30:11 +00:00
|
|
|
if (cvalue)
|
|
|
|
entry->display_crop_mode = Settings::ParseDisplayCropMode(cvalue);
|
|
|
|
cvalue = ini.GetValue(section, "DisplayAspectRatio", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->display_aspect_ratio = Settings::ParseDisplayAspectRatio(cvalue);
|
2020-09-01 14:00:48 +00:00
|
|
|
cvalue = ini.GetValue(section, "DisplayLinearUpscaling", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->display_linear_upscaling = StringUtil::FromChars<bool>(cvalue);
|
|
|
|
cvalue = ini.GetValue(section, "DisplayIntegerUpscaling", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->display_integer_upscaling = StringUtil::FromChars<bool>(cvalue);
|
2020-09-26 05:21:17 +00:00
|
|
|
cvalue = ini.GetValue(section, "DisplayForce4_3For24Bit", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->display_force_4_3_for_24bit = StringUtil::FromChars<bool>(cvalue);
|
2020-09-01 14:00:48 +00:00
|
|
|
|
|
|
|
cvalue = ini.GetValue(section, "GPUResolutionScale", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->gpu_resolution_scale = StringUtil::FromChars<u32>(cvalue);
|
2020-11-26 14:34:25 +00:00
|
|
|
cvalue = ini.GetValue(section, "GPUMultisamples", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->gpu_multisamples = StringUtil::FromChars<u32>(cvalue);
|
|
|
|
cvalue = ini.GetValue(section, "GPUPerSampleShading", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->gpu_per_sample_shading = StringUtil::FromChars<bool>(cvalue);
|
2020-09-01 14:00:48 +00:00
|
|
|
cvalue = ini.GetValue(section, "GPUTrueColor", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->gpu_true_color = StringUtil::FromChars<bool>(cvalue);
|
|
|
|
cvalue = ini.GetValue(section, "GPUScaledDithering", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->gpu_scaled_dithering = StringUtil::FromChars<bool>(cvalue);
|
|
|
|
cvalue = ini.GetValue(section, "GPUBilinearTextureFiltering", nullptr);
|
|
|
|
if (cvalue)
|
2020-09-11 12:20:19 +00:00
|
|
|
entry->gpu_texture_filter = Settings::ParseTextureFilterName(cvalue);
|
2020-09-01 14:00:48 +00:00
|
|
|
cvalue = ini.GetValue(section, "GPUForceNTSCTimings", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->gpu_force_ntsc_timings = StringUtil::FromChars<bool>(cvalue);
|
|
|
|
cvalue = ini.GetValue(section, "GPUWidescreenHack", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->gpu_widescreen_hack = StringUtil::FromChars<bool>(cvalue);
|
|
|
|
cvalue = ini.GetValue(section, "GPUPGXP", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->gpu_pgxp = StringUtil::FromChars<bool>(cvalue);
|
2020-12-22 15:11:51 +00:00
|
|
|
cvalue = ini.GetValue(section, "GPUPGXPDepthBuffer", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->gpu_pgxp_depth_buffer = StringUtil::FromChars<bool>(cvalue);
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
cvalue = ini.GetValue(section, "Controller1Type", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->controller_1_type = Settings::ParseControllerTypeName(cvalue);
|
|
|
|
cvalue = ini.GetValue(section, "Controller2Type", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->controller_2_type = Settings::ParseControllerTypeName(cvalue);
|
|
|
|
|
2020-09-01 14:00:48 +00:00
|
|
|
cvalue = ini.GetValue(section, "MemoryCard1Type", nullptr);
|
2020-08-20 11:30:11 +00:00
|
|
|
if (cvalue)
|
2020-09-01 14:00:48 +00:00
|
|
|
entry->memory_card_1_type = Settings::ParseMemoryCardTypeName(cvalue);
|
|
|
|
cvalue = ini.GetValue(section, "MemoryCard2Type", nullptr);
|
|
|
|
if (cvalue)
|
|
|
|
entry->memory_card_2_type = Settings::ParseMemoryCardTypeName(cvalue);
|
|
|
|
cvalue = ini.GetValue(section, "MemoryCard1SharedPath");
|
|
|
|
if (cvalue)
|
|
|
|
entry->memory_card_1_shared_path = cvalue;
|
|
|
|
cvalue = ini.GetValue(section, "MemoryCard2SharedPath");
|
|
|
|
if (cvalue)
|
|
|
|
entry->memory_card_2_shared_path = cvalue;
|
2020-10-04 08:20:18 +00:00
|
|
|
cvalue = ini.GetValue(section, "InputProfileName");
|
|
|
|
if (cvalue)
|
|
|
|
entry->input_profile_name = cvalue;
|
2020-08-20 11:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void StoreIniSection(const Entry& entry, const char* section, CSimpleIniA& ini)
|
|
|
|
{
|
|
|
|
for (u32 trait = 0; trait < static_cast<u32>(Trait::Count); trait++)
|
|
|
|
{
|
|
|
|
if (entry.HasTrait(static_cast<Trait>(trait)))
|
|
|
|
ini.SetBoolValue(section, s_trait_names[trait].first, true);
|
|
|
|
}
|
|
|
|
|
2020-09-30 13:46:35 +00:00
|
|
|
if (entry.cpu_overclock_numerator.has_value())
|
|
|
|
ini.SetLongValue(section, "CPUOverclockNumerator", static_cast<long>(entry.cpu_overclock_numerator.value()));
|
|
|
|
if (entry.cpu_overclock_denominator.has_value())
|
|
|
|
ini.SetLongValue(section, "CPUOverclockDenominator", static_cast<long>(entry.cpu_overclock_denominator.value()));
|
|
|
|
if (entry.cpu_overclock_enable.has_value())
|
|
|
|
ini.SetBoolValue(section, "CPUOverclockEnable", entry.cpu_overclock_enable.value());
|
|
|
|
|
2020-10-04 14:17:12 +00:00
|
|
|
if (entry.cdrom_read_speedup.has_value())
|
2020-11-07 14:12:37 +00:00
|
|
|
ini.SetLongValue(section, "CDROMReadSpeedup", static_cast<long>(entry.cdrom_read_speedup.value()));
|
2020-10-04 14:17:12 +00:00
|
|
|
|
2020-08-20 11:30:11 +00:00
|
|
|
if (entry.display_active_start_offset.has_value())
|
|
|
|
ini.SetLongValue(section, "DisplayActiveStartOffset", entry.display_active_start_offset.value());
|
|
|
|
if (entry.display_active_end_offset.has_value())
|
|
|
|
ini.SetLongValue(section, "DisplayActiveEndOffset", entry.display_active_end_offset.value());
|
2020-12-03 12:31:21 +00:00
|
|
|
if (entry.display_line_start_offset.has_value())
|
|
|
|
ini.SetLongValue(section, "DisplayLineStartOffset", entry.display_line_start_offset.value());
|
|
|
|
if (entry.display_line_end_offset.has_value())
|
|
|
|
ini.SetLongValue(section, "DisplayLineEndOffset", entry.display_line_end_offset.value());
|
2020-10-29 13:59:48 +00:00
|
|
|
if (entry.dma_max_slice_ticks.has_value())
|
|
|
|
ini.SetLongValue(section, "DMAMaxSliceTicks", static_cast<long>(entry.dma_max_slice_ticks.value()));
|
|
|
|
if (entry.dma_halt_ticks.has_value())
|
|
|
|
ini.SetLongValue(section, "DMAHaltTicks", static_cast<long>(entry.dma_halt_ticks.value()));
|
|
|
|
if (entry.gpu_fifo_size.has_value())
|
|
|
|
ini.SetLongValue(section, "GPUFIFOSize", static_cast<long>(entry.gpu_fifo_size.value()));
|
|
|
|
if (entry.gpu_max_run_ahead.has_value())
|
|
|
|
ini.SetLongValue(section, "GPUMaxRunAhead", static_cast<long>(entry.gpu_max_run_ahead.value()));
|
2020-11-26 14:34:25 +00:00
|
|
|
if (entry.gpu_pgxp_tolerance.has_value())
|
|
|
|
ini.SetDoubleValue(section, "GPUPGXPTolerance", static_cast<double>(entry.gpu_pgxp_tolerance.value()));
|
2020-12-22 15:11:51 +00:00
|
|
|
if (entry.gpu_pgxp_depth_threshold.has_value())
|
|
|
|
ini.SetDoubleValue(section, "GPUPGXPDepthThreshold", static_cast<double>(entry.gpu_pgxp_depth_threshold.value()));
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
if (entry.display_crop_mode.has_value())
|
|
|
|
ini.SetValue(section, "DisplayCropMode", Settings::GetDisplayCropModeName(entry.display_crop_mode.value()));
|
|
|
|
if (entry.display_aspect_ratio.has_value())
|
|
|
|
{
|
|
|
|
ini.SetValue(section, "DisplayAspectRatio",
|
|
|
|
Settings::GetDisplayAspectRatioName(entry.display_aspect_ratio.value()));
|
|
|
|
}
|
2020-09-01 14:00:48 +00:00
|
|
|
if (entry.display_linear_upscaling.has_value())
|
|
|
|
ini.SetValue(section, "DisplayLinearUpscaling", entry.display_linear_upscaling.value() ? "true" : "false");
|
|
|
|
if (entry.display_integer_upscaling.has_value())
|
|
|
|
ini.SetValue(section, "DisplayIntegerUpscaling", entry.display_integer_upscaling.value() ? "true" : "false");
|
2020-09-26 05:21:17 +00:00
|
|
|
if (entry.display_force_4_3_for_24bit.has_value())
|
|
|
|
ini.SetValue(section, "DisplayForce4_3For24Bit", entry.display_force_4_3_for_24bit.value() ? "true" : "false");
|
2020-09-01 14:00:48 +00:00
|
|
|
|
|
|
|
if (entry.gpu_resolution_scale.has_value())
|
|
|
|
ini.SetLongValue(section, "GPUResolutionScale", static_cast<s32>(entry.gpu_resolution_scale.value()));
|
2020-11-26 14:34:25 +00:00
|
|
|
if (entry.gpu_multisamples.has_value())
|
|
|
|
ini.SetLongValue(section, "GPUMultisamples", static_cast<s32>(entry.gpu_multisamples.value()));
|
|
|
|
if (entry.gpu_per_sample_shading.has_value())
|
|
|
|
ini.SetValue(section, "GPUPerSampleShading", entry.gpu_per_sample_shading.value() ? "true" : "false");
|
2020-09-01 14:00:48 +00:00
|
|
|
if (entry.gpu_true_color.has_value())
|
|
|
|
ini.SetValue(section, "GPUTrueColor", entry.gpu_true_color.value() ? "true" : "false");
|
|
|
|
if (entry.gpu_scaled_dithering.has_value())
|
|
|
|
ini.SetValue(section, "GPUScaledDithering", entry.gpu_scaled_dithering.value() ? "true" : "false");
|
2020-09-11 12:20:19 +00:00
|
|
|
if (entry.gpu_texture_filter.has_value())
|
|
|
|
ini.SetValue(section, "GPUTextureFilter", Settings::GetTextureFilterName(entry.gpu_texture_filter.value()));
|
2020-09-01 14:00:48 +00:00
|
|
|
if (entry.gpu_force_ntsc_timings.has_value())
|
|
|
|
ini.SetValue(section, "GPUForceNTSCTimings", entry.gpu_force_ntsc_timings.value() ? "true" : "false");
|
|
|
|
if (entry.gpu_widescreen_hack.has_value())
|
|
|
|
ini.SetValue(section, "GPUWidescreenHack", entry.gpu_widescreen_hack.value() ? "true" : "false");
|
|
|
|
if (entry.gpu_pgxp.has_value())
|
|
|
|
ini.SetValue(section, "GPUPGXP", entry.gpu_pgxp.value() ? "true" : "false");
|
2020-12-22 15:11:51 +00:00
|
|
|
if (entry.gpu_pgxp_depth_buffer.has_value())
|
|
|
|
ini.SetValue(section, "GPUPGXPDepthBuffer", entry.gpu_pgxp_depth_buffer.value() ? "true" : "false");
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
if (entry.controller_1_type.has_value())
|
|
|
|
ini.SetValue(section, "Controller1Type", Settings::GetControllerTypeName(entry.controller_1_type.value()));
|
|
|
|
if (entry.controller_2_type.has_value())
|
|
|
|
ini.SetValue(section, "Controller2Type", Settings::GetControllerTypeName(entry.controller_2_type.value()));
|
|
|
|
|
2020-09-01 14:00:48 +00:00
|
|
|
if (entry.controller_1_type.has_value())
|
|
|
|
ini.SetValue(section, "Controller1Type", Settings::GetControllerTypeName(entry.controller_1_type.value()));
|
|
|
|
if (entry.controller_2_type.has_value())
|
|
|
|
ini.SetValue(section, "Controller2Type", Settings::GetControllerTypeName(entry.controller_2_type.value()));
|
|
|
|
if (entry.memory_card_1_type.has_value())
|
|
|
|
ini.SetValue(section, "MemoryCard1Type", Settings::GetMemoryCardTypeName(entry.memory_card_1_type.value()));
|
|
|
|
if (entry.memory_card_2_type.has_value())
|
|
|
|
ini.SetValue(section, "MemoryCard2Type", Settings::GetMemoryCardTypeName(entry.memory_card_2_type.value()));
|
|
|
|
if (!entry.memory_card_1_shared_path.empty())
|
|
|
|
ini.SetValue(section, "MemoryCard1SharedPath", entry.memory_card_1_shared_path.c_str());
|
|
|
|
if (!entry.memory_card_2_shared_path.empty())
|
|
|
|
ini.SetValue(section, "MemoryCard2SharedPath", entry.memory_card_2_shared_path.c_str());
|
2020-10-04 08:20:18 +00:00
|
|
|
if (!entry.input_profile_name.empty())
|
|
|
|
ini.SetValue(section, "InputProfileName", entry.input_profile_name.c_str());
|
2020-08-20 11:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Database::Database() = default;
|
|
|
|
|
|
|
|
Database::~Database() = default;
|
|
|
|
|
|
|
|
const GameSettings::Entry* Database::GetEntry(const std::string& code) const
|
|
|
|
{
|
|
|
|
auto it = m_entries.find(code);
|
|
|
|
return (it != m_entries.end()) ? &it->second : nullptr;
|
|
|
|
}
|
|
|
|
|
2020-11-27 07:58:06 +00:00
|
|
|
bool Database::Load(const std::string_view& ini_data)
|
2020-08-20 11:30:11 +00:00
|
|
|
{
|
|
|
|
CSimpleIniA ini;
|
2020-11-27 07:58:06 +00:00
|
|
|
SI_Error err = ini.LoadData(ini_data.data(), ini_data.size());
|
2020-08-20 14:26:14 +00:00
|
|
|
if (err != SI_OK)
|
2020-08-20 11:30:11 +00:00
|
|
|
{
|
|
|
|
Log_ErrorPrintf("Failed to parse game settings ini: %d", static_cast<int>(err));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::list<CSimpleIniA::Entry> sections;
|
|
|
|
ini.GetAllSections(sections);
|
|
|
|
for (const CSimpleIniA::Entry& section_entry : sections)
|
|
|
|
{
|
|
|
|
std::string code(section_entry.pItem);
|
|
|
|
auto it = m_entries.find(code);
|
|
|
|
if (it != m_entries.end())
|
|
|
|
{
|
|
|
|
ParseIniSection(&it->second, code.c_str(), ini);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Entry entry;
|
|
|
|
ParseIniSection(&entry, code.c_str(), ini);
|
|
|
|
m_entries.emplace(std::move(code), std::move(entry));
|
|
|
|
}
|
|
|
|
|
2020-11-27 07:58:06 +00:00
|
|
|
Log_InfoPrintf("Loaded settings for %zu games", sections.size());
|
2020-08-20 11:30:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Database::SetEntry(const std::string& code, const std::string& name, const Entry& entry, const char* save_path)
|
|
|
|
{
|
|
|
|
if (save_path)
|
|
|
|
{
|
|
|
|
CSimpleIniA ini;
|
|
|
|
if (FileSystem::FileExists(save_path))
|
|
|
|
{
|
|
|
|
auto fp = FileSystem::OpenManagedCFile(save_path, "rb");
|
|
|
|
if (fp)
|
|
|
|
{
|
|
|
|
SI_Error err = ini.LoadFile(fp.get());
|
2020-08-20 14:26:14 +00:00
|
|
|
if (err != SI_OK)
|
2020-08-20 11:30:11 +00:00
|
|
|
Log_ErrorPrintf("Failed to parse game settings ini: %d. Contents will be lost.", static_cast<int>(err));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Log_ErrorPrintf("Failed to open existing settings ini: '%s'", save_path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ini.Delete(code.c_str(), nullptr, false);
|
|
|
|
ini.SetValue(code.c_str(), nullptr, nullptr, SmallString::FromFormat("# %s (%s)", code.c_str(), name.c_str()),
|
|
|
|
false);
|
|
|
|
StoreIniSection(entry, code.c_str(), ini);
|
|
|
|
|
|
|
|
const bool did_exist = FileSystem::FileExists(save_path);
|
|
|
|
auto fp = FileSystem::OpenManagedCFile(save_path, "wb");
|
|
|
|
if (fp)
|
|
|
|
{
|
|
|
|
// write file comment so simpleini doesn't get confused
|
|
|
|
if (!did_exist)
|
|
|
|
std::fputs("# DuckStation Game Settings\n\n", fp.get());
|
|
|
|
|
|
|
|
SI_Error err = ini.SaveFile(fp.get());
|
2020-08-20 14:26:14 +00:00
|
|
|
if (err != SI_OK)
|
2020-08-20 11:30:11 +00:00
|
|
|
Log_ErrorPrintf("Failed to save game settings ini: %d", static_cast<int>(err));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Log_ErrorPrintf("Failed to open settings ini for saving: '%s'", save_path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto it = m_entries.find(code);
|
|
|
|
if (it != m_entries.end())
|
|
|
|
it->second = entry;
|
|
|
|
else
|
|
|
|
m_entries.emplace(code, entry);
|
|
|
|
}
|
|
|
|
|
2020-11-27 05:42:22 +00:00
|
|
|
#endif
|
|
|
|
|
2020-08-20 11:30:11 +00:00
|
|
|
void Entry::ApplySettings(bool display_osd_messages) const
|
|
|
|
{
|
|
|
|
constexpr float osd_duration = 10.0f;
|
|
|
|
|
2020-09-30 13:46:35 +00:00
|
|
|
if (cpu_overclock_numerator.has_value())
|
|
|
|
g_settings.cpu_overclock_numerator = cpu_overclock_numerator.value();
|
|
|
|
if (cpu_overclock_denominator.has_value())
|
|
|
|
g_settings.cpu_overclock_denominator = cpu_overclock_denominator.value();
|
|
|
|
if (cpu_overclock_enable.has_value())
|
|
|
|
g_settings.cpu_overclock_enable = cpu_overclock_enable.value();
|
|
|
|
g_settings.UpdateOverclockActive();
|
|
|
|
|
2020-10-04 14:17:12 +00:00
|
|
|
if (cdrom_read_speedup.has_value())
|
|
|
|
g_settings.cdrom_read_speedup = cdrom_read_speedup.value();
|
|
|
|
|
2020-08-20 11:30:11 +00:00
|
|
|
if (display_active_start_offset.has_value())
|
|
|
|
g_settings.display_active_start_offset = display_active_start_offset.value();
|
|
|
|
if (display_active_end_offset.has_value())
|
|
|
|
g_settings.display_active_end_offset = display_active_end_offset.value();
|
2020-12-03 12:31:21 +00:00
|
|
|
if (display_line_start_offset.has_value())
|
|
|
|
g_settings.display_line_start_offset = display_line_start_offset.value();
|
|
|
|
if (display_line_end_offset.has_value())
|
|
|
|
g_settings.display_line_end_offset = display_line_end_offset.value();
|
2020-10-29 13:59:48 +00:00
|
|
|
if (dma_max_slice_ticks.has_value())
|
|
|
|
g_settings.dma_max_slice_ticks = dma_max_slice_ticks.value();
|
|
|
|
if (dma_halt_ticks.has_value())
|
|
|
|
g_settings.dma_halt_ticks = dma_halt_ticks.value();
|
|
|
|
if (gpu_fifo_size.has_value())
|
|
|
|
g_settings.gpu_fifo_size = gpu_fifo_size.value();
|
|
|
|
if (gpu_max_run_ahead.has_value())
|
|
|
|
g_settings.gpu_max_run_ahead = gpu_max_run_ahead.value();
|
2020-11-26 14:34:25 +00:00
|
|
|
if (gpu_pgxp_tolerance.has_value())
|
|
|
|
g_settings.gpu_pgxp_tolerance = gpu_pgxp_tolerance.value();
|
2020-12-22 15:11:51 +00:00
|
|
|
if (gpu_pgxp_depth_threshold.has_value())
|
|
|
|
g_settings.SetPGXPDepthClearThreshold(gpu_pgxp_depth_threshold.value());
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
if (display_crop_mode.has_value())
|
|
|
|
g_settings.display_crop_mode = display_crop_mode.value();
|
|
|
|
if (display_aspect_ratio.has_value())
|
|
|
|
g_settings.display_aspect_ratio = display_aspect_ratio.value();
|
2020-09-01 14:00:48 +00:00
|
|
|
if (display_linear_upscaling.has_value())
|
|
|
|
g_settings.display_linear_filtering = display_linear_upscaling.value();
|
|
|
|
if (display_integer_upscaling.has_value())
|
|
|
|
g_settings.display_integer_scaling = display_integer_upscaling.value();
|
2020-09-26 05:21:17 +00:00
|
|
|
if (display_force_4_3_for_24bit.has_value())
|
|
|
|
g_settings.display_force_4_3_for_24bit = display_force_4_3_for_24bit.value();
|
2020-09-01 14:00:48 +00:00
|
|
|
|
|
|
|
if (gpu_resolution_scale.has_value())
|
|
|
|
g_settings.gpu_resolution_scale = gpu_resolution_scale.value();
|
2020-11-26 14:34:25 +00:00
|
|
|
if (gpu_multisamples.has_value())
|
|
|
|
g_settings.gpu_multisamples = gpu_multisamples.value();
|
|
|
|
if (gpu_per_sample_shading.has_value())
|
|
|
|
g_settings.gpu_per_sample_shading = gpu_per_sample_shading.value();
|
2020-09-01 14:00:48 +00:00
|
|
|
if (gpu_true_color.has_value())
|
|
|
|
g_settings.gpu_true_color = gpu_true_color.value();
|
|
|
|
if (gpu_scaled_dithering.has_value())
|
|
|
|
g_settings.gpu_scaled_dithering = gpu_scaled_dithering.value();
|
|
|
|
if (gpu_force_ntsc_timings.has_value())
|
|
|
|
g_settings.gpu_force_ntsc_timings = gpu_force_ntsc_timings.value();
|
2020-09-11 12:20:19 +00:00
|
|
|
if (gpu_texture_filter.has_value())
|
|
|
|
g_settings.gpu_texture_filter = gpu_texture_filter.value();
|
2020-09-01 14:00:48 +00:00
|
|
|
if (gpu_widescreen_hack.has_value())
|
|
|
|
g_settings.gpu_widescreen_hack = gpu_widescreen_hack.value();
|
|
|
|
if (gpu_pgxp.has_value())
|
|
|
|
g_settings.gpu_pgxp_enable = gpu_pgxp.value();
|
2020-12-22 15:11:51 +00:00
|
|
|
if (gpu_pgxp_depth_buffer.has_value())
|
|
|
|
g_settings.gpu_pgxp_depth_buffer = gpu_pgxp_depth_buffer.value();
|
2020-09-01 14:00:48 +00:00
|
|
|
|
2020-08-20 11:30:11 +00:00
|
|
|
if (controller_1_type.has_value())
|
|
|
|
g_settings.controller_types[0] = controller_1_type.value();
|
|
|
|
if (controller_2_type.has_value())
|
|
|
|
g_settings.controller_types[1] = controller_2_type.value();
|
2020-09-01 14:00:48 +00:00
|
|
|
|
|
|
|
if (memory_card_1_type.has_value())
|
|
|
|
g_settings.memory_card_types[0] = memory_card_1_type.value();
|
|
|
|
if (!memory_card_1_shared_path.empty())
|
|
|
|
g_settings.memory_card_paths[0] = memory_card_1_shared_path;
|
|
|
|
if (memory_card_2_type.has_value())
|
|
|
|
g_settings.memory_card_types[1] = memory_card_2_type.value();
|
|
|
|
if (!memory_card_1_shared_path.empty())
|
|
|
|
g_settings.memory_card_paths[1] = memory_card_2_shared_path;
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
if (HasTrait(Trait::ForceInterpreter))
|
|
|
|
{
|
|
|
|
if (display_osd_messages && g_settings.cpu_execution_mode != CPUExecutionMode::Interpreter)
|
2020-08-29 11:57:29 +00:00
|
|
|
{
|
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "CPU interpreter forced by game settings."), osd_duration);
|
|
|
|
}
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
g_settings.cpu_execution_mode = CPUExecutionMode::Interpreter;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HasTrait(Trait::ForceSoftwareRenderer))
|
|
|
|
{
|
|
|
|
if (display_osd_messages && g_settings.gpu_renderer != GPURenderer::Software)
|
2020-08-29 11:57:29 +00:00
|
|
|
{
|
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "Software renderer forced by game settings."), osd_duration);
|
|
|
|
}
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
g_settings.gpu_renderer = GPURenderer::Software;
|
|
|
|
}
|
|
|
|
|
2020-08-29 11:53:52 +00:00
|
|
|
if (HasTrait(Trait::ForceInterlacing))
|
2020-08-20 11:30:11 +00:00
|
|
|
{
|
|
|
|
if (display_osd_messages && g_settings.gpu_disable_interlacing)
|
2020-08-29 11:57:29 +00:00
|
|
|
{
|
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "Interlacing forced by game settings."), osd_duration);
|
|
|
|
}
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
g_settings.gpu_disable_interlacing = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HasTrait(Trait::DisableTrueColor))
|
|
|
|
{
|
|
|
|
if (display_osd_messages && g_settings.gpu_true_color)
|
2020-08-29 11:57:29 +00:00
|
|
|
{
|
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "True color disabled by game settings."), osd_duration);
|
|
|
|
}
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
g_settings.gpu_true_color = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HasTrait(Trait::DisableUpscaling))
|
|
|
|
{
|
|
|
|
if (display_osd_messages && g_settings.gpu_resolution_scale > 1)
|
2020-08-29 11:57:29 +00:00
|
|
|
{
|
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "Upscaling disabled by game settings."), osd_duration);
|
|
|
|
}
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
g_settings.gpu_resolution_scale = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HasTrait(Trait::DisableScaledDithering))
|
|
|
|
{
|
|
|
|
if (display_osd_messages && g_settings.gpu_scaled_dithering)
|
2020-08-29 11:57:29 +00:00
|
|
|
{
|
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "Scaled dithering disabled by game settings."),
|
|
|
|
osd_duration);
|
|
|
|
}
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
g_settings.gpu_scaled_dithering = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HasTrait(Trait::DisableWidescreen))
|
|
|
|
{
|
|
|
|
if (display_osd_messages &&
|
|
|
|
(g_settings.display_aspect_ratio == DisplayAspectRatio::R16_9 || g_settings.gpu_widescreen_hack))
|
|
|
|
{
|
2020-08-29 11:57:29 +00:00
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "Widescreen disabled by game settings."), osd_duration);
|
2020-08-20 11:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_settings.display_aspect_ratio = DisplayAspectRatio::R4_3;
|
|
|
|
g_settings.gpu_widescreen_hack = false;
|
|
|
|
}
|
|
|
|
|
2020-09-01 14:03:53 +00:00
|
|
|
if (HasTrait(Trait::DisableForceNTSCTimings))
|
|
|
|
{
|
|
|
|
if (display_osd_messages && g_settings.gpu_force_ntsc_timings)
|
|
|
|
{
|
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "Forcing NTSC Timings disallowed by game settings."),
|
|
|
|
osd_duration);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_settings.gpu_force_ntsc_timings = false;
|
|
|
|
}
|
|
|
|
|
2020-08-20 11:30:11 +00:00
|
|
|
if (HasTrait(Trait::DisablePGXP))
|
|
|
|
{
|
|
|
|
if (display_osd_messages && g_settings.gpu_pgxp_enable)
|
2020-08-29 11:57:29 +00:00
|
|
|
{
|
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "PGXP geometry correction disabled by game settings."),
|
|
|
|
osd_duration);
|
|
|
|
}
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
g_settings.gpu_pgxp_enable = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HasTrait(Trait::DisablePGXPCulling))
|
|
|
|
{
|
2020-11-29 15:15:04 +00:00
|
|
|
if (display_osd_messages && g_settings.gpu_pgxp_enable && g_settings.gpu_pgxp_culling)
|
2020-08-29 11:57:29 +00:00
|
|
|
{
|
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "PGXP culling disabled by game settings."), osd_duration);
|
|
|
|
}
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
g_settings.gpu_pgxp_culling = false;
|
|
|
|
}
|
|
|
|
|
2020-09-14 08:20:42 +00:00
|
|
|
if (HasTrait(Trait::DisablePGXPTextureCorrection))
|
|
|
|
{
|
2020-11-29 15:15:04 +00:00
|
|
|
if (display_osd_messages && g_settings.gpu_pgxp_enable && g_settings.gpu_pgxp_texture_correction)
|
2020-09-14 08:20:42 +00:00
|
|
|
{
|
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "PGXP texture correction disabled by game settings."),
|
|
|
|
osd_duration);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_settings.gpu_pgxp_texture_correction = false;
|
|
|
|
}
|
|
|
|
|
2020-08-29 11:53:52 +00:00
|
|
|
if (HasTrait(Trait::ForcePGXPVertexCache))
|
2020-08-20 11:30:11 +00:00
|
|
|
{
|
|
|
|
if (display_osd_messages && g_settings.gpu_pgxp_enable && !g_settings.gpu_pgxp_vertex_cache)
|
2020-08-29 11:57:29 +00:00
|
|
|
{
|
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "PGXP vertex cache forced by game settings."), osd_duration);
|
|
|
|
}
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
g_settings.gpu_pgxp_vertex_cache = true;
|
|
|
|
}
|
|
|
|
|
2020-08-29 11:53:52 +00:00
|
|
|
if (HasTrait(Trait::ForcePGXPCPUMode))
|
2020-08-20 11:30:11 +00:00
|
|
|
{
|
|
|
|
if (display_osd_messages && g_settings.gpu_pgxp_enable && !g_settings.gpu_pgxp_cpu)
|
2020-08-29 11:57:29 +00:00
|
|
|
{
|
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "PGXP CPU mode forced by game settings."), osd_duration);
|
|
|
|
}
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
g_settings.gpu_pgxp_cpu = true;
|
|
|
|
}
|
|
|
|
|
2020-12-22 15:11:51 +00:00
|
|
|
if (HasTrait(Trait::DisablePGXPDepthBuffer))
|
|
|
|
{
|
|
|
|
if (display_osd_messages && g_settings.gpu_pgxp_enable && g_settings.gpu_pgxp_depth_buffer)
|
|
|
|
{
|
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "PGXP Depth Buffer disabled by game settings."),
|
|
|
|
osd_duration);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_settings.gpu_pgxp_depth_buffer = false;
|
|
|
|
}
|
|
|
|
|
2020-12-11 08:59:40 +00:00
|
|
|
if (HasTrait(Trait::DisableAnalogModeForcing))
|
2020-08-20 11:30:11 +00:00
|
|
|
{
|
2020-12-11 08:59:40 +00:00
|
|
|
g_settings.controller_disable_analog_mode_forcing = true;
|
2020-08-20 11:30:11 +00:00
|
|
|
}
|
|
|
|
|
2020-08-29 11:53:52 +00:00
|
|
|
if (HasTrait(Trait::ForceRecompilerMemoryExceptions))
|
2020-08-20 11:30:11 +00:00
|
|
|
{
|
|
|
|
if (display_osd_messages && g_settings.cpu_execution_mode == CPUExecutionMode::Recompiler &&
|
|
|
|
!g_settings.cpu_recompiler_memory_exceptions)
|
|
|
|
{
|
2020-08-29 11:57:29 +00:00
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "Recompiler memory exceptions forced by game settings."),
|
|
|
|
osd_duration);
|
2020-08-20 11:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_settings.cpu_recompiler_memory_exceptions = true;
|
|
|
|
}
|
2020-08-29 12:11:10 +00:00
|
|
|
|
|
|
|
if (HasTrait(Trait::ForceRecompilerICache))
|
|
|
|
{
|
|
|
|
if (display_osd_messages && g_settings.cpu_execution_mode != CPUExecutionMode::Interpreter &&
|
|
|
|
!g_settings.cpu_recompiler_icache)
|
|
|
|
{
|
|
|
|
g_host_interface->AddOSDMessage(
|
|
|
|
g_host_interface->TranslateStdString("OSDMessage", "Recompiler ICache forced by game settings."), osd_duration);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_settings.cpu_recompiler_icache = true;
|
|
|
|
}
|
2020-08-20 11:30:11 +00:00
|
|
|
}
|
|
|
|
|
2020-11-29 15:15:04 +00:00
|
|
|
} // namespace GameSettings
|