diff options
| author | 2025-10-31 08:11:08 -0700 | |
|---|---|---|
| committer | 2025-10-31 11:11:08 -0400 | |
| commit | a47e3a2c49d4dae66f17a6141833482a5df1221e (patch) | |
| tree | 4d795e371aa098cf766364c5c98db144a926bb53 | |
| parent | a7a0a9ead2cb5f5843bc49fbd02d2156af6be539 (diff) | |
TMS32031: ABSF was mistakenly using ~man instead of -man, causing problems for MK4 which checks whether |A|+|B| == |A + B|. (#14440)
Fixed this problem: walking both players toward each other would result in no collision.
The relevant block of mk4 code:
01f3ad:07020000: ldf R0,R2
01f3ae:07030001: ldf R1,R3
01f3af:00020002: absf R2,R2
01f3b0:00030003: absf R3,R3
01f3b1:01830002: addf R2,R3
01f3b2:01810000: addf R0,R1
01f3b3:00010001: absf R1,R1
01f3b4:04010003: cmpf R3,R1
01f3b5:42e40000: ldfeq #1,R4
01f3b6:43e4f800: ldflt #-1,R4
Co-authored-by: Daniel Filner <cybermat@tilekiller.com>
| -rw-r--r-- | src/devices/cpu/tms32031/32031ops.hxx | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/devices/cpu/tms32031/32031ops.hxx b/src/devices/cpu/tms32031/32031ops.hxx index f419c85c943..a2a4b826bdd 100644 --- a/src/devices/cpu/tms32031/32031ops.hxx +++ b/src/devices/cpu/tms32031/32031ops.hxx @@ -1409,16 +1409,36 @@ uint32_t tms3203x_device::modillegal_def(uint32_t op, uint8_t ar, uint32_t *&def #define ABSF(dreg, sreg) \ { \ - int32_t man = FREGMAN(sreg); \ + int32_t man = FREGMAN(sreg); \ + int8_t fexp = FREGEXP(sreg); \ CLR_NZVUF(); \ - m_r[dreg] = m_r[sreg]; \ + m_r[dreg] = m_r[sreg]; \ + if (fexp == -128) \ + { /* if sreg was misformed, it should come out 80:00000000 */ \ + m_r[dreg].set_mantissa(0); \ + } \ + else \ if (man < 0) \ { \ - m_r[dreg].set_mantissa(~man); \ - if (man == (int32_t)0x80000000 && FREGEXP(sreg) == 127) \ - IREG(TMR_ST) |= VFLAG | LVFLAG; \ + if (man == (int32_t)0x80000000) \ + { \ + if (fexp == 127) \ + { /* total overflow result: 7F:7FFFFFFFF */ \ + IREG(TMR_ST) |= VFLAG | LVFLAG; \ + m_r[dreg].set_mantissa(0x7fffffff); \ + } \ + else \ + { /* man overflow -80000000 to +80000000 : increment exp */ \ + m_r[dreg].set_exponent(fexp + 1); \ + m_r[dreg].set_mantissa(0); \ + } \ + } \ + else \ + { /* normal case */ \ + m_r[dreg].set_mantissa(-man); /* aka (~man)+1 */ \ + } \ } \ - OR_NZF(m_r[dreg]); \ + OR_NZF(m_r[dreg]); \ } void tms3203x_device::absf_reg(uint32_t op) |
