DSP Jit: rewrite dsp_increase_addr_reg a couple of times, only to find that int was wrong - credits to LordMark for finding that.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5374 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
j4ck.fr0st
2010-04-15 20:01:44 +00:00
parent 6cc0ddadd4
commit 01fc261c2f
2 changed files with 106 additions and 48 deletions

View File

@ -63,44 +63,41 @@ inline u16 ToMask(u16 a)
return a | (a >> 1);
}
inline s16 dsp_increment_addr_reg(int reg, s32 value = -1)
inline s16 dsp_increment_addr_reg(int reg, s16 value)
{
u16 tmb = ToMask(g_dsp.r[DSP_REG_WR0 + reg]);
s16 tmp;
if (value == -1)
tmp = g_dsp.r[reg];
else
tmp = value;
if ((tmp & tmb) == tmb)
tmp ^= g_dsp.r[DSP_REG_WR0 + reg];
if ((value & tmb) == tmb)
value ^= g_dsp.r[DSP_REG_WR0 + reg];
else
tmp++;
value++;
return tmp;
return value;
}
inline s16 dsp_increment_addr_reg(int reg)
{
return dsp_increment_addr_reg(reg, g_dsp.r[reg]);
}
// See http://code.google.com/p/dolphin-emu/source/detail?r=3125
inline s16 dsp_decrement_addr_reg(int reg, s32 value = -1)
inline s16 dsp_decrement_addr_reg(int reg, s16 value)
{
s16 tmp;
if (value == -1)
tmp = g_dsp.r[reg];
else
tmp = value;
// This one is easy. Looks like a hw implementation. Increment is worse...
if ((tmp & g_dsp.r[DSP_REG_WR0 + reg]) == 0)
tmp |= g_dsp.r[DSP_REG_WR0 + reg];
if ((value & g_dsp.r[DSP_REG_WR0 + reg]) == 0)
value |= g_dsp.r[DSP_REG_WR0 + reg];
else
tmp--;
value--;
return tmp;
return value;
}
inline s16 dsp_decrement_addr_reg(int reg)
{
return dsp_decrement_addr_reg(reg, g_dsp.r[reg]);
}
inline s16 dsp_increase_addr_reg(int reg, s16 value)
{
s16 tmp = - 1;
s16 tmp = g_dsp.r[reg];
// TODO: DO RIGHT!
if (value > 0) {
@ -111,15 +108,14 @@ inline s16 dsp_increase_addr_reg(int reg, s16 value)
for (int i = 0; i < (int)(-value); i++) {
tmp = dsp_decrement_addr_reg(reg, tmp);
}
} else
tmp = g_dsp.r[reg];
}
return tmp;
}
inline s16 dsp_decrease_addr_reg(int reg, s16 value)
{
s16 tmp = - 1;
s16 tmp = g_dsp.r[reg];
// TODO: DO RIGHT!
if (value > 0) {
@ -130,8 +126,7 @@ inline s16 dsp_decrease_addr_reg(int reg, s16 value)
for (int i = 0; i < (int)(-value); i++) {
tmp = dsp_increment_addr_reg(reg, tmp);
}
} else
tmp = g_dsp.r[reg];
}
return tmp;
}