diff --git a/rpcs3/Emu/Cell/PPUInterpreter.cpp b/rpcs3/Emu/Cell/PPUInterpreter.cpp index 8fda79db5d..1347bcc08e 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.cpp +++ b/rpcs3/Emu/Cell/PPUInterpreter.cpp @@ -2903,15 +2903,14 @@ bool ppu_interpreter::BC(ppu_thread& ppu, ppu_opcode_t op) const bool bo3 = (op.bo & 0x02) != 0; ppu.ctr -= (bo2 ^ true); + if (op.lk) ppu.lr = ppu.cia + 4; const bool ctr_ok = bo2 | ((ppu.ctr != 0) ^ bo3); const bool cond_ok = bo0 | (ppu.cr[op.bi] ^ (bo1 ^ true)); if (ctr_ok && cond_ok) { - const u32 link = ppu.cia + 4; ppu.cia = (op.aa ? 0 : ppu.cia) + op.bt14; - if (op.lk) ppu.lr = link; return false; } else @@ -2958,11 +2957,12 @@ bool ppu_interpreter::BCLR(ppu_thread& ppu, ppu_opcode_t op) const bool ctr_ok = bo2 | ((ppu.ctr != 0) ^ bo3); const bool cond_ok = bo0 | (ppu.cr[op.bi] ^ (bo1 ^ true)); + const u32 target = (u32)ppu.lr & ~3; + if (op.lk) ppu.lr = ppu.cia + 4; + if (ctr_ok && cond_ok) { - const u32 link = ppu.cia + 4; - ppu.cia = (u32)ppu.lr & ~3; - if (op.lk) ppu.lr = link; + ppu.cia = target; return false; } else @@ -3027,11 +3027,11 @@ bool ppu_interpreter::CROR(ppu_thread& ppu, ppu_opcode_t op) bool ppu_interpreter::BCCTR(ppu_thread& ppu, ppu_opcode_t op) { + if (op.lk) ppu.lr = ppu.cia + 4; + if (op.bo & 0x10 || ppu.cr[op.bi] == ((op.bo & 0x8) != 0)) { - const u32 link = ppu.cia + 4; ppu.cia = (u32)ppu.ctr & ~3; - if (op.lk) ppu.lr = link; return false; } diff --git a/rpcs3/Emu/Cell/PPUTranslator.cpp b/rpcs3/Emu/Cell/PPUTranslator.cpp index 314387144b..784771975e 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.cpp +++ b/rpcs3/Emu/Cell/PPUTranslator.cpp @@ -1772,13 +1772,13 @@ void PPUTranslator::BC(ppu_opcode_t op) CompilationError("Branch with absolute address"); } - UseCondition(CheckBranchProbability(op.bo), CheckBranchCondition(op.bo, op.bi)); - if (op.lk) { m_ir->CreateStore(GetAddr(+4), m_ir->CreateStructGEP(nullptr, m_thread, &m_lr - m_locals)); } + UseCondition(CheckBranchProbability(op.bo), CheckBranchCondition(op.bo, op.bi)); + CallFunction(target); } @@ -1842,13 +1842,13 @@ void PPUTranslator::BCLR(ppu_opcode_t op) { const auto target = RegLoad(m_lr); - UseCondition(CheckBranchProbability(op.bo), CheckBranchCondition(op.bo, op.bi)); - if (op.lk) { m_ir->CreateStore(GetAddr(+4), m_ir->CreateStructGEP(nullptr, m_thread, &m_lr - m_locals)); } + UseCondition(CheckBranchProbability(op.bo), CheckBranchCondition(op.bo, op.bi)); + CallFunction(0, target); } @@ -1905,13 +1905,13 @@ void PPUTranslator::BCCTR(ppu_opcode_t op) { const auto target = RegLoad(m_ctr); - UseCondition(CheckBranchProbability(op.bo | 0x4), CheckBranchCondition(op.bo | 0x4, op.bi)); - if (op.lk) { m_ir->CreateStore(GetAddr(+4), m_ir->CreateStructGEP(nullptr, m_thread, &m_lr - m_locals)); } + UseCondition(CheckBranchProbability(op.bo | 0x4), CheckBranchCondition(op.bo | 0x4, op.bi)); + CallFunction(0, target); }