From 673de3995b7f08d51fcc281439c05c368b7bd1ae Mon Sep 17 00:00:00 2001 From: german77 Date: Mon, 26 Sep 2022 00:58:36 -0500 Subject: nfp: Multiple fixes against HW --- src/core/hle/service/nfp/nfp_types.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/core/hle/service/nfp/nfp_types.h') diff --git a/src/core/hle/service/nfp/nfp_types.h b/src/core/hle/service/nfp/nfp_types.h index 2685ae8fe..448791846 100644 --- a/src/core/hle/service/nfp/nfp_types.h +++ b/src/core/hle/service/nfp/nfp_types.h @@ -75,11 +75,19 @@ enum class AmiiboSeries : u8 { Diablo, }; -using TagUuid = std::array; +using UniqueSerialNumber = std::array; +using LockBytes = std::array; using HashData = std::array; using ApplicationArea = std::array; using AmiiboName = std::array; +struct TagUuid { + UniqueSerialNumber uid; + u8 nintendo_id; + LockBytes lock_bytes; +}; +static_assert(sizeof(TagUuid) == 10, "TagUuid is an invalid size"); + struct AmiiboDate { u16 raw_date{}; @@ -91,7 +99,7 @@ struct AmiiboDate { return static_cast(((GetValue() & 0xFE00) >> 9) + 2000); } u8 GetMonth() const { - return static_cast(((GetValue() & 0x01E0) >> 5) - 1); + return static_cast((GetValue() & 0x01E0) >> 5); } u8 GetDay() const { return static_cast(GetValue() & 0x001F); @@ -102,7 +110,7 @@ struct AmiiboDate { raw_date = Common::swap16((GetValue() & ~0xFE00) | year_converted); } void SetMonth(u8 month) { - const u16 month_converted = static_cast((month + 1) << 5); + const u16 month_converted = static_cast(month << 5); raw_date = Common::swap16((GetValue() & ~0x01E0) | month_converted); } void SetDay(u8 day) { @@ -137,7 +145,7 @@ struct AmiiboModelInfo { u16 character_id; u8 character_variant; AmiiboType amiibo_type; - u16 model_number; + u16_be model_number; AmiiboSeries series; u8 constant_value; // Must be 02 INSERT_PADDING_BYTES(0x4); // Unknown @@ -172,7 +180,7 @@ struct EncryptedAmiiboFile { static_assert(sizeof(EncryptedAmiiboFile) == 0x1F8, "AmiiboFile is an invalid size"); struct NTAG215File { - std::array uuid2; + LockBytes lock_bytes; // Tag UUID u16 static_lock; // Set defined pages as read only u32 compability_container; // Defines available memory HashData hmac_data; // Hash @@ -188,7 +196,8 @@ struct NTAG215File { HashData hash; // Probably a SHA256-HMAC hash? ApplicationArea application_area; // Encrypted Game data HashData hmac_tag; // Hash - std::array uuid; + UniqueSerialNumber uid; // Unique serial number + u8 nintendo_id; // Tag UUID AmiiboModelInfo model_info; HashData keygen_salt; // Salt u32 dynamic_lock; // Dynamic lock @@ -215,7 +224,8 @@ static_assert(std::is_trivially_copyable_v, "EncryptedNTAG215File must be trivially copyable."); struct TagInfo { - TagUuid uuid; + UniqueSerialNumber uuid; + INSERT_PADDING_BYTES(0x3); u8 uuid_length; INSERT_PADDING_BYTES(0x15); s32 protocol; -- cgit v1.2.3