diff --git a/src/xenia/kernel/title_id_utils.h b/src/xenia/kernel/title_id_utils.h index 42a080300..ab60a80a2 100644 --- a/src/xenia/kernel/title_id_utils.h +++ b/src/xenia/kernel/title_id_utils.h @@ -124,7 +124,7 @@ inline constexpr bool IsGamerPictureCustom(const uint32_t title_id) { } inline constexpr bool IsGamerPictureFromDash(const uint32_t title_id) { - return title_id == 0xFFFE07D1; + return title_id == kDashboardID; } inline constexpr bool IsGamerPictureKeySet(const uint32_t title_id) { @@ -134,8 +134,8 @@ inline constexpr bool IsGamerPictureKeySet(const uint32_t title_id) { static_assert(IsGamerPictureAvatar(0xFFFE0854)); // Avatar Gamer Picture static_assert(IsGamerPictureCustom(0xFFFE0700)); // Custom Gamer Picture static_assert( - IsGamerPictureFromDash(0xFFFE07D1)); // Default or OS Gamer Picture? -static_assert(!IsGamerPictureKeySet(0)); // No Gamer Picture Key + IsGamerPictureFromDash(kDashboardID)); // Default or OS Gamer Picture? +static_assert(!IsGamerPictureKeySet(0)); // No Gamer Picture Key } // namespace kernel } // namespace xe diff --git a/src/xenia/kernel/xam/user_settings.h b/src/xenia/kernel/xam/user_settings.h index 60f431e2e..bdc797b7a 100644 --- a/src/xenia/kernel/xam/user_settings.h +++ b/src/xenia/kernel/xam/user_settings.h @@ -445,6 +445,25 @@ enum ACCELERATOR_CONTROL_OPTIONS : uint8_t { ACCELERATOR_CONTROL_BUTTON }; +struct GamerPictureKey { + char title_id[8]; + char big_tile_id[8]; + char small_tile_id[8]; + + uint32_t GetTitleId() const { + return string_util::from_string(title_id, true); + } + + uint32_t GetBigTileId() const { + return string_util::from_string(big_tile_id, true); + } + + uint32_t GetSmallTileId() const { + return string_util::from_string(small_tile_id, true); + } +}; +static_assert_size(GamerPictureKey, 0x18); + class UserSetting : public UserData { public: UserSetting(const UserSetting& setting); diff --git a/src/xenia/kernel/xam/xam_user.cc b/src/xenia/kernel/xam/xam_user.cc index 132757253..46ab2bd25 100644 --- a/src/xenia/kernel/xam/xam_user.cc +++ b/src/xenia/kernel/xam/xam_user.cc @@ -758,8 +758,7 @@ dword_result_t XamParseGamerTileKey_entry(pointer_t key_ptr, kernel_memory()->TranslateVirtual( key_ptr->data.unicode.ptr))); - // Default key size is 24 bytes, but we need to include null terminator - if (tile_key.empty() || tile_key.size() != 24) { + if (tile_key.empty() || tile_key.size() != sizeof(GamerPictureKey)) { return X_ERROR_INVALID_PARAMETER; } @@ -770,23 +769,20 @@ dword_result_t XamParseGamerTileKey_entry(pointer_t key_ptr, if (!is_valid_hex_string) { return X_ERROR_INVALID_PARAMETER; } - // Simple parser for key. Key (lower case) contains: title_id (8 chars), - // big_tile_id (8 chars), small_tile_id (8 chars) - std::string title_id = tile_key.substr(0, 8); - std::string big_tile_id = tile_key.substr(8, 8); - std::string small_tile_id = tile_key.substr(16, 8); + + const GamerPictureKey* gamer_picture_key = + reinterpret_cast(tile_key.data()); if (title_id_ptr) { - *title_id_ptr = string_util::from_string(title_id, true); + *title_id_ptr = gamer_picture_key->GetTitleId(); } if (big_tile_id_ptr) { - *big_tile_id_ptr = string_util::from_string(big_tile_id, true); + *big_tile_id_ptr = gamer_picture_key->GetBigTileId(); } if (small_tile_id_ptr) { - *small_tile_id_ptr = - string_util::from_string(small_tile_id, true); + *small_tile_id_ptr = gamer_picture_key->GetSmallTileId(); } bool is_from_dash = false;