mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Merge pull request #12635 from unknownbrackets/thread-status
Kernel: Delay better in sceKernelReferThreadStatus
This commit is contained in:
commit
6610cd7663
@ -739,7 +739,7 @@ const HLEFunction ThreadManForUser[] =
|
|||||||
{0X3B183E26, &WrapI_I<sceKernelGetThreadExitStatus>, "sceKernelGetThreadExitStatus", 'i', "i" },
|
{0X3B183E26, &WrapI_I<sceKernelGetThreadExitStatus>, "sceKernelGetThreadExitStatus", 'i', "i" },
|
||||||
{0X52089CA1, &WrapI_I<sceKernelGetThreadStackFreeSize>, "sceKernelGetThreadStackFreeSize", 'i', "i" },
|
{0X52089CA1, &WrapI_I<sceKernelGetThreadStackFreeSize>, "sceKernelGetThreadStackFreeSize", 'i', "i" },
|
||||||
{0XFFC36A14, &WrapU_UU<sceKernelReferThreadRunStatus>, "sceKernelReferThreadRunStatus", 'x', "xx" },
|
{0XFFC36A14, &WrapU_UU<sceKernelReferThreadRunStatus>, "sceKernelReferThreadRunStatus", 'x', "xx" },
|
||||||
{0X17C1684E, &WrapU_UU<sceKernelReferThreadStatus>, "sceKernelReferThreadStatus", 'x', "xx" },
|
{0X17C1684E, &WrapU_UU<sceKernelReferThreadStatus>, "sceKernelReferThreadStatus", 'i', "xp" },
|
||||||
{0X2C34E053, &WrapI_I<sceKernelReleaseWaitThread>, "sceKernelReleaseWaitThread", 'i', "i" },
|
{0X2C34E053, &WrapI_I<sceKernelReleaseWaitThread>, "sceKernelReleaseWaitThread", 'i', "i" },
|
||||||
{0X75156E8F, &WrapI_I<sceKernelResumeThread>, "sceKernelResumeThread", 'i', "i" },
|
{0X75156E8F, &WrapI_I<sceKernelResumeThread>, "sceKernelResumeThread", 'i', "i" },
|
||||||
{0X3AD58B8C, &WrapU_V<sceKernelSuspendDispatchThread>, "sceKernelSuspendDispatchThread", 'x', "", HLE_NOT_IN_INTERRUPT },
|
{0X3AD58B8C, &WrapU_V<sceKernelSuspendDispatchThread>, "sceKernelSuspendDispatchThread", 'x', "", HLE_NOT_IN_INTERRUPT },
|
||||||
|
@ -1256,44 +1256,37 @@ u32 sceKernelReferThreadStatus(u32 threadID, u32 statusPtr)
|
|||||||
|
|
||||||
u32 error;
|
u32 error;
|
||||||
Thread *t = kernelObjects.Get<Thread>(threadID, error);
|
Thread *t = kernelObjects.Get<Thread>(threadID, error);
|
||||||
if (!t)
|
if (!t) {
|
||||||
{
|
hleEatCycles(700);
|
||||||
ERROR_LOG(SCEKERNEL, "%08x=sceKernelReferThreadStatus(%i, %08x): bad thread", error, threadID, statusPtr);
|
hleReSchedule("refer thread status");
|
||||||
return error;
|
return hleLogError(SCEKERNEL, error, "bad thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 wantedSize = Memory::Read_U32(statusPtr);
|
u32 wantedSize = Memory::Read_U32(statusPtr);
|
||||||
|
|
||||||
if (sceKernelGetCompiledSdkVersion() > 0x02060010)
|
if (sceKernelGetCompiledSdkVersion() > 0x02060010) {
|
||||||
{
|
if (wantedSize > THREADINFO_SIZE_AFTER_260) {
|
||||||
if (wantedSize > THREADINFO_SIZE_AFTER_260)
|
hleEatCycles(1200);
|
||||||
{
|
hleReSchedule("refer thread status");
|
||||||
ERROR_LOG(SCEKERNEL, "%08x=sceKernelReferThreadStatus(%i, %08x): bad size %d", SCE_KERNEL_ERROR_ILLEGAL_SIZE, threadID, statusPtr, wantedSize);
|
return hleLogError(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_SIZE, "bad size %d", wantedSize);
|
||||||
return SCE_KERNEL_ERROR_ILLEGAL_SIZE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VERBOSE_LOG(SCEKERNEL, "sceKernelReferThreadStatus(%i, %08x)", threadID, statusPtr);
|
|
||||||
|
|
||||||
t->nt.nativeSize = THREADINFO_SIZE_AFTER_260;
|
t->nt.nativeSize = THREADINFO_SIZE_AFTER_260;
|
||||||
if (wantedSize != 0)
|
if (wantedSize != 0)
|
||||||
Memory::Memcpy(statusPtr, &t->nt, std::min(wantedSize, (u32)sizeof(t->nt)));
|
Memory::Memcpy(statusPtr, &t->nt, std::min(wantedSize, (u32)sizeof(t->nt)));
|
||||||
// TODO: What is this value? Basic tests show 0...
|
// TODO: What is this value? Basic tests show 0...
|
||||||
if (wantedSize > sizeof(t->nt))
|
if (wantedSize > sizeof(t->nt))
|
||||||
Memory::Memset(statusPtr + sizeof(t->nt), 0, wantedSize - sizeof(t->nt));
|
Memory::Memset(statusPtr + sizeof(t->nt), 0, wantedSize - sizeof(t->nt));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
VERBOSE_LOG(SCEKERNEL, "sceKernelReferThreadStatus(%i, %08x)", threadID, statusPtr);
|
|
||||||
|
|
||||||
t->nt.nativeSize = THREADINFO_SIZE;
|
t->nt.nativeSize = THREADINFO_SIZE;
|
||||||
u32 sz = std::min(THREADINFO_SIZE, wantedSize);
|
u32 sz = std::min(THREADINFO_SIZE, wantedSize);
|
||||||
if (sz != 0)
|
if (sz != 0)
|
||||||
Memory::Memcpy(statusPtr, &t->nt, sz);
|
Memory::Memcpy(statusPtr, &t->nt, sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
hleEatCycles(1220);
|
hleEatCycles(1400);
|
||||||
hleReSchedule("refer thread status");
|
hleReSchedule("refer thread status");
|
||||||
return 0;
|
return hleLogSuccessVerboseI(SCEKERNEL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Thanks JPCSP
|
// Thanks JPCSP
|
||||||
|
Loading…
Reference in New Issue
Block a user