Core/DSP: Fix loop/loopi for Interpreter and JIT.

A repeat count of zero still executed the instruction once. Fixes Zelda Ucode
audio crackling.

Fixes DSPLLE audio in: Luigi Mansion, Pikmin, Super Mario Galaxy,
Zelda CE, Zelda Four Swords, Zelda WW, Zelda TP.
(Thanks LM for testing)



git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7370 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
pierre 2011-03-18 21:21:19 +00:00
parent a2159f38bd
commit ed6fa744ad
2 changed files with 18 additions and 2 deletions

View File

@ -193,6 +193,8 @@ void loop(const UDSPInstruction opc)
dsp_reg_store_stack(2, loop_pc);
dsp_reg_store_stack(3, cnt);
}
else
dsp_skip_inst();
}
// LOOPI #I
@ -214,6 +216,8 @@ void loopi(const UDSPInstruction opc)
dsp_reg_store_stack(2, loop_pc);
dsp_reg_store_stack(3, cnt);
}
else
dsp_skip_inst();
}

View File

@ -377,9 +377,15 @@ void DSPEmitter::loop(const UDSPInstruction opc)
MOV(16, R(RDX), Imm16(loop_pc));
dsp_reg_store_stack(2);
gpr.flushRegs(c);
MOV(16, M(&(g_dsp.pc)), Imm16(compilePC + 1));
FixupBranch exit = J(true);
SetJumpTarget(cnt);
MOV(16, M(&(g_dsp.pc)), Imm16(compilePC + 1));
// dsp_skip_inst();
MOV(16, M(&g_dsp.pc), Imm16(loop_pc + opTable[loop_pc]->size));
WriteBranchExit(*this);
gpr.flushRegs(c,false);
SetJumpTarget(exit);
}
// LOOPI #I
@ -395,7 +401,7 @@ void DSPEmitter::loopi(const UDSPInstruction opc)
u16 cnt = opc & 0xff;
u16 loop_pc = compilePC + 1;
if (cnt)
if (cnt)
{
MOV(16, R(RDX), Imm16(compilePC + 1));
dsp_reg_store_stack(0);
@ -406,6 +412,12 @@ void DSPEmitter::loopi(const UDSPInstruction opc)
MOV(16, M(&(g_dsp.pc)), Imm16(compilePC + 1));
}
else
{
// dsp_skip_inst();
MOV(16, M(&g_dsp.pc), Imm16(loop_pc + opTable[loop_pc]->size));
WriteBranchExit(*this);
}
}