mirror of
https://github.com/InoriRus/Kyty.git
synced 2026-08-28 05:06:40 +00:00
one step closer to run games
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
#include "Kyty/Core/Common.h"
|
||||
#include "Kyty/Core/DbgAssert.h"
|
||||
#include "Kyty/Core/File.h"
|
||||
#include "Kyty/Core/String.h"
|
||||
|
||||
#include "Emulator/Common.h"
|
||||
#include "Emulator/Kernel/FileSystem.h"
|
||||
#include "Emulator/Libs/Errno.h"
|
||||
#include "Emulator/Libs/Libs.h"
|
||||
#include "Emulator/SymbolDatabase.h"
|
||||
@@ -15,6 +17,10 @@ LIB_VERSION("SaveData", 1, "SaveData", 1, 1);
|
||||
|
||||
namespace SaveData {
|
||||
|
||||
// TODO(): specify dir at launcher
|
||||
static constexpr char32_t SAVE_DATA_DIR[] = U"_SaveData";
|
||||
static constexpr char32_t SAVE_DATA_POINT[] = U"/savedata0";
|
||||
|
||||
struct SceSaveDataDirName
|
||||
{
|
||||
char data[32];
|
||||
@@ -46,6 +52,17 @@ struct SaveDataMountResult
|
||||
int pad;
|
||||
};
|
||||
|
||||
struct SaveDataParam
|
||||
{
|
||||
char title[128];
|
||||
char sub_title[128];
|
||||
char detail[1024];
|
||||
uint32_t user_param;
|
||||
int pad;
|
||||
int64_t mtime;
|
||||
uint8_t reserved[32];
|
||||
};
|
||||
|
||||
int KYTY_SYSV_ABI SaveDataInitialize(const void* /*init*/)
|
||||
{
|
||||
PRINT_NAME();
|
||||
@@ -85,18 +102,90 @@ int KYTY_SYSV_ABI SaveDataMount2(const SaveDataMount2* mount, SaveDataMountResul
|
||||
printf("\t blocks = %" PRIu64 "\n", mount->blocks);
|
||||
printf("\t mount_mode = %" PRIu32 "\n", mount->mount_mode);
|
||||
|
||||
if (mount->mount_mode == 1)
|
||||
{
|
||||
return SAVE_DATA_ERROR_NOT_FOUND;
|
||||
} else // NOLINT
|
||||
String mount_dir = String(SAVE_DATA_DIR) + U"/" + String::FromUtf8(mount->dir_name->data);
|
||||
String mount_point = SAVE_DATA_POINT;
|
||||
bool create = (mount->mount_mode == 22);
|
||||
bool open = (mount->mount_mode == 1 || mount->mount_mode == 2);
|
||||
|
||||
if (!create && !open)
|
||||
{
|
||||
EXIT("unknown mount mode: %u", mount->mount_mode);
|
||||
}
|
||||
|
||||
strcpy(mount_result->mount_point.data, "/savedata0");
|
||||
if (open)
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED(create);
|
||||
|
||||
if (!Core::File::IsDirectoryExisting(mount_dir))
|
||||
{
|
||||
return SAVE_DATA_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
LibKernel::FileSystem::Mount(mount_dir, mount_point);
|
||||
|
||||
mount_result->mount_status = 0;
|
||||
}
|
||||
|
||||
if (create)
|
||||
{
|
||||
EXIT_NOT_IMPLEMENTED(open);
|
||||
|
||||
if (Core::File::IsDirectoryExisting(mount_dir))
|
||||
{
|
||||
return SAVE_DATA_ERROR_EXISTS;
|
||||
}
|
||||
|
||||
Core::File::CreateDirectories(mount_dir);
|
||||
|
||||
EXIT_NOT_IMPLEMENTED((!Core::File::IsDirectoryExisting(mount_dir)));
|
||||
|
||||
LibKernel::FileSystem::Mount(mount_dir, mount_point);
|
||||
|
||||
mount_result->mount_status = 1;
|
||||
}
|
||||
|
||||
snprintf(mount_result->mount_point.data, 16, "%s", mount_point.C_Str());
|
||||
|
||||
mount_result->required_blocks = 0;
|
||||
mount_result->mount_status = 1;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI SaveDataUmount(const SaveDataMountPoint* mount_point)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(mount_point == nullptr);
|
||||
|
||||
printf("\t mount_point = %s\n", mount_point->data);
|
||||
|
||||
LibKernel::FileSystem::Umount(String::FromUtf8(mount_point->data));
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI SaveDataSetParam(const SaveDataMountPoint* mount_point, uint32_t param_type, const void* param_buf, size_t param_buf_size)
|
||||
{
|
||||
PRINT_NAME();
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(mount_point == nullptr);
|
||||
|
||||
printf("\t mount_point = %s\n", mount_point->data);
|
||||
printf("\t param_type = %u\n", param_type);
|
||||
printf("\t param_buf_size = %" PRIu64 "\n", param_buf_size);
|
||||
|
||||
if (param_type == 0)
|
||||
{
|
||||
const auto* p = static_cast<const SaveDataParam*>(param_buf);
|
||||
|
||||
printf("\t title = %s\n", p->title);
|
||||
printf("\t sub_title = %s\n", p->sub_title);
|
||||
printf("\t detail = %s\n", p->detail);
|
||||
printf("\t user_param = %u\n", p->user_param);
|
||||
} else
|
||||
{
|
||||
KYTY_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -109,6 +198,8 @@ LIB_DEFINE(InitSaveData_1)
|
||||
LIB_FUNC("l1NmDeDpNGU", SaveData::SaveDataInitialize2);
|
||||
LIB_FUNC("TywrFKCoLGY", SaveData::SaveDataInitialize3);
|
||||
LIB_FUNC("0z45PIH+SNI", SaveData::SaveDataMount2);
|
||||
LIB_FUNC("BMR4F-Uek3E", SaveData::SaveDataUmount);
|
||||
LIB_FUNC("85zul--eGXs", SaveData::SaveDataSetParam);
|
||||
}
|
||||
|
||||
} // namespace Kyty::Libs
|
||||
|
||||
Reference in New Issue
Block a user