Skip to content

Commit

Permalink
x87: Fix Final Reality discolored screen for interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
Cacodemon345 committed Feb 26, 2025
1 parent 48e35e9 commit 6d3816d
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/cpu/x87_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,33 @@ typedef union {
static __inline void
x87_push(double i)
{
#ifdef X87_INLINE_ASM
unsigned char buffer[10];
#else
x87_conv_t test;
#endif
#ifdef USE_NEW_DYNAREC
cpu_state.TOP--;
#else
cpu_state.TOP = (cpu_state.TOP - 1) & 7;
#endif
cpu_state.ST[cpu_state.TOP & 7] = i;

#ifdef X87_INLINE_ASM
__asm volatile(""
:
:
: "memory");

__asm volatile("fldl %1\n"
"fstpt %0\n" : "=m"(buffer) : "m"(i));

cpu_state.MM[cpu_state.TOP & 7].q = (*(uint64_t*)buffer);
#else
x87_to80(i, &test);
cpu_state.MM[cpu_state.TOP & 7].q = test.eind.ll;
#endif

#ifdef USE_NEW_DYNAREC
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID;
#else
Expand All @@ -129,6 +150,11 @@ x87_push(double i)
static __inline void
x87_push_u64(uint64_t i)
{
#ifdef X87_INLINE_ASM
unsigned char buffer[10];
#else
x87_conv_t test;
#endif
union {
double d;
uint64_t ll;
Expand All @@ -142,6 +168,21 @@ x87_push_u64(uint64_t i)
cpu_state.TOP = (cpu_state.TOP - 1) & 7;
#endif
cpu_state.ST[cpu_state.TOP & 7] = td.d;

#ifdef X87_INLINE_ASM
__asm volatile(""
:
:
: "memory");

__asm volatile("fldl %1\n"
"fstpt %0\n" : "=m"(buffer) : "m"(td.d));

cpu_state.MM[cpu_state.TOP & 7].q = (*(uint64_t*)buffer);
#else
x87_to80(td.d, &test);
cpu_state.MM[cpu_state.TOP & 7].q = test.eind.ll;
#endif
#ifdef USE_NEW_DYNAREC
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID;
#else
Expand Down

0 comments on commit 6d3816d

Please sign in to comment.