mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
Improve some nfp types/enums
This commit is contained in:
parent
29f6f4fa7a
commit
e4f73f5337
@ -113,6 +113,15 @@ typedef struct {
|
|||||||
u8 unk_x57;
|
u8 unk_x57;
|
||||||
} MiiCharInfo;
|
} MiiCharInfo;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
u8 data[0x44];
|
||||||
|
} MiiStoreData;
|
||||||
|
|
||||||
|
// Mii format used in 3DS (https://www.3dbrew.org/wiki/Mii#Mii_format).
|
||||||
|
typedef struct {
|
||||||
|
u8 data[0x60];
|
||||||
|
} MiiVer3StoreData;
|
||||||
|
|
||||||
// Original Mii colors and types before Ver3StoreData conversion
|
// Original Mii colors and types before Ver3StoreData conversion
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u8 faceline_color;
|
u8 faceline_color;
|
||||||
|
@ -23,11 +23,6 @@ typedef enum {
|
|||||||
NfcServiceType_System = 1, ///< Initializes nfc:sys.
|
NfcServiceType_System = 1, ///< Initializes nfc:sys.
|
||||||
} NfcServiceType;
|
} NfcServiceType;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
NfpState_NonInitialized = 0,
|
|
||||||
NfpState_Initialized = 1,
|
|
||||||
} NfpState;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NfcState_NonInitialized = 0,
|
NfcState_NonInitialized = 0,
|
||||||
NfcState_Initialized = 1,
|
NfcState_Initialized = 1,
|
||||||
@ -40,7 +35,6 @@ typedef enum {
|
|||||||
NfpDeviceState_TagRemoved = 3,
|
NfpDeviceState_TagRemoved = 3,
|
||||||
NfpDeviceState_TagMounted = 4,
|
NfpDeviceState_TagMounted = 4,
|
||||||
NfpDeviceState_Unavailable = 5,
|
NfpDeviceState_Unavailable = 5,
|
||||||
NfpDeviceState_Finalized = 6,
|
|
||||||
} NfpDeviceState;
|
} NfpDeviceState;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -49,16 +43,23 @@ typedef enum {
|
|||||||
NfcDeviceState_TagFound = 2,
|
NfcDeviceState_TagFound = 2,
|
||||||
NfcDeviceState_TagRemoved = 3,
|
NfcDeviceState_TagRemoved = 3,
|
||||||
NfcDeviceState_TagMounted = 4,
|
NfcDeviceState_TagMounted = 4,
|
||||||
NfcDeviceState_Unavailable = 5,
|
|
||||||
NfcDeviceState_Finalized = 6,
|
|
||||||
} NfcDeviceState;
|
} NfcDeviceState;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NfpApplicationAreaVersion_3DS = 0,
|
NfcMifareDeviceState_Initialized = 0,
|
||||||
NfpApplicationAreaVersion_WiiU = 1,
|
NfcMifareDeviceState_SearchingForTag = 1,
|
||||||
NfpApplicationAreaVersion_3DSv2 = 2,
|
NfcMifareDeviceState_TagFound = 2,
|
||||||
NfpApplicationAreaVersion_Switch = 3,
|
NfcMifareDeviceState_TagRemoved = 3,
|
||||||
NfpApplicationAreaVersion_NotSet = 0xFF,
|
NfcMifareDeviceState_TagMounted = 4,
|
||||||
|
NfcMifareDeviceState_Unavailable = 5,
|
||||||
|
} NfcMifareDeviceState;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NfpApplicationAreaVersion_3DS = 0, ///< Application area created by a 3DS game.
|
||||||
|
NfpApplicationAreaVersion_WiiU = 1, ///< Application area created by a Wii U game.
|
||||||
|
NfpApplicationAreaVersion_3DSv2 = 2, ///< Application area created by a (new?) 3DS game.
|
||||||
|
NfpApplicationAreaVersion_Switch = 3, ///< Application area created by a Switch game.
|
||||||
|
NfpApplicationAreaVersion_Invalid = 0xFF, ///< Invalid value (application area not created).
|
||||||
} NfpApplicationAreaVersion;
|
} NfpApplicationAreaVersion;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -66,9 +67,9 @@ typedef enum {
|
|||||||
} NfpDeviceType;
|
} NfpDeviceType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NfpMountTarget_Rom = 1,
|
NfpMountTarget_Rom = BIT(0),
|
||||||
NfpMountTarget_Ram = 2,
|
NfpMountTarget_Ram = BIT(1),
|
||||||
NfpMountTarget_All = 3,
|
NfpMountTarget_All = NfpMountTarget_Rom | NfpMountTarget_Ram,
|
||||||
} NfpMountTarget;
|
} NfpMountTarget;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -102,28 +103,39 @@ typedef enum {
|
|||||||
NfcMifareCommand_Store = 0xC2,
|
NfcMifareCommand_Store = 0xC2,
|
||||||
} NfcMifareCommand;
|
} NfcMifareCommand;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NfpAmiiboFlag_Valid = BIT(0), ///< Initialized in system settings.
|
||||||
|
NfpAmiiboFlag_ApplicationAreaExists = BIT(1), ///< Application area exists.
|
||||||
|
} NfpAmiiboFlag;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u8 uuid[10];
|
u16 year;
|
||||||
u8 uuid_length;
|
u8 month;
|
||||||
|
u8 day;
|
||||||
|
} NX_PACKED NfpDate;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
u8 uid[10]; ///< UUID.
|
||||||
|
u8 uid_length; ///< UUID length.
|
||||||
u8 reserved1[0x15];
|
u8 reserved1[0x15];
|
||||||
u32 protocol;
|
} NX_PACKED NfcTagUid;
|
||||||
u32 tag_type;
|
|
||||||
|
typedef struct {
|
||||||
|
NfcTagUid uid; ///< UUID.
|
||||||
|
u32 protocol; ///< \ref NfcProtocol
|
||||||
|
u32 tag_type; ///< \ref NfcTagType
|
||||||
u8 reserved2[0x30];
|
u8 reserved2[0x30];
|
||||||
} NX_PACKED NfpTagInfo;
|
} NX_PACKED NfpTagInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u8 uuid[10];
|
NfcTagUid uid; ///< UUID.
|
||||||
u8 uuid_length;
|
u32 protocol; ///< \ref NfcProtocol
|
||||||
u8 reserved1[0x15];
|
u32 tag_type; ///< \ref NfcTagType
|
||||||
u32 protocol;
|
|
||||||
u32 tag_type;
|
|
||||||
u8 reserved2[0x30];
|
u8 reserved2[0x30];
|
||||||
} NX_PACKED NfcTagInfo;
|
} NX_PACKED NfcTagInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u16 last_write_year;
|
NfpDate last_write_date;
|
||||||
u8 last_write_month;
|
|
||||||
u8 last_write_day;
|
|
||||||
u16 write_counter;
|
u16 write_counter;
|
||||||
u16 version;
|
u16 version;
|
||||||
u32 application_area_size;
|
u32 application_area_size;
|
||||||
@ -131,34 +143,33 @@ typedef struct {
|
|||||||
} NX_PACKED NfpCommonInfo;
|
} NX_PACKED NfpCommonInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u8 amiibo_id[0x8];
|
u8 character_id[3];
|
||||||
u8 reserved[0x38];
|
u8 series_id;
|
||||||
|
u16 numbering_id;
|
||||||
|
u8 nfp_type;
|
||||||
|
u8 reserved1[0x39];
|
||||||
} NX_PACKED NfpModelInfo;
|
} NX_PACKED NfpModelInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MiiCharInfo mii;
|
MiiCharInfo mii;
|
||||||
u16 first_write_year;
|
NfpDate first_write_date;
|
||||||
u8 first_write_month;
|
char amiibo_name[(10*4)+1]; ///< Amiibo name (utf-8, null-terminated).
|
||||||
u8 first_write_day;
|
|
||||||
char amiibo_name[(10*4)+1]; ///< utf-8, null-terminated
|
|
||||||
u8 font_region;
|
u8 font_region;
|
||||||
u8 reserved[0x7A];
|
u8 reserved[0x7A];
|
||||||
} NX_PACKED NfpRegisterInfo;
|
} NX_PACKED NfpRegisterInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u8 mii_store_data[0x44];
|
MiiStoreData mii_store_data;
|
||||||
u16 first_write_year;
|
NfpDate first_write_date;
|
||||||
u8 first_write_month;
|
char amiibo_name[(10*4)+1]; ///< Amiibo name (utf-8, null-terminated).
|
||||||
u8 first_write_day;
|
|
||||||
char amiibo_name[(10*4)+1]; ///< utf-8, null-terminated
|
|
||||||
u8 font_region;
|
u8 font_region;
|
||||||
u8 reserved[0x8E];
|
u8 reserved[0x8E];
|
||||||
} NX_PACKED NfpRegisterInfoPrivate;
|
} NX_PACKED NfpRegisterInfoPrivate;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u64 application_id;
|
u64 application_id;
|
||||||
u32 application_area_id;
|
u32 access_id;
|
||||||
u16 crc_change_counter;
|
u16 crc32_change_counter;
|
||||||
u8 flags;
|
u8 flags;
|
||||||
u8 tag_type;
|
u8 tag_type;
|
||||||
u8 application_area_version;
|
u8 application_area_version;
|
||||||
@ -166,39 +177,34 @@ typedef struct {
|
|||||||
} NX_PACKED NfpAdminInfo;
|
} NX_PACKED NfpAdminInfo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u8 magic;
|
u8 tag_magic; ///< Tag magic (always 0xA5: https://www.3dbrew.org/wiki/Amiibo#Page_layout).
|
||||||
u8 reserved1[0x1];
|
u8 reserved1[0x1];
|
||||||
u8 write_counter;
|
u16 tag_write_counter; ///< Incremented every tag write.
|
||||||
u8 reserved2[0x1];
|
u32 crc32_1; ///< CRC32 of some internal 8-byte data.
|
||||||
u32 settings_crc;
|
u8 reserved2[0x38];
|
||||||
u8 reserved3[0x38];
|
NfpDate last_write_date; ///< Updated every write.
|
||||||
u16 last_write_year;
|
u16 write_counter; ///< Incremented every write, until it maxes out at 0xFFFF.
|
||||||
u8 last_write_month;
|
u16 version; ///< Version.
|
||||||
u8 last_write_day;
|
u32 application_area_size; ///< Size of the application area.
|
||||||
u16 application_write_counter;
|
u8 reserved3[0x34];
|
||||||
u16 version;
|
MiiVer3StoreData mii_v3; ///< Ver3StoreData (Mii format used in 3DS).
|
||||||
u32 application_area_size;
|
MiiNfpStoreDataExtension mii_store_data_extension; ///< StoreDataExtension
|
||||||
u8 reserved4[0x34];
|
NfpDate first_write_date; ///< Set when the amiibo is first written to.
|
||||||
MiiCharInfo mii;
|
u16 amiibo_name[10+1]; ///< Amiibo name (utf-16, null-terminated).
|
||||||
MiiNfpStoreDataExtension mii_store_data_extension;
|
u8 font_region; ///< Font region.
|
||||||
u16 first_write_year;
|
|
||||||
u8 first_write_month;
|
|
||||||
u8 first_write_day;
|
|
||||||
u16 amiibo_name[10+1]; ///< utf-16, null-terminated
|
|
||||||
u8 settings_flag; ///< bit4 = amiibo was initialized in console settings, bit5 = has application area
|
|
||||||
u8 unknown1; ///< Normally zero
|
u8 unknown1; ///< Normally zero
|
||||||
u32 register_info_crc;
|
u32 crc32_2; ///< CRC32 of Ver3StoreData + application_id_byte + unknown1 + StoreDataExtension + unknown2 (0x7E bytes total)
|
||||||
u32 unknown2[0x5]; ///< Normally zero
|
u32 unknown2[0x5]; ///< Normally zero
|
||||||
u8 reserved5[0x64];
|
u8 reserved4[0x64];
|
||||||
u64 application_id;
|
u64 application_id; ///< Modified application ID (Application ID & 0xFFFFFFFF0FFFFFFF | 0x30000000)
|
||||||
u32 access_id;
|
u32 access_id; ///< Application area access ID
|
||||||
u16 settings_crc_counter;
|
u16 settings_crc32_change_counter;
|
||||||
u8 font_region;
|
u8 flags; ///< \ref NfpAmiiboFlag
|
||||||
u8 tag_type;
|
u8 tag_type; ///< \ref NfcTagType
|
||||||
u8 console_type;
|
u8 application_area_version; ///< \ref NfpApplicationAreaVersion
|
||||||
u8 application_id_byte; ///< (Original Program ID >> 0x24) & 0xF byte (Program ID has this byte swapped with console type)
|
u8 application_id_byte; ///< Application ID byte ((Application ID >> 28) & 0xFF)
|
||||||
u8 reserved6[0x2E];
|
u8 reserved5[0x2E];
|
||||||
u8 application_area[0xD8];
|
u8 application_area[0xD8]; ///< Application area.
|
||||||
} NX_PACKED NfpData;
|
} NX_PACKED NfpData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -347,7 +353,7 @@ Result nfcMfAttachActivateEvent(const NfcDeviceHandle *handle, Event *out_event)
|
|||||||
/// Returned event will have autoclear off.
|
/// Returned event will have autoclear off.
|
||||||
Result nfcMfAttachDeactivateEvent(const NfcDeviceHandle *handle, Event *out_event);
|
Result nfcMfAttachDeactivateEvent(const NfcDeviceHandle *handle, Event *out_event);
|
||||||
|
|
||||||
Result nfpGetState(NfpState *out);
|
Result nfpGetState(NfcState *out);
|
||||||
Result nfpGetDeviceState(const NfcDeviceHandle *handle, NfpDeviceState *out);
|
Result nfpGetDeviceState(const NfcDeviceHandle *handle, NfpDeviceState *out);
|
||||||
Result nfpGetNpadId(const NfcDeviceHandle *handle, u32 *out);
|
Result nfpGetNpadId(const NfcDeviceHandle *handle, u32 *out);
|
||||||
|
|
||||||
@ -359,7 +365,7 @@ Result nfcGetDeviceState(const NfcDeviceHandle *handle, NfcDeviceState *out);
|
|||||||
Result nfcGetNpadId(const NfcDeviceHandle *handle, u32 *out);
|
Result nfcGetNpadId(const NfcDeviceHandle *handle, u32 *out);
|
||||||
|
|
||||||
Result nfcMfGetState(NfcState *out);
|
Result nfcMfGetState(NfcState *out);
|
||||||
Result nfcMfGetDeviceState(const NfcDeviceHandle *handle, NfcDeviceState *out);
|
Result nfcMfGetDeviceState(const NfcDeviceHandle *handle, NfcMifareDeviceState *out);
|
||||||
Result nfcMfGetNpadId(const NfcDeviceHandle *handle, u32 *out);
|
Result nfcMfGetNpadId(const NfcDeviceHandle *handle, u32 *out);
|
||||||
|
|
||||||
/// Returned event will have autoclear on.
|
/// Returned event will have autoclear on.
|
||||||
|
@ -493,7 +493,7 @@ Result nfcMfAttachDeactivateEvent(const NfcDeviceHandle *handle, Event *out_even
|
|||||||
return _nfcCmdInDevhandleOutEvent(&g_nfcMfInterface, handle, out_event, 9);
|
return _nfcCmdInDevhandleOutEvent(&g_nfcMfInterface, handle, out_event, 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result nfpGetState(NfpState *out) {
|
Result nfpGetState(NfcState *out) {
|
||||||
u32 tmp=0;
|
u32 tmp=0;
|
||||||
Result rc = _nfcCmdNoInOutU32(&g_nfpInterface, &tmp, 19);
|
Result rc = _nfcCmdNoInOutU32(&g_nfpInterface, &tmp, 19);
|
||||||
if (R_SUCCEEDED(rc) && out) *out = tmp;
|
if (R_SUCCEEDED(rc) && out) *out = tmp;
|
||||||
@ -531,7 +531,7 @@ Result nfcGetDeviceState(const NfcDeviceHandle *handle, NfcDeviceState *out) {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result nfcMfGetDeviceState(const NfcDeviceHandle *handle, NfcDeviceState *out) {
|
Result nfcMfGetDeviceState(const NfcDeviceHandle *handle, NfcMifareDeviceState *out) {
|
||||||
u32 tmp=0;
|
u32 tmp=0;
|
||||||
Result rc = _nfcCmdInDevhandleOutU32(&g_nfcMfInterface, handle, &tmp, 11);
|
Result rc = _nfcCmdInDevhandleOutU32(&g_nfcMfInterface, handle, &tmp, 11);
|
||||||
if (R_SUCCEEDED(rc) && out) *out = tmp;
|
if (R_SUCCEEDED(rc) && out) *out = tmp;
|
||||||
|
Loading…
Reference in New Issue
Block a user