2026-01-12 05:18:12 -05:00
|
|
|
// SPDX-FileCopyrightText: 2002-2026 PCSX2 Dev Team
|
2024-07-30 13:42:36 +02:00
|
|
|
// SPDX-License-Identifier: GPL-3.0+
|
2010-06-18 14:27:13 +00:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-03-03 22:36:05 +10:00
|
|
|
#include "Config.h"
|
2022-12-27 21:33:03 +00:00
|
|
|
#include "Patch.h"
|
2023-12-26 20:25:26 +10:00
|
|
|
|
|
|
|
|
#include "common/FPControl.h"
|
|
|
|
|
|
2023-12-26 21:25:10 +10:00
|
|
|
#include <cstring>
|
2022-03-03 22:36:05 +10:00
|
|
|
#include <optional>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <string_view>
|
2014-07-15 20:55:52 -05:00
|
|
|
#include <unordered_map>
|
2022-09-27 22:57:06 +10:00
|
|
|
#include <utility>
|
2020-11-02 18:21:20 -05:00
|
|
|
#include <vector>
|
2010-06-18 14:27:13 +00:00
|
|
|
|
2021-12-11 12:01:23 +10:00
|
|
|
enum GamefixId;
|
|
|
|
|
|
2022-03-03 22:36:05 +10:00
|
|
|
namespace GameDatabaseSchema
|
2010-06-28 03:05:10 +00:00
|
|
|
{
|
2020-11-02 18:21:20 -05:00
|
|
|
enum class Compatibility
|
2010-06-28 03:05:10 +00:00
|
|
|
{
|
2020-11-02 18:21:20 -05:00
|
|
|
Unknown = 0,
|
|
|
|
|
Nothing,
|
|
|
|
|
Intro,
|
|
|
|
|
Menu,
|
|
|
|
|
InGame,
|
|
|
|
|
Playable,
|
|
|
|
|
Perfect
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class ClampMode
|
|
|
|
|
{
|
2020-11-13 21:26:27 -05:00
|
|
|
Undefined = -1,
|
2020-11-02 18:21:20 -05:00
|
|
|
Disabled = 0,
|
|
|
|
|
Normal,
|
|
|
|
|
Extra,
|
2023-12-26 20:25:26 +10:00
|
|
|
Full,
|
2026-08-15 19:48:03 +02:00
|
|
|
Exact, // eeClampMode only; the VUs stop at Extra+Preserve Sign.
|
2023-12-26 20:25:26 +10:00
|
|
|
Count
|
2020-11-02 18:21:20 -05:00
|
|
|
};
|
|
|
|
|
|
2022-03-03 22:36:05 +10:00
|
|
|
enum class GSHWFixId : u32
|
|
|
|
|
{
|
|
|
|
|
// boolean settings
|
|
|
|
|
AutoFlush,
|
|
|
|
|
CPUFramebufferConversion,
|
2023-02-23 21:00:48 +10:00
|
|
|
FlushTCOnClose,
|
2022-03-03 22:36:05 +10:00
|
|
|
DisableDepthSupport,
|
|
|
|
|
PreloadFrameData,
|
2022-03-18 13:06:26 +00:00
|
|
|
DisablePartialInvalidation,
|
2022-03-03 22:36:05 +10:00
|
|
|
TextureInsideRT,
|
2026-01-11 03:08:43 +00:00
|
|
|
Limit24BitDepth,
|
2022-03-03 22:36:05 +10:00
|
|
|
AlignSprite,
|
|
|
|
|
MergeSprite,
|
2024-05-12 21:12:41 +02:00
|
|
|
Mipmap,
|
2026-03-19 14:59:30 +00:00
|
|
|
AccurateAlphaTest,
|
2024-06-08 21:08:01 +01:00
|
|
|
ForceEvenSpritePosition,
|
2023-03-16 02:50:59 +00:00
|
|
|
BilinearUpscale,
|
2023-03-31 23:19:07 +10:00
|
|
|
NativePaletteDraw,
|
2023-02-15 21:51:34 +10:00
|
|
|
EstimateTextureRegion,
|
2026-02-03 10:13:51 +00:00
|
|
|
DrawBuffering,
|
2023-03-03 23:04:50 +10:00
|
|
|
PCRTCOffsets,
|
|
|
|
|
PCRTCOverscan,
|
2026-07-25 18:17:16 -07:00
|
|
|
CoalesceRenderPasses,
|
2022-03-03 22:36:05 +10:00
|
|
|
|
|
|
|
|
// integer settings
|
|
|
|
|
TrilinearFiltering,
|
|
|
|
|
SkipDrawStart,
|
|
|
|
|
SkipDrawEnd,
|
|
|
|
|
HalfPixelOffset,
|
|
|
|
|
RoundSprite,
|
2024-06-06 16:45:20 +01:00
|
|
|
NativeScaling,
|
2022-03-03 22:36:05 +10:00
|
|
|
TexturePreloading,
|
2022-04-03 19:08:56 +02:00
|
|
|
Deinterlace,
|
2022-06-03 01:00:39 +10:00
|
|
|
CPUSpriteRenderBW,
|
2023-03-19 22:24:29 +10:00
|
|
|
CPUSpriteRenderLevel,
|
2022-10-22 11:43:29 +01:00
|
|
|
CPUCLUTRender,
|
2023-01-03 22:31:03 +10:00
|
|
|
GPUTargetCLUT,
|
2022-08-26 20:11:17 +10:00
|
|
|
GPUPaletteConversion,
|
2023-03-03 23:04:50 +10:00
|
|
|
MinimumBlendingLevel,
|
|
|
|
|
MaximumBlendingLevel,
|
|
|
|
|
RecommendedBlendingLevel,
|
2026-06-15 15:36:58 +01:00
|
|
|
RecommendedAccurateAlphaTest,
|
2026-06-15 16:01:39 +01:00
|
|
|
RecommendedHWAA1,
|
2026-07-22 15:39:25 -04:00
|
|
|
HWDownloadMode,
|
2023-01-05 22:08:33 +10:00
|
|
|
GetSkipCount,
|
|
|
|
|
BeforeDraw,
|
2023-07-07 21:48:16 +10:00
|
|
|
MoveHandler,
|
2022-03-03 22:36:05 +10:00
|
|
|
|
|
|
|
|
Count
|
|
|
|
|
};
|
|
|
|
|
|
2020-11-02 18:21:20 -05:00
|
|
|
struct GameEntry
|
|
|
|
|
{
|
|
|
|
|
std::string name;
|
2023-07-04 16:59:43 -05:00
|
|
|
std::string name_sort;
|
|
|
|
|
std::string name_en;
|
2020-11-02 18:21:20 -05:00
|
|
|
std::string region;
|
|
|
|
|
Compatibility compat = Compatibility::Unknown;
|
2023-12-26 20:25:26 +10:00
|
|
|
FPRoundMode eeRoundMode = FPRoundMode::MaxCount;
|
2024-01-06 00:34:21 +10:00
|
|
|
FPRoundMode eeDivRoundMode = FPRoundMode::MaxCount;
|
2023-12-26 20:25:26 +10:00
|
|
|
FPRoundMode vu0RoundMode = FPRoundMode::MaxCount;
|
|
|
|
|
FPRoundMode vu1RoundMode = FPRoundMode::MaxCount;
|
2020-11-13 21:26:27 -05:00
|
|
|
ClampMode eeClampMode = ClampMode::Undefined;
|
2022-12-28 14:44:34 +10:00
|
|
|
ClampMode vu0ClampMode = ClampMode::Undefined;
|
|
|
|
|
ClampMode vu1ClampMode = ClampMode::Undefined;
|
2021-12-11 12:01:23 +10:00
|
|
|
std::vector<GamefixId> gameFixes;
|
2023-07-07 20:24:15 +10:00
|
|
|
std::vector<std::pair<SpeedHack, int>> speedHacks;
|
2022-03-03 22:36:05 +10:00
|
|
|
std::vector<std::pair<GSHWFixId, s32>> gsHWFixes;
|
2020-11-02 18:21:20 -05:00
|
|
|
std::vector<std::string> memcardFilters;
|
2022-04-12 18:59:59 +10:00
|
|
|
std::unordered_map<u32, std::string> patches;
|
2023-05-26 02:24:01 +10:00
|
|
|
std::vector<Patch::DynamicPatch> dynaPatches;
|
2020-11-02 18:21:20 -05:00
|
|
|
|
2021-01-05 17:44:30 -05:00
|
|
|
// Returns the list of memory card serials as a `/` delimited string
|
2021-12-23 22:00:47 -05:00
|
|
|
std::string memcardFiltersAsString() const;
|
2022-04-12 18:59:59 +10:00
|
|
|
const std::string* findPatch(u32 crc) const;
|
2021-12-23 22:00:47 -05:00
|
|
|
const char* compatAsString() const;
|
2022-03-03 22:36:05 +10:00
|
|
|
|
2023-06-24 04:14:54 +01:00
|
|
|
/// Applies Core game fixes to an existing config.
|
|
|
|
|
void applyGameFixes(Pcsx2Config& config, bool applyAuto) const;
|
2022-03-30 19:46:06 +01:00
|
|
|
|
2023-06-24 04:14:54 +01:00
|
|
|
/// Applies GS hardware fixes to an existing config.
|
|
|
|
|
void applyGSHardwareFixes(Pcsx2Config::GSOptions& config) const;
|
2022-06-29 23:09:04 +10:00
|
|
|
|
|
|
|
|
/// Returns true if the current config value for the specified hw fix id matches the value.
|
2022-08-26 20:11:17 +10:00
|
|
|
static bool configMatchesHWFix(const Pcsx2Config::GSOptions& config, GSHWFixId id, int value);
|
2020-11-02 18:21:20 -05:00
|
|
|
};
|
2022-09-27 22:57:06 +10:00
|
|
|
}; // namespace GameDatabaseSchema
|
2010-06-28 03:05:10 +00:00
|
|
|
|
2021-11-06 11:49:18 +10:00
|
|
|
namespace GameDatabase
|
2010-06-22 18:57:48 +00:00
|
|
|
{
|
2021-12-23 22:00:47 -05:00
|
|
|
void ensureLoaded();
|
2024-05-15 09:42:40 +10:00
|
|
|
const GameDatabaseSchema::GameEntry* findGame(const std::string_view serial);
|
2022-09-27 22:57:06 +10:00
|
|
|
|
|
|
|
|
struct TrackHash
|
|
|
|
|
{
|
|
|
|
|
static constexpr u32 SIZE = 16;
|
|
|
|
|
|
2024-05-15 09:42:40 +10:00
|
|
|
bool parseHash(const std::string_view str);
|
2022-09-27 22:57:06 +10:00
|
|
|
std::string toString() const;
|
|
|
|
|
|
|
|
|
|
#define MAKE_OPERATOR(op) \
|
|
|
|
|
bool operator op(const TrackHash& hash) const { return (std::memcmp(data, hash.data, sizeof(data)) op 0); }
|
|
|
|
|
MAKE_OPERATOR(==);
|
|
|
|
|
MAKE_OPERATOR(!=);
|
|
|
|
|
MAKE_OPERATOR(<);
|
|
|
|
|
MAKE_OPERATOR(<=);
|
|
|
|
|
MAKE_OPERATOR(>);
|
|
|
|
|
MAKE_OPERATOR(>=);
|
|
|
|
|
#undef MAKE_OPERATOR
|
|
|
|
|
|
|
|
|
|
u8 data[SIZE];
|
|
|
|
|
u64 size;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct HashDatabaseEntry
|
|
|
|
|
{
|
|
|
|
|
std::string serial;
|
|
|
|
|
std::string name;
|
|
|
|
|
std::string version;
|
|
|
|
|
std::vector<TrackHash> tracks;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool loadHashDatabase();
|
|
|
|
|
void unloadHashDatabase();
|
|
|
|
|
const HashDatabaseEntry* lookupHash(const TrackHash* tracks, size_t num_tracks, bool* tracks_matched, std::string* match_error);
|
2021-11-06 11:49:18 +10:00
|
|
|
}; // namespace GameDatabase
|