diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index c4907dc6e3..9aace5b6d1 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -220,13 +220,15 @@ int FPRdouble::Cmp(PPCdouble a, PPCdouble b) return CR_SO; } -u64 PPUThread::FastCall(u64 addr, u64 arg1, u64 arg2, u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7, u64 arg8) +u64 PPUThread::FastCall(u64 addr, u64 rtoc, u64 arg1, u64 arg2, u64 arg3, u64 arg4, u64 arg5, u64 arg6, u64 arg7, u64 arg8) { auto old_status = m_status; auto old_PC = PC; auto old_LR = LR; + auto old_rtoc = GPR[2]; PC = addr; + GPR[2] = rtoc; GPR[3] = arg1; GPR[4] = arg2; GPR[5] = arg3; @@ -239,6 +241,7 @@ u64 PPUThread::FastCall(u64 addr, u64 arg1, u64 arg2, u64 arg3, u64 arg4, u64 ar Task(); + GPR[2] = old_rtoc; LR = old_LR; PC = old_PC; m_status = old_status; diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index 7d8cd62197..15c1a95339 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -842,7 +842,7 @@ public: public: virtual void InitRegs(); virtual u64 GetFreeStackSize() const; - u64 FastCall(u64 addr, u64 arg1 = 0, u64 arg2 = 0, u64 arg3 = 0, u64 arg4 = 0, u64 arg5 = 0, u64 arg6 = 0, u64 arg7 = 0, u64 arg8 = 0); + u64 FastCall(u64 addr, u64 rtoc, u64 arg1 = 0, u64 arg2 = 0, u64 arg3 = 0, u64 arg4 = 0, u64 arg5 = 0, u64 arg6 = 0, u64 arg7 = 0, u64 arg8 = 0); void FastStop(); protected: diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp index 00f6c79479..ab2a31d936 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp @@ -13,7 +13,8 @@ Module *cellSync = nullptr; #ifdef PRX_DEBUG #include "rpcs3.h" #include "prx_libsre.h" -u32 libsre = 0; +u32 libsre; +u32 libsre_rtoc; #endif s32 syncMutexInitialize(mem_ptr_t mutex) @@ -1078,7 +1079,7 @@ void syncLFQueueInit(mem_ptr_t queue, u32 buffer_addr, u32 size s32 syncLFQueueInitialize(mem_ptr_t queue, u32 buffer_addr, u32 size, u32 depth, CellSyncQueueDirection direction, u32 eaSignal_addr) { #ifdef PRX_DEBUG_XXX - return GetCurrentPPUThread().FastCall(libsre + 0x205C, queue.GetAddr(), buffer_addr, size, depth, direction, eaSignal_addr); + return GetCurrentPPUThread().FastCall(libsre + 0x205C, libsre_rtoc, queue.GetAddr(), buffer_addr, size, depth, direction, eaSignal_addr); #else if (!queue) @@ -1522,7 +1523,7 @@ s32 _cellSyncLFQueuePushBody(mem_ptr_t queue, u32 buffer_addr, if (queue->m_direction.ToBE() != se32(CELL_SYNC_QUEUE_ANY2ANY)) { #ifdef PRX_DEBUG_XXX - res = GetCurrentPPUThread().FastCall(libsre + 0x24B0, queue.GetAddr(), position_v.GetAddr(), isBlocking, 0); + res = GetCurrentPPUThread().FastCall(libsre + 0x24B0, libsre_rtoc, queue.GetAddr(), position_v.GetAddr(), isBlocking, 0); position = position_v->ToLE(); #else res = syncLFQueueGetPushPointer(queue, position, isBlocking, 0); @@ -1531,7 +1532,7 @@ s32 _cellSyncLFQueuePushBody(mem_ptr_t queue, u32 buffer_addr, else { #ifdef PRX_DEBUG - res = GetCurrentPPUThread().FastCall(libsre + 0x3050, queue.GetAddr(), position_v.GetAddr(), isBlocking, 0); + res = GetCurrentPPUThread().FastCall(libsre + 0x3050, libsre_rtoc, queue.GetAddr(), position_v.GetAddr(), isBlocking, 0); position = position_v->ToLE(); #else res = syncLFQueueGetPushPointer2(queue, position, isBlocking, 0); @@ -1566,7 +1567,7 @@ s32 _cellSyncLFQueuePushBody(mem_ptr_t queue, u32 buffer_addr, if (queue->m_direction.ToBE() != se32(CELL_SYNC_QUEUE_ANY2ANY)) { #ifdef PRX_DEBUG_XXX - res = GetCurrentPPUThread().FastCall(libsre + 0x26C0, queue.GetAddr(), position, 0); + res = GetCurrentPPUThread().FastCall(libsre + 0x26C0, libsre_rtoc, queue.GetAddr(), position, 0); #else res = syncLFQueueCompletePushPointer(queue, position, nullptr); #endif @@ -1574,7 +1575,7 @@ s32 _cellSyncLFQueuePushBody(mem_ptr_t queue, u32 buffer_addr, else { #ifdef PRX_DEBUG - res = GetCurrentPPUThread().FastCall(libsre + 0x355C, queue.GetAddr(), position, 0); + res = GetCurrentPPUThread().FastCall(libsre + 0x355C, libsre_rtoc, queue.GetAddr(), position, 0); #else res = syncLFQueueCompletePushPointer2(queue, position, nullptr); #endif @@ -1913,7 +1914,7 @@ s32 _cellSyncLFQueuePopBody(mem_ptr_t queue, u32 buffer_addr, u if (queue->m_direction.ToBE() != se32(CELL_SYNC_QUEUE_ANY2ANY)) { #ifdef PRX_DEBUG_XXX - res = GetCurrentPPUThread().FastCall(libsre + 0x2A90, queue.GetAddr(), position_v.GetAddr(), isBlocking, 0, 0); + res = GetCurrentPPUThread().FastCall(libsre + 0x2A90, libsre_rtoc, queue.GetAddr(), position_v.GetAddr(), isBlocking, 0, 0); position = position_v->ToLE(); #else res = syncLFQueueGetPopPointer(queue, position, isBlocking, 0, 0); @@ -1922,7 +1923,7 @@ s32 _cellSyncLFQueuePopBody(mem_ptr_t queue, u32 buffer_addr, u else { #ifdef PRX_DEBUG - res = GetCurrentPPUThread().FastCall(libsre + 0x39AC, queue.GetAddr(), position_v.GetAddr(), isBlocking, 0); + res = GetCurrentPPUThread().FastCall(libsre + 0x39AC, libsre_rtoc, queue.GetAddr(), position_v.GetAddr(), isBlocking, 0); position = position_v->ToLE(); #else res = syncLFQueueGetPopPointer2(queue, position, isBlocking, 0); @@ -1954,7 +1955,7 @@ s32 _cellSyncLFQueuePopBody(mem_ptr_t queue, u32 buffer_addr, u if (queue->m_direction.ToBE() != se32(CELL_SYNC_QUEUE_ANY2ANY)) { #ifdef PRX_DEBUG_XXX - res = GetCurrentPPUThread().FastCall(libsre + 0x2CA8, queue.GetAddr(), position, 0, 0); + res = GetCurrentPPUThread().FastCall(libsre + 0x2CA8, libsre_rtoc, queue.GetAddr(), position, 0, 0); #else res = syncLFQueueCompletePopPointer(queue, position, nullptr, 0); #endif @@ -1962,7 +1963,7 @@ s32 _cellSyncLFQueuePopBody(mem_ptr_t queue, u32 buffer_addr, u else { #ifdef PRX_DEBUG - res = GetCurrentPPUThread().FastCall(libsre + 0x3EB8, queue.GetAddr(), position, 0, 0); + res = GetCurrentPPUThread().FastCall(libsre + 0x3EB8, libsre_rtoc, queue.GetAddr(), position, 0, 0); #else res = syncLFQueueCompletePopPointer2(queue, position, nullptr, 0); #endif @@ -2207,6 +2208,7 @@ void cellSync_init() { libsre = Memory.PRXMem.AllocAlign(sizeof(libsre_data), 4096); memcpy(Memory + libsre, libsre_data, sizeof(libsre_data)); + libsre_rtoc = libsre + 0x399B0; }); #endif }