cellSaveData* progress & reverted commit 950fcfe

* Reverted commit
950fcfe4ef
(Reverted ConLog changes) that fixed the "Bad flip!" error since there
is a better way of solving it. It will be fixed soon.
* Moved cellSaveData to cellSysutil (but preserving the functions in a
separated file named: cellSysutil_SaveData.cpp).
* Progress on cellSaveDataList* functions.
* Added a small margin to the new Settings dialog. :-)
This commit is contained in:
Alexandro Sánchez Bach 2014-03-28 20:06:15 +01:00
parent 64b80f5a2e
commit 503c24453a
9 changed files with 702 additions and 473 deletions

View File

@ -1,435 +0,0 @@
#include "stdafx.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/SysCalls/SC_FUNC.h"
// TODO: Is this really a module? Or is everything part of cellSysutil?
void cellSaveData_init();
Module cellSaveData("cellSaveData", cellSaveData_init);
// Error codes
enum
{
CELL_SAVEDATA_RET_OK = 0,
CELL_SAVEDATA_RET_CANCEL = 1,
CELL_SAVEDATA_ERROR_CBRESULT,
CELL_SAVEDATA_ERROR_ACCESS_ERROR,
CELL_SAVEDATA_ERROR_INTERNAL,
CELL_SAVEDATA_ERROR_PARAM,
CELL_SAVEDATA_ERROR_NOSPACE,
CELL_SAVEDATA_ERROR_BROKEN,
CELL_SAVEDATA_ERROR_FAILURE,
CELL_SAVEDATA_ERROR_BUSY,
CELL_SAVEDATA_ERROR_NOUSER,
};
// Constants
enum
{
// CellSaveDataParamSize
CELL_SAVEDATA_DIRNAME_SIZE = 32,
CELL_SAVEDATA_FILENAME_SIZE = 13,
CELL_SAVEDATA_SECUREFILEID_SIZE = 16,
CELL_SAVEDATA_PREFIX_SIZE = 256,
CELL_SAVEDATA_LISTITEM_MAX = 2048,
CELL_SAVEDATA_SECUREFILE_MAX = 113,
CELL_SAVEDATA_DIRLIST_MAX = 2048,
CELL_SAVEDATA_INVALIDMSG_MAX = 256,
CELL_SAVEDATA_INDICATORMSG_MAX = 64,
// CellSaveDataSystemParamSize
CELL_SAVEDATA_SYSP_TITLE_SIZE = 128,
CELL_SAVEDATA_SYSP_SUBTITLE_SIZE = 128,
CELL_SAVEDATA_SYSP_DETAIL_SIZE = 1024,
CELL_SAVEDATA_SYSP_LPARAM_SIZE = 8,
};
// Datatypes
struct CellSaveDataSetList
{
be_t<u32> sortType;
be_t<u32> sortOrder;
be_t<u32> dirNamePrefix_addr; // char*
};
struct CellSaveDataSetBuf
{
be_t<u32> dirListMax;
be_t<u32> fileListMax;
be_t<u32> reserved[6];
be_t<u32> bufSize;
be_t<u32> buf_addr; // void*
};
struct CellSaveDataNewDataIcon
{
be_t<u32> title_addr; // char*
be_t<u32> iconBufSize;
be_t<u32> iconBuf_addr; // void*
};
struct CellSaveDataListNewData
{
be_t<u32> iconPosition;
be_t<u32> dirName_addr; // char*
be_t<u32> icon_addr; // CellSaveDataNewDataIcon*
};
struct CellSaveDataDirList
{
s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE];
s8 listParam[CELL_SAVEDATA_SYSP_LPARAM_SIZE];
};
struct CellSaveDataListGet
{
be_t<u32> dirNum;
be_t<u32> dirListNum;
be_t<u32> dirList_addr; // CellSaveDataDirList*
};
struct CellSaveDataListSet
{
be_t<u32> focusPosition;
be_t<u32> focusDirName_addr; // char*
be_t<u32> fixedListNum;
be_t<u32> fixedList_addr; // CellSaveDataDirList*
be_t<u32> newData_addr; // CellSaveDataListNewData*
};
struct CellSaveDataFixedSet
{
be_t<u32> dirName_addr; // char*
be_t<u32> newIcon_addr; // CellSaveDataNewDataIcon*
be_t<u32> option;
};
struct CellSaveDataSystemFileParam
{
s8 title[CELL_SAVEDATA_SYSP_TITLE_SIZE];
s8 subTitle[CELL_SAVEDATA_SYSP_SUBTITLE_SIZE];
s8 detail[CELL_SAVEDATA_SYSP_DETAIL_SIZE];
be_t<u32> attribute;
s8 reserved2[4];
s8 listParam[CELL_SAVEDATA_SYSP_LPARAM_SIZE];
s8 reserved[256];
};
struct CellSaveDataDirStat
{
be_t<s64> st_atime_;
be_t<s64> st_mtime_;
be_t<s64> st_ctime_;
s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE];
};
struct CellSaveDataFileStat
{
be_t<u32> fileType;
u8 reserved1[4];
be_t<u64> st_size;
be_t<s64> st_atime_;
be_t<s64> st_mtime_;
be_t<s64> st_ctime_;
u8 fileName[CELL_SAVEDATA_FILENAME_SIZE];
u8 reserved2[3];
};
struct CellSaveDataStatGet
{
be_t<s32> hddFreeSizeKB;
be_t<u32> isNewData;
CellSaveDataDirStat dir;
CellSaveDataSystemFileParam getParam;
be_t<u32> bind;
be_t<s32> sizeKB;
be_t<s32> sysSizeKB;
be_t<u32> fileNum;
be_t<u32> fileListNum;
be_t<u32> fileList_addr; // CellSaveDataFileStat*
};
struct CellSaveDataAutoIndicator
{
be_t<u32> dispPosition;
be_t<u32> dispMode;
be_t<u32> dispMsg_addr; // char*
be_t<u32> picBufSize;
be_t<u32> picBuf_addr; // void*
};
struct CellSaveDataStatSet
{
be_t<u32> setParam_addr; // CellSaveDataSystemFileParam*
be_t<u32> reCreateMode;
be_t<u32> indicator_addr; // CellSaveDataAutoIndicator*
};
struct CellSaveDataFileGet
{
be_t<u32> excSize;
};
struct CellSaveDataFileSet
{
be_t<u32> fileOperation;
be_t<u32> reserved_addr; // void*
be_t<u32> fileType;
u8 secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE];
be_t<u32> fileName_addr; // char*
be_t<u32> fileOffset;
be_t<u32> fileSize;
be_t<u32> fileBufSize;
be_t<u32> fileBuf_addr; // void*
};
struct CellSaveDataCBResult
{
be_t<s32> result;
be_t<u32> progressBarInc;
be_t<s32> errNeedSizeKB;
be_t<u32> invalidMsg_addr; // char*
be_t<u32> userdata_addr; // void*
};
struct CellSaveDataDoneGet
{
be_t<s32> excResult;
s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE];
be_t<s32> sizeKB;
be_t<s32> hddFreeSizeKB;
};
// Functions
int cellSaveDataListSave2() //u32 version, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataListLoad2() //u32 version, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataFixedSave2() //u32 version, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile,sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataFixedLoad2() //u32 version, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataAutoSave2() //u32 version, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataAutoLoad2() //u32 version, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataListAutoSave() //u32 version, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile,sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataListAutoLoad() //u32 version, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataDelete2() //sys_memory_container_t container
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_CANCEL;
}
int cellSaveDataFixedDelete() //CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserListSave() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserListLoad() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserFixedSave() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserFixedLoad() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserAutoSave() //u32 version, CellSysutilUserId userId, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserAutoLoad() //u32 version, CellSysutilUserId userId, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserListAutoSave() //u32 version, CellSysutilUserId userId, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserListAutoLoad() //u32 version, CellSysutilUserId userId, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserFixedDelete() //CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
//void cellSaveDataEnableOverlay(); //int enable
// Functions (Extensions)
int cellSaveDataListDelete() //CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataListImport() //CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataListExport() //CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataFixedImport() //const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataFixedExport() //const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataGetListItem() //const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, mem32_t bind, mem32_t sizeKB
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserListDelete() //CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataDoneCallback funcDone,sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserListImport() //CellSysutilUserId userId, CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserListExport() //CellSysutilUserId userId, CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserFixedImport() //CellSysutilUserId userId, const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserFixedExport() //CellSysutilUserId userId, const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserGetListItem() //CellSysutilUserId userId, const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, mem32_t bind, mem32_t sizeKB
{
UNIMPLEMENTED_FUNC(cellSaveData);
return CELL_SAVEDATA_RET_OK;
}
// Callback Functions
void (*CellSaveDataFixedCallback)(); //CellSaveDataCBResult *cbResult, CellSaveDataListGet *get, CellSaveDataFixedSet *set
void (*CellSaveDataListCallback)(); //CellSaveDataCBResult *cbResult, CellSaveDataListGet *get, CellSaveDataListSet *set
void (*CellSaveDataStatCallback)(); //CellSaveDataCBResult *cbResult, CellSaveDataStatGet *get, CellSaveDataStatSet *set
void (*CellSaveDataFileCallback)(); //CellSaveDataCBResult *cbResult, CellSaveDataFileGet *get, CellSaveDataFileSet *set
void (*CellSaveDataDoneCallback)(); //CellSaveDataCBResult *cbResult, CellSaveDataDoneGet *get
void cellSaveData_init()
{
cellSaveData.AddFunc(0x04c06fc2, cellSaveDataGetListItem);
cellSaveData.AddFunc(0x273d116a, cellSaveDataUserListExport);
cellSaveData.AddFunc(0x27cb8bc2, cellSaveDataListDelete);
cellSaveData.AddFunc(0x39d6ee43, cellSaveDataUserListImport);
cellSaveData.AddFunc(0x46a2d878, cellSaveDataFixedExport);
cellSaveData.AddFunc(0x491cc554, cellSaveDataListExport);
cellSaveData.AddFunc(0x52541151, cellSaveDataFixedImport);
cellSaveData.AddFunc(0x529231b0, cellSaveDataUserFixedImport);
cellSaveData.AddFunc(0x6b4e0de6, cellSaveDataListImport);
cellSaveData.AddFunc(0x7048a9ba, cellSaveDataUserListDelete);
cellSaveData.AddFunc(0x95ae2cde, cellSaveDataUserFixedExport);
cellSaveData.AddFunc(0xf6482036, cellSaveDataUserGetListItem);
cellSaveData.AddFunc(0x2de0d663, cellSaveDataListSave2);
cellSaveData.AddFunc(0x1dfbfdd6, cellSaveDataListLoad2);
cellSaveData.AddFunc(0x2aae9ef5, cellSaveDataFixedSave2);
cellSaveData.AddFunc(0x2a8eada2, cellSaveDataFixedLoad2);
cellSaveData.AddFunc(0x8b7ed64b, cellSaveDataAutoSave2);
cellSaveData.AddFunc(0xfbd5c856, cellSaveDataAutoLoad2);
cellSaveData.AddFunc(0x4dd03a4e, cellSaveDataListAutoSave);
cellSaveData.AddFunc(0x21425307, cellSaveDataListAutoLoad);
cellSaveData.AddFunc(0xedadd797, cellSaveDataDelete2);
cellSaveData.AddFunc(0x0f03cfb0, cellSaveDataUserListSave);
cellSaveData.AddFunc(0x39dd8425, cellSaveDataUserListLoad);
cellSaveData.AddFunc(0x40b34847, cellSaveDataUserFixedSave);
cellSaveData.AddFunc(0x6e7264ed, cellSaveDataUserFixedLoad);
cellSaveData.AddFunc(0x52aac4fa, cellSaveDataUserAutoSave);
cellSaveData.AddFunc(0xcdc6aefd, cellSaveDataUserAutoLoad);
cellSaveData.AddFunc(0x0e091c36, cellSaveDataUserListAutoSave);
//cellSaveData.AddFunc(0xe7fa820b, cellSaveDataEnableOverlay);
}

View File

@ -4,6 +4,7 @@
#include "Emu/Audio/sysutil_audio.h" #include "Emu/Audio/sysutil_audio.h"
#include "cellSysutil.h" #include "cellSysutil.h"
#include "cellSysutil_SaveData.h"
#include "Loader/PSF.h" #include "Loader/PSF.h"
@ -949,4 +950,35 @@ void cellSysutil_init()
//cellSysutil.AddFunc(0xf82e2ef7, cellHddGameGetSizeKB); //cellSysutil.AddFunc(0xf82e2ef7, cellHddGameGetSizeKB);
//cellSysutil.AddFunc(0x9ca9ffa7, cellHddGameSetSystemVer); //cellSysutil.AddFunc(0x9ca9ffa7, cellHddGameSetSystemVer);
//cellSysutil.AddFunc(0xafd605b3, cellHddGameExitBroken); //cellSysutil.AddFunc(0xafd605b3, cellHddGameExitBroken);
//cellSysutil_SaveData
//cellSysutil.AddFunc(0x04c06fc2, cellSaveDataGetListItem);
//cellSysutil.AddFunc(0x273d116a, cellSaveDataUserListExport);
//cellSysutil.AddFunc(0x27cb8bc2, cellSaveDataListDelete);
//cellSysutil.AddFunc(0x39d6ee43, cellSaveDataUserListImport);
//cellSysutil.AddFunc(0x46a2d878, cellSaveDataFixedExport);
//cellSysutil.AddFunc(0x491cc554, cellSaveDataListExport);
//cellSysutil.AddFunc(0x52541151, cellSaveDataFixedImport);
//cellSysutil.AddFunc(0x529231b0, cellSaveDataUserFixedImport);
//cellSysutil.AddFunc(0x6b4e0de6, cellSaveDataListImport);
//cellSysutil.AddFunc(0x7048a9ba, cellSaveDataUserListDelete);
//cellSysutil.AddFunc(0x95ae2cde, cellSaveDataUserFixedExport);
//cellSysutil.AddFunc(0xf6482036, cellSaveDataUserGetListItem);
cellSysutil.AddFunc(0x2de0d663, cellSaveDataListSave2);
cellSysutil.AddFunc(0x1dfbfdd6, cellSaveDataListLoad2);
//cellSysutil.AddFunc(0x2aae9ef5, cellSaveDataFixedSave2);
//cellSysutil.AddFunc(0x2a8eada2, cellSaveDataFixedLoad2);
//cellSysutil.AddFunc(0x8b7ed64b, cellSaveDataAutoSave2);
//cellSysutil.AddFunc(0xfbd5c856, cellSaveDataAutoLoad2);
//cellSysutil.AddFunc(0x4dd03a4e, cellSaveDataListAutoSave);
//cellSysutil.AddFunc(0x21425307, cellSaveDataListAutoLoad);
//cellSysutil.AddFunc(0xedadd797, cellSaveDataDelete2);
//cellSysutil.AddFunc(0x0f03cfb0, cellSaveDataUserListSave);
//cellSysutil.AddFunc(0x39dd8425, cellSaveDataUserListLoad);
//cellSysutil.AddFunc(0x40b34847, cellSaveDataUserFixedSave);
//cellSysutil.AddFunc(0x6e7264ed, cellSaveDataUserFixedLoad);
//cellSysutil.AddFunc(0x52aac4fa, cellSaveDataUserAutoSave);
//cellSysutil.AddFunc(0xcdc6aefd, cellSaveDataUserAutoLoad);
//cellSysutil.AddFunc(0x0e091c36, cellSaveDataUserListAutoSave);
//cellSysutil.AddFunc(0xe7fa820b, cellSaveDataEnableOverlay);
} }

View File

@ -0,0 +1,396 @@
#include "stdafx.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/SysCalls/SC_FUNC.h"
#include <algorithm>
#include "cellSysutil_SaveData.h"
#include "Loader/PSF.h"
#include "stblib/stb_image.h"
//#include "Emu/SysCalls/Dialogs/SaveDataList.h"
extern Module cellSysutil;
// Auxiliary Classes
class sortSaveDataEntry
{
u32 sortType;
u32 sortOrder;
public:
sortSaveDataEntry(u32 type, u32 order) : sortType(type), sortOrder(order) {}
bool operator()(const SaveDataListEntry& entry1, const SaveDataListEntry& entry2) const
{
if (sortOrder == CELL_SAVEDATA_SORTORDER_DESCENT)
{
if (sortType == CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME)
return entry1.timestamp >= entry2.timestamp;
else //if (sortType == CELL_SAVEDATA_SORTTYPE_SUBTITLE)
return entry1.subtitle >= entry2.subtitle;
}
else //if (sortOrder == CELL_SAVEDATA_SORTORDER_ASCENT)
{
if (sortType == CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME)
return entry1.timestamp < entry2.timestamp;
else //if (sortType == CELL_SAVEDATA_SORTTYPE_SUBTITLE)
return entry1.subtitle < entry2.subtitle;
}
}
};
// Auxiliary Functions
u64 getSaveDataSize(const std::string& dirName)
{
vfsDir dir(dirName);
if (!dir.IsOpened())
return 0;
u64 totalSize = 0;
for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read()) {
if (entry->flags & DirEntry_TypeFile) {
vfsFile file(dirName+"/"+entry->name);
totalSize += file.GetSize();
}
}
return totalSize;
}
void getSaveDataEntry(std::vector<SaveDataListEntry>& saveEntries, const std::string& saveDir)
{
// PSF parameters
vfsFile f(saveDir + "/PARAM.SFO");
PSFLoader psf(f);
if(!psf.Load(false))
return;
// PNG icon
wxString localPath;
int width, height, actual_components;
Emu.GetVFS().GetDevice(saveDir + "/ICON0.PNG", localPath);
SaveDataListEntry saveEntry;
saveEntry.dirName = psf.GetString("SAVEDATA_DIRECTORY");
saveEntry.listParam = psf.GetString("SAVEDATA_LIST_PARAM");
saveEntry.title = psf.GetString("TITLE");
saveEntry.subtitle = psf.GetString("SUB_TITLE");
saveEntry.details = psf.GetString("DETAIL");
saveEntry.sizeKb = getSaveDataSize(saveDir)/1024;
saveEntry.timestamp = 0; // TODO
saveEntry.iconBuffer = stbi_load(localPath.mb_str(), &width, &height, &actual_components, 3);
saveEntries.push_back(saveEntry);
}
// Functions
int cellSaveDataListSave2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataListCallback> funcList, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata)
{
cellSysutil.Warning("cellSaveDataListSave2(version=%d, setList_addr=0x%x, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=%d, userdata_addr=0x%x)",
version, setList.GetAddr(), setBuf.GetAddr(), funcList.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata);
if (!setList.IsGood() || !setBuf.IsGood() || !funcList.IsGood() || !funcStat.IsGood() || !funcFile.IsGood())
return CELL_SAVEDATA_ERROR_PARAM;
MemoryAllocator<CellSaveDataCBResult> result;
MemoryAllocator<CellSaveDataListGet> listGet;
MemoryAllocator<CellSaveDataListGet> listSet;
std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user
vfsDir dir(saveBaseDir);
if(!dir.IsOpened())
return CELL_SAVEDATA_ERROR_INTERNAL;
std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr).mb_str();
std::vector<SaveDataListEntry> saveEntries;
for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
{
if (entry->flags & DirEntry_TypeDir || entry->name.Left(dirNamePrefix.size()) == dirNamePrefix)
{
// Count the amount of matches and the amount of listed directories
listGet->dirListNum++;
if (listGet->dirListNum > setBuf->dirListMax)
continue;
listGet->dirNum++;
std::string saveDir = saveBaseDir + (const char*)(entry->name.mb_str());
getSaveDataEntry(saveEntries, saveDir);
}
}
// Sort the entries and fill the listGet->dirList array
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
listGet->dirList_addr = setBuf->buf_addr;
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList_addr);
for (u32 i=0; i<saveEntries.size(); i++) {
memcpy(dirList[i].dirName, saveEntries[i].dirName.c_str(), CELL_SAVEDATA_DIRNAME_SIZE);
memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE);
}
funcList(result.GetAddr(), listGet.GetAddr(), listSet.GetAddr());
MemoryAllocator<CellSaveDataStatGet> statGet;
MemoryAllocator<CellSaveDataStatSet> statSet;
funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr());
MemoryAllocator<CellSaveDataFileGet> fileGet;
MemoryAllocator<CellSaveDataFileSet> fileSet;
funcFile(result.GetAddr(), fileGet.GetAddr(), fileSet.GetAddr());
for (auto& entry : saveEntries) {
delete[] entry.iconBuffer;
entry.iconBuffer = nullptr;
}
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataListLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataListCallback> funcList, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata)
{
cellSysutil.Warning("cellSaveDataListLoad2(version=%d, setList_addr=0x%x, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=%d, userdata_addr=0x%x)",
version, setList.GetAddr(), setBuf.GetAddr(), funcList.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata);
if (!setList.IsGood() || !setBuf.IsGood() || !funcList.IsGood() || !funcStat.IsGood() || !funcFile.IsGood())
return CELL_SAVEDATA_ERROR_PARAM;
MemoryAllocator<CellSaveDataCBResult> result;
MemoryAllocator<CellSaveDataListGet> listGet;
MemoryAllocator<CellSaveDataListGet> listSet;
std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user
vfsDir dir(saveBaseDir);
if(!dir.IsOpened())
return CELL_SAVEDATA_ERROR_INTERNAL;
std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr).mb_str();
std::vector<SaveDataListEntry> saveEntries;
for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read())
{
if (entry->flags & DirEntry_TypeDir || entry->name.Left(dirNamePrefix.size()) == dirNamePrefix)
{
// Count the amount of matches and the amount of listed directories
listGet->dirListNum++;
if (listGet->dirListNum > setBuf->dirListMax)
continue;
listGet->dirNum++;
std::string saveDir = saveBaseDir + (const char*)(entry->name.mb_str());
getSaveDataEntry(saveEntries, saveDir);
}
}
// Sort the entries and fill the listGet->dirList array
std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder));
listGet->dirList_addr = setBuf->buf_addr;
CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList_addr);
for (u32 i=0; i<saveEntries.size(); i++) {
memcpy(dirList[i].dirName, saveEntries[i].dirName.c_str(), CELL_SAVEDATA_DIRNAME_SIZE);
memcpy(dirList[i].listParam, saveEntries[i].listParam.c_str(), CELL_SAVEDATA_SYSP_LPARAM_SIZE);
}
funcList(result.GetAddr(), listGet.GetAddr(), listSet.GetAddr());
MemoryAllocator<CellSaveDataStatGet> statGet;
MemoryAllocator<CellSaveDataStatSet> statSet;
funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr());
MemoryAllocator<CellSaveDataFileGet> fileGet;
MemoryAllocator<CellSaveDataFileSet> fileSet;
funcFile(result.GetAddr(), fileGet.GetAddr(), fileSet.GetAddr());
for (auto& entry : saveEntries) {
delete[] entry.iconBuffer;
entry.iconBuffer = nullptr;
}
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataFixedSave2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataFixedCallback> funcFixed, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr)
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataFixedLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataFixedCallback> funcFixed, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr)
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr)
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr)
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataListAutoSave() //u32 version, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile,sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataListAutoLoad() //u32 version, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataDelete2() //sys_memory_container_t container
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_CANCEL;
}
int cellSaveDataFixedDelete() //CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserListSave() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserListLoad() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserFixedSave() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserFixedLoad() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserAutoSave() //u32 version, CellSysutilUserId userId, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserAutoLoad() //u32 version, CellSysutilUserId userId, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserListAutoSave() //u32 version, CellSysutilUserId userId, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserListAutoLoad() //u32 version, CellSysutilUserId userId, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserFixedDelete() //CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
//void cellSaveDataEnableOverlay(); //int enable
// Functions (Extensions)
int cellSaveDataListDelete() //CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataListImport() //CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataListExport() //CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataFixedImport() //const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataFixedExport() //const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataGetListItem() //const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, mem32_t bind, mem32_t sizeKB
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserListDelete() //CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataDoneCallback funcDone,sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserListImport() //CellSysutilUserId userId, CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserListExport() //CellSysutilUserId userId, CellSaveDataSetList *setList, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserFixedImport() //CellSysutilUserId userId, const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserFixedExport() //CellSysutilUserId userId, const char *dirName, u32 maxSizeKB, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}
int cellSaveDataUserGetListItem() //CellSysutilUserId userId, const char *dirName, CellSaveDataDirStat *dir, CellSaveDataSystemFileParam *sysFileParam, mem32_t bind, mem32_t sizeKB
{
UNIMPLEMENTED_FUNC(cellSysutil);
return CELL_SAVEDATA_RET_OK;
}

View File

@ -0,0 +1,238 @@
#pragma once
// Return codes
enum
{
CELL_SAVEDATA_RET_OK = 0,
CELL_SAVEDATA_RET_CANCEL = 1,
CELL_SAVEDATA_ERROR_CBRESULT = 0x8002b401,
CELL_SAVEDATA_ERROR_ACCESS_ERROR = 0x8002b402,
CELL_SAVEDATA_ERROR_INTERNAL = 0x8002b403,
CELL_SAVEDATA_ERROR_PARAM = 0x8002b404,
CELL_SAVEDATA_ERROR_NOSPACE = 0x8002b405,
CELL_SAVEDATA_ERROR_BROKEN = 0x8002b406,
CELL_SAVEDATA_ERROR_FAILURE = 0x8002b407,
CELL_SAVEDATA_ERROR_BUSY = 0x8002b408,
CELL_SAVEDATA_ERROR_NOUSER = 0x8002b409,
CELL_SAVEDATA_ERROR_SIZEOVER = 0x8002b40a,
CELL_SAVEDATA_ERROR_NODATA = 0x8002b40b,
CELL_SAVEDATA_ERROR_NOTSUPPORTED = 0x8002b40c,
};
// Constants
enum
{
// CellSaveDataParamSize
CELL_SAVEDATA_DIRNAME_SIZE = 32,
CELL_SAVEDATA_FILENAME_SIZE = 13,
CELL_SAVEDATA_SECUREFILEID_SIZE = 16,
CELL_SAVEDATA_PREFIX_SIZE = 256,
CELL_SAVEDATA_LISTITEM_MAX = 2048,
CELL_SAVEDATA_SECUREFILE_MAX = 113,
CELL_SAVEDATA_DIRLIST_MAX = 2048,
CELL_SAVEDATA_INVALIDMSG_MAX = 256,
CELL_SAVEDATA_INDICATORMSG_MAX = 64,
// CellSaveDataSystemParamSize
CELL_SAVEDATA_SYSP_TITLE_SIZE = 128,
CELL_SAVEDATA_SYSP_SUBTITLE_SIZE = 128,
CELL_SAVEDATA_SYSP_DETAIL_SIZE = 1024,
CELL_SAVEDATA_SYSP_LPARAM_SIZE = 8,
// CellSaveDataSortType
CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME = 0,
CELL_SAVEDATA_SORTTYPE_SUBTITLE = 1,
// CellSaveDataSortOrder
CELL_SAVEDATA_SORTORDER_DESCENT = 0,
CELL_SAVEDATA_SORTORDER_ASCENT = 1,
};
// Datatypes
struct CellSaveDataSetList
{
be_t<u32> sortType;
be_t<u32> sortOrder;
be_t<u32> dirNamePrefix_addr; // char*
};
struct CellSaveDataSetBuf
{
be_t<u32> dirListMax;
be_t<u32> fileListMax;
be_t<u32> reserved[6];
be_t<u32> bufSize;
be_t<u32> buf_addr; // void*
};
struct CellSaveDataNewDataIcon
{
be_t<u32> title_addr; // char*
be_t<u32> iconBufSize;
be_t<u32> iconBuf_addr; // void*
};
struct CellSaveDataListNewData
{
be_t<u32> iconPosition;
be_t<u32> dirName_addr; // char*
be_t<u32> icon_addr; // CellSaveDataNewDataIcon*
};
struct CellSaveDataDirList
{
s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE];
s8 listParam[CELL_SAVEDATA_SYSP_LPARAM_SIZE];
};
struct CellSaveDataListGet
{
be_t<u32> dirNum;
be_t<u32> dirListNum;
be_t<u32> dirList_addr; // CellSaveDataDirList*
};
struct CellSaveDataListSet
{
be_t<u32> focusPosition;
be_t<u32> focusDirName_addr; // char*
be_t<u32> fixedListNum;
be_t<u32> fixedList_addr; // CellSaveDataDirList*
be_t<u32> newData_addr; // CellSaveDataListNewData*
};
struct CellSaveDataFixedSet
{
be_t<u32> dirName_addr; // char*
be_t<u32> newIcon_addr; // CellSaveDataNewDataIcon*
be_t<u32> option;
};
struct CellSaveDataSystemFileParam
{
s8 title[CELL_SAVEDATA_SYSP_TITLE_SIZE];
s8 subTitle[CELL_SAVEDATA_SYSP_SUBTITLE_SIZE];
s8 detail[CELL_SAVEDATA_SYSP_DETAIL_SIZE];
be_t<u32> attribute;
s8 reserved2[4];
s8 listParam[CELL_SAVEDATA_SYSP_LPARAM_SIZE];
s8 reserved[256];
};
struct CellSaveDataDirStat
{
be_t<s64> st_atime_;
be_t<s64> st_mtime_;
be_t<s64> st_ctime_;
s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE];
};
struct CellSaveDataFileStat
{
be_t<u32> fileType;
u8 reserved1[4];
be_t<u64> st_size;
be_t<s64> st_atime_;
be_t<s64> st_mtime_;
be_t<s64> st_ctime_;
u8 fileName[CELL_SAVEDATA_FILENAME_SIZE];
u8 reserved2[3];
};
struct CellSaveDataStatGet
{
be_t<s32> hddFreeSizeKB;
be_t<u32> isNewData;
CellSaveDataDirStat dir;
CellSaveDataSystemFileParam getParam;
be_t<u32> bind;
be_t<s32> sizeKB;
be_t<s32> sysSizeKB;
be_t<u32> fileNum;
be_t<u32> fileListNum;
be_t<u32> fileList_addr; // CellSaveDataFileStat*
};
struct CellSaveDataAutoIndicator
{
be_t<u32> dispPosition;
be_t<u32> dispMode;
be_t<u32> dispMsg_addr; // char*
be_t<u32> picBufSize;
be_t<u32> picBuf_addr; // void*
};
struct CellSaveDataStatSet
{
be_t<u32> setParam_addr; // CellSaveDataSystemFileParam*
be_t<u32> reCreateMode;
be_t<u32> indicator_addr; // CellSaveDataAutoIndicator*
};
struct CellSaveDataFileGet
{
be_t<u32> excSize;
};
struct CellSaveDataFileSet
{
be_t<u32> fileOperation;
be_t<u32> reserved_addr; // void*
be_t<u32> fileType;
u8 secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE];
be_t<u32> fileName_addr; // char*
be_t<u32> fileOffset;
be_t<u32> fileSize;
be_t<u32> fileBufSize;
be_t<u32> fileBuf_addr; // void*
};
struct CellSaveDataCBResult
{
be_t<s32> result;
be_t<u32> progressBarInc;
be_t<s32> errNeedSizeKB;
be_t<u32> invalidMsg_addr; // char*
be_t<u32> userdata_addr; // void*
};
struct CellSaveDataDoneGet
{
be_t<s32> excResult;
s8 dirName[CELL_SAVEDATA_DIRNAME_SIZE];
be_t<s32> sizeKB;
be_t<s32> hddFreeSizeKB;
};
// Callback Functions
typedef void (*CellSaveDataFixedCallback)(mem_ptr_t<CellSaveDataCBResult> cbResult, mem_ptr_t<CellSaveDataListGet> get, mem_ptr_t<CellSaveDataFixedSet> set);
typedef void (*CellSaveDataListCallback) (mem_ptr_t<CellSaveDataCBResult> cbResult, mem_ptr_t<CellSaveDataListGet> get, mem_ptr_t<CellSaveDataListSet> set);
typedef void (*CellSaveDataStatCallback) (mem_ptr_t<CellSaveDataCBResult> cbResult, mem_ptr_t<CellSaveDataStatGet> get, mem_ptr_t<CellSaveDataStatSet> set);
typedef void (*CellSaveDataFileCallback) (mem_ptr_t<CellSaveDataCBResult> cbResult, mem_ptr_t<CellSaveDataFileGet> get, mem_ptr_t<CellSaveDataFileSet> set);
typedef void (*CellSaveDataDoneCallback) (mem_ptr_t<CellSaveDataCBResult> cbResult, mem_ptr_t<CellSaveDataDoneGet> get);
// Auxiliary Structs
struct SaveDataListEntry
{
std::string dirName;
std::string listParam;
std::string title;
std::string subtitle;
std::string details;
u32 sizeKb;
u64 timestamp;
void* iconBuffer;
};
// Function declarations
int cellSaveDataListSave2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataListCallback> funcList, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr);
int cellSaveDataListLoad2(u32 version, mem_ptr_t<CellSaveDataSetList> setList, mem_ptr_t<CellSaveDataSetBuf> setBuf,
mem_func_ptr_t<CellSaveDataListCallback> funcList, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile,
u32 container, u32 userdata_addr);

View File

@ -14,22 +14,23 @@ std::mutex g_cs_conlog;
static const uint max_item_count = 500; static const uint max_item_count = 500;
static const uint buffer_size = 1024 * 64; static const uint buffer_size = 1024 * 64;
static const std::string g_log_colors[] = static const wxString g_log_colors[] =
{ {
"Black", "Green", "White", "Yellow", "Red", "Black", "Green", "White", "Yellow", "Red",
}; };
struct LogPacket struct LogPacket
{ {
std::string m_prefix; wxString m_prefix;
std::string m_text; wxString m_text;
std::string m_colour; wxString m_colour;
LogPacket(const std::string& prefix, const std::string& text, const std::string& colour) LogPacket(const wxString& prefix, const wxString& text, const wxString& colour)
: m_prefix(prefix) : m_prefix(prefix)
, m_text(text) , m_text(text)
, m_colour(colour) , m_colour(colour)
{ {
} }
LogPacket() LogPacket()
@ -45,9 +46,9 @@ struct _LogBuffer : public MTPacketBuffer<LogPacket>
void _push(const LogPacket& data) void _push(const LogPacket& data)
{ {
const u32 sprefix = data.m_prefix.length(); const u32 sprefix = data.m_prefix.length() * sizeof(wxChar);
const u32 stext = data.m_text.length(); const u32 stext = data.m_text.length() * sizeof(wxChar);
const u32 scolour = data.m_colour.length(); const u32 scolour = data.m_colour.length() * sizeof(wxChar);
m_buffer.Reserve( m_buffer.Reserve(
sizeof(u32) + sprefix + sizeof(u32) + sprefix +
@ -58,17 +59,17 @@ struct _LogBuffer : public MTPacketBuffer<LogPacket>
memcpy(&m_buffer[c_put], &sprefix, sizeof(u32)); memcpy(&m_buffer[c_put], &sprefix, sizeof(u32));
c_put += sizeof(u32); c_put += sizeof(u32);
memcpy(&m_buffer[c_put], data.m_prefix.c_str(), sprefix); memcpy(&m_buffer[c_put], data.m_prefix.wx_str(), sprefix);
c_put += sprefix; c_put += sprefix;
memcpy(&m_buffer[c_put], &stext, sizeof(u32)); memcpy(&m_buffer[c_put], &stext, sizeof(u32));
c_put += sizeof(u32); c_put += sizeof(u32);
memcpy(&m_buffer[c_put], data.m_text.c_str(), stext); memcpy(&m_buffer[c_put], data.m_text.wx_str(), stext);
c_put += stext; c_put += stext;
memcpy(&m_buffer[c_put], &scolour, sizeof(u32)); memcpy(&m_buffer[c_put], &scolour, sizeof(u32));
c_put += sizeof(u32); c_put += sizeof(u32);
memcpy(&m_buffer[c_put], data.m_colour.c_str(), scolour); memcpy(&m_buffer[c_put], data.m_colour.wx_str(), scolour);
c_put += scolour; c_put += scolour;
m_put = c_put; m_put = c_put;
@ -83,20 +84,17 @@ struct _LogBuffer : public MTPacketBuffer<LogPacket>
const u32& sprefix = *(u32*)&m_buffer[c_get]; const u32& sprefix = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32); c_get += sizeof(u32);
ret.m_prefix.resize(sprefix); ret.m_prefix = wxString((wxChar*)&m_buffer[c_get], sprefix / sizeof(wxChar));
if(sprefix) memcpy((void*)ret.m_prefix.c_str(), &m_buffer[c_get], sprefix);
c_get += sprefix; c_get += sprefix;
const u32& stext = *(u32*)&m_buffer[c_get]; const u32& stext = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32); c_get += sizeof(u32);
ret.m_text.resize(stext); ret.m_text = wxString((wxChar*)&m_buffer[c_get], stext / sizeof(wxChar));
if(stext) memcpy((void*)ret.m_text.c_str(), &m_buffer[c_get], stext);
c_get += stext; c_get += stext;
const u32& scolour = *(u32*)&m_buffer[c_get]; const u32& scolour = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32); c_get += sizeof(u32);
ret.m_colour.resize(scolour); ret.m_colour = wxString((wxChar*)&m_buffer[c_get], scolour / sizeof(wxChar));
if(scolour) memcpy((void*)ret.m_colour.c_str(), &m_buffer[c_get], scolour);
c_get += scolour; c_get += scolour;
m_get = c_get; m_get = c_get;
@ -116,7 +114,7 @@ LogWriter::LogWriter()
} }
} }
void LogWriter::WriteToLog(std::string prefix, std::string value, u8 lvl/*, wxColour bgcolour*/) void LogWriter::WriteToLog(wxString prefix, wxString value, u8 lvl/*, wxColour bgcolour*/)
{ {
if(!prefix.empty()) if(!prefix.empty())
{ {
@ -126,8 +124,8 @@ void LogWriter::WriteToLog(std::string prefix, std::string value, u8 lvl/*, wxCo
} }
} }
if(m_logfile.IsOpened()) if(m_logfile.IsOpened() && !prefix.empty())
m_logfile.Write(wxString(prefix.empty() ? "" : std::string("[" + prefix + "]: ") + value + "\n").wx_str()); m_logfile.Write(wxString("[") + prefix + "]: " + value + "\n");
if(!ConLogFrame || Ini.HLELogLvl.GetValue() == 4 || (lvl != 0 && lvl <= Ini.HLELogLvl.GetValue())) if(!ConLogFrame || Ini.HLELogLvl.GetValue() == 4 || (lvl != 0 && lvl <= Ini.HLELogLvl.GetValue()))
return; return;
@ -174,7 +172,7 @@ void LogWriter::Write(const wxString fmt, ...)
va_end(list); va_end(list);
WriteToLog("!", (const char *)frmt.ToAscii(), 2); WriteToLog("!", frmt, 2);
} }
void LogWriter::Error(const wxString fmt, ...) void LogWriter::Error(const wxString fmt, ...)
@ -187,7 +185,7 @@ void LogWriter::Error(const wxString fmt, ...)
va_end(list); va_end(list);
WriteToLog("E", static_cast<const char *>(frmt), 4); WriteToLog("E", frmt, 4);
} }
void LogWriter::Warning(const wxString fmt, ...) void LogWriter::Warning(const wxString fmt, ...)
@ -200,7 +198,7 @@ void LogWriter::Warning(const wxString fmt, ...)
va_end(list); va_end(list);
WriteToLog("W", static_cast<const char *>(frmt), 3); WriteToLog("W", frmt, 3);
} }
void LogWriter::Success(const wxString fmt, ...) void LogWriter::Success(const wxString fmt, ...)
@ -213,7 +211,7 @@ void LogWriter::Success(const wxString fmt, ...)
va_end(list); va_end(list);
WriteToLog("S", static_cast<const char *>(frmt), 1); WriteToLog("S", frmt, 1);
} }
void LogWriter::SkipLn() void LogWriter::SkipLn()
@ -278,9 +276,9 @@ void LogFrame::Task()
const int cur_item = m_log.GetItemCount(); const int cur_item = m_log.GetItemCount();
m_log.InsertItem(cur_item, wxString(item.m_prefix).wx_str()); m_log.InsertItem(cur_item, item.m_prefix);
m_log.SetItem(cur_item, 1, wxString(item.m_text).wx_str()); m_log.SetItem(cur_item, 1, item.m_text);
m_log.SetItemTextColour(cur_item, wxString(item.m_colour).wx_str()); m_log.SetItemTextColour(cur_item, item.m_colour);
m_log.SetColumnWidth(0, -1); // crashes on exit m_log.SetColumnWidth(0, -1); // crashes on exit
m_log.SetColumnWidth(1, -1); m_log.SetColumnWidth(1, -1);

View File

@ -8,10 +8,10 @@ class LogWriter
wxFile m_logfile; wxFile m_logfile;
wxColour m_txtcolour; wxColour m_txtcolour;
std::string m_prefix; //wxString m_prefix;
std::string m_value; //wxString m_value;
virtual void WriteToLog(std::string prefix, std::string value, u8 lvl); virtual void WriteToLog(wxString prefix, wxString value, u8 lvl);
public: public:
LogWriter(); LogWriter();

View File

@ -322,11 +322,11 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
} }
wxDialog diag(this, wxID_ANY, "Settings", wxDefaultPosition); wxDialog diag(this, wxID_ANY, "Settings", wxDefaultPosition);
static const u32 m_height = 400; static const u32 height = 400;
static const u32 m_width = 385; static const u32 width = 385;
// Settings panels // Settings panels
wxNotebook* nb_config = new wxNotebook(&diag, wxID_ANY, wxDefaultPosition, wxSize(m_width, m_height)); wxNotebook* nb_config = new wxNotebook(&diag, wxID_ANY, wxPoint(6,6), wxSize(width, height));
wxPanel* p_system = new wxPanel(nb_config, wxID_ANY); wxPanel* p_system = new wxPanel(nb_config, wxID_ANY);
wxPanel* p_cpu = new wxPanel(nb_config, wxID_ANY); wxPanel* p_cpu = new wxPanel(nb_config, wxID_ANY);
wxPanel* p_graphics = new wxPanel(nb_config, wxID_ANY); wxPanel* p_graphics = new wxPanel(nb_config, wxID_ANY);
@ -541,7 +541,7 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
diag.SetSizerAndFit(s_subpanel_system, false); diag.SetSizerAndFit(s_subpanel_system, false);
diag.SetSizerAndFit(s_b_panel, false); diag.SetSizerAndFit(s_b_panel, false);
diag.SetSize(m_width, m_height + 80); diag.SetSize(width+26, height+80);
if(diag.ShowModal() == wxID_OK) if(diag.ShowModal() == wxID_OK)
{ {

View File

@ -301,12 +301,12 @@
<ClCompile Include="Emu\SysCalls\Modules\cellPngDec.cpp" /> <ClCompile Include="Emu\SysCalls\Modules\cellPngDec.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellResc.cpp" /> <ClCompile Include="Emu\SysCalls\Modules\cellResc.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellRtc.cpp" /> <ClCompile Include="Emu\SysCalls\Modules\cellRtc.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellSaveData.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellSpurs.cpp" /> <ClCompile Include="Emu\SysCalls\Modules\cellSpurs.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellSync.cpp" /> <ClCompile Include="Emu\SysCalls\Modules\cellSync.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellSysmodule.cpp" /> <ClCompile Include="Emu\SysCalls\Modules\cellSysmodule.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellSysutil.cpp" /> <ClCompile Include="Emu\SysCalls\Modules\cellSysutil.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellSysutilAp.cpp" /> <ClCompile Include="Emu\SysCalls\Modules\cellSysutilAp.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellSysutil_SaveData.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellUserInfo.cpp" /> <ClCompile Include="Emu\SysCalls\Modules\cellUserInfo.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellVdec.cpp" /> <ClCompile Include="Emu\SysCalls\Modules\cellVdec.cpp" />
<ClCompile Include="Emu\SysCalls\Modules\cellVpost.cpp" /> <ClCompile Include="Emu\SysCalls\Modules\cellVpost.cpp" />

View File

@ -472,10 +472,10 @@
<ClCompile Include="Loader\TROPUSR.cpp"> <ClCompile Include="Loader\TROPUSR.cpp">
<Filter>Loader</Filter> <Filter>Loader</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Emu\SysCalls\Modules\cellSaveData.cpp"> <ClCompile Include="Emu\SysCalls\Modules\cellAtrac.cpp">
<Filter>Emu\SysCalls\Modules</Filter> <Filter>Emu\SysCalls\Modules</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Emu\SysCalls\Modules\cellAtrac.cpp"> <ClCompile Include="Emu\SysCalls\Modules\cellSysutil_SaveData.cpp">
<Filter>Emu\SysCalls\Modules</Filter> <Filter>Emu\SysCalls\Modules</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>