diff --git a/Core/HLE/HLEHelperThread.cpp b/Core/HLE/HLEHelperThread.cpp index 5c8a0278fb..0975d1ea96 100644 --- a/Core/HLE/HLEHelperThread.cpp +++ b/Core/HLE/HLEHelperThread.cpp @@ -29,7 +29,7 @@ HLEHelperThread::HLEHelperThread() : id_(-1), entry_(0) { } -HLEHelperThread::HLEHelperThread(const char *threadName, u32 instructions[], u32 instrCount, u32 prio, int stacksize) { +HLEHelperThread::HLEHelperThread(const char *threadName, const u32 instructions[], u32 instrCount, u32 prio, int stacksize) { u32 instrBytes = instrCount * sizeof(u32); u32 totalBytes = instrBytes + sizeof(u32) * 2; AllocEntry(totalBytes); diff --git a/Core/HLE/HLEHelperThread.h b/Core/HLE/HLEHelperThread.h index 39df4c7402..d932c2ea23 100644 --- a/Core/HLE/HLEHelperThread.h +++ b/Core/HLE/HLEHelperThread.h @@ -25,7 +25,7 @@ class HLEHelperThread { public: // For savestates. HLEHelperThread(); - HLEHelperThread(const char *threadName, u32 instructions[], u32 instrCount, u32 prio, int stacksize); + HLEHelperThread(const char *threadName, const u32 instructions[], u32 instrCount, u32 prio, int stacksize); HLEHelperThread(const char *threadName, const char *module, const char *func, u32 prio, int stacksize); ~HLEHelperThread(); void DoState(PointerWrap &p); diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index 6540147346..89e58a93e1 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -2025,22 +2025,24 @@ int __KernelStartThread(SceUID threadToStartID, int argSize, u32 argBlockPtr, bo u32 &sp = startThread->context.r[MIPS_REG_SP]; // Force args means just use those as a0/a1 without any special treatment. // This is a hack to avoid allocating memory for helper threads which take args. - if ((argBlockPtr && argSize > 0) || forceArgs) { + if (forceArgs) { + startThread->context.r[MIPS_REG_A0] = argSize; + startThread->context.r[MIPS_REG_A1] = argBlockPtr; + } else if (argBlockPtr && argSize > 0) { // Make room for the arguments, always 0x10 aligned. - if (!forceArgs) - sp -= (argSize + 0xf) & ~0xf; + sp -= (argSize + 0xf) & ~0xf; startThread->context.r[MIPS_REG_A0] = argSize; startThread->context.r[MIPS_REG_A1] = sp; + + // Now copy argument to stack. + if (Memory::IsValidAddress(argBlockPtr)) { + Memory::Memcpy(sp, argBlockPtr, argSize, "ThreadStartArgs"); + } } else { startThread->context.r[MIPS_REG_A0] = 0; startThread->context.r[MIPS_REG_A1] = 0; } - // Now copy argument to stack. - if (!forceArgs && Memory::IsValidAddress(argBlockPtr)) { - Memory::Memcpy(sp, argBlockPtr, argSize, "ThreadStartArgs"); - } - // On the PSP, there's an extra 64 bytes of stack eaten after the args. // This could be stack overflow safety, or just stack eaten by the kernel entry func. sp -= 64;