DSP: Fix the invalid memory accesses that the Zelda Ucode does in LLE. No LLE sound yet but at least no crazy errors :p

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3516 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-06-21 06:56:44 +00:00
parent b7e5fb6ef2
commit 80217a6ed7
2 changed files with 19 additions and 1 deletions

View File

@ -97,7 +97,11 @@ void addarn(const UDSPInstruction& opc)
u8 dreg = opc.hex & 0x3;
u8 sreg = (opc.hex >> 2) & 0x3;
g_dsp.r[dreg] += (s16)g_dsp.r[DSP_REG_IX0 + sreg];
// g_dsp.r[dreg] += (s16)g_dsp.r[DSP_REG_IX0 + sreg];
dsp_increase_addr_reg(dreg, (s16)g_dsp.r[DSP_REG_IX0 + sreg]);
// It is critical for the Zelda ucode that this one wraps correctly.
}
// NX

View File

@ -82,6 +82,20 @@ inline void dsp_increment_addr_reg(int reg)
g_dsp.r[reg]++;
}
inline void dsp_increase_addr_reg(int reg, s16 value)
{
// TODO: DO RIGHT!
if (value > 0) {
for (int i = 0; i < value; i++) {
dsp_increment_addr_reg(reg);
}
} else if (value < 0) {
for (int i = 0; i < (int)(-value); i++) {
dsp_decrement_addr_reg(reg);
}
}
}
// ---------------------------------------------------------------------------------------
// --- reg