summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/am
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2021-08-19 18:42:18 +0200
committerMorph <39850852+Morph1984@users.noreply.github.com>2021-08-19 19:16:48 +0200
commit9cb376f8c2b73468912f47d7b25a0796b1a61180 (patch)
tree75c5071e1b054d95cc38b69878bbce206103a8f9 /src/core/hle/service/am
parentMerge pull request #6885 from v1993/patch-1 (diff)
downloadyuzu-9cb376f8c2b73468912f47d7b25a0796b1a61180.tar
yuzu-9cb376f8c2b73468912f47d7b25a0796b1a61180.tar.gz
yuzu-9cb376f8c2b73468912f47d7b25a0796b1a61180.tar.bz2
yuzu-9cb376f8c2b73468912f47d7b25a0796b1a61180.tar.lz
yuzu-9cb376f8c2b73468912f47d7b25a0796b1a61180.tar.xz
yuzu-9cb376f8c2b73468912f47d7b25a0796b1a61180.tar.zst
yuzu-9cb376f8c2b73468912f47d7b25a0796b1a61180.zip
Diffstat (limited to 'src/core/hle/service/am')
-rw-r--r--src/core/hle/service/am/applets/applet_error.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/core/hle/service/am/applets/applet_error.cpp b/src/core/hle/service/am/applets/applet_error.cpp
index ef6854d62..36a4aa9cd 100644
--- a/src/core/hle/service/am/applets/applet_error.cpp
+++ b/src/core/hle/service/am/applets/applet_error.cpp
@@ -16,6 +16,30 @@
namespace Service::AM::Applets {
+struct ErrorCode {
+ u32 error_category{};
+ u32 error_number{};
+
+ static constexpr ErrorCode FromU64(u64 error_code) {
+ return {
+ .error_category{static_cast<u32>(error_code >> 32)},
+ .error_number{static_cast<u32>(error_code & 0xFFFFFFFF)},
+ };
+ }
+
+ static constexpr ErrorCode FromResultCode(ResultCode result) {
+ return {
+ .error_category{2000 + static_cast<u32>(result.module.Value())},
+ .error_number{result.description.Value()},
+ };
+ }
+
+ constexpr ResultCode ToResultCode() const {
+ return ResultCode{static_cast<ErrorModule>(error_category - 2000), error_number};
+ }
+};
+static_assert(sizeof(ErrorCode) == 0x8, "ErrorCode has incorrect size.");
+
#pragma pack(push, 4)
struct ShowError {
u8 mode;
@@ -76,12 +100,7 @@ void CopyArgumentData(const std::vector<u8>& data, T& variable) {
}
ResultCode Decode64BitError(u64 error) {
- const auto description = (error >> 32) & 0x1FFF;
- auto module = error & 0x3FF;
- if (module >= 2000)
- module -= 2000;
- module &= 0x1FF;
- return {static_cast<ErrorModule>(module), static_cast<u32>(description)};
+ return ErrorCode::FromU64(error).ToResultCode();
}
} // Anonymous namespace