2020-08-20 11:30:11 +00:00
|
|
|
#pragma once
|
2020-09-01 02:29:22 +00:00
|
|
|
#include "core/types.h"
|
2020-08-20 11:30:11 +00:00
|
|
|
#include <bitset>
|
|
|
|
#include <optional>
|
|
|
|
#include <string>
|
2020-11-27 07:58:06 +00:00
|
|
|
#include <string_view>
|
2020-08-20 11:30:11 +00:00
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
class ByteStream;
|
|
|
|
|
|
|
|
namespace GameSettings {
|
|
|
|
enum class Trait : u32
|
|
|
|
{
|
|
|
|
ForceInterpreter,
|
|
|
|
ForceSoftwareRenderer,
|
2021-05-19 04:22:19 +00:00
|
|
|
ForceSoftwareRendererForReadbacks,
|
2020-08-29 11:53:52 +00:00
|
|
|
ForceInterlacing,
|
2020-08-20 11:30:11 +00:00
|
|
|
DisableTrueColor,
|
|
|
|
DisableUpscaling,
|
|
|
|
DisableScaledDithering,
|
2020-09-01 14:03:53 +00:00
|
|
|
DisableForceNTSCTimings,
|
2020-08-20 11:30:11 +00:00
|
|
|
DisableWidescreen,
|
|
|
|
DisablePGXP,
|
|
|
|
DisablePGXPCulling,
|
2020-09-14 08:20:42 +00:00
|
|
|
DisablePGXPTextureCorrection,
|
2020-12-22 15:11:51 +00:00
|
|
|
DisablePGXPDepthBuffer,
|
2020-08-29 11:53:52 +00:00
|
|
|
ForcePGXPVertexCache,
|
|
|
|
ForcePGXPCPUMode,
|
|
|
|
ForceRecompilerMemoryExceptions,
|
2020-08-29 12:11:10 +00:00
|
|
|
ForceRecompilerICache,
|
2021-04-26 17:11:19 +00:00
|
|
|
ForceRecompilerLUTFastmem,
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
Count
|
|
|
|
};
|
|
|
|
|
|
|
|
const char* GetTraitName(Trait trait);
|
|
|
|
const char* GetTraitDisplayName(Trait trait);
|
|
|
|
|
|
|
|
struct Entry
|
|
|
|
{
|
|
|
|
std::bitset<static_cast<int>(Trait::Count)> traits{};
|
|
|
|
std::optional<s16> display_active_start_offset;
|
|
|
|
std::optional<s16> display_active_end_offset;
|
2020-12-03 12:31:21 +00:00
|
|
|
std::optional<s8> display_line_start_offset;
|
|
|
|
std::optional<s8> display_line_end_offset;
|
2020-10-29 13:59:48 +00:00
|
|
|
std::optional<u32> dma_max_slice_ticks;
|
|
|
|
std::optional<u32> dma_halt_ticks;
|
|
|
|
std::optional<u32> gpu_fifo_size;
|
|
|
|
std::optional<u32> gpu_max_run_ahead;
|
2020-11-26 14:34:25 +00:00
|
|
|
std::optional<float> gpu_pgxp_tolerance;
|
2020-12-22 15:11:51 +00:00
|
|
|
std::optional<float> gpu_pgxp_depth_threshold;
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
// user settings
|
2021-01-25 17:12:19 +00:00
|
|
|
std::optional<u32> runahead_frames;
|
2020-09-30 13:46:35 +00:00
|
|
|
std::optional<u32> cpu_overclock_numerator;
|
|
|
|
std::optional<u32> cpu_overclock_denominator;
|
|
|
|
std::optional<bool> cpu_overclock_enable;
|
2021-05-07 17:02:57 +00:00
|
|
|
std::optional<bool> enable_8mb_ram;
|
2020-10-04 14:17:12 +00:00
|
|
|
std::optional<u32> cdrom_read_speedup;
|
2021-05-23 03:44:40 +00:00
|
|
|
std::optional<u32> cdrom_seek_speedup;
|
2020-08-20 11:30:11 +00:00
|
|
|
std::optional<DisplayCropMode> display_crop_mode;
|
|
|
|
std::optional<DisplayAspectRatio> display_aspect_ratio;
|
2021-05-07 17:02:57 +00:00
|
|
|
std::optional<GPURenderer> gpu_renderer;
|
2020-12-30 07:53:51 +00:00
|
|
|
std::optional<GPUDownsampleMode> gpu_downsample_mode;
|
2020-09-01 14:00:48 +00:00
|
|
|
std::optional<bool> display_linear_upscaling;
|
|
|
|
std::optional<bool> display_integer_upscaling;
|
2020-09-26 05:21:17 +00:00
|
|
|
std::optional<bool> display_force_4_3_for_24bit;
|
2021-04-29 16:48:48 +00:00
|
|
|
std::optional<u16> display_aspect_ratio_custom_numerator;
|
|
|
|
std::optional<u16> display_aspect_ratio_custom_denominator;
|
2020-09-01 14:00:48 +00:00
|
|
|
std::optional<u32> gpu_resolution_scale;
|
2020-11-26 14:34:25 +00:00
|
|
|
std::optional<u32> gpu_multisamples;
|
|
|
|
std::optional<bool> gpu_per_sample_shading;
|
2020-09-01 14:00:48 +00:00
|
|
|
std::optional<bool> gpu_true_color;
|
|
|
|
std::optional<bool> gpu_scaled_dithering;
|
|
|
|
std::optional<bool> gpu_force_ntsc_timings;
|
2020-09-11 12:20:19 +00:00
|
|
|
std::optional<GPUTextureFilter> gpu_texture_filter;
|
2020-09-01 14:00:48 +00:00
|
|
|
std::optional<bool> gpu_widescreen_hack;
|
|
|
|
std::optional<bool> gpu_pgxp;
|
2021-02-17 16:19:43 +00:00
|
|
|
std::optional<bool> gpu_pgxp_projection_precision;
|
2020-12-22 15:11:51 +00:00
|
|
|
std::optional<bool> gpu_pgxp_depth_buffer;
|
2021-03-03 11:43:20 +00:00
|
|
|
std::optional<MultitapMode> multitap_mode;
|
2020-08-20 11:30:11 +00:00
|
|
|
std::optional<ControllerType> controller_1_type;
|
|
|
|
std::optional<ControllerType> controller_2_type;
|
2020-09-01 14:00:48 +00:00
|
|
|
std::optional<MemoryCardType> memory_card_1_type;
|
|
|
|
std::optional<MemoryCardType> memory_card_2_type;
|
|
|
|
std::string memory_card_1_shared_path;
|
|
|
|
std::string memory_card_2_shared_path;
|
2020-10-04 08:20:18 +00:00
|
|
|
std::string input_profile_name;
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
ALWAYS_INLINE bool HasTrait(Trait trait) const { return traits[static_cast<int>(trait)]; }
|
|
|
|
ALWAYS_INLINE void AddTrait(Trait trait) { traits[static_cast<int>(trait)] = true; }
|
|
|
|
ALWAYS_INLINE void RemoveTrait(Trait trait) { traits[static_cast<int>(trait)] = false; }
|
|
|
|
ALWAYS_INLINE void SetTrait(Trait trait, bool enabled) { traits[static_cast<int>(trait)] = enabled; }
|
|
|
|
|
|
|
|
bool LoadFromStream(ByteStream* stream);
|
|
|
|
bool SaveToStream(ByteStream* stream) const;
|
|
|
|
|
2021-01-26 04:39:38 +00:00
|
|
|
u32 GetUserSettingsCount() const;
|
|
|
|
|
2020-08-20 11:30:11 +00:00
|
|
|
void ApplySettings(bool display_osd_messages) const;
|
2021-01-03 07:26:51 +00:00
|
|
|
|
|
|
|
// Key-based interface, used by Android.
|
|
|
|
std::optional<std::string> GetValueForKey(const std::string_view& key) const;
|
|
|
|
void SetValueForKey(const std::string_view& key, const std::optional<std::string>& value);
|
2020-08-20 11:30:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Database
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Database();
|
|
|
|
~Database();
|
|
|
|
|
|
|
|
const Entry* GetEntry(const std::string& code) const;
|
|
|
|
void SetEntry(const std::string& code, const std::string& name, const Entry& entry, const char* save_path);
|
|
|
|
|
2020-11-27 07:58:06 +00:00
|
|
|
bool Load(const std::string_view& ini_data);
|
2020-08-20 11:30:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::unordered_map<std::string, Entry> m_entries;
|
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace GameSettings
|