From 0f7ac377cd3084abbf16e31a7c26f752391fe850 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 10 Sep 2013 01:12:51 -0700 Subject: [PATCH] Offset the root thread's stack by arg size. Otherwise it'll just overwrite, right? --- Core/HLE/sceKernelThread.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index a05cc387aa..2e617e3824 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -1989,10 +1989,11 @@ SceUID __KernelSetupRootThread(SceUID moduleID, int args, const char *argp, int strcpy(thread->nt.name, "root"); __KernelLoadContext(&thread->context, (attr & PSP_THREAD_ATTR_VFPU) != 0); - mipsr4k.r[MIPS_REG_A0] = args; - mipsr4k.r[MIPS_REG_SP] -= 256; - u32 location = mipsr4k.r[MIPS_REG_SP]; - mipsr4k.r[MIPS_REG_A1] = location; + currentMIPS->r[MIPS_REG_A0] = args; + currentMIPS->r[MIPS_REG_SP] -= 256; + u32 location = currentMIPS->r[MIPS_REG_SP]; + currentMIPS->r[MIPS_REG_SP] -= (args + 0xf) & ~0xf; + currentMIPS->r[MIPS_REG_A1] = location; for (int i = 0; i < args; i++) Memory::Write_U8(argp[i], location + i);