dsp16: better rnd on negative (nw)

This commit is contained in:
Vas Crabb 2018-05-09 16:34:20 +10:00
parent cc65ce9e94
commit 896db0c0db

View File

@ -146,7 +146,7 @@ inline void dsp16_device_base::core_state::dau_f2(u16 op)
// p 3-13: "Round upper 20 bits of accumulator."
// p 3-14: "The contents of the source accumulator, aS, are rounded to 16 bits, and the sign-extended result is placed in aD[35 - 16] with zeroes in aD[15 - 0]."
// It presumably rounds to nearest, but does it yield a 16-bit or 20-bit result, and what does it do about overflow?
d = (s + ((0 > s) ? -(s16(1) << 15) : (s16(1) << 15))) & ~((u64(1) << 16) - 1);
d = (s + ((s32(1) << 15) - ((0 > s) ? 1 : 0))) & ~((u64(1) << 16) - 1);
break;
case 0xc: // aD = y
d = dau_y;