From 2e037b50760c4ee35b86104e5102bbc1cb1881a5 Mon Sep 17 00:00:00 2001 From: SarahW Date: Wed, 2 Jun 2021 21:13:39 +0100 Subject: [PATCH] FSCALE should always return 0.0 if ST(0) input is 0.0, regardless of value of ST(1); this might otherwise return infinity or NaN if not trapped. Fixes fade-in on MDK2. --- src/x87_ops_misc.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/x87_ops_misc.h b/src/x87_ops_misc.h index bde89c78..8abb5442 100644 --- a/src/x87_ops_misc.h +++ b/src/x87_ops_misc.h @@ -673,7 +673,8 @@ static int opFSCALE(uint32_t fetchdat) cpu_state.pc++; if (fplog) pclog("FSCALE\n"); temp64 = (int64_t)ST(1); - ST(0) = ST(0) * pow(2.0, (double)temp64); + if (ST(0) != 0.0) + ST(0) = ST(0) * pow(2.0, (double)temp64); cpu_state.tag[cpu_state.TOP&7] = TAG_VALID; CLOCK_CYCLES(x87_timings.fscale); return 0;