From a4061ce3b6477fe969d1f986407e8b0e1d119f6e Mon Sep 17 00:00:00 2001 From: Cancerous Date: Sat, 28 Dec 2019 22:25:58 -0500 Subject: [PATCH] [Kernel] HDD and save detection changes --- src/xenia/kernel/kernel_state.cc | 7 +++++++ src/xenia/kernel/xam/xam_content.cc | 16 ++++++++-------- src/xenia/kernel/xam/xam_ui.cc | 19 ++++++++++++++----- src/xenia/kernel/xam/xam_user.cc | 3 ++- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/xenia/kernel/kernel_state.cc b/src/xenia/kernel/kernel_state.cc index 9366c1160..0d9f3f354 100644 --- a/src/xenia/kernel/kernel_state.cc +++ b/src/xenia/kernel/kernel_state.cc @@ -608,18 +608,25 @@ void KernelState::RegisterNotifyListener(XNotifyListener* listener) { // https://cs.rin.ru/forum/viewtopic.php?f=38&t=60668&hilit=resident+evil+5&start=375 if (!has_notified_startup_ && listener->mask() & 0x00000001) { has_notified_startup_ = true; + // begin + listener->EnqueueNotification(0x00000001, 1); // XN_SYS_UI (on, off) listener->EnqueueNotification(0x00000009, 1); listener->EnqueueNotification(0x00000009, 0); // XN_SYS_SIGNINCHANGED x2 listener->EnqueueNotification(0x0000000A, 1); listener->EnqueueNotification(0x0000000A, 1); + // HDD ? + listener->EnqueueNotification(0x0000000B, 0); + listener->EnqueueNotification(0x0000000B, 1); // XN_SYS_INPUTDEVICESCHANGED x2 listener->EnqueueNotification(0x00000012, 0); listener->EnqueueNotification(0x00000012, 0); // XN_SYS_INPUTDEVICECONFIGCHANGED x2 listener->EnqueueNotification(0x00000013, 0); listener->EnqueueNotification(0x00000013, 0); + // end + listener->EnqueueNotification(0x00000026, 1); } } diff --git a/src/xenia/kernel/xam/xam_content.cc b/src/xenia/kernel/xam/xam_content.cc index aef634198..10e88fabc 100644 --- a/src/xenia/kernel/xam/xam_content.cc +++ b/src/xenia/kernel/xam/xam_content.cc @@ -54,9 +54,9 @@ struct DeviceInfo { // will not be recognized properly. #define ONE_GB (1024ull * 1024ull * 1024ull) static const DeviceInfo dummy_device_info_ = { - 0xF00D0000, 1, - 4ull * ONE_GB, // 4GB - 3ull * ONE_GB, // 3GB, so it looks a little used. + 0x00000001, 1, + 120ull * ONE_GB, // 4GB + 42ull * ONE_GB, // 3GB, so it looks a little used. L"Dummy HDD", }; #undef ONE_GB @@ -81,7 +81,7 @@ DECLARE_XAM_EXPORT2(XamContentGetLicenseMask, kContent, kStub, kHighFrequency); dword_result_t XamContentGetDeviceName(dword_t device_id, lpwstring_t name_buffer, dword_t name_capacity) { - if ((device_id & 0xFFFF0000) != dummy_device_info_.device_id) { + if ((device_id & 0x0000000F) != dummy_device_info_.device_id) { return X_ERROR_DEVICE_NOT_CONNECTED; } @@ -98,12 +98,12 @@ DECLARE_XAM_EXPORT1(XamContentGetDeviceName, kContent, kImplemented); dword_result_t XamContentGetDeviceState(dword_t device_id, lpunknown_t overlapped_ptr) { - if ((device_id & 0xFFFF0000) != dummy_device_info_.device_id) { + if ((device_id & 0x0000000F) != dummy_device_info_.device_id) { if (overlapped_ptr) { kernel_state()->CompleteOverlappedImmediateEx( overlapped_ptr, X_ERROR_FUNCTION_FAILED, X_ERROR_DEVICE_NOT_CONNECTED, 0); - return X_ERROR_IO_PENDING; + return X_ERROR_SUCCESS; } else { return X_ERROR_DEVICE_NOT_CONNECTED; } @@ -130,7 +130,7 @@ static_assert_size(X_CONTENT_DEVICE_DATA, 0x50); dword_result_t XamContentGetDeviceData( dword_t device_id, pointer_t device_data) { - if ((device_id & 0xFFFF0000) != dummy_device_info_.device_id) { + if ((device_id & 0x0000000F) != dummy_device_info_.device_id) { // TODO(benvanik): memset 0 the data? return X_ERROR_DEVICE_NOT_CONNECTED; } @@ -169,7 +169,7 @@ dword_result_t XamContentCreateEnumerator(dword_t user_index, dword_t device_id, lpdword_t buffer_size_ptr, lpdword_t handle_out) { assert_not_null(handle_out); - if ((device_id && (device_id & 0xFFFF0000) != dummy_device_info_.device_id) || + if ((device_id && (device_id & 0x0000000F) != dummy_device_info_.device_id) || !handle_out) { if (buffer_size_ptr) { *buffer_size_ptr = 0; diff --git a/src/xenia/kernel/xam/xam_ui.cc b/src/xenia/kernel/xam/xam_ui.cc index a3860ff48..768dec3a0 100644 --- a/src/xenia/kernel/xam/xam_ui.cc +++ b/src/xenia/kernel/xam/xam_ui.cc @@ -396,9 +396,14 @@ dword_result_t XamShowDeviceSelectorUI(dword_t user_index, dword_t content_type, if (overlapped) { XOverlappedSetResult((void*)overlapped.host_address(), X_ERROR_IO_PENDING); } - + + // broadcast begin + kernel_state()->BroadcastNotification(0x1, 1); // Broadcast XN_SYS_UI = true kernel_state()->BroadcastNotification(0x9, true); + // broadcast HDD changed + kernel_state()->BroadcastNotification(0xB, 0); + kernel_state()->BroadcastNotification(0xB, 1); auto ui_fn = [content_type, device_id_ptr, overlapped]() { XELOGW("XamShowDeviceSelectorUI Content_type:(%X) device_id_ptr: %.8X overlapped:(%X)", @@ -407,18 +412,18 @@ dword_result_t XamShowDeviceSelectorUI(dword_t user_index, dword_t content_type, // NOTE: 0xF00D0000 magic from xam_content.cc switch (content_type) { case 1: // save game - *device_id_ptr = 0xF00D0000 | 0x0001; + *device_id_ptr = 0x00000001 | 0x0001; break; case 2: // marketplace - *device_id_ptr = 0xF00D0000 | 0x0002; + *device_id_ptr = 0x00000001 | 0x0002; break; case 3: // title/publisher update? - *device_id_ptr = 0xF00D0000 | 0x0003; + *device_id_ptr = 0x00000001 | 0x0003; break; default: XELOGW("XamShowDeviceSelectorUI Unhandled Content_type:(%X)", content_type); assert_unhandled_case(content_type); - *device_id_ptr = 0xF00D0000 | 0x0001; + *device_id_ptr = 0x00000001 | 0x0001; break; } @@ -447,9 +452,13 @@ dword_result_t XamShowDeviceSelectorUI(dword_t user_index, dword_t content_type, while (ui_thread->last_error() != X_ERROR_SUCCESS) { xe::threading::Sleep(std::chrono::milliseconds(110)); } + // broadcast end + kernel_state()->BroadcastNotification(0x26, 1); return X_ERROR_IO_PENDING; } else { ui_fn(); + // broadcast end + kernel_state()->BroadcastNotification(0x26, 1); return X_ERROR_SUCCESS; } } diff --git a/src/xenia/kernel/xam/xam_user.cc b/src/xenia/kernel/xam/xam_user.cc index 4f21538e3..f80e1d622 100644 --- a/src/xenia/kernel/xam/xam_user.cc +++ b/src/xenia/kernel/xam/xam_user.cc @@ -47,9 +47,10 @@ dword_result_t XamProfileCreateEnumerator(dword_t device_id, X_PROFILEENUMRESULT* profile = (X_PROFILEENUMRESULT*)e->AppendItem(); memset(profile, 0, sizeof(X_PROFILEENUMRESULT)); profile->xuid_offline = user_profile->xuid(); - profile->device_id = 0xF00D0000; + profile->device_id = 0x00000001; auto tag = xe::to_wstring(user_profile->name()); + XELOGI("XamProfileCreateEnumerator profile:(%S)", tag.c_str()); xe::copy_and_swap(profile->account.gamertag, tag.c_str(), tag.length()); profile->account.xuid_online = user_profile->xuid();