From c682e070a6e3892e48e03016c2a88747abdb26f3 Mon Sep 17 00:00:00 2001 From: SarahW Date: Sat, 11 May 2019 18:41:31 +0100 Subject: [PATCH] Fix x87 tag register when using MMX instructions. Fixes numerous issues when an MMX process is running at the same time as one or more other MMX/FPU processes (usually seen running 3dfx games with AudioPCI). --- src/x87.c | 2 +- src/x87.h | 2 +- src/x87_ops_misc.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/x87.c b/src/x87.c index 44f22e0..ac2650d 100644 --- a/src/x87.c +++ b/src/x87.c @@ -35,7 +35,7 @@ uint16_t x87_gettag() ret |= X87_TAG_EMPTY << (c * 2); else if (cpu_state.tag[c] & TAG_UINT64) ret |= 2 << (c*2); - else if (cpu_state.ST[c] == 0.0) + else if (cpu_state.ST[c] == 0.0 && !cpu_state.ismmx) ret |= X87_TAG_ZERO << (c * 2); else ret |= X87_TAG_VALID << (c * 2); diff --git a/src/x87.h b/src/x87.h index 2ec4405..9441a41 100644 --- a/src/x87.h +++ b/src/x87.h @@ -9,7 +9,7 @@ uint16_t x87_pc_seg,x87_op_seg; static inline void x87_set_mmx() { cpu_state.TOP = 0; - *(uint64_t *)cpu_state.tag = 0; + *(uint64_t *)cpu_state.tag = 0x0101010101010101ull; cpu_state.ismmx = 1; } diff --git a/src/x87_ops_misc.h b/src/x87_ops_misc.h index f22d618..0cae387 100644 --- a/src/x87_ops_misc.h +++ b/src/x87_ops_misc.h @@ -117,8 +117,8 @@ static int FSTOR() something like this is needed*/ if (cpu_state.MM_w4[0] == 0xffff && cpu_state.MM_w4[1] == 0xffff && cpu_state.MM_w4[2] == 0xffff && cpu_state.MM_w4[3] == 0xffff && cpu_state.MM_w4[4] == 0xffff && cpu_state.MM_w4[5] == 0xffff && cpu_state.MM_w4[6] == 0xffff && cpu_state.MM_w4[7] == 0xffff && - !cpu_state.TOP && !(*(uint64_t *)cpu_state.tag)) - cpu_state.ismmx = 1; + !cpu_state.TOP && (*(uint64_t *)cpu_state.tag == 0x0101010101010101ull)) + cpu_state.ismmx = 1; CLOCK_CYCLES((cr0 & 1) ? 34 : 44); if (fplog) pclog("FRSTOR %08X:%08X %i %i %04X\n", easeg, cpu_state.eaaddr, cpu_state.ismmx, cpu_state.TOP, x87_gettag());