From 1382dec0667a90cb2339da99fe7424f704314267 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Thu, 17 Sep 2020 18:15:56 +0200 Subject: [PATCH] XNotifyGetNext - Overall improvements --- src/xenia/kernel/xam/xam_notify.cc | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/xenia/kernel/xam/xam_notify.cc b/src/xenia/kernel/xam/xam_notify.cc index 2504b472d..7da2c018a 100644 --- a/src/xenia/kernel/xam/xam_notify.cc +++ b/src/xenia/kernel/xam/xam_notify.cc @@ -38,15 +38,19 @@ DECLARE_XAM_EXPORT1(XamNotifyCreateListener, kNone, kImplemented); // https://github.com/CodeAsm/ffplay360/blob/master/Common/AtgSignIn.cpp dword_result_t XNotifyGetNext(dword_t handle, dword_t match_id, lpdword_t id_ptr, lpdword_t param_ptr) { - if (!handle) { - return 0; + if (param_ptr) { + *param_ptr = 0; } + if (!id_ptr) { + return X_ERROR_INVALID_PARAMETER; + } + *id_ptr = 0; // Grab listener. auto listener = kernel_state()->object_table()->LookupObject(handle); if (!listener) { - return 0; + return X_ERROR_INVALID_HANDLE; } bool dequeued = false; @@ -61,21 +65,13 @@ dword_result_t XNotifyGetNext(dword_t handle, dword_t match_id, dequeued = listener->DequeueNotification(&id, ¶m); } + *id_ptr = dequeued ? id : 0; // param_ptr may be null - Ghost Recon Advanced Warfighter 2 Demo explicitly // passes nullptr in the code. // https://github.com/xenia-project/xenia/pull/1577 - if (dequeued) { - *id_ptr = id; - if (param_ptr) { - *param_ptr = param; - } - } else { - *id_ptr = 0; - if (param_ptr) { - *param_ptr = 0; - } + if (param_ptr) { + *param_ptr = dequeued ? param : 0; } - return dequeued ? 1 : 0; } DECLARE_XAM_EXPORT1(XNotifyGetNext, kNone, kImplemented);