From 4d79754f781c46164f6b4a9adf1510851474fa07 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Sun, 13 Dec 2020 21:23:28 -0500 Subject: [PATCH] GameDB: Follow the same pattern for Speedhacks as for GameFixes In preparation for #3998 GameDB: Update with current master's GameDB file --- bin/GameIndex.md | 22 ++----- bin/GameIndex.yaml | 114 +++++++++++++++++++++++++++++++++++- pcsx2/Config.h | 18 +++++- pcsx2/GameDatabase.cpp | 27 ++++++--- pcsx2/Patch.cpp | 40 +++++++------ pcsx2/Pcsx2Config.cpp | 55 ++++++++++++----- pcsx2/R3000A.h | 14 ++--- pcsx2/R5900.h | 14 ++--- pcsx2/gui/AppCoreThread.cpp | 36 ++++++------ 9 files changed, 246 insertions(+), 94 deletions(-) diff --git a/bin/GameIndex.md b/bin/GameIndex.md index 3751612238..fa0b617938 100644 --- a/bin/GameIndex.md +++ b/bin/GameIndex.md @@ -30,22 +30,6 @@ SERIAL-12345: # !required! Serial number for the game, this is how games are loo # If a GameFix is included in the list, it will be enabled. # If you'd like to temporarily disable it, either comment out the line, or remove it! gameFixes: - - VuAddSubHack - - FpuCompareHack - - FpuMulHack - - FpuNegDivHack - - XGKickHack - - IPUWaitHack - - EETimingHack - - SkipMPEGHack - - OPHFlagHack - - DMABusyHack - - VIFFIFOHack - - VIF1StallHack - - GIFFIFOHack - - ScarfaceIbitHack - - CrashTagTeamRaci - - VU0KickstartHack - VuAddSubHack - FpuCompareHack - FpuMulHack @@ -63,9 +47,10 @@ SERIAL-12345: # !required! Serial number for the game, this is how games are loo - CrashTagTeamRacingIbitHack - VU0KickstartHack # The value of the speedhacks is assumed to be an integer, - # but at the time of writing there is only one speedhack option and its effectively a boolean (0/1) + # but at the time of writing speedhacks are effectively booleans (0/1) speedHacks: mvuFlagSpeedHack: 0 + InstantVU1SpeedHack: 0 memcardFilters: - "SERIAL-123" - "SERIAL-456" @@ -174,6 +159,9 @@ These values are in a key-value format, where the value is assumed to be an inte - `mvuFlagSpeedHack` - Accepted Values - `0` / `1` - Katamari Damacy have weird speed bug when this speed hack is enabled (and it is by default) +- `InstantVU1SpeedHack` + - Accepted Values - `0` / `1` + - Games such as Parappa the Rapper 2 need VU1 to sync, so you can force disable the speedhack here ## Memory Card Filter Override diff --git a/bin/GameIndex.yaml b/bin/GameIndex.yaml index 0851338af5..edfbc90171 100644 --- a/bin/GameIndex.yaml +++ b/bin/GameIndex.yaml @@ -1238,6 +1238,8 @@ SCES-50408: name: "PaRappa the Rapper 2" region: "PAL-M5" compat: 5 + speedHacks: + InstantVU1SpeedHack: 0 # Fixes noodles. SCES-50409: name: "MotoGP 2" region: "PAL-M5" @@ -3108,6 +3110,8 @@ SCPS-15016: SCPS-15017: name: "PaRappa the Rapper 2" region: "NTSC-J" + speedHacks: + InstantVU1SpeedHack: 0 # Fixes noodles. SCPS-15018: name: "Train Simulator Real, The - Yamanote Sen" region: "NTSC-J" @@ -3605,6 +3609,8 @@ SCPS-19153: SCPS-19201: name: "PaRappa the Rapper 2 [PlayStation 2 The Best]" region: "NTSC-J" + speedHacks: + InstantVU1SpeedHack: 0 # Fixes noodles. SCPS-19202: name: "Extermination [PlayStation 2 The Best]" region: "NTSC-J" @@ -4390,6 +4396,8 @@ SCUS-97167: name: "PaRappa the Rapper 2" region: "NTSC-U" compat: 5 + speedHacks: + InstantVU1SpeedHack: 0 # Fixes noodles. SCUS-97169: name: "Drakan - The Ancients' Gates [Demo]" region: "NTSC-U" @@ -4519,6 +4527,8 @@ SCUS-97206: SCUS-97208: name: "Hot Shots Golf 3 & PaRappa the Rapper 2 [Demo]" region: "NTSC-U" + speedHacks: + InstantVU1SpeedHack: 0 # Fixes noodles on Parappa 2. SCUS-97209: name: "Ratchet & Clank [E3 Demo]" region: "NTSC-U" @@ -5958,6 +5968,8 @@ SLED-52476: SLED-52488: name: "Suffering, The [Demo]" region: "PAL-E" + speedHacks: + InstantVU1SpeedHack: 1 # Fixes SPS. SLED-52597: name: "Burnout 3 - Takedown [Demo]" region: "PAL-E" @@ -6795,6 +6807,8 @@ SLES-50382: name: "Silent Hill 2" region: "PAL-M6" compat: 5 + speedHacks: + InstantVU1SpeedHack: 0 # Fixes hang on FMV's when CDVD timing is accurate. SLES-50383: name: "Metal Gear Solid 2 - Sons of Liberty" region: "PAL-M3" @@ -6928,6 +6942,8 @@ SLES-50446: name: "Shadow Man - 2econd Coming" region: "PAL-M4" compat: 4 + speedHacks: + InstantVU1SpeedHack: 0 # Fixes SPS. SLES-50447: name: "All-Star Baseball 2003" region: "PAL-E" @@ -7187,6 +7203,8 @@ SLES-50606: SLES-50608: name: "Shadow Man - 2econd Coming" region: "PAL-G" + speedHacks: + InstantVU1SpeedHack: 0 # Fixes SPS. SLES-50613: name: "Woody Woodpecker" region: "PAL-M5" @@ -8270,6 +8288,8 @@ SLES-51144: name: "Shox - Rally Reinvented" region: "PAL-M7" compat: 5 + gameFixes: + - VU0KickstartHack # Fixes SPS. SLES-51145: name: "Monopoly Party" region: "PAL-M5" @@ -8295,6 +8315,8 @@ SLES-51156: name: "Silent Hill 2 - Director's Cut" region: "PAL-M5" compat: 5 + speedHacks: + InstantVU1SpeedHack: 0 # Fixes hang on FMV's when CDVD timing is accurate. SLES-51157: name: "Silent Scope 3" region: "PAL-M5" @@ -8477,9 +8499,13 @@ SLES-51250: name: "Shox - Rally Reinvented" region: "PAL-E" compat: 5 + gameFixes: + - VU0KickstartHack # Fixes SPS. SLES-51251: name: "Shox - Rally Reinvented" region: "PAL-E" + gameFixes: + - VU0KickstartHack # Fixes SPS. SLES-51252: name: "Lord of the Rings, The - The Two Towers" region: "PAL-M3" @@ -9243,6 +9269,8 @@ SLES-51690: SLES-51693: name: "Suffering, The" region: "PAL-E-F-G" + speedHacks: + InstantVU1SpeedHack: 1 # Fixes SPS. SLES-51696: name: "Dragon's Lair 3D - Special Edition" region: "PAL-M5" @@ -9885,6 +9913,8 @@ SLES-52001: name: "Mission Impossible - Operation Surma" region: "PAL-M5" compat: 5 + gameFixes: + - VU0KickstartHack # Fixes crashes and broken graphics. SLES-52002: name: "Rogue Ops" region: "PAL-M6" @@ -10598,6 +10628,8 @@ SLES-52439: name: "Suffering, The" region: "PAL-E-I-S" compat: 5 + speedHacks: + InstantVU1SpeedHack: 1 # Fixes SPS. SLES-52440: name: "Harry Potter and the Prisoner of Azkaban" region: "PAL-M7" @@ -10791,6 +10823,8 @@ SLES-52527: SLES-52531: name: "Suffering, The" region: "PAL-G" + speedHacks: + InstantVU1SpeedHack: 1 # Fixes SPS. SLES-52532: name: "Aces of War" region: "PAL-E" @@ -12822,6 +12856,8 @@ SLES-53525: SLES-53526: name: "Suffering, The - Ties that Bind" region: "PAL-E-F" + speedHacks: + InstantVU1SpeedHack: 1 # Fixes SPS. memcardFilters: - "SLES-53526" - "SLES-53527" @@ -12833,6 +12869,8 @@ SLES-53526: SLES-53527: name: "Suffering, The - Ties that Bind" region: "PAL-E-I-S" + speedHacks: + InstantVU1SpeedHack: 1 # Fixes SPS. memcardFilters: - "SLES-53526" - "SLES-53527" @@ -12844,6 +12882,8 @@ SLES-53527: SLES-53528: name: "Suffering, The - Ties that Bind" region: "PAL-G" + speedHacks: + InstantVU1SpeedHack: 1 # Fixes SPS. memcardFilters: - "SLES-53526" - "SLES-53527" @@ -13119,6 +13159,8 @@ SLES-53624: SLES-53626: name: "Suffering, The - Ties that Bind" region: "PAL-E-G" + speedHacks: + InstantVU1SpeedHack: 1 # Fixes SPS. memcardFilters: - "SLES-53526" - "SLES-53527" @@ -18205,12 +18247,16 @@ SLPM-60273: SLPM-61009: name: "Silent Hill 2 (Red Ribbon) [Trial]" region: "NTSC-J" + speedHacks: + InstantVU1SpeedHack: 0 # Fixes hang on FMV's when CDVD timing is accurate. SLPM-61010: name: "Devil May Cry [Trial Version]" region: "NTSC-J" SLPM-61011: name: "Silent Hill 2 (Black Ribbon) [Video Trial]" region: "NTSC-J" + speedHacks: + InstantVU1SpeedHack: 0 # Fixes hang on FMV's when CDVD timing is accurate. SLPM-61051: name: "Dengeki PS2 D61" region: "NTSC-J" @@ -20032,6 +20078,8 @@ SLPM-62736: SLPM-62737: name: "Rally Shox & Freestyle Motorcross [EA Best Hits]" region: "NTSC-J" + gameFixes: + - VU0KickstartHack # Fixes SPS. SLPM-62739: name: "Suro Genjin" region: "NTSC-J" @@ -20339,6 +20387,8 @@ SLPM-65051: name: "Silent Hill 2" region: "NTSC-J" compat: 5 + speedHacks: + InstantVU1SpeedHack: 0 # Fixes hang on FMV's when CDVD timing is accurate. SLPM-65052: name: "Guitar Freaks 4th Mix & Drummania 3rd Mix" region: "NTSC-J" @@ -20499,6 +20549,8 @@ SLPM-65098: name: "Silent Hill 2 - Saigo no Uta" region: "NTSC-J" compat: 5 + speedHacks: + InstantVU1SpeedHack: 0 # Fixes hang on FMV's when CDVD timing is accurate. SLPM-65100: name: "Onimusha 2" region: "NTSC-J" @@ -21158,6 +21210,8 @@ SLPM-65340: SLPM-65341: name: "Silent Hill 2 - Saigo No Uta [Konami The Best]" region: "NTSC-J" + speedHacks: + InstantVU1SpeedHack: 0 # Fixes hang on FMV's when CDVD timing is accurate. SLPM-65342: name: "Kyoufu Shinbun (Heisei) Kaiki! Shinrei File" region: "NTSC-J" @@ -21694,6 +21748,8 @@ SLPM-65527: SLPM-65529: name: "Mission Impossible - Operation Surma" region: "NTSC-J" + gameFixes: + - VU0KickstartHack # Fixes crashes and broken graphics. SLPM-65530: name: "J-League Pro Soccer Club - Tsukuku 2004" region: "NTSC-J" @@ -22009,6 +22065,8 @@ SLPM-65630: SLPM-65631: name: "Silent Hill 2 [Konami The Best]" region: "NTSC-J" + speedHacks: + InstantVU1SpeedHack: 0 # Fixes hang on FMV's when CDVD timing is accurate. SLPM-65632: name: "Virtua Fighter Cyber Generation - Ambition of the Judgement Six" region: "NTSC-J" @@ -23540,6 +23598,13 @@ SLPM-66142: SLPM-66143: name: "Rebirth Moon" region: "NTSC-J" + patches: + 1B139735: + content: |- + author=PSI, Jelta + // Game does weird stack manipulation, causing data sent to the IOP to be corrupted unless EE data cache is enabled. + // This patch skips over the stack code, allowing the game to boot. + patch=1,EE,0023B0C8,word,10000003 SLPM-66144: name: "D1 Grand Prix 2005" region: "NTSC-J" @@ -24028,6 +24093,13 @@ SLPM-66295: SLPM-66296: name: "Yamiyo ni Sasayaku - Tantei Sagara Kyouichirou" region: "NTSC-J" + patches: + 23A9A026: + content: |- + author=PSI, Jelta + // Game does weird stack manipulation, causing data sent to the IOP to be corrupted unless EE data cache is enabled. + // This patch skips over the stack code, allowing the game to boot. + patch=1,EE,00156888,word,10000003 SLPM-66297: name: "Separate Hearts [Limited Edition]" region: "NTSC-J" @@ -24324,6 +24396,13 @@ SLPM-66399: SLPM-66400: name: "Samurai 7" region: "NTSC-J" + patches: + 836F4606: + content: |- + author=PSI, Jelta + // Game does weird stack manipulation, causing data sent to the IOP to be corrupted unless EE data cache is enabled. + // This patch skips over the stack code, allowing the game to boot. + patch=1,EE,00157F78,word,10000003 SLPM-66401: name: "Wrestle Kingdom" region: "NTSC-J" @@ -24496,6 +24575,13 @@ SLPM-66456: SLPM-66457: name: "Asobi ni Iku Yo! Chikyuu Pinchi no Konyaku Sengen" region: "NTSC-J" + patches: + 87FFC318: + content: |- + author=PSI, Jelta + // Game does weird stack manipulation, causing data sent to the IOP to be corrupted unless EE data cache is enabled. + // This patch skips over the stack code, allowing the game to boot. + patch=1,EE,001579D8,word,10000003 SLPM-66458: name: "Acheter Fuuraiki" region: "NTSC-J" @@ -24618,6 +24704,13 @@ SLPM-66494: SLPM-66495: name: "Joshikousei Game's High!" region: "NTSC-J" + patches: + 9FEA4A95: + content: |- + author=PSI, Jelta + // Game does weird stack manipulation, causing data sent to the IOP to be corrupted unless EE data cache is enabled. + // This patch skips over the stack code, allowing the game to boot. + patch=1,EE,00149F18,word,10000003 SLPM-66496: name: "Tom Clancy's Splinter Cell - Chaos Theory" region: "NTSC-J" @@ -24826,6 +24919,13 @@ SLPM-66564: SLPM-66565: name: "REC - DokiDoki Seiyuu Paradise" region: "NTSC-J" + patches: + 17E04DE7: + content: |- + author=PSI, Jelta + // Game does weird stack manipulation, causing data sent to the IOP to be corrupted unless EE data cache is enabled. + // This patch skips over the stack code, allowing the game to boot. + patch=1,EE,001BAA28,word,10000003 SLPM-66566: name: "Tenshou Gakuen Gekkou Hasumi" region: "NTSC-J" @@ -31656,8 +31756,6 @@ SLUS-20217: name: "Arctic Thunder" region: "NTSC-U" compat: 5 - gameFixes: - - SkipMPEGHack SLUS-20218: name: "Stunt GP" region: "NTSC-U" @@ -31716,6 +31814,8 @@ SLUS-20228: name: "Silent Hill 2" region: "NTSC-U" compat: 5 + speedHacks: + InstantVU1SpeedHack: 0 # Fixes hang on FMV's when CDVD timing is accurate. SLUS-20229: name: "Jonny Moseley - Mad Trix" region: "NTSC-U" @@ -32440,6 +32540,8 @@ SLUS-20400: name: "Mission Impossible - Operation Surma" region: "NTSC-U" compat: 5 + gameFixes: + - VU0KickstartHack # Fixes crashes and broken graphics. SLUS-20402: name: "Britney's Dance Beat" region: "NTSC-U" @@ -32479,6 +32581,8 @@ SLUS-20413: name: "Shadow Man - 2econd Coming" region: "NTSC-U" compat: 4 + speedHacks: + InstantVU1SpeedHack: 0 # Fixes SPS. SLUS-20414: name: "Legaia 2 - Duel Saga" region: "NTSC-U" @@ -32977,6 +33081,8 @@ SLUS-20533: name: "Shox" region: "NTSC-U" compat: 5 + gameFixes: + - VU0KickstartHack # Fixes SPS. SLUS-20534: name: "Cabela's Big Game Hunter" region: "NTSC-U" @@ -33403,6 +33509,8 @@ SLUS-20636: name: "Suffering, The" region: "NTSC-U" compat: 5 + speedHacks: + InstantVU1SpeedHack: 1 # Fixes SPS. SLUS-20637: name: "Chessmaster (Online)" region: "NTSC-U" @@ -35706,6 +35814,8 @@ SLUS-21189: name: "Suffering, The - Ties That Bind" region: "NTSC-U" compat: 5 + speedHacks: + InstantVU1SpeedHack: 1 # Fixes SPS. memcardFilters: - "SLUS-21189" - "SLUS-20636" diff --git a/pcsx2/Config.h b/pcsx2/Config.h index 2923450786..8273c9c2e2 100644 --- a/pcsx2/Config.h +++ b/pcsx2/Config.h @@ -62,6 +62,19 @@ enum GamefixId GamefixId_COUNT }; +// TODO - config - not a fan of the excessive use of enums and macros to make them work +// a proper object would likely make more sense (if possible). + +enum SpeedhackId +{ + SpeedhackId_FIRST = 0, + + Speedhack_mvuFlag = SpeedhackId_FIRST, + Speedhack_InstantVU1, + + SpeedhackId_COUNT +}; + enum class VsyncMode { Off, @@ -77,6 +90,7 @@ typename std::underlying_type::type enum_cast(Enumeration E) } ImplementEnumOperators( GamefixId ); +ImplementEnumOperators( SpeedhackId ); //------------ DEFAULT sseMXCSR VALUES --------------- #define DEFAULT_sseMXCSR 0xffc0 //FPU rounding > DaZ, FtZ, "chop" @@ -402,9 +416,11 @@ struct Pcsx2Config u8 EECycleSkip; // EE Cycle skip factor (0, 1, 2, or 3) SpeedhackOptions(); - void LoadSave( IniInterface& conf ); + void LoadSave(IniInterface& conf); SpeedhackOptions& DisableAll(); + void Set(SpeedhackId id, bool enabled = true); + bool operator ==( const SpeedhackOptions& right ) const { return OpEqu( bitset ) && OpEqu( EECycleRate ) && OpEqu( EECycleSkip ); diff --git a/pcsx2/GameDatabase.cpp b/pcsx2/GameDatabase.cpp index c7147adf94..4ae66d0d48 100644 --- a/pcsx2/GameDatabase.cpp +++ b/pcsx2/GameDatabase.cpp @@ -104,9 +104,9 @@ GameDatabaseSchema::GameEntry YamlGameDatabaseImpl::entryFromYaml(const std::str for (std::string& fix : node["gameFixes"].as>(std::vector())) { bool fixValidated = false; - for (GamefixId id = GamefixId_FIRST; id < pxEnumEnd; ++id) + for (GamefixId id = GamefixId_FIRST; id < pxEnumEnd; id++) { - std::string validFix = wxString(EnumToString(id)).Append(L"Hack").ToStdString(); + std::string validFix = fmt::format("{}Hack", wxString(EnumToString(id))); if (validFix == fix) { fixValidated = true; @@ -123,21 +123,30 @@ GameDatabaseSchema::GameEntry YamlGameDatabaseImpl::entryFromYaml(const std::str } } + // Validate speed hacks, invalid ones will be dropped! if (YAML::Node speedHacksNode = node["speedHacks"]) { for (const auto& entry : speedHacksNode) { - // Validate speedhacks, invalid ones will be skipped! std::string speedHack = entry.first.as(); - - // NOTE - currently only 1 speedhack! - if (speedHack != "mvuFlagSpeedHack") + bool speedHackValidated = false; + for (SpeedhackId id = SpeedhackId_FIRST; id < pxEnumEnd; id++) + { + std::string validSpeedHack = fmt::format("{}SpeedHack", wxString(EnumToString(id))); + if (validSpeedHack == speedHack) + { + speedHackValidated = true; + break; + } + } + if (speedHackValidated) + { + gameEntry.speedHacks[speedHack] = entry.second.as(); + } + else { Console.Error(fmt::format("[GameDB] Invalid speedhack: '{}', specified for serial: '{}'. Dropping!", speedHack, serial)); - continue; } - - gameEntry.speedHacks[speedHack] = entry.second.as(); } } diff --git a/pcsx2/Patch.cpp b/pcsx2/Patch.cpp index e0748a2c56..d8715e5e75 100644 --- a/pcsx2/Patch.cpp +++ b/pcsx2/Patch.cpp @@ -41,33 +41,35 @@ wxString strgametitle; struct PatchTextTable { - int code; - const wxChar* text; - PATCHTABLEFUNC* func; + int code; + const wxChar* text; + PATCHTABLEFUNC* func; }; static const PatchTextTable commands_patch[] = - { - {1, L"author", PatchFunc::author}, - {2, L"comment", PatchFunc::comment}, - {3, L"patch", PatchFunc::patch}, - {0, wxEmptyString, NULL} // Array Terminator +{ + { 1, L"author", PatchFunc::author}, + { 2, L"comment", PatchFunc::comment }, + { 3, L"patch", PatchFunc::patch }, + { 0, wxEmptyString, NULL } // Array Terminator }; static const PatchTextTable dataType[] = - { - {1, L"byte", NULL}, - {2, L"short", NULL}, - {3, L"word", NULL}, - {4, L"double", NULL}, - {5, L"extended", NULL}, - {0, wxEmptyString, NULL}}; +{ + { 1, L"byte", NULL }, + { 2, L"short", NULL }, + { 3, L"word", NULL }, + { 4, L"double", NULL }, + { 5, L"extended", NULL }, + { 0, wxEmptyString, NULL } +}; static const PatchTextTable cpuCore[] = - { - {1, L"EE", NULL}, - {2, L"IOP", NULL}, - {0, wxEmptyString, NULL}}; +{ + { 1, L"EE", NULL }, + { 2, L"IOP", NULL }, + { 0, wxEmptyString, NULL } +}; // IniFile Functions. diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index a1375c3765..5a079c1c69 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -35,10 +35,35 @@ void TraceLogFilters::LoadSave( IniInterface& ini ) IniEntry( IOP.bitset ); } +const wxChar* const tbl_SpeedhackNames[] = + { + L"mvuFlag", + L"InstantVU1"}; + +const __fi wxChar* EnumToString(SpeedhackId id) +{ + return tbl_SpeedhackNames[id]; +} + +void Pcsx2Config::SpeedhackOptions::Set(SpeedhackId id, bool enabled) +{ + EnumAssert(id); + switch (id) + { + case Speedhack_mvuFlag: + vuFlagHack = enabled; + break; + case Speedhack_InstantVU1: + vu1Instant = enabled; + break; + jNO_DEFAULT; + } +} + Pcsx2Config::SpeedhackOptions::SpeedhackOptions() { DisableAll(); - + // Set recommended speedhacks to enabled by default. They'll still be off globally on resets. WaitLoop = true; IntcStat = true; @@ -48,25 +73,25 @@ Pcsx2Config::SpeedhackOptions::SpeedhackOptions() Pcsx2Config::SpeedhackOptions& Pcsx2Config::SpeedhackOptions::DisableAll() { - bitset = 0; - EECycleRate = 0; - EECycleSkip = 0; - + bitset = 0; + EECycleRate = 0; + EECycleSkip = 0; + return *this; } -void Pcsx2Config::SpeedhackOptions::LoadSave( IniInterface& ini ) +void Pcsx2Config::SpeedhackOptions::LoadSave(IniInterface& ini) { - ScopedIniGroup path( ini, L"Speedhacks" ); + ScopedIniGroup path(ini, L"Speedhacks"); - IniBitfield( EECycleRate ); - IniBitfield( EECycleSkip ); - IniBitBool( fastCDVD ); - IniBitBool( IntcStat ); - IniBitBool( WaitLoop ); - IniBitBool( vuFlagHack ); - IniBitBool( vuThread ); - IniBitBool( vu1Instant ); + IniBitfield(EECycleRate); + IniBitfield(EECycleSkip); + IniBitBool(fastCDVD); + IniBitBool(IntcStat); + IniBitBool(WaitLoop); + IniBitBool(vuFlagHack); + IniBitBool(vuThread); + IniBitBool(vu1Instant); } void Pcsx2Config::ProfilerOptions::LoadSave( IniInterface& ini ) diff --git a/pcsx2/R3000A.h b/pcsx2/R3000A.h index 1e8c272d40..c57692c583 100644 --- a/pcsx2/R3000A.h +++ b/pcsx2/R3000A.h @@ -135,13 +135,13 @@ extern s32 iopCycleEE; // tracks IOP's current sych status with the EE /**** R3000A Instruction Macros ****/ #define _PC_ psxRegs.pc // The next PC to be executed -#define _Funct_ ((psxRegs.code ) & 0x3F) // The funct part of the instruction register -#define _Rd_ ((psxRegs.code >> 11) & 0x1F) // The rd part of the instruction register -#define _Rt_ ((psxRegs.code >> 16) & 0x1F) // The rt part of the instruction register -#define _Rs_ ((psxRegs.code >> 21) & 0x1F) // The rs part of the instruction register -#define _Sa_ ((psxRegs.code >> 6) & 0x1F) // The sa part of the instruction register -#define _Im_ ((u16)psxRegs.code) // The immediate part of the instruction register -#define _InstrucTarget_ (psxRegs.code & 0x03ffffff) // The target part of the instruction register +#define _Funct_ ((psxRegs.code ) & 0x3F) // The funct part of the instruction register +#define _Rd_ ((psxRegs.code >> 11) & 0x1F) // The rd part of the instruction register +#define _Rt_ ((psxRegs.code >> 16) & 0x1F) // The rt part of the instruction register +#define _Rs_ ((psxRegs.code >> 21) & 0x1F) // The rs part of the instruction register +#define _Sa_ ((psxRegs.code >> 6) & 0x1F) // The sa part of the instruction register +#define _Im_ ((u16)psxRegs.code) // The immediate part of the instruction register +#define _InstrucTarget_ (psxRegs.code & 0x03ffffff) // The target part of the instruction register #define _Imm_ ((short)psxRegs.code) // sign-extended immediate #define _ImmU_ (psxRegs.code&0xffff) // zero-extended immediate diff --git a/pcsx2/R5900.h b/pcsx2/R5900.h index 96924bbbf7..ec1f2c77b8 100644 --- a/pcsx2/R5900.h +++ b/pcsx2/R5900.h @@ -231,13 +231,13 @@ struct tlbs #define _PC_ cpuRegs.pc // The next PC to be executed - only used in this header and R3000A.h -#define _Funct_ ((cpuRegs.code ) & 0x3F) // The funct part of the instruction register -#define _Rd_ ((cpuRegs.code >> 11) & 0x1F) // The rd part of the instruction register -#define _Rt_ ((cpuRegs.code >> 16) & 0x1F) // The rt part of the instruction register -#define _Rs_ ((cpuRegs.code >> 21) & 0x1F) // The rs part of the instruction register -#define _Sa_ ((cpuRegs.code >> 6) & 0x1F) // The sa part of the instruction register -#define _Im_ ((u16)cpuRegs.code) // The immediate part of the instruction register -#define _InstrucTarget_ (cpuRegs.code & 0x03ffffff) // The target part of the instruction register +#define _Funct_ ((cpuRegs.code ) & 0x3F) // The funct part of the instruction register +#define _Rd_ ((cpuRegs.code >> 11) & 0x1F) // The rd part of the instruction register +#define _Rt_ ((cpuRegs.code >> 16) & 0x1F) // The rt part of the instruction register +#define _Rs_ ((cpuRegs.code >> 21) & 0x1F) // The rs part of the instruction register +#define _Sa_ ((cpuRegs.code >> 6) & 0x1F) // The sa part of the instruction register +#define _Im_ ((u16)cpuRegs.code) // The immediate part of the instruction register +#define _InstrucTarget_ (cpuRegs.code & 0x03ffffff) // The target part of the instruction register #define _Imm_ ((s16)cpuRegs.code) // sign-extended immediate #define _ImmU_ (cpuRegs.code&0xffff) // zero-extended immediate diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp index 1fe3971f0a..b058badcd8 100644 --- a/pcsx2/gui/AppCoreThread.cpp +++ b/pcsx2/gui/AppCoreThread.cpp @@ -19,6 +19,7 @@ #include "AppGameDatabase.h" #include +#include "fmt/core.h" #include "Debugger/DisassemblyDialog.h" @@ -255,7 +256,7 @@ static int loadGameSettings(Pcsx2Config& dest, const GameDatabaseSchema::GameEnt SSE_RoundMode eeRM = (SSE_RoundMode)enum_cast(game.eeRoundMode); if (EnumIsValid(eeRM)) { - PatchesCon->WriteLn("(GameDB) Changing EE/FPU roundmode to %d [%s]", eeRM, EnumToString(eeRM)); + PatchesCon->WriteLn(L"(GameDB) Changing EE/FPU roundmode to %d [%s]", eeRM, EnumToString(eeRM)); dest.Cpu.sseMXCSR.SetRoundMode(eeRM); gf++; } @@ -266,7 +267,7 @@ static int loadGameSettings(Pcsx2Config& dest, const GameDatabaseSchema::GameEnt SSE_RoundMode vuRM = (SSE_RoundMode)enum_cast(game.vuRoundMode); if (EnumIsValid(vuRM)) { - PatchesCon->WriteLn("(GameDB) Changing VU0/VU1 roundmode to %d [%s]", vuRM, EnumToString(vuRM)); + PatchesCon->WriteLn(L"(GameDB) Changing VU0/VU1 roundmode to %d [%s]", vuRM, EnumToString(vuRM)); dest.Cpu.sseVUMXCSR.SetRoundMode(vuRM); gf++; } @@ -275,7 +276,7 @@ static int loadGameSettings(Pcsx2Config& dest, const GameDatabaseSchema::GameEnt if (game.eeClampMode != GameDatabaseSchema::ClampMode::Undefined) { int clampMode = enum_cast(game.eeClampMode); - PatchesCon->WriteLn("(GameDB) Changing EE/FPU clamp mode [mode=%d]", clampMode); + PatchesCon->WriteLn(L"(GameDB) Changing EE/FPU clamp mode [mode=%d]", clampMode); dest.Cpu.Recompiler.fpuOverflow = (clampMode >= 1); dest.Cpu.Recompiler.fpuExtraOverflow = (clampMode >= 2); dest.Cpu.Recompiler.fpuFullMode = (clampMode >= 3); @@ -292,26 +293,27 @@ static int loadGameSettings(Pcsx2Config& dest, const GameDatabaseSchema::GameEnt gf++; } - if (game.speedHacks.count("mvuFlagSpeedHack") == 1) + // TODO - config - this could be simplified with maps instead of bitfields and enums + for (SpeedhackId id = SpeedhackId_FIRST; id < pxEnumEnd; id++) { - bool vuFlagHack = game.speedHacks.at("mvuFlagSpeedHack") ? 1 : 0; - PatchesCon->WriteLn("(GameDB) Changing mVU flag speed hack [mode=%d]", vuFlagHack); - dest.Speedhacks.vuFlagHack = vuFlagHack; - gf++; - } + std::string key = fmt::format("{}SpeedHack", wxString(EnumToString(id))); - if (game.keyExists("InstantVU1SpeedHack")) - { - bool vu1InstantHack = game.getInt("InstantVU1SpeedHack") ? 1 : 0; - PatchesCon->WriteLn("(GameDB) Changing Instant VU1 speedhack [mode=%d]", vu1InstantHack); - dest.Speedhacks.vu1Instant = vu1InstantHack; - gf++; + // Gamefixes are already guaranteed to be valid, any invalid ones are dropped + if (game.speedHacks.count(key) == 1) + { + // Legacy note - speedhacks are setup in the GameDB as integer values, but + // are effectively booleans like the gamefixes + bool mode = game.speedHacks.at(key) ? 1: 0; + dest.Speedhacks.Set(id, mode); + PatchesCon->WriteLn(L"(GameDB) Setting Speedhack '" + key + "' to [mode=%d]", mode); + gf++; + } } // TODO - config - this could be simplified with maps instead of bitfields and enums - for (GamefixId id = GamefixId_FIRST; id < pxEnumEnd; ++id) + for (GamefixId id = GamefixId_FIRST; id < pxEnumEnd; id++) { - std::string key = wxString(EnumToString(id)).Append(L"Hack").ToStdString(); + std::string key = fmt::format("{}Hack", wxString(EnumToString(id))); // Gamefixes are already guaranteed to be valid, any invalid ones are dropped if (std::find(game.gameFixes.begin(), game.gameFixes.end(), key) != game.gameFixes.end())