Savedata: Skip and defer texture exist check.
We can skip if there's no UI.
This commit is contained in:
parent
8c1acc30e4
commit
5bed35b293
5 changed files with 78 additions and 24 deletions
|
@ -56,6 +56,29 @@ const static int SAVEDATA_DIALOG_SIZE_V1 = 1480;
|
||||||
const static int SAVEDATA_DIALOG_SIZE_V2 = 1500;
|
const static int SAVEDATA_DIALOG_SIZE_V2 = 1500;
|
||||||
const static int SAVEDATA_DIALOG_SIZE_V3 = 1536;
|
const static int SAVEDATA_DIALOG_SIZE_V3 = 1536;
|
||||||
|
|
||||||
|
static bool IsNotVisibleAction(SceUtilitySavedataType type) {
|
||||||
|
switch (type) {
|
||||||
|
case SCE_UTILITY_SAVEDATA_TYPE_AUTOLOAD:
|
||||||
|
case SCE_UTILITY_SAVEDATA_TYPE_AUTOSAVE:
|
||||||
|
case SCE_UTILITY_SAVEDATA_TYPE_SIZES:
|
||||||
|
case SCE_UTILITY_SAVEDATA_TYPE_LIST:
|
||||||
|
case SCE_UTILITY_SAVEDATA_TYPE_FILES:
|
||||||
|
case SCE_UTILITY_SAVEDATA_TYPE_GETSIZE:
|
||||||
|
case SCE_UTILITY_SAVEDATA_TYPE_MAKEDATASECURE:
|
||||||
|
case SCE_UTILITY_SAVEDATA_TYPE_MAKEDATA:
|
||||||
|
case SCE_UTILITY_SAVEDATA_TYPE_WRITEDATASECURE:
|
||||||
|
case SCE_UTILITY_SAVEDATA_TYPE_WRITEDATA:
|
||||||
|
case SCE_UTILITY_SAVEDATA_TYPE_READDATASECURE:
|
||||||
|
case SCE_UTILITY_SAVEDATA_TYPE_READDATA:
|
||||||
|
case SCE_UTILITY_SAVEDATA_TYPE_DELETEDATA:
|
||||||
|
case SCE_UTILITY_SAVEDATA_TYPE_AUTODELETE:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
PSPSaveDialog::PSPSaveDialog(UtilityDialogType type) : PSPDialog(type) {
|
PSPSaveDialog::PSPSaveDialog(UtilityDialogType type) : PSPDialog(type) {
|
||||||
param.SetPspParam(0);
|
param.SetPspParam(0);
|
||||||
|
@ -87,6 +110,7 @@ int PSPSaveDialog::Init(int paramAddr)
|
||||||
Memory::Memcpy(&request, requestAddr, size);
|
Memory::Memcpy(&request, requestAddr, size);
|
||||||
Memory::Memcpy(&originalRequest, requestAddr, size);
|
Memory::Memcpy(&originalRequest, requestAddr, size);
|
||||||
|
|
||||||
|
param.SetIgnoreTextures(IsNotVisibleAction((SceUtilitySavedataType)(u32)request.mode));
|
||||||
int retval = param.SetPspParam(&request);
|
int retval = param.SetPspParam(&request);
|
||||||
|
|
||||||
const u32 mode = (u32)param.GetPspParam()->mode;
|
const u32 mode = (u32)param.GetPspParam()->mode;
|
||||||
|
@ -345,7 +369,7 @@ void PSPSaveDialog::DisplaySaveList(bool canMove) {
|
||||||
PPGeImageStyle imageStyle = FadedImageStyle();
|
PPGeImageStyle imageStyle = FadedImageStyle();
|
||||||
auto fileInfo = param.GetFileInfo(displayCount);
|
auto fileInfo = param.GetFileInfo(displayCount);
|
||||||
|
|
||||||
if (fileInfo.size == 0 && fileInfo.texture != NULL)
|
if (fileInfo.size == 0 && fileInfo.texture && fileInfo.texture->IsValid())
|
||||||
imageStyle.color = CalcFadedColor(0xFF777777);
|
imageStyle.color = CalcFadedColor(0xFF777777);
|
||||||
|
|
||||||
// Calc save image position on screen
|
// Calc save image position on screen
|
||||||
|
@ -370,7 +394,7 @@ void PSPSaveDialog::DisplaySaveList(bool canMove) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int pad = 0;
|
int pad = 0;
|
||||||
if (fileInfo.texture != nullptr) {
|
if (fileInfo.texture != nullptr && fileInfo.texture->IsValid()) {
|
||||||
fileInfo.texture->SetTexture();
|
fileInfo.texture->SetTexture();
|
||||||
int tw = fileInfo.texture->Width();
|
int tw = fileInfo.texture->Width();
|
||||||
int th = fileInfo.texture->Height();
|
int th = fileInfo.texture->Height();
|
||||||
|
@ -420,7 +444,7 @@ void PSPSaveDialog::DisplaySaveIcon(bool checkExists)
|
||||||
|
|
||||||
int tw = 256;
|
int tw = 256;
|
||||||
int th = 256;
|
int th = 256;
|
||||||
if (curSave.texture != NULL) {
|
if (curSave.texture != nullptr && curSave.texture->IsValid()) {
|
||||||
curSave.texture->SetTexture();
|
curSave.texture->SetTexture();
|
||||||
tw = curSave.texture->Width();
|
tw = curSave.texture->Width();
|
||||||
th = curSave.texture->Height();
|
th = curSave.texture->Height();
|
||||||
|
|
|
@ -1600,15 +1600,14 @@ void SavedataParam::SetFileInfo(SaveFileInfo &saveInfo, PSPFileInfo &info, std::
|
||||||
|
|
||||||
// Search save image icon0
|
// Search save image icon0
|
||||||
// TODO : If icon0 don't exist, need to use icon1 which is a moving icon. Also play sound
|
// TODO : If icon0 don't exist, need to use icon1 which is a moving icon. Also play sound
|
||||||
std::string fileDataPath2 = savePath + saveDir + "/" + ICON0_FILENAME;
|
if (!ignoreTextures_) {
|
||||||
PSPFileInfo info2 = pspFileSystem.GetFileInfo(fileDataPath2);
|
saveInfo.texture = new PPGeImage(savePath + saveDir + "/" + ICON0_FILENAME);
|
||||||
if (info2.exists)
|
}
|
||||||
saveInfo.texture = new PPGeImage(fileDataPath2);
|
|
||||||
|
|
||||||
// Load info in PARAM.SFO
|
// Load info in PARAM.SFO
|
||||||
std::vector<u8> sfoData;
|
std::vector<u8> sfoData;
|
||||||
fileDataPath2 = savePath + saveDir + "/" + SFO_FILENAME;
|
std::string sfoFilename = savePath + saveDir + "/" + SFO_FILENAME;
|
||||||
if (pspFileSystem.ReadEntireFile(fileDataPath2, sfoData) >= 0) {
|
if (pspFileSystem.ReadEntireFile(sfoFilename, sfoData) >= 0) {
|
||||||
ParamSFOData sfoFile;
|
ParamSFOData sfoFile;
|
||||||
if (sfoFile.ReadSFO(sfoData)) {
|
if (sfoFile.ReadSFO(sfoData)) {
|
||||||
SetStringFromSFO(sfoFile, "TITLE", saveInfo.title, sizeof(saveInfo.title));
|
SetStringFromSFO(sfoFile, "TITLE", saveInfo.title, sizeof(saveInfo.title));
|
||||||
|
@ -1859,9 +1858,8 @@ bool SavedataParam::wouldHasMultiSaveName(SceUtilitySavedataParam* param) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SavedataParam::DoState(PointerWrap &p)
|
void SavedataParam::DoState(PointerWrap &p) {
|
||||||
{
|
auto s = p.Section("SavedataParam", 1, 2);
|
||||||
auto s = p.Section("SavedataParam", 1);
|
|
||||||
if (!s)
|
if (!s)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1869,20 +1867,24 @@ void SavedataParam::DoState(PointerWrap &p)
|
||||||
Do(p, selectedSave);
|
Do(p, selectedSave);
|
||||||
Do(p, saveDataListCount);
|
Do(p, saveDataListCount);
|
||||||
Do(p, saveNameListDataCount);
|
Do(p, saveNameListDataCount);
|
||||||
if (p.mode == p.MODE_READ)
|
if (p.mode == p.MODE_READ) {
|
||||||
{
|
|
||||||
if (saveDataList != NULL)
|
if (saveDataList != NULL)
|
||||||
delete [] saveDataList;
|
delete [] saveDataList;
|
||||||
if (saveDataListCount != 0)
|
if (saveDataListCount != 0) {
|
||||||
{
|
|
||||||
saveDataList = new SaveFileInfo[saveDataListCount];
|
saveDataList = new SaveFileInfo[saveDataListCount];
|
||||||
DoArray(p, saveDataList, saveDataListCount);
|
DoArray(p, saveDataList, saveDataListCount);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
saveDataList = NULL;
|
saveDataList = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
DoArray(p, saveDataList, saveDataListCount);
|
DoArray(p, saveDataList, saveDataListCount);
|
||||||
|
|
||||||
|
if (s >= 2) {
|
||||||
|
Do(p, ignoreTextures_);
|
||||||
|
} else {
|
||||||
|
ignoreTextures_ = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SavedataParam::GetSaveCryptMode(SceUtilitySavedataParam *param, const std::string &saveDirName) {
|
int SavedataParam::GetSaveCryptMode(SceUtilitySavedataParam *param, const std::string &saveDirName) {
|
||||||
|
|
|
@ -324,6 +324,9 @@ public:
|
||||||
|
|
||||||
static std::string GetSpaceText(u64 size, bool roundUp);
|
static std::string GetSpaceText(u64 size, bool roundUp);
|
||||||
|
|
||||||
|
void SetIgnoreTextures(bool state) {
|
||||||
|
ignoreTextures_ = state;
|
||||||
|
}
|
||||||
int SetPspParam(SceUtilitySavedataParam* param);
|
int SetPspParam(SceUtilitySavedataParam* param);
|
||||||
SceUtilitySavedataParam *GetPspParam();
|
SceUtilitySavedataParam *GetPspParam();
|
||||||
const SceUtilitySavedataParam *GetPspParam() const;
|
const SceUtilitySavedataParam *GetPspParam() const;
|
||||||
|
@ -379,4 +382,5 @@ private:
|
||||||
SaveFileInfo *noSaveIcon = nullptr;
|
SaveFileInfo *noSaveIcon = nullptr;
|
||||||
int saveDataListCount = 0;
|
int saveDataListCount = 0;
|
||||||
int saveNameListDataCount = 0;
|
int saveNameListDataCount = 0;
|
||||||
|
bool ignoreTextures_ = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1256,11 +1256,11 @@ void PPGeDisableTexture()
|
||||||
std::vector<PPGeImage *> PPGeImage::loadedTextures_;
|
std::vector<PPGeImage *> PPGeImage::loadedTextures_;
|
||||||
|
|
||||||
PPGeImage::PPGeImage(const std::string &pspFilename)
|
PPGeImage::PPGeImage(const std::string &pspFilename)
|
||||||
: filename_(pspFilename), texture_(0) {
|
: filename_(pspFilename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PPGeImage::PPGeImage(u32 pngPointer, size_t pngSize)
|
PPGeImage::PPGeImage(u32 pngPointer, size_t pngSize)
|
||||||
: filename_(""), png_(pngPointer), size_(pngSize), texture_(0) {
|
: filename_(""), png_(pngPointer), size_(pngSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PPGeImage::~PPGeImage() {
|
PPGeImage::~PPGeImage() {
|
||||||
|
@ -1268,6 +1268,7 @@ PPGeImage::~PPGeImage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PPGeImage::Load() {
|
bool PPGeImage::Load() {
|
||||||
|
loadFailed_ = false;
|
||||||
Free();
|
Free();
|
||||||
|
|
||||||
// In case it fails to load.
|
// In case it fails to load.
|
||||||
|
@ -1281,7 +1282,8 @@ bool PPGeImage::Load() {
|
||||||
} else {
|
} else {
|
||||||
std::vector<u8> pngData;
|
std::vector<u8> pngData;
|
||||||
if (pspFileSystem.ReadEntireFile(filename_, pngData) < 0) {
|
if (pspFileSystem.ReadEntireFile(filename_, pngData) < 0) {
|
||||||
WARN_LOG(SCEGE, "Bad PPGeImage - cannot load file");
|
WARN_LOG(SCEGE, "PPGeImage cannot load file %s", filename_.c_str());
|
||||||
|
loadFailed_ = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1289,6 +1291,7 @@ bool PPGeImage::Load() {
|
||||||
}
|
}
|
||||||
if (!success) {
|
if (!success) {
|
||||||
WARN_LOG(SCEGE, "Bad PPGeImage - not a valid png");
|
WARN_LOG(SCEGE, "Bad PPGeImage - not a valid png");
|
||||||
|
loadFailed_ = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1298,6 +1301,7 @@ bool PPGeImage::Load() {
|
||||||
if (texture_ == 0) {
|
if (texture_ == 0) {
|
||||||
free(textureData);
|
free(textureData);
|
||||||
WARN_LOG(SCEGE, "Bad PPGeImage - unable to allocate space for texture");
|
WARN_LOG(SCEGE, "Bad PPGeImage - unable to allocate space for texture");
|
||||||
|
// Don't set loadFailed_ here, we'll try again if there's more memory later.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1310,16 +1314,28 @@ bool PPGeImage::Load() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PPGeImage::IsValid() {
|
||||||
|
if (loadFailed_)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (texture_ == 0) {
|
||||||
|
Decimate();
|
||||||
|
return Load();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void PPGeImage::Free() {
|
void PPGeImage::Free() {
|
||||||
if (texture_ != 0) {
|
if (texture_ != 0) {
|
||||||
kernelMemory.Free(texture_);
|
kernelMemory.Free(texture_);
|
||||||
texture_ = 0;
|
texture_ = 0;
|
||||||
loadedTextures_.erase(std::remove(loadedTextures_.begin(), loadedTextures_.end(), this), loadedTextures_.end());
|
loadedTextures_.erase(std::remove(loadedTextures_.begin(), loadedTextures_.end(), this), loadedTextures_.end());
|
||||||
|
loadFailed_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPGeImage::DoState(PointerWrap &p) {
|
void PPGeImage::DoState(PointerWrap &p) {
|
||||||
auto s = p.Section("PPGeImage", 1);
|
auto s = p.Section("PPGeImage", 1, 2);
|
||||||
if (!s)
|
if (!s)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1330,6 +1346,11 @@ void PPGeImage::DoState(PointerWrap &p) {
|
||||||
Do(p, width_);
|
Do(p, width_);
|
||||||
Do(p, height_);
|
Do(p, height_);
|
||||||
Do(p, lastFrame_);
|
Do(p, lastFrame_);
|
||||||
|
if (s >= 2) {
|
||||||
|
Do(p, loadFailed_);
|
||||||
|
} else {
|
||||||
|
loadFailed_ = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPGeImage::CompatLoad(u32 texture, int width, int height) {
|
void PPGeImage::CompatLoad(u32 texture, int width, int height) {
|
||||||
|
@ -1337,6 +1358,7 @@ void PPGeImage::CompatLoad(u32 texture, int width, int height) {
|
||||||
texture_ = texture;
|
texture_ = texture;
|
||||||
width_ = width;
|
width_ = width;
|
||||||
height_ = height;
|
height_ = height;
|
||||||
|
loadFailed_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPGeImage::Decimate(int age) {
|
void PPGeImage::Decimate(int age) {
|
||||||
|
@ -1351,7 +1373,7 @@ void PPGeImage::Decimate(int age) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPGeImage::SetTexture() {
|
void PPGeImage::SetTexture() {
|
||||||
if (texture_ == 0) {
|
if (texture_ == 0 && !loadFailed_) {
|
||||||
Decimate();
|
Decimate();
|
||||||
Load();
|
Load();
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,7 @@ public:
|
||||||
// Does not normally need to be called (except to force preloading.)
|
// Does not normally need to be called (except to force preloading.)
|
||||||
bool Load();
|
bool Load();
|
||||||
void Free();
|
void Free();
|
||||||
|
bool IsValid();
|
||||||
|
|
||||||
void DoState(PointerWrap &p);
|
void DoState(PointerWrap &p);
|
||||||
|
|
||||||
|
@ -147,11 +148,12 @@ private:
|
||||||
u32 png_;
|
u32 png_;
|
||||||
size_t size_;
|
size_t size_;
|
||||||
|
|
||||||
u32 texture_;
|
u32 texture_ = 0;
|
||||||
int width_;
|
int width_;
|
||||||
int height_;
|
int height_;
|
||||||
|
|
||||||
int lastFrame_;
|
int lastFrame_;
|
||||||
|
bool loadFailed_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
void PPGeDrawRect(float x1, float y1, float x2, float y2, u32 color);
|
void PPGeDrawRect(float x1, float y1, float x2, float y2, u32 color);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue