Files

171 lines
3.9 KiB
C++
Raw Permalink Normal View History

// 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
#include "Config.h"
#include "Patch.h"
#include "common/FPControl.h"
2023-12-26 21:25:10 +10:00
#include <cstring>
#include <optional>
#include <string>
#include <string_view>
#include <unordered_map>
#include <utility>
2020-11-02 18:21:20 -05:00
#include <vector>
2010-06-18 14:27:13 +00:00
enum GamefixId;
namespace GameDatabaseSchema
{
2020-11-02 18:21:20 -05:00
enum class Compatibility
{
2020-11-02 18:21:20 -05:00
Unknown = 0,
Nothing,
Intro,
Menu,
InGame,
Playable,
Perfect
};
enum class ClampMode
{
Undefined = -1,
2020-11-02 18:21:20 -05:00
Disabled = 0,
Normal,
Extra,
Full,
Exact, // eeClampMode only; the VUs stop at Extra+Preserve Sign.
Count
2020-11-02 18:21:20 -05:00
};
enum class GSHWFixId : u32
{
// boolean settings
AutoFlush,
CPUFramebufferConversion,
2023-02-23 21:00:48 +10:00
FlushTCOnClose,
DisableDepthSupport,
PreloadFrameData,
2022-03-18 13:06:26 +00:00
DisablePartialInvalidation,
TextureInsideRT,
2026-01-11 03:08:43 +00:00
Limit24BitDepth,
AlignSprite,
MergeSprite,
Mipmap,
2026-03-19 14:59:30 +00:00
AccurateAlphaTest,
2024-06-08 21:08:01 +01:00
ForceEvenSpritePosition,
BilinearUpscale,
2023-03-31 23:19:07 +10:00
NativePaletteDraw,
EstimateTextureRegion,
2026-02-03 10:13:51 +00:00
DrawBuffering,
2023-03-03 23:04:50 +10:00
PCRTCOffsets,
PCRTCOverscan,
CoalesceRenderPasses,
// integer settings
TrilinearFiltering,
SkipDrawStart,
SkipDrawEnd,
HalfPixelOffset,
RoundSprite,
NativeScaling,
TexturePreloading,
2022-04-03 19:08:56 +02:00
Deinterlace,
CPUSpriteRenderBW,
CPUSpriteRenderLevel,
2022-10-22 11:43:29 +01:00
CPUCLUTRender,
2023-01-03 22:31:03 +10:00
GPUTargetCLUT,
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,
HWDownloadMode,
2023-01-05 22:08:33 +10:00
GetSkipCount,
BeforeDraw,
2023-07-07 21:48:16 +10:00
MoveHandler,
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;
FPRoundMode eeRoundMode = FPRoundMode::MaxCount;
FPRoundMode eeDivRoundMode = FPRoundMode::MaxCount;
FPRoundMode vu0RoundMode = FPRoundMode::MaxCount;
FPRoundMode vu1RoundMode = FPRoundMode::MaxCount;
ClampMode eeClampMode = ClampMode::Undefined;
ClampMode vu0ClampMode = ClampMode::Undefined;
ClampMode vu1ClampMode = ClampMode::Undefined;
std::vector<GamefixId> gameFixes;
2023-07-07 20:24:15 +10:00
std::vector<std::pair<SpeedHack, int>> speedHacks;
std::vector<std::pair<GSHWFixId, s32>> gsHWFixes;
2020-11-02 18:21:20 -05:00
std::vector<std::string> memcardFilters;
std::unordered_map<u32, std::string> patches;
std::vector<Patch::DynamicPatch> dynaPatches;
2020-11-02 18:21:20 -05:00
// Returns the list of memory card serials as a `/` delimited string
std::string memcardFiltersAsString() const;
const std::string* findPatch(u32 crc) const;
const char* compatAsString() const;
/// Applies Core game fixes to an existing config.
void applyGameFixes(Pcsx2Config& config, bool applyAuto) const;
/// 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.
static bool configMatchesHWFix(const Pcsx2Config::GSOptions& config, GSHWFixId id, int value);
2020-11-02 18:21:20 -05:00
};
}; // namespace GameDatabaseSchema
2021-11-06 11:49:18 +10:00
namespace GameDatabase
{
void ensureLoaded();
const GameDatabaseSchema::GameEntry* findGame(const std::string_view serial);
struct TrackHash
{
static constexpr u32 SIZE = 16;
bool parseHash(const std::string_view str);
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