summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2022-10-29 22:03:55 -0400
committer AJR <ajrhacker@users.noreply.github.com>2022-10-29 22:03:55 -0400
commit9e98def219d4635926fad9f1354f97b22d618ec8 (patch)
tree72723654b7410533c2f59572c50625408ab8d08d
parent16b6207d1ae4ed8122b182bcfc430dae26898625 (diff)
cpu/dsp32: Simplify int24 operator logic
-rw-r--r--src/devices/cpu/dsp32/dsp32ops.hxx7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/devices/cpu/dsp32/dsp32ops.hxx b/src/devices/cpu/dsp32/dsp32ops.hxx
index ecffcde443c..1b8ab6b5951 100644
--- a/src/devices/cpu/dsp32/dsp32ops.hxx
+++ b/src/devices/cpu/dsp32/dsp32ops.hxx
@@ -2443,14 +2443,11 @@ void dsp32c_device::d5_int24(uint32_t op)
{
double val = dau_read_pi_double_1st(op >> 7, 0);
int zpi = (op >> 0) & 0x7f;
- int32_t res;
if (!(DAUC & 0x10)) val = floor(val + 0.5);
else val = ceil(val - 0.5);
- res = (int32_t)val;
- if (res > 0x7fffff) res = 0x7fffff;
- else if (res < -0x800000) res = -0x800000;
+ int32_t res = std::clamp<int32_t>(val, -0x800000, 0x7fffff);
if (zpi != 7)
- dau_write_pi_4bytes(zpi, (int32_t)(res << 8) >> 8);
+ dau_write_pi_4bytes(zpi, res);
dau_set_val_noflags((op >> 21) & 3, dsp_to_double(res << 8));
}