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.
This commit is contained in:
Unknown W. Brackets 2013-10-16 01:31:58 -07:00
parent 80702109f5
commit f5e0d80ead

View File

@ -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;
}