diff options
author | german77 <juangerman-13@hotmail.com> | 2023-09-17 18:45:24 +0200 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2023-09-18 00:06:25 +0200 |
commit | bd409c34162783d512d71a1c9e46bc874f73de38 (patch) | |
tree | 5ad8613891c29b0f86aae89d56490d3b352f06d6 /src/core | |
parent | service: nfc: Fully Implement GetRegisterInfoPrivate (diff) | |
download | yuzu-bd409c34162783d512d71a1c9e46bc874f73de38.tar yuzu-bd409c34162783d512d71a1c9e46bc874f73de38.tar.gz yuzu-bd409c34162783d512d71a1c9e46bc874f73de38.tar.bz2 yuzu-bd409c34162783d512d71a1c9e46bc874f73de38.tar.lz yuzu-bd409c34162783d512d71a1c9e46bc874f73de38.tar.xz yuzu-bd409c34162783d512d71a1c9e46bc874f73de38.tar.zst yuzu-bd409c34162783d512d71a1c9e46bc874f73de38.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hle/service/mii/mii_util.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/core/hle/service/mii/mii_util.h b/src/core/hle/service/mii/mii_util.h index ddb544c23..3534fa31d 100644 --- a/src/core/hle/service/mii/mii_util.h +++ b/src/core/hle/service/mii/mii_util.h @@ -28,6 +28,32 @@ public: return Common::swap16(static_cast<u16>(crc)); } + static u16 CalculateDeviceCrc16(const Common::UUID& uuid, std::size_t data_size) { + constexpr u16 magic{0x1021}; + s32 crc{}; + + for (std::size_t i = 0; i < uuid.uuid.size(); i++) { + for (std::size_t j = 0; j < 8; j++) { + crc <<= 1; + if ((crc & 0x10000) != 0) { + crc = crc ^ magic; + } + } + crc ^= uuid.uuid[i]; + } + + // As much as this looks wrong this is what N's does + + for (std::size_t i = 0; i < data_size * 8; i++) { + crc <<= 1; + if ((crc & 0x10000) != 0) { + crc = crc ^ magic; + } + } + + return Common::swap16(static_cast<u16>(crc)); + } + static Common::UUID MakeCreateId() { return Common::UUID::MakeRandomRFC4122V4(); } |