DSPInterpreter: Sign-extend acS.h to 32 bits

Thus, the 40-bit accumulator is treated as properly sign-extended when read as a 64-bit number.  This affects e.g. overflow detection.
This commit is contained in:
Pokechu22 2021-08-18 15:34:01 -07:00
parent 105d8860fb
commit 74440c468f
2 changed files with 2 additions and 2 deletions

View File

@ -271,7 +271,7 @@ struct DSP_Regs
{ {
u16 l; u16 l;
u16 m; u16 m;
u16 h; u32 h; // 32 bits so that val is fully sign-extended (only 8 bits are actually used)
}; };
} ac[2]; } ac[2];
}; };

View File

@ -769,7 +769,7 @@ void Interpreter::ConditionalExtendAccum(int reg)
// Sign extend into whole accum. // Sign extend into whole accum.
auto& state = m_dsp_core.DSPState(); auto& state = m_dsp_core.DSPState();
const u16 val = state.r.ac[reg - DSP_REG_ACM0].m; const u16 val = state.r.ac[reg - DSP_REG_ACM0].m;
state.r.ac[reg - DSP_REG_ACM0].h = (val & 0x8000) != 0 ? 0xFFFF : 0x0000; state.r.ac[reg - DSP_REG_ACM0].h = (val & 0x8000) != 0 ? 0xFFFFFFFF : 0x0000;
state.r.ac[reg - DSP_REG_ACM0].l = 0; state.r.ac[reg - DSP_REG_ACM0].l = 0;
} }