summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/cfg_u.cpp45
1 files changed, 33 insertions, 12 deletions
diff --git a/src/core/hle/service/cfg_u.cpp b/src/core/hle/service/cfg_u.cpp
index 1a128a0aa..b97181cbd 100644
--- a/src/core/hle/service/cfg_u.cpp
+++ b/src/core/hle/service/cfg_u.cpp
@@ -44,16 +44,32 @@ struct UsernameBlock {
44}; 44};
45static_assert(sizeof(UsernameBlock) == 0x1C, "Size of UsernameBlock must be 0x1C"); 45static_assert(sizeof(UsernameBlock) == 0x1C, "Size of UsernameBlock must be 0x1C");
46 46
47struct ConsoleModelInfo {
48 u8 model; ///< The console model (3DS, 2DS, etc)
49 u8 unknown[3]; ///< Unknown data
50};
51static_assert(sizeof(ConsoleModelInfo) == 4, "ConsoleModelInfo must be exactly 4 bytes");
52
53struct ConsoleCountryInfo {
54 u8 unknown[3]; ///< Unknown data
55 u8 country_code; ///< The country code of the console
56};
57static_assert(sizeof(ConsoleCountryInfo) == 4, "ConsoleCountryInfo must be exactly 4 bytes");
58
47static std::unique_ptr<FileSys::Archive_SystemSaveData> cfg_system_save_data; 59static std::unique_ptr<FileSys::Archive_SystemSaveData> cfg_system_save_data;
48static const u64 CFG_SAVE_ID = 0x00010017; 60static const u64 CFG_SAVE_ID = 0x00010017;
49static const u64 CONSOLE_UNIQUE_ID = 0xDEADC0DE; 61static const u64 CONSOLE_UNIQUE_ID = 0xDEADC0DE;
50static const u32 CONSOLE_MODEL = NINTENDO_3DS_XL; 62static const ConsoleModelInfo CONSOLE_MODEL = { NINTENDO_3DS_XL, 0, 0, 0 };
51static const u8 CONSOLE_LANGUAGE = LANGUAGE_EN; 63static const u8 CONSOLE_LANGUAGE = LANGUAGE_EN;
52static const char CONSOLE_USERNAME[0x14] = "CITRA"; 64static const char CONSOLE_USERNAME[0x14] = "CITRA";
53/// This will be initialized in the Interface constructor, and will be used when creating the block 65/// This will be initialized in the Interface constructor, and will be used when creating the block
54static UsernameBlock CONSOLE_USERNAME_BLOCK; 66static UsernameBlock CONSOLE_USERNAME_BLOCK;
55/// TODO(Subv): Find out what this actually is 67/// TODO(Subv): Find out what this actually is
56static const u8 SOUND_OUTPUT_MODE = 2; 68static const u8 SOUND_OUTPUT_MODE = 2;
69static const u8 UNITED_STATES_COUNTRY_ID = 49;
70/// TODO(Subv): Find what the other bytes are
71static const ConsoleCountryInfo COUNTRY_INFO = { 0, 0, 0, UNITED_STATES_COUNTRY_ID };
72
57static const u32 CONFIG_SAVEFILE_SIZE = 0x8000; 73static const u32 CONFIG_SAVEFILE_SIZE = 0x8000;
58static std::array<u8, CONFIG_SAVEFILE_SIZE> cfg_config_file_buffer = { }; 74static std::array<u8, CONFIG_SAVEFILE_SIZE> cfg_config_file_buffer = { };
59 75
@@ -67,13 +83,14 @@ static const std::array<float, 8> STEREO_CAMERA_SETTINGS = {
67 10.0f, 5.0f, 55.58000183105469f, 21.56999969482422f 83 10.0f, 5.0f, 55.58000183105469f, 21.56999969482422f
68}; 84};
69 85
86static_assert(sizeof(STEREO_CAMERA_SETTINGS) == 0x20, "STEREO_CAMERA_SETTINGS must be exactly 0x20 bytes");
87static_assert(sizeof(CONSOLE_UNIQUE_ID) == 8, "CONSOLE_UNIQUE_ID must be exactly 8 bytes");
88static_assert(sizeof(CONSOLE_LANGUAGE) == 1, "CONSOLE_LANGUAGE must be exactly 1 byte");
89static_assert(sizeof(SOUND_OUTPUT_MODE) == 1, "SOUND_OUTPUT_MODE must be exactly 1 byte");
90
70// TODO(Link Mauve): use a constexpr once MSVC starts supporting it. 91// TODO(Link Mauve): use a constexpr once MSVC starts supporting it.
71#define C(code) ((code)[0] | ((code)[1] << 8)) 92#define C(code) ((code)[0] | ((code)[1] << 8))
72 93
73static const u8 UNITED_STATES_COUNTRY_ID = 49;
74/// TODO(Subv): Find what the other bytes are
75static const std::array<u8, 4> COUNTRY_INFO = { 0, 0, 0, UNITED_STATES_COUNTRY_ID };
76
77static const std::array<u16, 187> country_codes = { 94static const std::array<u16, 187> country_codes = {
78 0, C("JP"), 0, 0, 0, 0, 0, 0, // 0-7 95 0, C("JP"), 0, 0, 0, 0, 0, 0, // 0-7
79 C("AI"), C("AG"), C("AR"), C("AW"), C("BS"), C("BB"), C("BZ"), C("BO"), // 8-15 96 C("AI"), C("AG"), C("AR"), C("AW"), C("BS"), C("BB"), C("BZ"), C("BO"), // 8-15
@@ -305,26 +322,30 @@ ResultCode FormatConfig() {
305 // This value is hardcoded, taken from 3dbrew, verified by hardware, it's always the same value 322 // This value is hardcoded, taken from 3dbrew, verified by hardware, it's always the same value
306 config->data_entries_offset = 0x455C; 323 config->data_entries_offset = 0x455C;
307 // Insert the default blocks 324 // Insert the default blocks
308 res = CreateConfigInfoBlk(0x00050005, 0x20, 0xE, 325 res = CreateConfigInfoBlk(0x00050005, sizeof(STEREO_CAMERA_SETTINGS), 0xE,
309 reinterpret_cast<const u8*>(STEREO_CAMERA_SETTINGS.data())); 326 reinterpret_cast<const u8*>(STEREO_CAMERA_SETTINGS.data()));
310 if (!res.IsSuccess()) 327 if (!res.IsSuccess())
311 return res; 328 return res;
312 res = CreateConfigInfoBlk(0x00090001, 0x8, 0xE, reinterpret_cast<const u8*>(&CONSOLE_UNIQUE_ID)); 329 res = CreateConfigInfoBlk(0x00090001, sizeof(CONSOLE_UNIQUE_ID), 0xE,
330 reinterpret_cast<const u8*>(&CONSOLE_UNIQUE_ID));
313 if (!res.IsSuccess()) 331 if (!res.IsSuccess())
314 return res; 332 return res;
315 res = CreateConfigInfoBlk(0x000F0004, 0x4, 0x8, reinterpret_cast<const u8*>(&CONSOLE_MODEL)); 333 res = CreateConfigInfoBlk(0x000F0004, sizeof(CONSOLE_MODEL), 0x8,
334 reinterpret_cast<const u8*>(&CONSOLE_MODEL));
316 if (!res.IsSuccess()) 335 if (!res.IsSuccess())
317 return res; 336 return res;
318 res = CreateConfigInfoBlk(0x000A0002, 0x1, 0xA, &CONSOLE_LANGUAGE); 337 res = CreateConfigInfoBlk(0x000A0002, sizeof(CONSOLE_LANGUAGE), 0xA, &CONSOLE_LANGUAGE);
319 if (!res.IsSuccess()) 338 if (!res.IsSuccess())
320 return res; 339 return res;
321 res = CreateConfigInfoBlk(0x00070001, 0x1, 0xE, &SOUND_OUTPUT_MODE); 340 res = CreateConfigInfoBlk(0x00070001, sizeof(SOUND_OUTPUT_MODE), 0xE, &SOUND_OUTPUT_MODE);
322 if (!res.IsSuccess()) 341 if (!res.IsSuccess())
323 return res; 342 return res;
324 res = CreateConfigInfoBlk(0x000B0000, 0x4, 0xE, COUNTRY_INFO.data()); 343 res = CreateConfigInfoBlk(0x000B0000, sizeof(COUNTRY_INFO), 0xE,
344 reinterpret_cast<const u8*>(&COUNTRY_INFO));
325 if (!res.IsSuccess()) 345 if (!res.IsSuccess())
326 return res; 346 return res;
327 res = CreateConfigInfoBlk(0x000A0000, 0x1C, 0xE, reinterpret_cast<const u8*>(&CONSOLE_USERNAME_BLOCK)); 347 res = CreateConfigInfoBlk(0x000A0000, sizeof(CONSOLE_USERNAME_BLOCK), 0xE,
348 reinterpret_cast<const u8*>(&CONSOLE_USERNAME_BLOCK));
328 if (!res.IsSuccess()) 349 if (!res.IsSuccess())
329 return res; 350 return res;
330 // Save the buffer to the file 351 // Save the buffer to the file