summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-12-10 22:17:45 -0500
committerGravatar Zach Hilman2018-12-27 00:18:00 -0500
commitc643f364b4c81543782009ce4bb5a87021fe35ed (patch)
tree9ef68f80306b0bfbd17e84e70c44f3656c057fc5 /src
parentfilesystem: Populate save data sizes from control data (diff)
downloadyuzu-c643f364b4c81543782009ce4bb5a87021fe35ed.tar.gz
yuzu-c643f364b4c81543782009ce4bb5a87021fe35ed.tar.xz
yuzu-c643f364b4c81543782009ce4bb5a87021fe35ed.zip
am: Implement GetSaveDataSize and ExtendSaveData
These functions come in a pair and are needed by Smash Ultimate, Minecraft, and Skyrim, amongst others.
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/control_metadata.cpp2
-rw-r--r--src/core/file_sys/control_metadata.h2
-rw-r--r--src/core/file_sys/savedata_factory.cpp2
-rw-r--r--src/core/hle/service/am/am.cpp47
-rw-r--r--src/core/hle/service/am/am.h2
-rw-r--r--src/yuzu/configuration/configure_per_general.cpp6
6 files changed, 53 insertions, 8 deletions
diff --git a/src/core/file_sys/control_metadata.cpp b/src/core/file_sys/control_metadata.cpp
index 9624df054..83c184750 100644
--- a/src/core/file_sys/control_metadata.cpp
+++ b/src/core/file_sys/control_metadata.cpp
@@ -36,7 +36,7 @@ std::string LanguageEntry::GetDeveloperName() const {
36 developer_name.size()); 36 developer_name.size());
37} 37}
38 38
39NACP::NACP() : raw{} {} 39NACP::NACP() = default;
40 40
41NACP::NACP(VirtualFile file) { 41NACP::NACP(VirtualFile file) {
42 file->ReadObject(&raw); 42 file->ReadObject(&raw);
diff --git a/src/core/file_sys/control_metadata.h b/src/core/file_sys/control_metadata.h
index 9bc2720c9..7b9cdc910 100644
--- a/src/core/file_sys/control_metadata.h
+++ b/src/core/file_sys/control_metadata.h
@@ -100,7 +100,7 @@ public:
100 std::vector<u8> GetRawBytes() const; 100 std::vector<u8> GetRawBytes() const;
101 101
102private: 102private:
103 RawNACP raw; 103 RawNACP raw{};
104}; 104};
105 105
106} // namespace FileSys 106} // namespace FileSys
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp
index 54f5b698a..1913dc956 100644
--- a/src/core/file_sys/savedata_factory.cpp
+++ b/src/core/file_sys/savedata_factory.cpp
@@ -13,7 +13,7 @@
13 13
14namespace FileSys { 14namespace FileSys {
15 15
16constexpr const char* SAVE_DATA_SIZE_FILENAME = ".yuzu_save_size"; 16constexpr char SAVE_DATA_SIZE_FILENAME[] = ".yuzu_save_size";
17 17
18std::string SaveDataDescriptor::DebugInfo() const { 18std::string SaveDataDescriptor::DebugInfo() const {
19 return fmt::format("[type={:02X}, title_id={:016X}, user_id={:016X}{:016X}, save_id={:016X}]", 19 return fmt::format("[type={:02X}, title_id={:016X}, user_id={:016X}{:016X}, save_id={:016X}]",
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 5fc02a521..d13ce4dca 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -8,6 +8,7 @@
8#include <stack> 8#include <stack>
9#include "audio_core/audio_renderer.h" 9#include "audio_core/audio_renderer.h"
10#include "core/core.h" 10#include "core/core.h"
11#include "core/file_sys/savedata_factory.h"
11#include "core/hle/ipc_helpers.h" 12#include "core/hle/ipc_helpers.h"
12#include "core/hle/kernel/kernel.h" 13#include "core/hle/kernel/kernel.h"
13#include "core/hle/kernel/process.h" 14#include "core/hle/kernel/process.h"
@@ -865,8 +866,8 @@ IApplicationFunctions::IApplicationFunctions() : ServiceFramework("IApplicationF
865 {22, &IApplicationFunctions::SetTerminateResult, "SetTerminateResult"}, 866 {22, &IApplicationFunctions::SetTerminateResult, "SetTerminateResult"},
866 {23, &IApplicationFunctions::GetDisplayVersion, "GetDisplayVersion"}, 867 {23, &IApplicationFunctions::GetDisplayVersion, "GetDisplayVersion"},
867 {24, nullptr, "GetLaunchStorageInfoForDebug"}, 868 {24, nullptr, "GetLaunchStorageInfoForDebug"},
868 {25, nullptr, "ExtendSaveData"}, 869 {25, &IApplicationFunctions::ExtendSaveData, "ExtendSaveData"},
869 {26, nullptr, "GetSaveDataSize"}, 870 {26, &IApplicationFunctions::GetSaveDataSize, "GetSaveDataSize"},
870 {30, &IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed, "BeginBlockingHomeButtonShortAndLongPressed"}, 871 {30, &IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed, "BeginBlockingHomeButtonShortAndLongPressed"},
871 {31, &IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed, "EndBlockingHomeButtonShortAndLongPressed"}, 872 {31, &IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed, "EndBlockingHomeButtonShortAndLongPressed"},
872 {32, &IApplicationFunctions::BeginBlockingHomeButton, "BeginBlockingHomeButton"}, 873 {32, &IApplicationFunctions::BeginBlockingHomeButton, "BeginBlockingHomeButton"},
@@ -1043,6 +1044,48 @@ void IApplicationFunctions::GetPseudoDeviceId(Kernel::HLERequestContext& ctx) {
1043 rb.Push<u64>(0); 1044 rb.Push<u64>(0);
1044} 1045}
1045 1046
1047void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) {
1048 IPC::RequestParser rp{ctx};
1049 const auto type{rp.PopRaw<FileSys::SaveDataType>()};
1050 rp.Skip(1, false);
1051 const auto user_id{rp.PopRaw<u128>()};
1052 const auto new_normal_size{rp.PopRaw<u64>()};
1053 const auto new_journal_size{rp.PopRaw<u64>()};
1054
1055 LOG_DEBUG(Service_AM,
1056 "called with type={:02X}, user_id={:016X}{:016X}, new_normal={:016X}, "
1057 "new_journal={:016X}",
1058 static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size);
1059
1060 FileSystem::WriteSaveDataSize(type, Core::CurrentProcess()->GetTitleID(), user_id,
1061 {new_normal_size, new_journal_size});
1062
1063 IPC::ResponseBuilder rb{ctx, 4};
1064 rb.Push(RESULT_SUCCESS);
1065
1066 // The following value is used upon failure to help the system recover.
1067 // Since we always succeed, this should be 0.
1068 rb.Push<u64>(0);
1069}
1070
1071void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) {
1072 IPC::RequestParser rp{ctx};
1073 const auto type{rp.PopRaw<FileSys::SaveDataType>()};
1074 rp.Skip(1, false);
1075 const auto user_id{rp.PopRaw<u128>()};
1076
1077 LOG_DEBUG(Service_AM, "called with type={:02X}, user_id={:016X}{:016X}", static_cast<u8>(type),
1078 user_id[1], user_id[0]);
1079
1080 const auto size =
1081 FileSystem::ReadSaveDataSize(type, Core::CurrentProcess()->GetTitleID(), user_id);
1082
1083 IPC::ResponseBuilder rb{ctx, 6};
1084 rb.Push(RESULT_SUCCESS);
1085 rb.Push(size.normal);
1086 rb.Push(size.journal);
1087}
1088
1046void InstallInterfaces(SM::ServiceManager& service_manager, 1089void InstallInterfaces(SM::ServiceManager& service_manager,
1047 std::shared_ptr<NVFlinger::NVFlinger> nvflinger) { 1090 std::shared_ptr<NVFlinger::NVFlinger> nvflinger) {
1048 auto message_queue = std::make_shared<AppletMessageQueue>(); 1091 auto message_queue = std::make_shared<AppletMessageQueue>();
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h
index 34c45fadf..b6113cfdd 100644
--- a/src/core/hle/service/am/am.h
+++ b/src/core/hle/service/am/am.h
@@ -206,6 +206,8 @@ private:
206 void SetGamePlayRecordingState(Kernel::HLERequestContext& ctx); 206 void SetGamePlayRecordingState(Kernel::HLERequestContext& ctx);
207 void NotifyRunning(Kernel::HLERequestContext& ctx); 207 void NotifyRunning(Kernel::HLERequestContext& ctx);
208 void GetPseudoDeviceId(Kernel::HLERequestContext& ctx); 208 void GetPseudoDeviceId(Kernel::HLERequestContext& ctx);
209 void ExtendSaveData(Kernel::HLERequestContext& ctx);
210 void GetSaveDataSize(Kernel::HLERequestContext& ctx);
209 void BeginBlockingHomeButtonShortAndLongPressed(Kernel::HLERequestContext& ctx); 211 void BeginBlockingHomeButtonShortAndLongPressed(Kernel::HLERequestContext& ctx);
210 void EndBlockingHomeButtonShortAndLongPressed(Kernel::HLERequestContext& ctx); 212 void EndBlockingHomeButtonShortAndLongPressed(Kernel::HLERequestContext& ctx);
211 void BeginBlockingHomeButton(Kernel::HLERequestContext& ctx); 213 void BeginBlockingHomeButton(Kernel::HLERequestContext& ctx);
diff --git a/src/yuzu/configuration/configure_per_general.cpp b/src/yuzu/configuration/configure_per_general.cpp
index 5ca493b6d..dffaba5ed 100644
--- a/src/yuzu/configuration/configure_per_general.cpp
+++ b/src/yuzu/configuration/configure_per_general.cpp
@@ -108,9 +108,9 @@ void ConfigurePerGameGeneral::loadConfiguration() {
108 if (loader->ReadTitle(title) == Loader::ResultStatus::Success) 108 if (loader->ReadTitle(title) == Loader::ResultStatus::Success)
109 ui->display_name->setText(QString::fromStdString(title)); 109 ui->display_name->setText(QString::fromStdString(title));
110 110
111 std::string developer; 111 FileSys::NACP nacp;
112 if (loader->ReadDeveloper(developer) == Loader::ResultStatus::Success) 112 if (loader->ReadControlData(nacp) == Loader::ResultStatus::Success)
113 ui->display_developer->setText(QString::fromStdString(developer)); 113 ui->display_developer->setText(QString::fromStdString(nacp.GetDeveloperName()));
114 114
115 ui->display_version->setText(QStringLiteral("1.0.0")); 115 ui->display_version->setText(QStringLiteral("1.0.0"));
116 } 116 }