Merge pull request #5665 from unknownbrackets/savedata

Fix SIZES savedata mode + minor logging
This commit is contained in:
Henrik Rydgård committed 2014-03-22 16:05:44 +01:00
commit 6aa20ac482
4 files changed
+54 -15

No files matched your search

+3 -1
View File
@@ -64,7 +64,9 @@ int PSPSaveDialog::Init(int paramAddr)
int retval = param.SetPspParam(&request);
INFO_LOG(SCEUTILITY,"sceUtilitySavedataInitStart(%08x) : Mode = %i", paramAddr, (SceUtilitySavedataType)(u32)param.GetPspParam()->mode);
const u32 mode = (u32)param.GetPspParam()->mode;
const char *modeName = mode < ARRAY_SIZE(utilitySavedataTypeNames) ? utilitySavedataTypeNames[mode] : "UNKNOWN";
INFO_LOG(SCEUTILITY,"sceUtilitySavedataInitStart(%08x) - %s (%d)", paramAddr, modeName, mode);
yesnoChoice = 1;
switch ((SceUtilitySavedataFocus)(u32)param.GetPspParam()->focus)
+20 -9
View File
@@ -871,16 +871,27 @@ int SavedataParam::GetSizes(SceUtilitySavedataParam *param)
{
const std::string gameName(param->msData->gameName, strnlen(param->msData->gameName, sizeof(param->msData->gameName)));
const std::string saveName(param->msData->saveName, strnlen(param->msData->saveName, sizeof(param->msData->saveName)));
std::string path = GetSaveFilePath(param, gameName + saveName);
// TODO: How should <> be handled?
std::string path = GetSaveFilePath(param, gameName + (saveName == "<>" ? "" : saveName));
PSPFileInfo finfo = pspFileSystem.GetFileInfo(path);
if(finfo.exists)
if (finfo.exists)
{
// TODO : fill correctly with the total save size, be aware of crypted file size
param->msData->info.usedClusters = 1;
param->msData->info.usedSpaceKB = 0x20;
strncpy(param->msData->info.usedSpaceStr, "", sizeof(param->msData->info.usedSpaceStr)); // "32 KB" // 8 u8
param->msData->info.usedSpace32KB = 0x20;
strncpy(param->msData->info.usedSpace32Str, "", sizeof(param->msData->info.usedSpace32Str)); // "32 KB" // 8 u8
param->msData->info.usedClusters = 0;
auto listing = pspFileSystem.GetDirListing(path);
for (auto it = listing.begin(), end = listing.end(); it != end; ++it) {
param->msData->info.usedClusters += (it->size + (u32)MemoryStick_SectorSize() - 1) / (u32)MemoryStick_SectorSize();
}
// The usedSpaceKB value is definitely based on clusters, not bytes or even KB.
// Fieldrunners expects 736 KB, even though the files add up to ~600 KB.
int total_size = param->msData->info.usedClusters * (u32)MemoryStick_SectorSize();
param->msData->info.usedSpaceKB = total_size / 0x400;
std::string spaceTxt = SavedataParam::GetSpaceText(total_size);
strncpy(param->msData->info.usedSpaceStr, spaceTxt.c_str(), sizeof(param->msData->info.usedSpaceStr));
// TODO: What does this mean, then? Seems to be the same.
param->msData->info.usedSpace32KB = param->msData->info.usedSpaceKB;
strncpy(param->msData->info.usedSpace32Str, spaceTxt.c_str(), sizeof(param->msData->info.usedSpace32Str));
}
else
{
@@ -896,7 +907,7 @@ int SavedataParam::GetSizes(SceUtilitySavedataParam *param)
{
int total_size = 0;
total_size += getSizeNormalized(1); // SFO;
total_size += getSizeNormalized(param->dataSize); // Save Data
total_size += getSizeNormalized((u32)param->dataSize == 0 ? 1 : (u32)param->dataSize); // Save Data
total_size += getSizeNormalized(param->icon0FileData.size);
total_size += getSizeNormalized(param->icon1FileData.size);
total_size += getSizeNormalized(param->pic1FileData.size);
+26
View File
@@ -57,6 +57,32 @@ enum SceUtilitySavedataType
SCE_UTILITY_SAVEDATA_TYPE_GETSIZE = 22,
};
static const char *const utilitySavedataTypeNames[] = {
"AUTOLOAD",
"AUTOSAVE",
"LOAD",
"SAVE",
"LISTLOAD",
"LISTSAVE",
"DELETE",
"LISTDELETE",
"SIZES",
"AUTODELETE",
"SINGLEDELETE",
"LIST",
"FILES",
"MAKEDATASECURE",
"MAKEDATA",
"READDATASECURE",
"READDATA",
"WRITEDATASECURE",
"WRITEDATA",
"ERASESECURE",
"ERASE",
"DELETEDATA",
"GETSIZE",
};
enum SceUtilitySavedataFocus
{
SCE_UTILITY_SAVEDATA_FOCUS_NAME = 0, // specified by saveName[]
+5 -5
View File
@@ -755,7 +755,7 @@ u32 sceFontOpen(u32 libHandle, u32 index, u32 mode, u32 errorCodePtr) {
return -1;
}
INFO_LOG(SCEFONT, "sceFontOpen(%x, %x, %x, %x)", libHandle, index, mode, errorCodePtr);
DEBUG_LOG(SCEFONT, "sceFontOpen(%x, %x, %x, %x)", libHandle, index, mode, errorCodePtr);
FontLib *fontLib = GetFontLib(libHandle);
if (fontLib == NULL) {
*errorCode = ERROR_FONT_INVALID_LIBID;
@@ -797,7 +797,7 @@ u32 sceFontOpenUserMemory(u32 libHandle, u32 memoryFontAddrPtr, u32 memoryFontLe
return 0;
}
INFO_LOG(SCEFONT, "sceFontOpenUserMemory(%08x, %08x, %08x, %08x)", libHandle, memoryFontAddrPtr, memoryFontLength, errorCodePtr);
DEBUG_LOG(SCEFONT, "sceFontOpenUserMemory(%08x, %08x, %08x, %08x)", libHandle, memoryFontAddrPtr, memoryFontLength, errorCodePtr);
const u8 *fontData = Memory::GetPointer(memoryFontAddrPtr);
Font *f = new Font(fontData, memoryFontLength);
LoadedFont *font = fontLib->OpenFont(f, FONT_OPEN_USERBUFFER, *errorCode);
@@ -864,7 +864,7 @@ int sceFontClose(u32 fontHandle) {
LoadedFont *font = GetLoadedFont(fontHandle, false);
if (font)
{
INFO_LOG(SCEFONT, "sceFontClose(%x)", fontHandle);
DEBUG_LOG(SCEFONT, "sceFontClose(%x)", fontHandle);
FontLib *fontLib = font->GetFontLib();
if (fontLib)
fontLib->CloseFont(font);
@@ -895,7 +895,7 @@ int sceFontFindOptimumFont(u32 libHandle, u32 fontStylePtr, u32 errorCodePtr) {
return 0;
}
INFO_LOG(SCEFONT, "sceFontFindOptimumFont(%08x, %08x, %08x)", libHandle, fontStylePtr, errorCodePtr);
DEBUG_LOG(SCEFONT, "sceFontFindOptimumFont(%08x, %08x, %08x)", libHandle, fontStylePtr, errorCodePtr);
auto requestedStyle = PSPPointer<const PGFFontStyle>::Create(fontStylePtr);
@@ -962,7 +962,7 @@ int sceFontFindFont(u32 libHandle, u32 fontStylePtr, u32 errorCodePtr) {
return 0;
}
INFO_LOG(SCEFONT, "sceFontFindFont(%x, %x, %x)", libHandle, fontStylePtr, errorCodePtr);
DEBUG_LOG(SCEFONT, "sceFontFindFont(%x, %x, %x)", libHandle, fontStylePtr, errorCodePtr);
auto requestedStyle = PSPPointer<const PGFFontStyle>::Create(fontStylePtr);