diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index e0a5eac4d4..92c5fee535 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -1336,32 +1336,21 @@ u32 sceKernelReferThreadRunStatus(u32 threadID, u32 statusPtr) int __KernelGetThreadExitStatus(SceUID threadID) { u32 error; PSPThread *t = kernelObjects.Get(threadID, error); - if (t) - { - if (t->nt.status == THREADSTATUS_DORMANT) // TODO: can be dormant before starting, too, need to avoid that - { - DEBUG_LOG(SCEKERNEL, "sceKernelGetThreadExitStatus(%d)", threadID); - return t->nt.exitStatus; - } - else - { - DEBUG_LOG(SCEKERNEL, "sceKernelGetThreadExitStatus(%d): not dormant", threadID); - return SCE_KERNEL_ERROR_NOT_DORMANT; - } + if (!t) { + return hleLogError(SCEKERNEL, error); } - else - { - ERROR_LOG(SCEKERNEL, "sceKernelGetThreadExitStatus Error %08x", error); - return SCE_KERNEL_ERROR_UNKNOWN_THID; + + // __KernelResetThread and __KernelCreateThread set exitStatus in case it's DORMANT. + if (t->nt.status == THREADSTATUS_DORMANT) { + return hleLogSuccessI(SCEKERNEL, t->nt.exitStatus); } + return hleLogDebug(SCEKERNEL, SCE_KERNEL_ERROR_NOT_DORMANT, "not dormant"); } -int sceKernelGetThreadExitStatus(SceUID threadID) -{ +int sceKernelGetThreadExitStatus(SceUID threadID) { u32 status = __KernelGetThreadExitStatus(threadID); // Seems this is called in a tight-ish loop, maybe awaiting an interrupt - issue #13698 - // Guess based on sceKernelGetThreadId. - hleEatCycles(180); + hleEatCycles(330); return status; }