From b7fd09740b6815d6f468c755f1144ae31a59067f Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sat, 18 Apr 2015 03:25:26 +0300 Subject: [PATCH] PPU stack fixed --- rpcs3/Emu/Cell/PPUThread.cpp | 5 +++-- rpcs3/Emu/SysCalls/CB_FUNC.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 393efddff1..d8fb12c3ec 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -663,7 +663,7 @@ void PPUThread::FastCall2(u32 addr, u32 rtoc) { auto old_status = m_status; auto old_PC = PC; - auto old_stack = GPR[1]; // only saved and restored (may be wrong) + auto old_stack = GPR[1]; auto old_rtoc = GPR[2]; auto old_LR = LR; auto old_thread = GetCurrentNamedThread(); @@ -671,6 +671,7 @@ void PPUThread::FastCall2(u32 addr, u32 rtoc) m_status = Running; PC = addr; + GPR[1] -= 0x70; // create stack frame reserved area GPR[2] = rtoc; LR = Emu.GetCPUThreadStop(); SetCurrentNamedThread(this); @@ -680,7 +681,7 @@ void PPUThread::FastCall2(u32 addr, u32 rtoc) m_status = old_status; PC = old_PC; - GPR[1] = old_stack; + GPR[1] = old_stack; // TODO: error check instead of blind assignment? GPR[1] shouldn't change GPR[2] = old_rtoc; LR = old_LR; SetCurrentNamedThread(old_thread); diff --git a/rpcs3/Emu/SysCalls/CB_FUNC.h b/rpcs3/Emu/SysCalls/CB_FUNC.h index 160eab9559..2fb0a99a70 100644 --- a/rpcs3/Emu/SysCalls/CB_FUNC.h +++ b/rpcs3/Emu/SysCalls/CB_FUNC.h @@ -14,7 +14,7 @@ namespace cb_detail // Current implementation can handle only fixed amount of stack arguments. // This constant can be increased if necessary. // It's possible to calculate suitable stack frame size in template, but too complicated. - static const auto FIXED_STACK_FRAME_SIZE = 0x100; + static const auto FIXED_STACK_FRAME_SIZE = 0x90; template struct _func_arg; @@ -61,7 +61,7 @@ namespace cb_detail __forceinline static void set_value(PPUThread& CPU, const T& arg) { - const int stack_pos = 0x70 + (g_count - 9) * 8 - FIXED_STACK_FRAME_SIZE; + const int stack_pos = (g_count - 9) * 8 - FIXED_STACK_FRAME_SIZE; static_assert(stack_pos < 0, "TODO: Increase fixed stack frame size (arg count limit broken)"); vm::write64(CPU.GPR[1] + stack_pos, cast_to_ppu_gpr(arg)); }