diff options
| author | 2016-05-03 19:27:47 +0300 | |
|---|---|---|
| committer | 2016-05-03 19:27:47 +0300 | |
| commit | 9b66e0dc8bec0bff0b211fb45c2c34cf93430be5 (patch) | |
| tree | 5195e2db96de33d81f9c7fa6b531243952af5a55 /src | |
| parent | Merge pull request #1754 from JayFoxRox/fix-const_color-revert (diff) | |
| download | yuzu-9b66e0dc8bec0bff0b211fb45c2c34cf93430be5.tar.gz yuzu-9b66e0dc8bec0bff0b211fb45c2c34cf93430be5.tar.xz yuzu-9b66e0dc8bec0bff0b211fb45c2c34cf93430be5.zip | |
clean up config block
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/cfg/cfg.cpp | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp index b9322c55d..acc509cb0 100644 --- a/src/core/hle/service/cfg/cfg.cpp +++ b/src/core/hle/service/cfg/cfg.cpp | |||
| @@ -47,6 +47,12 @@ struct UsernameBlock { | |||
| 47 | }; | 47 | }; |
| 48 | static_assert(sizeof(UsernameBlock) == 0x1C, "UsernameBlock must be exactly 0x1C bytes"); | 48 | static_assert(sizeof(UsernameBlock) == 0x1C, "UsernameBlock must be exactly 0x1C bytes"); |
| 49 | 49 | ||
| 50 | struct BirthdayBlock { | ||
| 51 | u8 month; ///< The month of the birthday | ||
| 52 | u8 day; ///< The day of the birthday | ||
| 53 | }; | ||
| 54 | static_assert(sizeof(BirthdayBlock) == 2, "BirthdayBlock must be exactly 2 bytes"); | ||
| 55 | |||
| 50 | struct ConsoleModelInfo { | 56 | struct ConsoleModelInfo { |
| 51 | u8 model; ///< The console model (3DS, 2DS, etc) | 57 | u8 model; ///< The console model (3DS, 2DS, etc) |
| 52 | u8 unknown[3]; ///< Unknown data | 58 | u8 unknown[3]; ///< Unknown data |
| @@ -65,9 +71,8 @@ static const u64 CFG_SAVE_ID = 0x00010017; | |||
| 65 | static const u64 CONSOLE_UNIQUE_ID = 0xDEADC0DE; | 71 | static const u64 CONSOLE_UNIQUE_ID = 0xDEADC0DE; |
| 66 | static const ConsoleModelInfo CONSOLE_MODEL = { NINTENDO_3DS_XL, { 0, 0, 0 } }; | 72 | static const ConsoleModelInfo CONSOLE_MODEL = { NINTENDO_3DS_XL, { 0, 0, 0 } }; |
| 67 | static const u8 CONSOLE_LANGUAGE = LANGUAGE_EN; | 73 | static const u8 CONSOLE_LANGUAGE = LANGUAGE_EN; |
| 68 | static const char CONSOLE_USERNAME[0x14] = "CITRA"; | 74 | static const UsernameBlock CONSOLE_USERNAME_BLOCK = { u"CITRA", 0, 0 }; |
| 69 | /// This will be initialized in Init, and will be used when creating the block | 75 | static const BirthdayBlock PROFILE_BIRTHDAY = { 3, 25 }; // March 25th, 2014 |
| 70 | static UsernameBlock CONSOLE_USERNAME_BLOCK; | ||
| 71 | /// TODO(Subv): Find out what this actually is | 76 | /// TODO(Subv): Find out what this actually is |
| 72 | static const u8 SOUND_OUTPUT_MODE = 2; | 77 | static const u8 SOUND_OUTPUT_MODE = 2; |
| 73 | static const u8 UNITED_STATES_COUNTRY_ID = 49; | 78 | static const u8 UNITED_STATES_COUNTRY_ID = 49; |
| @@ -329,32 +334,22 @@ ResultCode FormatConfig() { | |||
| 329 | 334 | ||
| 330 | res = CreateConfigInfoBlk(0x00050005, sizeof(STEREO_CAMERA_SETTINGS), 0xE, STEREO_CAMERA_SETTINGS.data()); | 335 | res = CreateConfigInfoBlk(0x00050005, sizeof(STEREO_CAMERA_SETTINGS), 0xE, STEREO_CAMERA_SETTINGS.data()); |
| 331 | if (!res.IsSuccess()) return res; | 336 | if (!res.IsSuccess()) return res; |
| 337 | |||
| 332 | res = CreateConfigInfoBlk(0x00070001, sizeof(SOUND_OUTPUT_MODE), 0xE, &SOUND_OUTPUT_MODE); | 338 | res = CreateConfigInfoBlk(0x00070001, sizeof(SOUND_OUTPUT_MODE), 0xE, &SOUND_OUTPUT_MODE); |
| 333 | if (!res.IsSuccess()) return res; | 339 | if (!res.IsSuccess()) return res; |
| 340 | |||
| 334 | res = CreateConfigInfoBlk(0x00090001, sizeof(CONSOLE_UNIQUE_ID), 0xE, &CONSOLE_UNIQUE_ID); | 341 | res = CreateConfigInfoBlk(0x00090001, sizeof(CONSOLE_UNIQUE_ID), 0xE, &CONSOLE_UNIQUE_ID); |
| 335 | if (!res.IsSuccess()) return res; | 342 | if (!res.IsSuccess()) return res; |
| 336 | res = CreateConfigInfoBlk(0x000A0000, sizeof(CONSOLE_USERNAME_BLOCK), 0xE, &CONSOLE_USERNAME_BLOCK); | ||
| 337 | if (!res.IsSuccess()) return res; | ||
| 338 | 343 | ||
| 339 | // 0x000A0000 - Profile username | 344 | res = CreateConfigInfoBlk(0x000A0000, sizeof(CONSOLE_USERNAME_BLOCK), 0xE, &CONSOLE_USERNAME_BLOCK); |
| 340 | struct { | ||
| 341 | u16_le username[10]; | ||
| 342 | u8 unused[4]; | ||
| 343 | u32_le wordfilter_version; // Unused by Citra | ||
| 344 | } profile_username = {}; | ||
| 345 | |||
| 346 | std::u16string username_string = Common::UTF8ToUTF16("Citra"); | ||
| 347 | std::copy(username_string.cbegin(), username_string.cend(), profile_username.username); | ||
| 348 | res = CreateConfigInfoBlk(0x000A0000, sizeof(profile_username), 0xE, &profile_username); | ||
| 349 | if (!res.IsSuccess()) return res; | 345 | if (!res.IsSuccess()) return res; |
| 350 | 346 | ||
| 351 | // 0x000A0001 - Profile birthday | 347 | res = CreateConfigInfoBlk(0x000A0001, sizeof(PROFILE_BIRTHDAY), 0xE, &PROFILE_BIRTHDAY); |
| 352 | const u8 profile_birthday[2] = {3, 25}; // March 25th, 2014 | ||
| 353 | res = CreateConfigInfoBlk(0x000A0001, sizeof(profile_birthday), 0xE, profile_birthday); | ||
| 354 | if (!res.IsSuccess()) return res; | 348 | if (!res.IsSuccess()) return res; |
| 355 | 349 | ||
| 356 | res = CreateConfigInfoBlk(0x000A0002, sizeof(CONSOLE_LANGUAGE), 0xE, &CONSOLE_LANGUAGE); | 350 | res = CreateConfigInfoBlk(0x000A0002, sizeof(CONSOLE_LANGUAGE), 0xE, &CONSOLE_LANGUAGE); |
| 357 | if (!res.IsSuccess()) return res; | 351 | if (!res.IsSuccess()) return res; |
| 352 | |||
| 358 | res = CreateConfigInfoBlk(0x000B0000, sizeof(COUNTRY_INFO), 0xE, &COUNTRY_INFO); | 353 | res = CreateConfigInfoBlk(0x000B0000, sizeof(COUNTRY_INFO), 0xE, &COUNTRY_INFO); |
| 359 | if (!res.IsSuccess()) return res; | 354 | if (!res.IsSuccess()) return res; |
| 360 | 355 | ||
| @@ -435,17 +430,6 @@ void Init() { | |||
| 435 | return; | 430 | return; |
| 436 | } | 431 | } |
| 437 | 432 | ||
| 438 | // Initialize the Username block | ||
| 439 | // TODO(Subv): Initialize this directly in the variable when MSVC supports char16_t string literals | ||
| 440 | memset(&CONSOLE_USERNAME_BLOCK, 0, sizeof(CONSOLE_USERNAME_BLOCK)); | ||
| 441 | CONSOLE_USERNAME_BLOCK.ng_word = 0; | ||
| 442 | CONSOLE_USERNAME_BLOCK.zero = 0; | ||
| 443 | |||
| 444 | // Copy string to buffer and pad with zeros at the end | ||
| 445 | auto size = Common::UTF8ToUTF16(CONSOLE_USERNAME).copy(CONSOLE_USERNAME_BLOCK.username, 0x14); | ||
| 446 | std::fill(std::begin(CONSOLE_USERNAME_BLOCK.username) + size, | ||
| 447 | std::end(CONSOLE_USERNAME_BLOCK.username), 0); | ||
| 448 | |||
| 449 | FormatConfig(); | 433 | FormatConfig(); |
| 450 | } | 434 | } |
| 451 | 435 | ||