summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/nfp/nfp_types.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-10-02 23:28:43 +0200
committerGitHub <noreply@github.com>2022-10-02 23:28:43 +0200
commit61399de5dbc64ada1c9e5ec3d84be76c215fdc0c (patch)
tree72313f1b749d0771e38dbfcf539121a02d4b9ae0 /src/core/hle/service/nfp/nfp_types.h
parentMerge pull request #8992 from Morph1984/vi-vsync-event (diff)
parentservice: mii: Copy only valid name bytes (diff)
downloadyuzu-61399de5dbc64ada1c9e5ec3d84be76c215fdc0c.tar
yuzu-61399de5dbc64ada1c9e5ec3d84be76c215fdc0c.tar.gz
yuzu-61399de5dbc64ada1c9e5ec3d84be76c215fdc0c.tar.bz2
yuzu-61399de5dbc64ada1c9e5ec3d84be76c215fdc0c.tar.lz
yuzu-61399de5dbc64ada1c9e5ec3d84be76c215fdc0c.tar.xz
yuzu-61399de5dbc64ada1c9e5ec3d84be76c215fdc0c.tar.zst
yuzu-61399de5dbc64ada1c9e5ec3d84be76c215fdc0c.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/nfp/nfp_types.h (renamed from src/core/hle/service/nfp/amiibo_types.h)116
1 files changed, 104 insertions, 12 deletions
diff --git a/src/core/hle/service/nfp/amiibo_types.h b/src/core/hle/service/nfp/nfp_types.h
index bf2de811a..dd4525b61 100644
--- a/src/core/hle/service/nfp/amiibo_types.h
+++ b/src/core/hle/service/nfp/nfp_types.h
@@ -5,6 +5,7 @@
#include <array>
+#include "common/swap.h"
#include "core/hle/service/mii/types.h"
namespace Service::NFP {
@@ -27,7 +28,7 @@ enum class DeviceState : u32 {
TagFound,
TagRemoved,
TagMounted,
- Unaviable,
+ Unavailable,
Finalized,
};
@@ -36,6 +37,7 @@ enum class ModelType : u32 {
};
enum class MountTarget : u32 {
+ None,
Rom,
Ram,
All,
@@ -73,21 +75,63 @@ enum class AmiiboSeries : u8 {
Diablo,
};
-using TagUuid = std::array<u8, 10>;
+enum class TagType : u32 {
+ None,
+ Type1, // ISO14443A RW 96-2k bytes 106kbit/s
+ Type2, // ISO14443A RW/RO 540 bytes 106kbit/s
+ Type3, // Sony Felica RW/RO 2k bytes 212kbit/s
+ Type4, // ISO14443A RW/RO 4k-32k bytes 424kbit/s
+ Type5, // ISO15693 RW/RO 540 bytes 106kbit/s
+};
+
+enum class TagProtocol : u32 {
+ None,
+ TypeA, // ISO14443A
+ TypeB, // ISO14443B
+ TypeF, // Sony Felica
+};
+
+using UniqueSerialNumber = std::array<u8, 7>;
+using LockBytes = std::array<u8, 2>;
using HashData = std::array<u8, 0x20>;
using ApplicationArea = std::array<u8, 0xD8>;
+using AmiiboName = std::array<char, (amiibo_name_length * 4) + 1>;
+
+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{};
+ u16 GetValue() const {
+ return Common::swap16(raw_date);
+ }
+
u16 GetYear() const {
- return static_cast<u16>(((raw_date & 0xFE00) >> 9) + 2000);
+ return static_cast<u16>(((GetValue() & 0xFE00) >> 9) + 2000);
}
u8 GetMonth() const {
- return static_cast<u8>(((raw_date & 0x01E0) >> 5) - 1);
+ return static_cast<u8>((GetValue() & 0x01E0) >> 5);
}
u8 GetDay() const {
- return static_cast<u8>(raw_date & 0x001F);
+ return static_cast<u8>(GetValue() & 0x001F);
+ }
+
+ void SetYear(u16 year) {
+ const u16 year_converted = static_cast<u16>((year - 2000) << 9);
+ raw_date = Common::swap16((GetValue() & ~0xFE00) | year_converted);
+ }
+ void SetMonth(u8 month) {
+ const u16 month_converted = static_cast<u16>(month << 5);
+ raw_date = Common::swap16((GetValue() & ~0x01E0) | month_converted);
+ }
+ void SetDay(u8 day) {
+ const u16 day_converted = static_cast<u16>(day);
+ raw_date = Common::swap16((GetValue() & ~0x001F) | day_converted);
}
};
static_assert(sizeof(AmiiboDate) == 2, "AmiiboDate is an invalid size");
@@ -117,7 +161,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
@@ -134,7 +178,7 @@ static_assert(sizeof(NTAG215Password) == 0x8, "NTAG215Password is an invalid siz
#pragma pack(1)
struct EncryptedAmiiboFile {
u8 constant_value; // Must be A5
- u16 write_counter; // Number of times the amiibo has been written?
+ u16_be write_counter; // Number of times the amiibo has been written?
INSERT_PADDING_BYTES(0x1); // Unknown 1
AmiiboSettings settings; // Encrypted amiibo settings
HashData hmac_tag; // Hash
@@ -146,18 +190,18 @@ struct EncryptedAmiiboFile {
u16_be applicaton_write_counter; // Encrypted Counter
u32_be application_area_id; // Encrypted Game id
std::array<u8, 0x2> unknown;
- HashData hash; // Probably a SHA256-HMAC hash?
+ std::array<u32, 0x8> unknown2;
ApplicationArea application_area; // Encrypted Game data
};
static_assert(sizeof(EncryptedAmiiboFile) == 0x1F8, "AmiiboFile is an invalid size");
struct NTAG215File {
- std::array<u8, 0x2> 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
u8 constant_value; // Must be A5
- u16 write_counter; // Number of times the amiibo has been written?
+ u16_be write_counter; // Number of times the amiibo has been written?
INSERT_PADDING_BYTES(0x1); // Unknown 1
AmiiboSettings settings;
Service::Mii::Ver3StoreData owner_mii; // Encrypted Mii data
@@ -165,10 +209,11 @@ struct NTAG215File {
u16_be applicaton_write_counter; // Encrypted Counter
u32_be application_area_id;
std::array<u8, 0x2> unknown;
- HashData hash; // Probably a SHA256-HMAC hash?
+ std::array<u32, 0x8> unknown2;
ApplicationArea application_area; // Encrypted Game data
HashData hmac_tag; // Hash
- std::array<u8, 0x8> uuid;
+ UniqueSerialNumber uid; // Unique serial number
+ u8 nintendo_id; // Tag UUID
AmiiboModelInfo model_info;
HashData keygen_salt; // Salt
u32 dynamic_lock; // Dynamic lock
@@ -194,4 +239,51 @@ static_assert(sizeof(EncryptedNTAG215File) == 0x21C, "EncryptedNTAG215File is an
static_assert(std::is_trivially_copyable_v<EncryptedNTAG215File>,
"EncryptedNTAG215File must be trivially copyable.");
+struct TagInfo {
+ UniqueSerialNumber uuid;
+ INSERT_PADDING_BYTES(0x3);
+ u8 uuid_length;
+ INSERT_PADDING_BYTES(0x15);
+ TagProtocol protocol;
+ TagType tag_type;
+ INSERT_PADDING_BYTES(0x30);
+};
+static_assert(sizeof(TagInfo) == 0x58, "TagInfo is an invalid size");
+
+struct WriteDate {
+ u16 year;
+ u8 month;
+ u8 day;
+};
+static_assert(sizeof(WriteDate) == 0x4, "WriteDate is an invalid size");
+
+struct CommonInfo {
+ WriteDate last_write_date;
+ u16 write_counter;
+ u8 version;
+ INSERT_PADDING_BYTES(0x1);
+ u32 application_area_size;
+ INSERT_PADDING_BYTES(0x34);
+};
+static_assert(sizeof(CommonInfo) == 0x40, "CommonInfo is an invalid size");
+
+struct ModelInfo {
+ u16 character_id;
+ u8 character_variant;
+ AmiiboType amiibo_type;
+ u16 model_number;
+ AmiiboSeries series;
+ INSERT_PADDING_BYTES(0x39); // Unknown
+};
+static_assert(sizeof(ModelInfo) == 0x40, "ModelInfo is an invalid size");
+
+struct RegisterInfo {
+ Service::Mii::CharInfo mii_char_info;
+ WriteDate creation_date;
+ AmiiboName amiibo_name;
+ u8 font_region;
+ INSERT_PADDING_BYTES(0x7A);
+};
+static_assert(sizeof(RegisterInfo) == 0x100, "RegisterInfo is an invalid size");
+
} // namespace Service::NFP