From ec00700730c0557fdbfb8add17fc9bd35cde94c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 22 Sep 2026 16:05:15 -0600 Subject: [PATCH] Dialog: Fade in 200ms like the firmware, and accept input while fading in On a PSP, dialog animations advance by animSpeed frames per Update and the fades take about 200ms. Ours took 500ms (1/30 s per animSpeed, over FADE_TIME 1.0), and all input was ignored until it finished, which made dialogs feel sluggish, noticeably so in 30fps games. Input is still ignored while fading out, once a choice has been made. Co-Authored-By: Claude Opus 5.5 (1M context) --- Core/Dialog/PSPDialog.cpp | 15 +++++++++++---- Core/Dialog/PSPDialog.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Core/Dialog/PSPDialog.cpp b/Core/Dialog/PSPDialog.cpp index 9f1aff2c1b..3bf53185b8 100644 --- a/Core/Dialog/PSPDialog.cpp +++ b/Core/Dialog/PSPDialog.cpp @@ -33,7 +33,9 @@ #include "Core/MemMapHelpers.h" #include "Core/Util/PPGeDraw.h" -#define FADE_TIME 1.0 +// In seconds. On a PSP, dialog animations advance by animSpeed frames per Update and take about +// this long. +#define FADE_TIME 0.2 constexpr float FONT_SCALE = 0.55f; @@ -218,7 +220,7 @@ void PSPDialog::StartFade(bool fadeIn_) void PSPDialog::UpdateFade(int animSpeed) { if (isFading) { - fadeTimer += 1.0f/30.0f * animSpeed; // Probably need a more real value of delta time + fadeTimer += animSpeed / 60.0f; if (fadeTimer < FADE_TIME) { if (fadeIn) fadeValue = (u32) (fadeTimer / FADE_TIME * 255); @@ -286,15 +288,20 @@ void PSPDialog::UpdateButtons() buttons = __CtrlReadLatch(); } +// Input is fine while fading in, but not while fading out: the choice has already been made. +bool PSPDialog::IsFadingOut() const { + return isFading && !fadeIn; +} + bool PSPDialog::IsButtonPressed(int checkButton) { - return !isFading && (buttons & checkButton); + return !IsFadingOut() && (buttons & checkButton); } bool PSPDialog::IsButtonHeld(int checkButton, int &framesHeld, int framesHeldThreshold, int framesHeldRepeatRate) { bool btnWasHeldLastFrame = (lastButtons & checkButton) && (__CtrlPeekButtons() & checkButton); - if (!isFading && btnWasHeldLastFrame) { + if (!IsFadingOut() && btnWasHeldLastFrame) { framesHeld++; } else { diff --git a/Core/Dialog/PSPDialog.h b/Core/Dialog/PSPDialog.h index cf79855266..f7fdf787ed 100644 --- a/Core/Dialog/PSPDialog.h +++ b/Core/Dialog/PSPDialog.h @@ -86,6 +86,7 @@ protected: PPGeStyle FadedStyle(PPGeAlign align, float scale); PPGeImageStyle FadedImageStyle(); void UpdateButtons(); + bool IsFadingOut() const; bool IsButtonPressed(int checkButton); bool IsButtonHeld(int checkButton, int &framesHeld, int framesHeldThreshold = 30, int framesHeldRepeatRate = 10); // The caption override is assumed to have a size of 64 bytes.