From 400db8ef0a002b2ccc6c5b24411ee9217e73a8ca Mon Sep 17 00:00:00 2001 From: wheremyfoodat Date: Thu, 5 Jan 2023 21:10:35 +0200 Subject: [PATCH] [APT] Some hacks --- src/core/kernel/events.cpp | 3 ++- src/core/services/apt.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/kernel/events.cpp b/src/core/kernel/events.cpp index 3c12ee2c..b74b5536 100644 --- a/src/core/kernel/events.cpp +++ b/src/core/kernel/events.cpp @@ -37,7 +37,7 @@ void Kernel::clearEvent() { logSVC("ClearEvent(event handle = %X)\n", handle); if (event == nullptr) [[unlikely]] { - Helpers::panic("Tried to clear non-existent event"); + Helpers::panic("Tried to clear non-existent event (handle = %X)", handle); regs[0] = SVCResult::BadHandle; return; } @@ -154,6 +154,7 @@ void Kernel::waitSynchronizationN() { } regs[0] = SVCResult::Success; + regs[1] = waitAll ? handleCount - 1 : 0; // Index of the handle that triggered the exit. STUBBED t.status = ThreadStatus::WaitSyncAll; t.waitAll = waitAll; t.outPointer = outPointer; diff --git a/src/core/services/apt.cpp b/src/core/services/apt.cpp index 1a38f643..24e41a17 100644 --- a/src/core/services/apt.cpp +++ b/src/core/services/apt.cpp @@ -104,9 +104,12 @@ void APTService::initialize(u32 messagePointer) { } void APTService::inquireNotification(u32 messagePointer) { - log("APT::InquireNotification\n"); + log("APT::InquireNotification (STUBBED TO FAIL)\n"); - mem.write32(messagePointer + 4, Result::Success); + // Thanks to our silly WaitSynchronization hacks, sometimes games will switch to the APT thread without actually getting a notif + // After REing the APT code, I figured that making InquireNotification fail is one way of making games not crash when this happens + // We should fix this in the future, when the sync object implementation is less hacky. + mem.write32(messagePointer + 4, Result::Failure); mem.write32(messagePointer + 8, static_cast(NotificationType::None)); }