1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - SPI - include
3   File:     userInfo_ts_300.h
4 
5   Copyright 2003-2008 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   $Date:: 2008-09-18#$
14   $Rev: 8573 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 #ifndef NITRO_SPI_COMMON_USERINFO_TS_300_H_
18 #define NITRO_SPI_COMMON_USERINFO_TS_300_H_
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 /*===========================================================================*/
25 
26 /*---------------------------------------------------------------------------*
27     Constant Definitions
28  *---------------------------------------------------------------------------*/
29 // Configuration setting data format version
30 #define NVRAM_CONFIG_DATA_VERSION           5
31 #define NVRAM_CONFIG_DATA_EX_VERSION        1
32 
33 // Various setting values within config
34 #define NVRAM_CONFIG_NICKNAME_LENGTH        10  // Nickname Length
35 #define NVRAM_CONFIG_COMMENT_LENGTH         26  // Comment Length
36 #define NVRAM_CONFIG_FAVORITE_COLOR_MAX     16  // Maximum number of favorite colors
37 
38 // IPL2 type
39 #define NVRAM_CONFIG_IPL2_TYPE_ADDRESS      0x001d
40 #define NVRAM_CONFIG_IPL2_TYPE_SIZE         1
41 #define NVRAM_CONFIG_IPL2_TYPE_NORMAL       0xff
42 #define NVRAM_CONFIG_IPL2_TYPE_EX_MASK      0x50
43 
44 // Language setting code
45 #define NVRAM_CONFIG_LANG_JAPANESE          0   // Japanese
46 #define NVRAM_CONFIG_LANG_ENGLISH           1   // English
47 #define NVRAM_CONFIG_LANG_FRENCH            2   // French
48 #define NVRAM_CONFIG_LANG_GERMAN            3   // German
49 #define NVRAM_CONFIG_LANG_ITALIAN           4   // Italian
50 #define NVRAM_CONFIG_LANG_SPANISH           5   // Spanish
51 #define NVRAM_CONFIG_LANG_CHINESE           6   // Chinese
52 #define NVRAM_CONFIG_LANG_HANGUL            7   // Korean
53 #define NVRAM_CONFIG_LANG_CODE_MAX          8   // Number of types of language setting codes
54 
55 // Bitmap of languages supported in the normal version
56 #define NVRAM_CONFIG_LANG_BITMAP_NORMAL     ( (0x0001 << NVRAM_CONFIG_LANG_JAPANESE ) \
57                                             | (0x0001 << NVRAM_CONFIG_LANG_ENGLISH) \
58                                             | (0x0001 << NVRAM_CONFIG_LANG_FRENCH) \
59                                             | (0x0001 << NVRAM_CONFIG_LANG_GERMAN) \
60                                             | (0x0001 << NVRAM_CONFIG_LANG_ITALIAN) \
61                                             | (0x0001 << NVRAM_CONFIG_LANG_SPANISH) )
62 
63 // Bitmap of languages supported in the Chinese version
64 #define NVRAM_CONFIG_LANG_BITMAP_CHINESE    ( (0x0001 << NVRAM_CONFIG_LANG_ENGLISH ) \
65                                             | (0x0001 << NVRAM_CONFIG_LANG_FRENCH) \
66                                             | (0x0001 << NVRAM_CONFIG_LANG_GERMAN) \
67                                             | (0x0001 << NVRAM_CONFIG_LANG_ITALIAN) \
68                                             | (0x0001 << NVRAM_CONFIG_LANG_SPANISH) \
69                                             | (0x0001 << NVRAM_CONFIG_LANG_CHINESE) )
70 
71 
72 // Bitmap of languages supported in the Korean version
73 #define NVRAM_CONFIG_LANG_BITMAP_HANGUL     ( (0x0001 << NVRAM_CONFIG_LANG_JAPANESE ) \
74                                             | (0x0001 << NVRAM_CONFIG_LANG_ENGLISH) \
75                                             | (0x0001 << NVRAM_CONFIG_LANG_FRENCH) \
76                                             | (0x0001 << NVRAM_CONFIG_LANG_GERMAN) \
77                                             | (0x0001 << NVRAM_CONFIG_LANG_SPANISH) \
78                                             | (0x0001 << NVRAM_CONFIG_LANG_HANGUL) )
79 
80 /*---------------------------------------------------------------------------*
81     Structure Definitions
82  *---------------------------------------------------------------------------*/
83 // Birthday data (2 bytes)
84 typedef struct NVRAMConfigDate
85 {
86     u8      month;                     // Month: 01 to 12
87     u8      day;                       // Day: 01 to 31
88 
89 }
90 NVRAMConfigDate;
91 
92 // Nickname (22 bytes)
93 typedef struct NVRAMConfigNickname
94 {
95     u16     str[NVRAM_CONFIG_NICKNAME_LENGTH];  // Nickname (Maximum of 10 characters in Unicode (UTF16), no terminating code)
96     u8      length;                    // Number of characters
97     u8      rsv;
98 
99 }
100 NVRAMConfigNickname;
101 
102 // Comment (54 bytes)
103 typedef struct NVRAMConfigComment
104 {
105     u16     str[NVRAM_CONFIG_COMMENT_LENGTH];   //Comment (A maximum of 26 characters in Unicode (UTF16), no terminating code)
106     u8      length;                    // Number of characters
107     u8      rsv;
108 
109 }
110 NVRAMConfigComment;
111 
112 // Owner Information (80 bytes)
113 typedef struct NVRAMConfigOwnerInfo
114 {
115     u8      favoriteColor:4;           // Favorite color
116     u8      rsv:4;                     // Reserved
117     NVRAMConfigDate birthday;          // Birthdate
118     u8      pad;
119     NVRAMConfigNickname nickname;      // Nickname
120     NVRAMConfigComment comment;        // Comment
121 
122 }
123 NVRAMConfigOwnerInfo;
124 
125 
126 // Alarm clock data for IPL (6 bytes)
127 typedef struct NVRAMConfigAlarm
128 {
129     u8      hour;                      // Alarm Hour: 00 - 23
130     u8      minute;                    // Alarm Minute: 00 - 59
131     u8      second;                    // Alarm Seconds: 00 - 59
132     u8      pad;
133     u16     enableWeek:7;              // Flag for which days of the week the alarm is enabled (bit0: Sunday, bit1: Monday, etc..."1" means "enabled")
134     u16     alarmOn:1;                 // Alarm ON/OFF (0: OFF, 1: ON)
135     u16     rsv:8;                     // Reserved
136 
137 }
138 NVRAMConfigAlarm;
139 
140 // Touch Panel Calibration Data (12 bytes)
141 typedef struct NVRAMConfigTpCalibData
142 {
143     u16     raw_x1;                    // TP-obtained x value of the first calibration point
144     u16     raw_y1;                    // TP-obtained y value of the first calibration point
145     u8      dx1;                       // LCD x coordinate of the first calibration point
146     u8      dy1;                       // LCD y coordinate of the first calibration point
147     u16     raw_x2;                    // TP-obtained x value of the second calibration point
148     u16     raw_y2;                    // TP-obtained y value of the second calibration point
149     u8      dx2;                       // LCD x coordinate of the second calibration point
150     u8      dy2;                       // LCD y coordinate of the second calibration point
151 
152 }
153 NVRAMConfigTpCalibData;
154 
155 // Option information (12 bytes)
156 typedef struct NVRAMConfigOption
157 {
158     u16     language:3;                // Language code
159     u16     agbLcd:1;                  // Start up on which LCD when booting in AGB mode? (0:TOP,1:BOTTOM)
160     u16     detectPullOutCardFlag:1;   // Flag that indicates that the card has been pulled out
161     u16     detectPullOutCtrdgFlag:1;  // Flag that indicates that the Game Pak has been pulled out
162     u16     autoBootFlag:1;            // Whether or not to automatically start up without stopping at the menu in the startup sequence.
163     u16     rsv:4;                     // Reserved
164     u16     input_favoriteColor:1;     // Was a favorite color input?
165     u16     input_tp:1;                // Has the Touch Screen been calibrated? ( " )
166     u16     input_language:1;          // Was a language input?         (0: Not configured, 1: Configured)
167     u16     input_rtc:1;               // Was the RTC configured?          (       "       )
168     u16     input_nickname:1;          // Was a nickname input? (       "       )
169     u8      timezone;                  // Time Zone (Currently reserved)
170     u8      rtcClockAdjust;            // RTC Clock adjustment value
171     s64     rtcOffset;                 // Offset value when configuring the RTC (each time the user changes the configuration of the RTC, this fluctuates in response to that value)
172 
173 }
174 NVRAMConfigOption;
175 
176 
177 // Various types of configuration data (112 bytes)
178 typedef struct NVRAMConfigData
179 {
180     u8      version;                   // Flash storage data format version
181     u8      pad;
182     NVRAMConfigOwnerInfo owner;        // Owner Information
183     NVRAMConfigAlarm alarm;            // Alarm clock data for IPL
184     NVRAMConfigTpCalibData tp;         // Touch Panel Calibration Data
185     NVRAMConfigOption option;          // Options
186 
187 }
188 NVRAMConfigData;
189 
190 // Format when saving NVRAM for various types of configuration data (116 bytes)
191 typedef struct NVRAMConfig
192 {
193     NVRAMConfigData ncd;               // Various types of configuration data
194     u16     saveCount;                 // Counts 0x00-0x7f by looping; valid if the count is new data.
195     u16     crc16;                     // 16-bit CRC of configuration settings data
196 
197 }
198 NVRAMConfig;
199 
200 // Each type of configuration extension data (138 bytes)
201 typedef struct NVRAMConfigDataEx
202 {
203     u8      version;                   // Version type of extension configuration data.
204     u8      language;                  // Extended language code. (Values extended past NVRAM_CONFIG_LANG_CHINESE are saved.)
205     u16     valid_language_bitmap;     // Bitmap that shows valid language codes
206     u8      padding[256 - sizeof(NVRAMConfigData) - 4 - 4 - 2];
207     // Padding so that the size of NVRAMConfigEx equals 1 page of NVRAM (256 bytes)
208 }
209 NVRAMConfigDataEx;
210 
211 // Format when saving the NVRAM for each type of extended NITRO configuration data (256 bytes)
212 typedef struct NVRAMConfigEx
213 {
214     NVRAMConfigData ncd;               // Various types of configuration data
215     u16     saveCount;                 // Counts 0x00-0x7f by looping; valid if the count is new data.
216     u16     crc16;                     // 16-bit CRC of configuration settings data
217     NVRAMConfigDataEx ncd_ex;          // Extended configuration settings data
218     u16     crc16_ex;                  // 16-bit CRC of extended configuration settings data
219 
220 }
221 NVRAMConfigEx;
222 
223 
224 /*===========================================================================*/
225 
226 #ifdef  __cplusplus
227 }       /* extern "C" */
228 #endif
229 
230 #endif /* NITRO_SPI_COMMON_USERINFO_TS_300_H_ */
231 
232 /*---------------------------------------------------------------------------*
233   End of file
234  *---------------------------------------------------------------------------*/
235