summaryrefslogtreecommitdiffstats
path: root/src/core/hle
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2023-03-17 00:47:32 +0100
committerNarr the Reg <juangerman-13@hotmail.com>2023-03-17 00:47:32 +0100
commit075a3d11723d629148e016d089e2c533264ae831 (patch)
tree34a53e89575609b3eabfda5bb1dfea10f4c86f1f /src/core/hle
parentservice: nfp: Close app area and recreate crc (diff)
downloadyuzu-075a3d11723d629148e016d089e2c533264ae831.tar
yuzu-075a3d11723d629148e016d089e2c533264ae831.tar.gz
yuzu-075a3d11723d629148e016d089e2c533264ae831.tar.bz2
yuzu-075a3d11723d629148e016d089e2c533264ae831.tar.lz
yuzu-075a3d11723d629148e016d089e2c533264ae831.tar.xz
yuzu-075a3d11723d629148e016d089e2c533264ae831.tar.zst
yuzu-075a3d11723d629148e016d089e2c533264ae831.zip
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/nfp/nfp_device.cpp44
-rw-r--r--src/core/hle/service/nfp/nfp_device.h1
2 files changed, 17 insertions, 28 deletions
diff --git a/src/core/hle/service/nfp/nfp_device.cpp b/src/core/hle/service/nfp/nfp_device.cpp
index 61a7ea7ac..268337d2e 100644
--- a/src/core/hle/service/nfp/nfp_device.cpp
+++ b/src/core/hle/service/nfp/nfp_device.cpp
@@ -3,6 +3,17 @@
#include <array>
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4701) // Potentially uninitialized local variable 'result' used
+#endif
+
+#include <boost/crc.hpp>
+
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
#include "common/input.h"
#include "common/logging/log.h"
#include "common/string_util.h"
@@ -843,7 +854,9 @@ void NfpDevice::UpdateSettingsCrc() {
// TODO: this reads data from a global, find what it is
std::array<u8, 8> unknown_input{};
- settings.crc = CalculateCrc(unknown_input);
+ boost::crc_32_type crc;
+ crc.process_bytes(&unknown_input, sizeof(unknown_input));
+ settings.crc = crc.checksum();
}
void NfpDevice::UpdateRegisterInfoCrc() {
@@ -866,32 +879,9 @@ void NfpDevice::UpdateRegisterInfoCrc() {
.unknown2 = tag_data.unknown2,
};
- std::array<u8, sizeof(CrcData)> data{};
- memcpy(data.data(), &crc_data, sizeof(CrcData));
- tag_data.register_info_crc = CalculateCrc(data);
-}
-
-u32 NfpDevice::CalculateCrc(std::span<const u8> data) {
- constexpr u32 magic = 0xedb88320;
- u32 crc = 0xffffffff;
-
- if (data.size() == 0) {
- return 0;
- }
-
- for (u8 input : data) {
- crc ^= input;
- crc = crc >> 1 ^ ((crc & 1) ? magic : 0x0);
- crc = crc >> 1 ^ ((crc & 1) ? magic : 0x0);
- crc = crc >> 1 ^ ((crc & 1) ? magic : 0x0);
- crc = crc >> 1 ^ ((crc & 1) ? magic : 0x0);
- crc = crc >> 1 ^ ((crc & 1) ? magic : 0x0);
- crc = crc >> 1 ^ ((crc & 1) ? magic : 0x0);
- crc = crc >> 1 ^ ((crc & 1) ? magic : 0x0);
- crc = crc >> 1 ^ ((crc & 1) ? magic : 0x0);
- }
-
- return ~crc;
+ boost::crc_32_type crc;
+ crc.process_bytes(&crc_data, sizeof(CrcData));
+ tag_data.register_info_crc = crc.checksum();
}
} // namespace Service::NFP
diff --git a/src/core/hle/service/nfp/nfp_device.h b/src/core/hle/service/nfp/nfp_device.h
index fc7fbd578..8813df998 100644
--- a/src/core/hle/service/nfp/nfp_device.h
+++ b/src/core/hle/service/nfp/nfp_device.h
@@ -81,7 +81,6 @@ private:
u64 RemoveVersionByte(u64 application_id) const;
void UpdateSettingsCrc();
void UpdateRegisterInfoCrc();
- u32 CalculateCrc(std::span<const u8>);
bool is_controller_set{};
int callback_key;