Abort taking a screenshot if the target doesn't get rendered

This commit is contained in:
Maschell 2023-01-26 13:23:10 +01:00
parent c0a2308edb
commit 41cc46ca0e
4 changed files with 33 additions and 3 deletions

View File

@ -47,6 +47,7 @@ void RequestScreenshot() {
if (gTakeScreenshotTV == SCREENSHOT_STATE_READY) {
DEBUG_FUNCTION_LINE("Requested screenshot for TV!");
gTakeScreenshotTV = SCREENSHOT_STATE_REQUESTED;
gReadySinceFramesTV = 0;
} else if (!gInProgressNotificationDisplayedTV) {
if ((err = NotificationModule_AddErrorNotificationWithCallback("Screenshot of the TV already in progress.",
AlreadyInProgressCallback,
@ -66,6 +67,7 @@ void RequestScreenshot() {
if (gTakeScreenshotDRC == SCREENSHOT_STATE_READY) {
DEBUG_FUNCTION_LINE("Requested screenshot for DRC!");
gTakeScreenshotDRC = SCREENSHOT_STATE_REQUESTED;
gReadySinceFramesDRC = 0;
} else if (!gInProgressNotificationDisplayedDRC) {
if ((err = NotificationModule_AddErrorNotificationWithCallback("Screenshot of the GamePad already in progress.",
AlreadyInProgressCallback,
@ -149,7 +151,17 @@ DECL_FUNCTION(void, WPADRead, WPADChan chan, WPADStatusProController *data) {
DECL_FUNCTION(void, GX2CopyColorBufferToScanBuffer, const GX2ColorBuffer *colorBuffer, GX2ScanTarget scan_target) {
if (gEnabled) {
if (gCheckIfScreenRendered) {
if (gTakeScreenshotTV == SCREENSHOT_STATE_REQUESTED && ++gReadySinceFramesTV > 5) {
gTakeScreenshotTV = SCREENSHOT_STATE_READY;
gReadySinceFramesTV = 0;
} else if (gTakeScreenshotDRC == SCREENSHOT_STATE_REQUESTED && ++gReadySinceFramesDRC > 5) {
gTakeScreenshotDRC = SCREENSHOT_STATE_READY;
gReadySinceFramesDRC = 0;
}
}
if (scan_target == GX2_SCAN_TARGET_TV && colorBuffer != nullptr && gTakeScreenshotTV == SCREENSHOT_STATE_REQUESTED) {
gReadySinceFramesTV = 0;
DEBUG_FUNCTION_LINE("Lets take a screenshot from TV.");
if (!takeScreenshot((GX2ColorBuffer *) colorBuffer, scan_target, gTVSurfaceFormat, gOutputFormat, gQuality)) {
gTakeScreenshotTV = SCREENSHOT_STATE_READY;
@ -157,6 +169,7 @@ DECL_FUNCTION(void, GX2CopyColorBufferToScanBuffer, const GX2ColorBuffer *colorB
gTakeScreenshotTV = SCREENSHOT_STATE_SAVING;
}
} else if (scan_target == GX2_SCAN_TARGET_DRC0 && colorBuffer != nullptr && gTakeScreenshotDRC == SCREENSHOT_STATE_REQUESTED) {
gReadySinceFramesDRC = 0;
DEBUG_FUNCTION_LINE("Lets take a screenshot from DRC.");
if (!takeScreenshot((GX2ColorBuffer *) colorBuffer, scan_target, gDRCSurfaceFormat, gOutputFormat, gQuality)) {
gTakeScreenshotDRC = SCREENSHOT_STATE_READY;

View File

@ -27,3 +27,7 @@ bool gBlockDRCScreenshots = false;
bool gBlockScreenshots = false;
bool gInitNotificationModule = false;
bool gCheckIfScreenRendered = false;
uint32_t gReadySinceFramesTV = 0;
uint32_t gReadySinceFramesDRC = 0;

View File

@ -30,3 +30,7 @@ extern bool gBlockDRCScreenshots;
extern bool gBlockScreenshots;
extern bool gInitNotificationModule;
extern bool gCheckIfScreenRendered;
extern uint32_t gReadySinceFramesTV;
extern uint32_t gReadySinceFramesDRC;

View File

@ -139,4 +139,13 @@ void ApplyGameSpecificPatches() {
} else {
gBlockScreenshots = false;
}
if (titleID == 0x0005000010138300L || // Donkey Kong Country Tropical Freeze EUR
titleID == 0x0005000010144800L || // Donkey Kong Country Tropical Freeze JPN
titleID == 0x0005000010137F00L // Donkey Kong Country Tropical Freeze USA
) {
gCheckIfScreenRendered = true;
} else {
gCheckIfScreenRendered = false;
}
}