From 15dd6ba40374b5f20baa270ada689a66ec7f6374 Mon Sep 17 00:00:00 2001 From: hap Date: Sun, 30 Mar 2025 20:39:21 +0200 Subject: [PATCH] v60: fix issue with CVTSW overflow flag after rounding --- src/devices/cpu/v60/op2.hxx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/devices/cpu/v60/op2.hxx b/src/devices/cpu/v60/op2.hxx index 86124e4034b..8227405ddc2 100644 --- a/src/devices/cpu/v60/op2.hxx +++ b/src/devices/cpu/v60/op2.hxx @@ -69,16 +69,19 @@ uint32_t v60_device::opCVTSW() F2DecodeFirstOperand(&v60_device::ReadAM, 2); - // Convert to uint32_t + // Apply RDI rounding control val = u2f(m_op1); switch (TKCW & 7) { - case 0: m_modwritevalw = (uint32_t)llroundf(val); break; - case 1: m_modwritevalw = (uint32_t)(int64_t)floorf(val); break; - case 2: m_modwritevalw = (uint32_t)(int64_t)ceilf(val); break; - default: m_modwritevalw = (uint32_t)(int64_t)truncf(val); break; + case 0: val = roundf(val); break; + case 1: val = floorf(val); break; + case 2: val = ceilf(val); break; + default: val = truncf(val); break; } + // Convert to uint32_t + m_modwritevalw = (uint32_t)(int64_t)val; + _S = ((m_modwritevalw & 0x80000000) != 0); _OV = (_S && val >= 0.0f) || (!_S && val <= -1.0f); _Z = (m_modwritevalw == 0); @@ -122,7 +125,7 @@ uint32_t v60_device::opABSFS() appf = u2f(m_op1); - if(appf < 0) + if (appf < 0) appf = -appf; _OV = 0;