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

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

View File

@ -27,3 +27,7 @@ bool gBlockDRCScreenshots = false;
bool gBlockScreenshots = false; bool gBlockScreenshots = false;
bool gInitNotificationModule = 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 gBlockScreenshots;
extern bool gInitNotificationModule; extern bool gInitNotificationModule;
extern bool gCheckIfScreenRendered;
extern uint32_t gReadySinceFramesTV;
extern uint32_t gReadySinceFramesDRC;

View File

@ -139,4 +139,13 @@ void ApplyGameSpecificPatches() {
} else { } else {
gBlockScreenshots = false; 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;
}
} }