From f5e0d80eadab060f73fd45ec0e29cdad78e553f9 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 16 Oct 2013 01:31:58 -0700 Subject: [PATCH] Pass arguments to root threads same as regular. Before it would have issues or crash if the args were > 256 bytes. Fixes Ys 1 & 2 Chronicles. --- 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 3602fdbce0..40d8cabe3b 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -2018,12 +2018,13 @@ SceUID __KernelSetupRootThread(SceUID moduleID, int args, const char *argp, int __KernelLoadContext(&thread->context, (attr & PSP_THREAD_ATTR_VFPU) != 0); 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; + u32 location = currentMIPS->r[MIPS_REG_SP]; currentMIPS->r[MIPS_REG_A1] = location; - for (int i = 0; i < args; i++) - Memory::Write_U8(argp[i], location + i); + if (argp) + Memory::Memcpy(location, argp, args); + // Let's assume same as starting a new thread, 64 bytes for safety/kernel. + currentMIPS->r[MIPS_REG_SP] -= 64; return id; }