diff --git a/src/main.cpp b/src/main.cpp index 9737730..3b59953 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -41,6 +41,9 @@ ON_APPLICATION_START() { gShortNameEn = GetSanitizedNameOfCurrentApplication(); startFSIOThreads(); + + ApplyGameSpecificPatches(); + VPADSetTVMenuInvalid(VPAD_CHAN_0, true); } diff --git a/src/retain_vars.cpp b/src/retain_vars.cpp index b16a5b7..bbc3386 100644 --- a/src/retain_vars.cpp +++ b/src/retain_vars.cpp @@ -19,4 +19,6 @@ bool gInProgressNotificationDisplayedDRC = false; bool gInProgressNotificationDisplayedTV = false; bool gNotAvailableNotificationDisplayed = false; -NMColor COLOR_RED = {237, 28, 36, 255}; \ No newline at end of file +NMColor COLOR_RED = {237, 28, 36, 255}; + +int32_t gThreadPriorityIncrease = 1; \ No newline at end of file diff --git a/src/retain_vars.hpp b/src/retain_vars.hpp index 15a8d1f..fd13244 100644 --- a/src/retain_vars.hpp +++ b/src/retain_vars.hpp @@ -22,4 +22,6 @@ extern bool gInProgressNotificationDisplayedDRC; extern bool gInProgressNotificationDisplayedTV; extern bool gNotAvailableNotificationDisplayed; -extern NMColor COLOR_RED; \ No newline at end of file +extern NMColor COLOR_RED; + +extern int32_t gThreadPriorityIncrease; \ No newline at end of file diff --git a/src/screenshot_utils.cpp b/src/screenshot_utils.cpp index 301e8c7..8506496 100644 --- a/src/screenshot_utils.cpp +++ b/src/screenshot_utils.cpp @@ -217,7 +217,7 @@ bool takeScreenshot(GX2ColorBuffer *srcBuffer, GX2ScanTarget scanTarget, GX2Surf bool res; - auto threadPriority = OSGetThreadPriority(OSGetCurrentThread()) + 1; + auto threadPriority = OSGetThreadPriority(OSGetCurrentThread()) + gThreadPriorityIncrease; if (threadPriority != OSGetThreadPriority(gThreadData.thread)) { DEBUG_FUNCTION_LINE_ERR("INFO! Set thread priority to %d", threadPriority); if (!OSSetThreadPriority(gThreadData.thread, threadPriority)) { diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index 54e3d60..934d72f 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -1,5 +1,6 @@ #include "StringTools.h" #include "logger.h" +#include "retain_vars.hpp" #include #include #include @@ -76,3 +77,24 @@ std::string GetSanitizedNameOfCurrentApplication() { } return result; } + +void ApplyGameSpecificPatches() { + uint64_t titleID = OSGetTitleID(); + // Mario Kart 8 has noticeable slowdown when taking screenshots in multiplayer + // Decrease the IO thread priority to fix this + if (titleID == 0x000500001010ED00L || // Mario Kart 8 EUR + titleID == 0x000500001010EB00L || // Mario Kart 8 JPN + titleID == 0x000500001010EC00L) { // Mario Kart 8 USA + gThreadPriorityIncrease = 2; + } else if (titleID == 0x0005000010128400L || // Need for Speed™ Most Wanted U EUR + titleID == 0x0005000010128800L || // Need for Speed™ Most Wanted U USA + titleID == 0x000500001012B700L) { // Need for Speed™ Most Wanted U JPN + gThreadPriorityIncrease = 14; + } else if (titleID == 0x0005000010101E00L || // New SUPER MARIO BROS. U EUR + titleID == 0x0005000010101D00L || // New SUPER MARIO BROS. U USA + titleID == 0x0005000010101C00L) { // NNew SUPER MARIO BROS. U JPN + gThreadPriorityIncrease = 2; + } else { + gThreadPriorityIncrease = 1; + } +} \ No newline at end of file diff --git a/src/utils/utils.h b/src/utils/utils.h index b18f614..f83dc35 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -15,3 +15,5 @@ inline uint8_t RGBComponentToSRGB(uint8_t ci) { } std::string GetSanitizedNameOfCurrentApplication(); + +void ApplyGameSpecificPatches();