mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-29 19:30:48 +00:00
Use a time delay to change sceUtility statuses.
This is probably more based on IO (maybe even loading and unloading the module for the dialog or something?) but time should approximate it. May improve games not expecting the status to switch right away.
This commit is contained in:
parent
b03ca7049b
commit
67b1aee1f8
@ -18,6 +18,7 @@
|
||||
#include "i18n/i18n.h"
|
||||
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "Core/CoreTiming.h"
|
||||
#include "Core/HLE/sceCtrl.h"
|
||||
#include "Core/Util/PPGeDraw.h"
|
||||
#include "Core/Dialog/PSPDialog.h"
|
||||
@ -25,9 +26,9 @@
|
||||
#define FADE_TIME 1.0
|
||||
const float FONT_SCALE = 0.55f;
|
||||
|
||||
PSPDialog::PSPDialog() : status(SCE_UTILITY_STATUS_SHUTDOWN)
|
||||
, lastButtons(0)
|
||||
, buttons(0)
|
||||
PSPDialog::PSPDialog()
|
||||
: status(SCE_UTILITY_STATUS_NONE), pendingStatus(SCE_UTILITY_STATUS_NONE),
|
||||
pendingStatusTicks(0), lastButtons(0), buttons(0)
|
||||
{
|
||||
|
||||
}
|
||||
@ -37,14 +38,41 @@ PSPDialog::~PSPDialog() {
|
||||
|
||||
PSPDialog::DialogStatus PSPDialog::GetStatus()
|
||||
{
|
||||
if (pendingStatusTicks != 0 && CoreTiming::GetTicks() >= pendingStatusTicks) {
|
||||
status = pendingStatus;
|
||||
pendingStatusTicks = 0;
|
||||
}
|
||||
|
||||
PSPDialog::DialogStatus retval = status;
|
||||
if (status == SCE_UTILITY_STATUS_SHUTDOWN)
|
||||
status = SCE_UTILITY_STATUS_NONE;
|
||||
if (status == SCE_UTILITY_STATUS_INITIALIZE)
|
||||
status = SCE_UTILITY_STATUS_RUNNING;
|
||||
if (UseAutoStatus()) {
|
||||
if (status == SCE_UTILITY_STATUS_SHUTDOWN)
|
||||
status = SCE_UTILITY_STATUS_NONE;
|
||||
if (status == SCE_UTILITY_STATUS_INITIALIZE)
|
||||
status = SCE_UTILITY_STATUS_RUNNING;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
void PSPDialog::ChangeStatus(DialogStatus newStatus, int delayUs) {
|
||||
if (delayUs <= 0) {
|
||||
status = newStatus;
|
||||
pendingStatusTicks = 0;
|
||||
} else {
|
||||
pendingStatus = newStatus;
|
||||
pendingStatusTicks = CoreTiming::GetTicks() + usToCycles(delayUs);
|
||||
}
|
||||
}
|
||||
|
||||
void PSPDialog::ChangeStatusInit(int delayUs) {
|
||||
status = SCE_UTILITY_STATUS_INITIALIZE;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_RUNNING, delayUs);
|
||||
}
|
||||
|
||||
void PSPDialog::ChangeStatusShutdown(int delayUs) {
|
||||
status = SCE_UTILITY_STATUS_SHUTDOWN;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_NONE, delayUs);
|
||||
}
|
||||
|
||||
void PSPDialog::StartDraw()
|
||||
{
|
||||
PPGeBegin();
|
||||
@ -58,7 +86,7 @@ void PSPDialog::EndDraw()
|
||||
|
||||
int PSPDialog::Shutdown(bool force)
|
||||
{
|
||||
status = SCE_UTILITY_STATUS_SHUTDOWN;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_SHUTDOWN, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -87,7 +115,7 @@ void PSPDialog::UpdateFade(int animSpeed)
|
||||
isFading = false;
|
||||
if (!fadeIn)
|
||||
{
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -102,7 +130,7 @@ u32 PSPDialog::CalcFadedColor(u32 inColor)
|
||||
|
||||
void PSPDialog::DoState(PointerWrap &p)
|
||||
{
|
||||
auto s = p.Section("PSPDialog", 1);
|
||||
auto s = p.Section("PSPDialog", 1, 2);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
@ -117,6 +145,13 @@ void PSPDialog::DoState(PointerWrap &p)
|
||||
p.Do(cancelButtonImg);
|
||||
p.Do(okButtonFlag);
|
||||
p.Do(cancelButtonFlag);
|
||||
|
||||
if (s >= 2) {
|
||||
p.Do(pendingStatus);
|
||||
p.Do(pendingStatusTicks);
|
||||
} else {
|
||||
pendingStatusTicks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pspUtilityDialogCommon *PSPDialog::GetCommonParam()
|
||||
|
@ -83,12 +83,22 @@ protected:
|
||||
bool IsButtonHeld(int checkButton, int &framesHeld, int framesHeldThreshold = 30, int framesHeldRepeatRate = 10);
|
||||
// The caption override is assumed to have a size of 64 bytes.
|
||||
void DisplayButtons(int flags, const char *caption = NULL);
|
||||
void ChangeStatus(DialogStatus newStatus, int delayUs);
|
||||
void ChangeStatusInit(int delayUs);
|
||||
void ChangeStatusShutdown(int delayUs);
|
||||
|
||||
// TODO: Remove this once all dialogs are updated.
|
||||
virtual bool UseAutoStatus() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void StartFade(bool fadeIn_);
|
||||
void UpdateFade(int animSpeed);
|
||||
u32 CalcFadedColor(u32 inColor);
|
||||
|
||||
DialogStatus status;
|
||||
DialogStatus pendingStatus;
|
||||
u64 pendingStatusTicks;
|
||||
|
||||
unsigned int lastButtons;
|
||||
unsigned int buttons;
|
||||
|
@ -28,7 +28,12 @@
|
||||
#include "Core/HW/MemoryStick.h"
|
||||
#include "Core/Dialog/PSPSaveDialog.h"
|
||||
|
||||
const float FONT_SCALE = 0.55f;
|
||||
const static float FONT_SCALE = 0.55f;
|
||||
|
||||
// These are rough, it seems to take at least 100ms or so to init, and shutdown depends on threads.
|
||||
const static int SAVEDATA_INIT_DELAY_US = 100000;
|
||||
const static int SAVEDATA_SHUTDOWN_DELAY_US = 2000;
|
||||
|
||||
|
||||
PSPSaveDialog::PSPSaveDialog()
|
||||
: PSPDialog()
|
||||
@ -56,7 +61,7 @@ int PSPSaveDialog::Init(int paramAddr)
|
||||
Memory::Memcpy(&request, requestAddr, size);
|
||||
Memory::Memcpy(&originalRequest, requestAddr, size);
|
||||
|
||||
u32 retval = param.SetPspParam(&request);
|
||||
int retval = param.SetPspParam(&request);
|
||||
|
||||
INFO_LOG(SCEUTILITY,"sceUtilitySavedataInitStart(%08x) : Mode = %i", paramAddr, (SceUtilitySavedataType)(u32)param.GetPspParam()->mode);
|
||||
|
||||
@ -167,14 +172,18 @@ int PSPSaveDialog::Init(int paramAddr)
|
||||
{
|
||||
ERROR_LOG_REPORT(SCEUTILITY, "Load/Save function %d not coded. Title: %s Save: %s File: %s", (SceUtilitySavedataType)(u32)param.GetPspParam()->mode, param.GetGameName(param.GetPspParam()).c_str(), param.GetGameName(param.GetPspParam()).c_str(), param.GetFileName(param.GetPspParam()).c_str());
|
||||
param.GetPspParam()->common.result = 0;
|
||||
status = SCE_UTILITY_STATUS_INITIALIZE;
|
||||
ChangeStatusInit(SAVEDATA_INIT_DELAY_US);
|
||||
display = DS_NONE;
|
||||
return 0; // Return 0 should allow the game to continue, but missing function must be implemented and returning the right value or the game can block.
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
status = (int)retval < 0 ? SCE_UTILITY_STATUS_SHUTDOWN : SCE_UTILITY_STATUS_INITIALIZE;
|
||||
if (retval < 0) {
|
||||
ChangeStatusShutdown(SAVEDATA_SHUTDOWN_DELAY_US);
|
||||
} else {
|
||||
ChangeStatusInit(SAVEDATA_INIT_DELAY_US);
|
||||
}
|
||||
|
||||
UpdateButtons();
|
||||
StartFade(true);
|
||||
@ -538,7 +547,12 @@ int PSPSaveDialog::Update(int animSpeed)
|
||||
return SCE_ERROR_UTILITY_INVALID_STATUS;
|
||||
|
||||
if (!param.GetPspParam()) {
|
||||
status = SCE_UTILITY_STATUS_SHUTDOWN;
|
||||
ChangeStatusShutdown(SAVEDATA_SHUTDOWN_DELAY_US);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pendingStatus != SCE_UTILITY_STATUS_RUNNING) {
|
||||
// We're actually done, we're just waiting to tell the game that.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -891,7 +905,7 @@ int PSPSaveDialog::Update(int animSpeed)
|
||||
param.GetPspParam()->common.result = 0;
|
||||
else
|
||||
param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_DATA;
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_SAVE: // Only save and exit
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_AUTOSAVE:
|
||||
@ -899,20 +913,20 @@ int PSPSaveDialog::Update(int animSpeed)
|
||||
param.GetPspParam()->common.result = 0;
|
||||
else
|
||||
param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_SAVE_MS_NOSPACE;
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_SIZES:
|
||||
param.GetPspParam()->common.result = param.GetSizes(param.GetPspParam());
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_LIST:
|
||||
param.GetList(param.GetPspParam());
|
||||
param.GetPspParam()->common.result = 0;
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_FILES:
|
||||
param.GetPspParam()->common.result = param.GetFilesList(param.GetPspParam());
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_GETSIZE:
|
||||
{
|
||||
@ -924,13 +938,13 @@ int PSPSaveDialog::Update(int animSpeed)
|
||||
param.GetPspParam()->common.result = 0;
|
||||
else
|
||||
param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA;
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
}
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_DELETEDATA:
|
||||
DEBUG_LOG(SCEUTILITY, "sceUtilitySavedata DELETEDATA: %s", param.GetPspParam()->saveName);
|
||||
param.GetPspParam()->common.result = param.DeleteData(param.GetPspParam());
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
break;
|
||||
//case SCE_UTILITY_SAVEDATA_TYPE_AUTODELETE:
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_SINGLEDELETE:
|
||||
@ -938,7 +952,7 @@ int PSPSaveDialog::Update(int animSpeed)
|
||||
param.GetPspParam()->common.result = 0;
|
||||
else
|
||||
param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_DELETE_NO_DATA;
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
break;
|
||||
// TODO: Should reset the directory's other files.
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_MAKEDATA:
|
||||
@ -947,7 +961,7 @@ int PSPSaveDialog::Update(int animSpeed)
|
||||
param.GetPspParam()->common.result = 0;
|
||||
else
|
||||
param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA;
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_WRITEDATA:
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_WRITEDATASECURE:
|
||||
@ -955,7 +969,7 @@ int PSPSaveDialog::Update(int animSpeed)
|
||||
param.GetPspParam()->common.result = 0;
|
||||
else
|
||||
param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA;
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_READDATA:
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_READDATASECURE:
|
||||
@ -967,20 +981,20 @@ int PSPSaveDialog::Update(int animSpeed)
|
||||
}
|
||||
else
|
||||
param.GetPspParam()->common.result = SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA; // not sure if correct code
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
break;
|
||||
default:
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_FINISHED, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == SCE_UTILITY_STATUS_FINISHED)
|
||||
if (status == SCE_UTILITY_STATUS_FINISHED || pendingStatus == SCE_UTILITY_STATUS_FINISHED)
|
||||
Memory::Memcpy(requestAddr, &request, request.common.size);
|
||||
|
||||
return 0;
|
||||
@ -992,6 +1006,7 @@ int PSPSaveDialog::Shutdown(bool force)
|
||||
return SCE_ERROR_UTILITY_INVALID_STATUS;
|
||||
|
||||
PSPDialog::Shutdown();
|
||||
ChangeStatusShutdown(SAVEDATA_SHUTDOWN_DELAY_US);
|
||||
param.SetPspParam(0);
|
||||
|
||||
return 0;
|
||||
|
@ -73,6 +73,11 @@ public:
|
||||
virtual void DoState(PointerWrap &p);
|
||||
virtual pspUtilityDialogCommon *GetCommonParam();
|
||||
|
||||
protected:
|
||||
virtual bool UseAutoStatus() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void DisplayBanner(int which);
|
||||
|
Loading…
Reference in New Issue
Block a user