Fix too-slow fade in/out of save dialogs and others in 30hz games.

This commit is contained in:
Henrik Rydgard 2013-10-16 18:54:17 +02:00
parent 66e210315b
commit 1ec0a977e4
15 changed files with 34 additions and 39 deletions

View File

@ -67,23 +67,23 @@ void PSPDialog::StartFade(bool fadeIn_)
fadeIn = fadeIn_;
}
void PSPDialog::UpdateFade()
void PSPDialog::UpdateFade(int animSpeed)
{
if(isFading)
if (isFading)
{
fadeTimer += 1.0f/30.0f; // Probably need a more real value of delta time
if(fadeTimer < FADE_TIME)
fadeTimer += 1.0f/30.0f * animSpeed; // Probably need a more real value of delta time
if (fadeTimer < FADE_TIME)
{
if(fadeIn)
if (fadeIn)
fadeValue = (u32) (fadeTimer / FADE_TIME * 255);
else
fadeValue = 255 - (u32) (fadeTimer / FADE_TIME * 255);
}
else
{
fadeValue = (fadeIn?255:0);
fadeValue = (fadeIn ? 255 : 0);
isFading = false;
if(!fadeIn)
if (!fadeIn)
{
status = SCE_UTILITY_STATUS_FINISHED;
}
@ -98,11 +98,6 @@ u32 PSPDialog::CalcFadedColor(u32 inColor)
return (inColor & 0x00FFFFFF) | (alpha << 24);
}
int PSPDialog::Update()
{
return 0;
}
void PSPDialog::DoState(PointerWrap &p)
{
auto s = p.Section("PSPDialog", 1);

View File

@ -51,7 +51,7 @@ public:
PSPDialog();
virtual ~PSPDialog();
virtual int Update();
virtual int Update(int animSpeed) = 0;
virtual int Shutdown(bool force = false);
virtual void DoState(PointerWrap &p);
virtual pspUtilityDialogCommon *GetCommonParam();
@ -82,7 +82,7 @@ protected:
void DisplayButtons(int flags);
void StartFade(bool fadeIn_);
void UpdateFade();
void UpdateFade(int animSpeed);
u32 CalcFadedColor(u32 inColor);
DialogStatus status;

View File

@ -67,7 +67,7 @@ int PSPGamedataInstallDialog::Init(u32 paramAddr) {
return 0;
}
int PSPGamedataInstallDialog::Update() {
int PSPGamedataInstallDialog::Update(int animSpeed) {
if (status == SCE_UTILITY_STATUS_INITIALIZE){
status = SCE_UTILITY_STATUS_RUNNING;
} else if (status == SCE_UTILITY_STATUS_RUNNING) {

View File

@ -43,7 +43,7 @@ public:
virtual ~PSPGamedataInstallDialog();
virtual int Init(u32 paramAddr);
virtual int Update();
virtual int Update(int animSpeed);
virtual int Shutdown(bool force = false);
virtual void DoState(PointerWrap &p);

View File

@ -204,7 +204,7 @@ void PSPMsgDialog::DisplayMessage(std::string text, bool hasYesNo, bool hasOK)
PPGeDrawRect(40.0f, ey, 440.0f, ey + 1.0f, CalcFadedColor(0xFFFFFFFF));
}
int PSPMsgDialog::Update()
int PSPMsgDialog::Update(int animSpeed)
{
if (status != SCE_UTILITY_STATUS_RUNNING)
{
@ -217,7 +217,7 @@ int PSPMsgDialog::Update()
}
else
{
UpdateFade();
UpdateFade(animSpeed);
buttons = __CtrlPeekButtons();

View File

@ -58,7 +58,7 @@ public:
virtual ~PSPMsgDialog();
virtual int Init(unsigned int paramAddr);
virtual int Update();
virtual int Update(int animSpeed);
virtual int Shutdown(bool force = false);
virtual void DoState(PointerWrap &p);
virtual pspUtilityDialogCommon *GetCommonParam();

View File

@ -39,7 +39,7 @@ int PSPNetconfDialog::Init(u32 paramAddr) {
return 0;
}
int PSPNetconfDialog::Update() {
int PSPNetconfDialog::Update(int animSpeed) {
return 0;
}

View File

@ -40,7 +40,7 @@ public:
virtual ~PSPNetconfDialog();
virtual int Init(u32 paramAddr);
virtual int Update();
virtual int Update(int animSpeed);
virtual int Shutdown(bool force = false);
virtual void DoState(PointerWrap &p);

View File

@ -842,7 +842,7 @@ int PSPOskDialog::NativeKeyboard()
}
#endif
int PSPOskDialog::Update()
int PSPOskDialog::Update(int animSpeed)
{
buttons = __CtrlReadLatch();
int selectedRow = selectedChar / numKeyCols[currentKeyboard];
@ -863,7 +863,7 @@ int PSPOskDialog::Update()
}
else if (status == SCE_UTILITY_STATUS_RUNNING)
{
UpdateFade();
UpdateFade(animSpeed);
StartDraw();
PPGeDrawRect(0, 0, 480, 272, CalcFadedColor(0x63636363));

View File

@ -206,7 +206,7 @@ public:
virtual ~PSPOskDialog();
virtual int Init(u32 oskPtr);
virtual int Update();
virtual int Update(int animSpeed);
virtual int Shutdown(bool force = false);
virtual void DoState(PointerWrap &p);
virtual pspUtilityDialogCommon *GetCommonParam();

View File

@ -31,7 +31,7 @@ int PSPPlaceholderDialog::Init()
return 0;
}
int PSPPlaceholderDialog::Update()
int PSPPlaceholderDialog::Update(int animSpeed)
{
//__UtilityUpdate();
if (status == SCE_UTILITY_STATUS_INITIALIZE)

View File

@ -25,6 +25,6 @@ public:
virtual ~PSPPlaceholderDialog();
virtual int Init();
virtual int Update();
virtual int Update(int animSpeed);
};

View File

@ -523,7 +523,7 @@ void PSPSaveDialog::DisplayMessage(std::string text, bool hasYesNo)
PPGeDrawRect(202.0f, ey, 466.0f, ey + 1.0f, CalcFadedColor(0xFFFFFFFF));
}
int PSPSaveDialog::Update()
int PSPSaveDialog::Update(int animSpeed)
{
switch (status) {
case SCE_UTILITY_STATUS_FINISHED:
@ -553,7 +553,7 @@ int PSPSaveDialog::Update()
}
buttons = __CtrlPeekButtons();
UpdateFade();
UpdateFade(animSpeed);
okButtonImg = I_CIRCLE;
cancelButtonImg = I_CROSS;

View File

@ -68,7 +68,7 @@ public:
virtual ~PSPSaveDialog();
virtual int Init(int paramAddr);
virtual int Update();
virtual int Update(int animSpeed);
virtual int Shutdown(bool force = false);
virtual void DoState(PointerWrap &p);
virtual pspUtilityDialogCommon *GetCommonParam();

View File

@ -160,7 +160,7 @@ int sceUtilitySavedataUpdate(int animSpeed)
}
DEBUG_LOG(SCEUTILITY,"sceUtilitySavedataUpdate(%d)", animSpeed);
int result = saveDialog.Update();
int result = saveDialog.Update(animSpeed);
if (result >= 0)
return hleDelayResult(result, "savedata update", 300);
return result;
@ -281,7 +281,7 @@ int sceUtilityMsgDialogUpdate(int animSpeed)
}
DEBUG_LOG(SCEUTILITY,"sceUtilityMsgDialogUpdate(%i)", animSpeed);
return msgDialog.Update();
return msgDialog.Update(animSpeed);
}
int sceUtilityMsgDialogGetStatus()
@ -349,7 +349,7 @@ int sceUtilityOskUpdate(int animSpeed)
}
DEBUG_LOG(SCEUTILITY, "sceUtilityOskUpdate(%i)", animSpeed);
return oskDialog.Update();
return oskDialog.Update(animSpeed);
}
int sceUtilityOskGetStatus()
@ -401,7 +401,7 @@ int sceUtilityNetconfShutdownStart(unsigned int unknown)
int sceUtilityNetconfUpdate(int animSpeed)
{
ERROR_LOG(SCEUTILITY, "UNIMPL sceUtilityNetconfUpdate(%i)", animSpeed);
return netDialog.Update();
return netDialog.Update(animSpeed);
}
int sceUtilityNetconfGetStatus()
@ -446,7 +446,7 @@ u32 sceUtilityScreenshotShutdownStart()
return screenshotDialog.Shutdown();
}
u32 sceUtilityScreenshotUpdate(u32 unknown)
u32 sceUtilityScreenshotUpdate(u32 animSpeed)
{
if (currentDialogType != UTILITY_DIALOG_SCREENSHOT)
{
@ -454,8 +454,8 @@ u32 sceUtilityScreenshotUpdate(u32 unknown)
return SCE_ERROR_UTILITY_WRONG_TYPE;
}
ERROR_LOG(SCEUTILITY, "UNIMPL sceUtilityScreenshotUpdate(%d)", unknown);
return screenshotDialog.Update();
ERROR_LOG(SCEUTILITY, "UNIMPL sceUtilityScreenshotUpdate(%d)", animSpeed);
return screenshotDialog.Update(animSpeed);
}
int sceUtilityScreenshotGetStatus()
@ -497,15 +497,15 @@ int sceUtilityGamedataInstallShutdownStart() {
return gamedataInstallDialog.Shutdown();
}
int sceUtilityGamedataInstallUpdate(int Speed) {
int sceUtilityGamedataInstallUpdate(int animSpeed) {
if (currentDialogType != UTILITY_DIALOG_GAMEDATAINSTALL)
{
WARN_LOG(SCEUTILITY, "sceUtilityGamedataInstallUpdate(): wrong dialog type");
return SCE_ERROR_UTILITY_WRONG_TYPE;
}
DEBUG_LOG(SCEUTILITY, "sceUtilityGamedataInstallUpdate(%i)", Speed);
return gamedataInstallDialog.Update();
DEBUG_LOG(SCEUTILITY, "sceUtilityGamedataInstallUpdate(%i)", animSpeed);
return gamedataInstallDialog.Update(animSpeed);
}
int sceUtilityGamedataInstallGetStatus()