From 4c88725f33240b67d2df63fdeedec6c4c810d978 Mon Sep 17 00:00:00 2001 From: emoose Date: Wed, 25 Dec 2019 20:26:04 +0000 Subject: [PATCH] [XAM] Small XamUserCreateTitlesPlayedEnumerator tweaks + other fixups --- src/xenia/kernel/xam/xam_info.cc | 3 ++- src/xenia/kernel/xam/xam_user.cc | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/xenia/kernel/xam/xam_info.cc b/src/xenia/kernel/xam/xam_info.cc index 235c54680..4511c7fab 100644 --- a/src/xenia/kernel/xam/xam_info.cc +++ b/src/xenia/kernel/xam/xam_info.cc @@ -348,7 +348,8 @@ DECLARE_XAM_EXPORT1(XamFree, kMemory, kImplemented); dword_result_t XamEnumerate(dword_t handle, dword_t flags, lpvoid_t buffer, dword_t buffer_length, lpdword_t items_returned, pointer_t overlapped) { - assert_true(flags == 0); + assert_true(flags == 0 || + flags == 2); // 2 seems to use more direct XAM code? auto e = kernel_state()->object_table()->LookupObject(handle); if (!e) { diff --git a/src/xenia/kernel/xam/xam_user.cc b/src/xenia/kernel/xam/xam_user.cc index 4785ad5ea..64d211633 100644 --- a/src/xenia/kernel/xam/xam_user.cc +++ b/src/xenia/kernel/xam/xam_user.cc @@ -462,6 +462,8 @@ dword_result_t XamUserWriteProfileSettings( gpd->UpdateSetting(setting); } + user_profile->UpdateAllGpds(); + if (overlapped_ptr) { kernel_state()->CompleteOverlappedImmediate(overlapped_ptr, X_ERROR_SUCCESS); @@ -718,18 +720,26 @@ DECLARE_XAM_EXPORT1(XamSessionRefObjByHandle, kUserProfiles, kStub); dword_result_t XamUserCreateTitlesPlayedEnumerator( dword_t user_index, dword_t xuid, dword_t flags, dword_t offset, dword_t games_count, lpdword_t buffer_size_ptr, lpdword_t handle_ptr) { - std::vector titles; - kernel_state()->user_profile()->GetDashboardGpd()->GetTitles(&titles); - // + 128 bytes for the 64-char titlename const uint32_t kEntrySize = sizeof(xdbf::X_XDBF_GPD_TITLEPLAYED) + 128; + if (buffer_size_ptr) { + *buffer_size_ptr = kEntrySize * games_count; + } + + std::vector titles; + kernel_state()->user_profile()->GetDashboardGpd()->GetTitles(&titles); + auto e = new XStaticEnumerator(kernel_state(), games_count, kEntrySize); e->Initialize(); *handle_ptr = e->handle(); for (auto title : titles) { + if (e->item_count() >= games_count) { + break; + } + // For some reason dashboard gpd stores info about itself if (title.title_id == kDashboardID) continue; @@ -741,6 +751,9 @@ dword_result_t XamUserCreateTitlesPlayedEnumerator( title.WriteGPD(details); } + XELOGD("XamUserCreateTitlesPlayedEnumerator: added %d items to enumerator", + e->item_count()); + return X_ERROR_SUCCESS; } DECLARE_XAM_EXPORT1(XamUserCreateTitlesPlayedEnumerator, kUserProfiles,