1 /*---------------------------------------------------------------------------* 2 Project: Cafe 3 File: nfp_Types.h 4 5 Copyright (C) Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 *---------------------------------------------------------------------------*/ 13 14 #ifndef NN_NFP_TYPES_H_ 15 #define NN_NFP_TYPES_H_ 16 17 #include <cafe/sci.h> 18 #include <nn/types.h> 19 #include <nn/ffl/FFLStandard.h> 20 21 namespace nn { 22 namespace nfp { 23 24 /*! 25 @addtogroup nn_nfp_api 26 @{ 27 */ 28 29 /* 30 @brief Application area size. In most cases, reference the <tt>applicationAreaSize</tt> member in the <tt>@ref CommonInfo</tt> structure rather than using this definition. 31 32 */ 33 const u16 APPLICATION_AREA_SIZE_V2 = 216; 34 35 //! Maximum UID length. 36 const u8 MAX_UID_SIZE = 10; 37 38 //! Maximum nickname length. 39 const u8 NICKNAME_LENGTH_MAX = 10; 40 41 //! Character ID size. 42 const u8 CHARACTER_ID_SIZE = 3; 43 44 //! Base error code value. 45 const u32 ERROR_CODE_BASE = 1680000U; 46 47 //! Unknown error code. 48 const u32 ERROR_CODE_UNKNOWN = ERROR_CODE_BASE + 0U; 49 50 /*! 51 * @enum NfpState 52 * @brief Enumerates library states. 53 * @details For more information, see the Programming Manual. 54 */ 55 enum NfpState 56 { 57 NONE, //!< The NFP library is in an uninitialized state. It starts in this state. If the wireless connection between the system and the Wii U GamePad (DRC) is lost, the library temporarily has a state of <tt>@ref NONE</tt> immediately after the connection is re-established until the NFP features are restored. 58 INIT, //!< The NFP library is in an initialized state. 59 RW_SEARCH, //!< The NFC library is searching for tags. Tags can be detected in this state. If the wireless connection between the system and the Wii U GamePad (DRC) is lost while the state is <tt>@ref RW_SEARCH</tt>, the state is automatically restored to <tt>@ref RW_SEARCH</tt> after the connection is re-established. 60 RW_ACTIVE, //!< The NFC library enters this state when tags are detected with <tt>@ref RW_SEARCH</tt>. 61 RW_DEACTIVE, //!< The NFC library enters this state when a tag is detected and later removed. 62 RW_MOUNT, //!< The NFC library enters this state when a nearby tag is mounted with <tt>@ref RW_ACTIVE</tt>. 63 UNEXPECTED, //!< This state is unexpected. 64 RW_MOUNT_ROM //!< This state only allows access to the ROM region. 65 }; 66 67 /*! 68 * @enum TagType 69 * @brief Enumerated type that represents the tag type. 70 */ 71 enum TagType 72 { 73 TYPE_ERROR = 0, //!< A tag with an unexpected type. 74 TYPE_TAG1 = 1, //!< TYPE1 75 TYPE_TAG2 = 1 << 1, //!< TYPE2 76 TYPE_TAG3 = 1 << 2, //!< TYPE3 77 TYPE_TAG4A = 1 << 3, //!< TYPE4A 78 TYPE_TAG4B = 1 << 4, //!< TYPE4B 79 TYPE_ISO15693 = 1 << 5, //!< ISO15693 80 TYPE_ALL = (TYPE_TAG1 | TYPE_TAG2 | TYPE_TAG3 | TYPE_TAG4A | TYPE_TAG4B | TYPE_ISO15693) //!< All types (default). 81 }; 82 83 /*! 84 * @enum DeactivateReason 85 * @brief Enumerated type that represents the deactivation reason. 86 */ 87 enum DeactivateReason 88 { 89 BEFORE_ACTIVATION = 0, //!< Indicates that a tag has not yet been found or accessed. 90 TAG_IS_ACTIVE, //!< Connecting to the tag. 91 DETECT_ERROR, //!< Could not be recognized as a valid tag. The tag data could be corrupted. 92 CONNECTION_LOST, //!< Indicates that the connection could not be maintained because the tag or the signal was lost. 93 UNKNOWN_DEACTIVATE_REASON, //!< Unknown reason. 94 DISCONNECT_REASON_MAX 95 }; 96 97 /*! 98 * @enum FontRegion 99 * @brief Enumerated type that represents the font region. 100 */ 101 enum FontRegion 102 { 103 FONT_REGION_JP_US_EU, //!< Japan, North America, and Europe Regions 104 FONT_REGION_CHINA, 105 FONT_REGION_KOREA, 106 FONT_REGION_TAIWAN, 107 108 FONT_REGION_COUNT, 109 FONT_REGION_TERM = FONT_REGION_COUNT, 110 FONT_REGION_MIN = 0, 111 FONT_REGION_MAX = FONT_REGION_COUNT - 1, 112 }; 113 114 /*! 115 * @enum AmiiboSettingsMode 116 * @brief Enumerates the startup modes for amiibo Settings. 117 */ 118 enum AmiiboSettingsMode 119 { 120 AMIIBO_SETTINGS_NICKNAME_OWNER = 0, //!< Nickname and owner settings. 121 AMIIBO_SETTINGS_ERASE_GAMEDATA, //!< Erase game data. 122 AMIIBO_SETTINGS_RESTORE //!< Tag restoration. 123 }; 124 125 /*! 126 * @enum AmiiboSettingsResultCode 127 * @brief Enumerates the processing results for amiibo Settings. 128 */ 129 enum AmiiboSettingsResultCode 130 { 131 AMIIBO_SETTINGS_RESULT_SUCCESS = 0, //!< Success. 132 AMIIBO_SETTINGS_RESULT_FAIL = -1, //!< Failed. 133 }; 134 135 /*! 136 * @struct TagId 137 * @brief Structure that stores the tag ID (UID). 138 */ 139 struct TagId 140 { 141 u8 length; //!< UID length. 142 bit8 uid[MAX_UID_SIZE]; //!< Tag UID. 143 bit8 reserved[21]; 144 }; 145 146 /*! 147 * @struct TagInfo 148 * @brief Structure that stores the tag information. 149 */ 150 struct TagInfo 151 { 152 TagId tagId; //!< Unique tag ID (UID). 153 bit8 protocol; //!< Communication protocol. 154 bit8 type; //!< Tag type. A <tt>@ref TagType</tt> value. 155 bit8 reserved[50]; 156 }; 157 158 /*! 159 * @struct Date 160 * @brief Structure that stores date information. 161 */ 162 struct Date 163 { 164 u16 year; //!< Year. 165 u8 month; //!< Month. 166 u8 day; //!< Day. 167 }; 168 169 /*! 170 * @struct ApplicationAreaCreateInfo 171 * @brief Structure that stores the application area initialization status. 172 */ 173 struct ApplicationAreaCreateInfo 174 { 175 u32 accessId; //!< Application ID. 176 const void* pInitialData; //!< Initial data. 177 u32 initialDataSize; //!< Initial data size. 178 bit8 reserved[48]; 179 }; 180 181 /*! 182 * @struct CommonInfo 183 * @brief Structure that stores common region information. 184 */ 185 struct CommonInfo 186 { 187 Date lastWriteDate; //!< The last write date. 188 u16 writeCounter; // Write count. 189 bit8 characterID[CHARACTER_ID_SIZE]; //!< Character ID. 190 bit8 seriesId; // Series ID. 191 bit16 numberingId; // Serial number. 192 bit8 nfpType; // Figure attribute. 193 bit8 nfpVersion; // NFP version. 194 u16 applicationAreaSize; //!< Application area size. 195 bit8 reserved[48]; 196 }; 197 198 /*! 199 * @struct RegisterInfo 200 * @brief Structure that stores initial registration information. 201 */ 202 struct RegisterInfo 203 { 204 FFLStoreData miiData; //!< The registered Mii data. 205 bit16 nickName[NICKNAME_LENGTH_MAX + 1]; //!< Nickname (plus the terminating character). Encoded as UTF-16 BE. 206 bit8 fontRegion; //!< Font region to use when displaying the nickname. Stores a <tt>@ref FontRegion</tt> value. 207 bit8 country; //!< The country information for the registered console. Stores the country ID. 208 Date registerDate; //!< The registration date. 209 bit8 reserved[44]; 210 }; 211 212 /*! 213 * @struct RomInfo 214 * @brief Structure that stores ROM region information. 215 */ 216 struct RomInfo 217 { 218 bit8 characterId[CHARACTER_ID_SIZE]; //!< Character ID. 219 bit8 seriesId; // Series ID. 220 bit16 numberingId; // Serial number. 221 bit8 nfpType; // Figure attribute. 222 bit8 reserved[47]; 223 }; 224 225 /*! 226 * @struct ConnectionStatus 227 * @brief Structure that stores the connection status of the tag. 228 */ 229 struct ConnectionStatus 230 { 231 s32 deactivateReason; //!< The deactivation reason. Always returns <tt>TAG_IS_ACTIVE</tt> while the tag is connected (Active state). 232 bit8 reserved[48]; 233 }; 234 235 /*! 236 * @struct AmiiboSettingsArgsIn 237 * @brief This structure is passed as an argument when calling amiibo Settings. 238 */ 239 struct AmiiboSettingsArgsIn 240 { 241 s32 mode; //!< Specifies the startup mode for amiibo Settings. Use a value from the <tt>@ref AmiiboSettingsMode</tt> enumeration. 242 nn::nfp::TagInfo tagInfo; //!< This information is used to prevent the tag from being switched. Specify the value that is retrieved from the <tt>@ref GetTagInfo</tt> function. 243 bool isRegistered; //!< This flag indicates whether the tag is already registered. Specify <tt>true</tt> if the return value of the <tt>@ref GetNfpRegisterInfo</tt> function is <tt>ResultSuccess</tt>. 244 bit8 padding[3]; 245 nn::nfp::RegisterInfo registerInfo; //!< The registration information. Specify the value that is retrieved from the <tt>@ref GetNfpRegisterInfo</tt> function. 246 nn::nfp::CommonInfo commonInfo; //!< Information in the common region. Specify the value that is retrieved from the <tt>@ref GetNfpCommonInfo</tt> function. 247 248 bit8 reserved[32]; 249 }; 250 251 /*! 252 * @struct AmiiboSettingsResult 253 * @brief The value returned to the application from amiibo Settings. 254 */ 255 struct AmiiboSettingsResult 256 { 257 s32 result; //!< The result of the process. An <tt>@ref AmiiboSettingsResultCode</tt> value is stored. 258 nn::nfp::TagInfo tagInfo; //!< The tag information to change. 259 nn::nfp::RegisterInfo registerInfo; //!< The registration information. The value changed in amiibo Settings is stored. 260 nn::nfp::CommonInfo commonInfo; //!< Information in the common region. The value changed in amiibo Settings is stored. 261 262 bit8 reserved[32]; 263 }; 264 265 266 /*! 267 @} 268 */ 269 270 } // end of namespace nfp 271 } // end of namespace nn 272 273 274 #endif // ifndef NN_NFP_TYPES_H_ 275