mirror of
https://github.com/libretro/ppsspp.git
synced 2025-04-03 20:21:34 +00:00
Merge pull request #1016 from unknownbrackets/savedata
Implement some of savedata GETSIZE and DELETEDATA
This commit is contained in:
commit
3ffffb3670
@ -21,6 +21,7 @@
|
||||
#include "../Core/MemMap.h"
|
||||
#include "../Config.h"
|
||||
#include "Core/Reporting.h"
|
||||
#include "Core/HW/MemoryStick.h"
|
||||
|
||||
PSPSaveDialog::PSPSaveDialog()
|
||||
: PSPDialog()
|
||||
@ -91,6 +92,7 @@ int PSPSaveDialog::Init(int paramAddr)
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_WRITEDATASECURE:
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_READDATASECURE:
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_SINGLEDELETE:
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_DELETEDATA:
|
||||
display = DS_NONE;
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_DELETE: // This run on PSP display a list of all save on the PSP. Weird. (Not really, it's to let you free up space)
|
||||
@ -729,14 +731,23 @@ int PSPSaveDialog::Update()
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_GETSIZE:
|
||||
if(param.GetSize(param.GetPspParam()))
|
||||
{
|
||||
param.GetPspParam()->result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
param.GetPspParam()->result = SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA;
|
||||
bool result = param.GetSize(param.GetPspParam());
|
||||
// TODO: According to JPCSP, should test/verify this part but seems edge casey.
|
||||
if (MemoryStick_State() != PSP_MEMORYSTICK_STATE_DRIVER_READY)
|
||||
param.GetPspParam()->result = SCE_UTILITY_SAVEDATA_ERROR_RW_NO_MEMSTICK;
|
||||
else if (result)
|
||||
param.GetPspParam()->result = 0;
|
||||
else
|
||||
param.GetPspParam()->result = SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA;
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
}
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_DELETEDATA:
|
||||
// TODO: This should probably actually delete something.
|
||||
// For now, since MAKEDATA doesn't work anyway, always say it couldn't be deleted.
|
||||
WARN_LOG(HLE, "FAKE sceUtilitySavedata DELETEDATA: %s", param.GetPspParam()->saveName);
|
||||
param.GetPspParam()->result = SCE_UTILITY_SAVEDATA_ERROR_RW_BAD_STATUS;
|
||||
status = SCE_UTILITY_STATUS_FINISHED;
|
||||
break;
|
||||
case SCE_UTILITY_SAVEDATA_TYPE_SINGLEDELETE:
|
||||
|
@ -30,7 +30,9 @@
|
||||
#define SCE_UTILITY_SAVEDATA_ERROR_LOAD_PARAM (0x80110308)
|
||||
#define SCE_UTILITY_SAVEDATA_ERROR_LOAD_INTERNAL (0x8011030b)
|
||||
|
||||
#define SCE_UTILITY_SAVEDATA_ERROR_RW_NO_MEMSTICK (0x80110321)
|
||||
#define SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA (0x80110327)
|
||||
#define SCE_UTILITY_SAVEDATA_ERROR_RW_BAD_STATUS (0x8011032c)
|
||||
|
||||
#define SCE_UTILITY_SAVEDATA_ERROR_SAVE_NO_MS (0x80110381)
|
||||
#define SCE_UTILITY_SAVEDATA_ERROR_SAVE_EJECT_MS (0x80110382)
|
||||
|
@ -905,9 +905,36 @@ bool SavedataParam::GetSize(SceUtilitySavedataParam *param)
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO code this
|
||||
std::string saveDir = savePath + GetGameName(param) + GetSaveName(param);
|
||||
PSPFileInfo info = pspFileSystem.GetFileInfo(saveDir);
|
||||
bool exists = info.exists;
|
||||
|
||||
return false;
|
||||
if (Memory::IsValidAddress(param->sizeAddr))
|
||||
{
|
||||
PspUtilitySavedataSizeInfo sizeInfo;
|
||||
Memory::ReadStruct(param->sizeAddr, &sizeInfo);
|
||||
|
||||
// TODO: Read the entries and count up the size vs. existing size?
|
||||
|
||||
sizeInfo.sectorSize = (int)MemoryStick_SectorSize();
|
||||
sizeInfo.freeSectors = (int)(MemoryStick_FreeSpace() / MemoryStick_SectorSize());
|
||||
|
||||
// TODO: Is this after the specified files? Before?
|
||||
sizeInfo.freeKB = (int)(MemoryStick_FreeSpace() / 1024);
|
||||
std::string spaceTxt = SavedataParam::GetSpaceText((int)MemoryStick_FreeSpace());
|
||||
strncpy(sizeInfo.freeString, spaceTxt.c_str(), 8);
|
||||
sizeInfo.freeString[7] = '\0';
|
||||
|
||||
// TODO.
|
||||
sizeInfo.neededKB = 0;
|
||||
strcpy(sizeInfo.neededString, "0 KB");
|
||||
sizeInfo.overwriteKB = 0;
|
||||
strcpy(sizeInfo.overwriteString, "0 KB");
|
||||
|
||||
Memory::WriteStruct(param->sizeAddr, &sizeInfo);
|
||||
}
|
||||
|
||||
return exists;
|
||||
}
|
||||
|
||||
void SavedataParam::Clear()
|
||||
|
@ -22,23 +22,24 @@
|
||||
|
||||
enum SceUtilitySavedataType
|
||||
{
|
||||
SCE_UTILITY_SAVEDATA_TYPE_AUTOLOAD = 0,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_AUTOSAVE = 1,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_LOAD = 2,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_SAVE = 3,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_LISTLOAD = 4,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_LISTSAVE = 5,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_DELETE = 6,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_LISTDELETE = 7,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_SIZES = 8,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_SINGLEDELETE = 10,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_LIST = 11,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_FILES = 12,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_MAKEDATASECURE = 13,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_READDATASECURE = 15,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_WRITEDATASECURE = 17,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_GETSIZE = 22
|
||||
} ;
|
||||
SCE_UTILITY_SAVEDATA_TYPE_AUTOLOAD = 0,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_AUTOSAVE = 1,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_LOAD = 2,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_SAVE = 3,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_LISTLOAD = 4,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_LISTSAVE = 5,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_DELETE = 6,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_LISTDELETE = 7,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_SIZES = 8,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_SINGLEDELETE = 10,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_LIST = 11,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_FILES = 12,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_MAKEDATASECURE = 13,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_READDATASECURE = 15,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_WRITEDATASECURE = 17,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_DELETEDATA = 21,
|
||||
SCE_UTILITY_SAVEDATA_TYPE_GETSIZE = 22,
|
||||
};
|
||||
|
||||
// title, savedataTitle, detail: parts of the unencrypted SFO
|
||||
// data, it contains what the VSH and standard load screen shows
|
||||
@ -58,6 +59,28 @@ struct PspUtilitySavedataFileData {
|
||||
int unknown;
|
||||
};
|
||||
|
||||
// TODO: According to JPCSP, should verify.
|
||||
struct PspUtilitySavedataSizeEntry {
|
||||
u64 size;
|
||||
char name[16];
|
||||
};
|
||||
|
||||
// TODO: According to JPCSP, should verify.
|
||||
struct PspUtilitySavedataSizeInfo {
|
||||
int secureNumEntries;
|
||||
int numEntries;
|
||||
u32 secureEntriesPtr;
|
||||
u32 entriesPtr;
|
||||
int sectorSize;
|
||||
int freeSectors;
|
||||
int freeKB;
|
||||
char freeString[8];
|
||||
int neededKB;
|
||||
char neededString[8];
|
||||
int overwriteKB;
|
||||
char overwriteString[8];
|
||||
};
|
||||
|
||||
// Structure to hold the parameters for the sceUtilitySavedataInitStart function.
|
||||
struct SceUtilitySavedataParam
|
||||
{
|
||||
|
@ -74,13 +74,15 @@ int sceUtilitySavedataShutdownStart()
|
||||
|
||||
int sceUtilitySavedataGetStatus()
|
||||
{
|
||||
return saveDialog.GetStatus();
|
||||
int status = saveDialog.GetStatus();
|
||||
DEBUG_LOG(HLE,"%08x=sceUtilitySavedataGetStatus()", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
int sceUtilitySavedataUpdate(int animSpeed)
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceUtilitySavedataUpdate(%d)", animSpeed);
|
||||
return saveDialog.Update();
|
||||
return hleDelayResult(saveDialog.Update(), "savedata update", 300);
|
||||
}
|
||||
|
||||
#define PSP_AV_MODULE_AVCODEC 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user