@@ -23,11 +23,6 @@ typedef enum {
23
23
NfcServiceType_System = 1 , ///< Initializes nfc:sys.
24
24
} NfcServiceType ;
25
25
26
- typedef enum {
27
- NfpState_NonInitialized = 0 ,
28
- NfpState_Initialized = 1 ,
29
- } NfpState ;
30
-
31
26
typedef enum {
32
27
NfcState_NonInitialized = 0 ,
33
28
NfcState_Initialized = 1 ,
@@ -40,7 +35,6 @@ typedef enum {
40
35
NfpDeviceState_TagRemoved = 3 ,
41
36
NfpDeviceState_TagMounted = 4 ,
42
37
NfpDeviceState_Unavailable = 5 ,
43
- NfpDeviceState_Finalized = 6 ,
44
38
} NfpDeviceState ;
45
39
46
40
typedef enum {
@@ -49,26 +43,33 @@ typedef enum {
49
43
NfcDeviceState_TagFound = 2 ,
50
44
NfcDeviceState_TagRemoved = 3 ,
51
45
NfcDeviceState_TagMounted = 4 ,
52
- NfcDeviceState_Unavailable = 5 ,
53
- NfcDeviceState_Finalized = 6 ,
54
46
} NfcDeviceState ;
55
47
56
48
typedef enum {
57
- NfpApplicationAreaVersion_3DS = 0 ,
58
- NfpApplicationAreaVersion_WiiU = 1 ,
59
- NfpApplicationAreaVersion_3DSv2 = 2 ,
60
- NfpApplicationAreaVersion_Switch = 3 ,
61
- NfpApplicationAreaVersion_NotSet = 0xFF ,
49
+ NfcMifareDeviceState_Initialized = 0 ,
50
+ NfcMifareDeviceState_SearchingForTag = 1 ,
51
+ NfcMifareDeviceState_TagFound = 2 ,
52
+ NfcMifareDeviceState_TagRemoved = 3 ,
53
+ NfcMifareDeviceState_TagMounted = 4 ,
54
+ NfcMifareDeviceState_Unavailable = 5 ,
55
+ } NfcMifareDeviceState ;
56
+
57
+ typedef enum {
58
+ NfpApplicationAreaVersion_3DS = 0 , ///< Application area created by a 3DS game.
59
+ NfpApplicationAreaVersion_WiiU = 1 , ///< Application area created by a Wii U game.
60
+ NfpApplicationAreaVersion_3DSv2 = 2 , ///< Application area created by a (new?) 3DS game.
61
+ NfpApplicationAreaVersion_Switch = 3 , ///< Application area created by a Switch game.
62
+ NfpApplicationAreaVersion_Invalid = 0xFF , ///< Invalid value (application area not created).
62
63
} NfpApplicationAreaVersion ;
63
64
64
65
typedef enum {
65
66
NfpDeviceType_Amiibo = 0 ,
66
67
} NfpDeviceType ;
67
68
68
69
typedef enum {
69
- NfpMountTarget_Rom = 1 ,
70
- NfpMountTarget_Ram = 2 ,
71
- NfpMountTarget_All = 3 ,
70
+ NfpMountTarget_Rom = BIT ( 0 ) ,
71
+ NfpMountTarget_Ram = BIT ( 1 ) ,
72
+ NfpMountTarget_All = NfpMountTarget_Rom | NfpMountTarget_Ram ,
72
73
} NfpMountTarget ;
73
74
74
75
typedef enum {
@@ -102,104 +103,123 @@ typedef enum {
102
103
NfcMifareCommand_Store = 0xC2 ,
103
104
} NfcMifareCommand ;
104
105
106
+ typedef enum {
107
+ NfpAmiiboFlag_Valid = BIT (0 ), ///< Initialized in system settings.
108
+ NfpAmiiboFlag_ApplicationAreaExists = BIT (1 ), ///< Application area exists.
109
+ } NfpAmiiboFlag ;
110
+
111
+ typedef enum {
112
+ NfpBreakType_Flush = 0 ,
113
+ NfpBreakType_Break1 = 1 ,
114
+ NfpBreakType_Break2 = 2 ,
115
+ } NfpBreakType ;
116
+
105
117
typedef struct {
106
- u8 uuid [10 ];
107
- u8 uuid_length ;
108
- u8 reserved1 [0x15 ];
109
- u32 protocol ;
110
- u32 tag_type ;
111
- u8 reserved2 [0x30 ];
112
- } NX_PACKED NfpTagInfo ;
118
+ u16 year ;
119
+ u8 month ;
120
+ u8 day ;
121
+ } NfpDate ;
113
122
114
123
typedef struct {
115
- u8 uuid [10 ];
116
- u8 uuid_length ;
117
- u8 reserved1 [0x15 ];
118
- u32 protocol ;
119
- u32 tag_type ;
120
- u8 reserved2 [0x30 ];
121
- } NX_PACKED NfcTagInfo ;
124
+ u8 uid [10 ]; ///< UUID.
125
+ u8 uid_length ; ///< UUID length.
126
+ u8 reserved [0x15 ];
127
+ } NfcTagUid ;
122
128
123
129
typedef struct {
124
- u16 last_write_year ;
125
- u8 last_write_month ;
126
- u8 last_write_day ;
130
+ NfcTagUid uid ; ///< UUID.
131
+ u32 protocol ; ///< \ref NfcProtocol
132
+ u32 tag_type ; ///< \ref NfcTagType
133
+ u8 reserved [0x30 ];
134
+ } NfpTagInfo ;
135
+
136
+ typedef struct {
137
+ NfcTagUid uid ; ///< UUID.
138
+ u32 protocol ; ///< \ref NfcProtocol
139
+ u32 tag_type ; ///< \ref NfcTagType
140
+ u8 reserved [0x30 ];
141
+ } NfcTagInfo ;
142
+
143
+ typedef struct {
144
+ NfpDate last_write_date ;
127
145
u16 write_counter ;
128
146
u16 version ;
129
147
u32 application_area_size ;
130
- u8 reserved [0x34 ];
131
- } NX_PACKED NfpCommonInfo ;
148
+ u8 reserved [0x34 ];
149
+ } NfpCommonInfo ;
132
150
133
151
typedef struct {
134
- u8 amiibo_id [0x8 ];
135
- u8 reserved [0x38 ];
136
- } NX_PACKED NfpModelInfo ;
152
+ union {
153
+ u8 character_id [3 ];
154
+ struct {
155
+ u16 game_character_id ;
156
+ u8 character_variant ;
157
+ } NX_PACKED ;
158
+ };
159
+ u8 series_id ; ///< Series.
160
+ u16 numbering_id ; ///< Model number.
161
+ u8 nfp_type ; ///< Figure type.
162
+ u8 reserved [0x39 ];
163
+ } NfpModelInfo ;
137
164
138
165
typedef struct {
139
166
MiiCharInfo mii ;
140
- u16 first_write_year ;
141
- u8 first_write_month ;
142
- u8 first_write_day ;
143
- char amiibo_name [(10 * 4 )+ 1 ]; ///< utf-8, null-terminated
167
+ NfpDate first_write_date ;
168
+ char amiibo_name [(10 * 4 )+ 1 ]; ///< Amiibo name (utf-8, null-terminated).
144
169
u8 font_region ;
145
170
u8 reserved [0x7A ];
146
- } NX_PACKED NfpRegisterInfo ;
171
+ } NfpRegisterInfo ;
147
172
148
173
typedef struct {
149
- u8 mii_store_data [0x44 ];
150
- u16 first_write_year ;
151
- u8 first_write_month ;
152
- u8 first_write_day ;
153
- char amiibo_name [(10 * 4 )+ 1 ]; ///< utf-8, null-terminated
174
+ MiiStoreData mii_store_data ;
175
+ NfpDate first_write_date ;
176
+ char amiibo_name [(10 * 4 )+ 1 ]; ///< Amiibo name (utf-8, null-terminated).
154
177
u8 font_region ;
155
178
u8 reserved [0x8E ];
156
- } NX_PACKED NfpRegisterInfoPrivate ;
179
+ } NfpRegisterInfoPrivate ;
157
180
158
181
typedef struct {
159
182
u64 application_id ;
160
- u32 application_area_id ;
161
- u16 crc_change_counter ;
183
+ u32 access_id ;
184
+ u16 crc32_change_counter ;
162
185
u8 flags ;
163
186
u8 tag_type ;
164
187
u8 application_area_version ;
165
188
u8 reserved [0x2F ];
166
- } NX_PACKED NfpAdminInfo ;
189
+ } NfpAdminInfo ;
167
190
168
191
typedef struct {
169
- u8 magic ;
192
+ u8 tag_magic ; ///< Tag magic (always 0xA5: https://www.3dbrew.org/wiki/Amiibo#Page_layout).
170
193
u8 reserved1 [0x1 ];
171
- u8 write_counter ;
172
- u8 reserved2 [0x1 ];
173
- u32 settings_crc ;
174
- u8 reserved3 [0x38 ];
175
- u16 last_write_year ;
176
- u8 last_write_month ;
177
- u8 last_write_day ;
178
- u16 application_write_counter ;
179
- u16 version ;
180
- u32 application_area_size ;
181
- u8 reserved4 [0x34 ];
182
- MiiCharInfo mii ;
183
- MiiNfpStoreDataExtension mii_store_data_extension ;
184
- u16 first_write_year ;
185
- u8 first_write_month ;
186
- u8 first_write_day ;
187
- u16 amiibo_name [10 + 1 ]; ///< utf-16, null-terminated
188
- u8 settings_flag ; ///< bit4 = amiibo was initialized in console settings, bit5 = has application area
189
- u8 unknown1 ; ///< Normally zero
190
- u32 register_info_crc ;
191
- u32 unknown2 [0x5 ]; ///< Normally zero
192
- u8 reserved5 [0x64 ];
193
- u64 application_id ;
194
- u32 access_id ;
195
- u16 settings_crc_counter ;
196
- u8 font_region ;
197
- u8 tag_type ;
198
- u8 console_type ;
199
- u8 application_id_byte ; ///< (Original Program ID >> 0x24) & 0xF byte (Program ID has this byte swapped with console type)
200
- u8 reserved6 [0x2E ];
201
- u8 application_area [0xD8 ];
202
- } NX_PACKED NfpData ;
194
+ u16 tag_write_counter ; ///< Incremented every tag write.
195
+ u32 crc32_1 ; ///< CRC32 of some internal 8-byte data.
196
+ u8 reserved2 [0x38 ];
197
+ NfpDate last_write_date ; ///< Updated every write.
198
+ u16 write_counter ; ///< Incremented every write, until it maxes out at 0xFFFF.
199
+ u16 version ; ///< Version.
200
+ u32 application_area_size ; ///< Size of the application area.
201
+ u8 reserved3 [0x34 ];
202
+ MiiVer3StoreData mii_v3 ; ///< Ver3StoreData (Mii format used in 3DS).
203
+ u8 pad [0x2 ];
204
+ u16 mii_v3_crc16 ; ///< CRC16 of Ver3StoreData.
205
+ MiiNfpStoreDataExtension mii_store_data_extension ; ///< StoreDataExtension
206
+ NfpDate first_write_date ; ///< Set when the amiibo is first written to.
207
+ u16 amiibo_name [10 + 1 ]; ///< Amiibo name (utf-16, null-terminated).
208
+ u8 font_region ; ///< Font region.
209
+ u8 unknown1 ; ///< Normally zero
210
+ u32 crc32_2 ; ///< CRC32 of Ver3StoreData + application_id_byte + unknown1 + StoreDataExtension + unknown2 (0x7E bytes total)
211
+ u32 unknown2 [0x5 ]; ///< Normally zero
212
+ u8 reserved4 [0x64 ];
213
+ u64 application_id ; ///< Modified application ID (Application ID & 0xFFFFFFFF0FFFFFFF | 0x30000000)
214
+ u32 access_id ; ///< Application area access ID
215
+ u16 settings_crc32_change_counter ;
216
+ u8 flags ; ///< \ref NfpAmiiboFlag
217
+ u8 tag_type ; ///< \ref NfcTagType
218
+ u8 application_area_version ; ///< \ref NfpApplicationAreaVersion
219
+ u8 application_id_byte ; ///< Application ID byte ((Application ID >> 28) & 0xFF)
220
+ u8 reserved5 [0x2E ];
221
+ u8 application_area [0xD8 ]; ///< Application area.
222
+ } NfpData ;
203
223
204
224
typedef struct {
205
225
u8 mifare_command ;
@@ -292,21 +312,29 @@ Result nfcMfStartDetection(const NfcDeviceHandle *handle);
292
312
Result nfcMfStopDetection (const NfcDeviceHandle * handle );
293
313
294
314
/// Not available with ::NfpServiceType_System.
315
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram.
295
316
Result nfpOpenApplicationArea (const NfcDeviceHandle * handle , u32 app_id );
296
317
297
318
/// Not available with ::NfpServiceType_System.
319
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram, and the application area to be opened.
298
320
Result nfpGetApplicationArea (const NfcDeviceHandle * handle , void * buf , size_t buf_size , u32 * out_size );
299
321
300
322
/// Not available with ::NfpServiceType_System.
323
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram, and the application area to be opened.
301
324
Result nfpSetApplicationArea (const NfcDeviceHandle * handle , const void * buf , size_t buf_size );
325
+
326
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram.
302
327
Result nfpFlush (const NfcDeviceHandle * handle );
328
+
303
329
Result nfpRestore (const NfcDeviceHandle * handle );
304
330
305
331
/// Not available with ::NfpServiceType_System.
332
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram.
306
333
Result nfpCreateApplicationArea (const NfcDeviceHandle * handle , u32 app_id , const void * buf , size_t buf_size );
307
334
308
335
/// Not available with ::NfpServiceType_System.
309
336
/// Only available with [3.0.0+].
337
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram, and the application area to be opened.
310
338
Result nfpRecreateApplicationArea (const NfcDeviceHandle * handle , u32 app_id , const void * buf , size_t buf_size );
311
339
312
340
/// Not available with ::NfpServiceType_System.
@@ -319,10 +347,18 @@ Result nfpDeleteApplicationArea(const NfcDeviceHandle *handle);
319
347
Result nfpExistsApplicationArea (const NfcDeviceHandle * handle , bool * out );
320
348
321
349
Result nfpGetTagInfo (const NfcDeviceHandle * handle , NfpTagInfo * out );
350
+
351
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram.
322
352
Result nfpGetRegisterInfo (const NfcDeviceHandle * handle , NfpRegisterInfo * out );
353
+
354
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram.
323
355
Result nfpGetCommonInfo (const NfcDeviceHandle * handle , NfpCommonInfo * out );
356
+
357
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Rom.
324
358
Result nfpGetModelInfo (const NfcDeviceHandle * handle , NfpModelInfo * out );
359
+
325
360
/// Not available with ::NfpServiceType_User.
361
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram.
326
362
Result nfpGetAdminInfo (const NfcDeviceHandle * handle , NfpAdminInfo * out );
327
363
328
364
/// Only available with [4.0.0+].
@@ -347,7 +383,7 @@ Result nfcMfAttachActivateEvent(const NfcDeviceHandle *handle, Event *out_event)
347
383
/// Returned event will have autoclear off.
348
384
Result nfcMfAttachDeactivateEvent (const NfcDeviceHandle * handle , Event * out_event );
349
385
350
- Result nfpGetState (NfpState * out );
386
+ Result nfpGetState (NfcState * out );
351
387
Result nfpGetDeviceState (const NfcDeviceHandle * handle , NfpDeviceState * out );
352
388
Result nfpGetNpadId (const NfcDeviceHandle * handle , u32 * out );
353
389
@@ -359,7 +395,7 @@ Result nfcGetDeviceState(const NfcDeviceHandle *handle, NfcDeviceState *out);
359
395
Result nfcGetNpadId (const NfcDeviceHandle * handle , u32 * out );
360
396
361
397
Result nfcMfGetState (NfcState * out );
362
- Result nfcMfGetDeviceState (const NfcDeviceHandle * handle , NfcDeviceState * out );
398
+ Result nfcMfGetDeviceState (const NfcDeviceHandle * handle , NfcMifareDeviceState * out );
363
399
Result nfcMfGetNpadId (const NfcDeviceHandle * handle , u32 * out );
364
400
365
401
/// Returned event will have autoclear on.
@@ -375,25 +411,39 @@ Result nfcMfAttachAvailabilityChangeEvent(Event *out_event);
375
411
Result nfpFormat (const NfcDeviceHandle * handle );
376
412
377
413
/// Not available with ::NfpServiceType_User.
414
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram.
378
415
Result nfpGetRegisterInfoPrivate (const NfcDeviceHandle * handle , NfpRegisterInfoPrivate * out );
416
+
379
417
/// Not available with ::NfpServiceType_User.
418
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram.
380
419
Result nfpSetRegisterInfoPrivate (const NfcDeviceHandle * handle , const NfpRegisterInfoPrivate * register_info_private );
420
+
381
421
/// Not available with ::NfpServiceType_User.
422
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram.
382
423
Result nfpDeleteRegisterInfo (const NfcDeviceHandle * handle );
383
424
384
425
/// Only available with ::NfpServiceType_Debug.
426
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram.
385
427
Result nfpGetAll (const NfcDeviceHandle * handle , NfpData * out );
428
+
386
429
/// Only available with ::NfpServiceType_Debug.
430
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram.
387
431
Result nfpSetAll (const NfcDeviceHandle * handle , const NfpData * nfp_data );
388
432
389
433
/// Only available with ::NfpServiceType_Debug.
434
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram.
390
435
Result nfpFlushDebug (const NfcDeviceHandle * handle );
436
+
391
437
/// Only available with ::NfpServiceType_Debug.
392
- Result nfpBreakTag (const NfcDeviceHandle * handle , u32 break_type );
438
+ /// Requires the amiibo to be mounted with ::NfpMountTarget_Ram.
439
+ Result nfpBreakTag (const NfcDeviceHandle * handle , NfpBreakType break_type );
440
+
393
441
/// Only available with ::NfpServiceType_Debug.
394
442
Result nfpReadBackupData (const NfcDeviceHandle * handle , void * out_buf , size_t buf_size , u32 * out_size );
443
+
395
444
/// Only available with ::NfpServiceType_Debug.
396
445
Result nfpWriteBackupData (const NfcDeviceHandle * handle , const void * buf , size_t buf_size );
446
+
397
447
/// Only available with ::NfpServiceType_Debug.
398
448
Result nfpWriteNtf (const NfcDeviceHandle * handle , u32 write_type , const void * buf , size_t buf_size );
399
449
0 commit comments