From c5b15cc9fcf337c2e8e60d789b666ff0b0fcff67 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 1 Sep 2014 14:52:46 -0700 Subject: [PATCH] Adjust semaphore timing slightly. This matches tests a bit better. --- Core/HLE/sceKernelSemaphore.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceKernelSemaphore.cpp b/Core/HLE/sceKernelSemaphore.cpp index ae2f728d6c..347b55582b 100644 --- a/Core/HLE/sceKernelSemaphore.cpp +++ b/Core/HLE/sceKernelSemaphore.cpp @@ -359,9 +359,9 @@ void __KernelSetSemaTimeout(Semaphore *s, u32 timeoutPtr) // This happens to be how the hardware seems to time things. if (micro <= 3) - micro = 25; + micro = 24; else if (micro <= 249) - micro = 250; + micro = 245; // This should call __KernelSemaTimeout() later, unless we cancel it. CoreTiming::ScheduleEvent(usToCycles(micro), semaWaitTimer, __KernelGetCurThread()); @@ -369,11 +369,18 @@ void __KernelSetSemaTimeout(Semaphore *s, u32 timeoutPtr) int __KernelWaitSema(SceUID id, int wantedCount, u32 timeoutPtr, bool processCallbacks) { + hleEatCycles(900); + + if (wantedCount <= 0) + return SCE_KERNEL_ERROR_ILLEGAL_COUNT; + + hleEatCycles(500); + u32 error; Semaphore *s = kernelObjects.Get(id, error); if (s) { - if (wantedCount > s->ns.maxCount || wantedCount <= 0) + if (wantedCount > s->ns.maxCount) return SCE_KERNEL_ERROR_ILLEGAL_COUNT; // If there are any callbacks, we always wait, and wake after the callbacks.