Skip to content

Commit 6d3816d

Browse files
committed
x87: Fix Final Reality discolored screen for interpreter
1 parent 48e35e9 commit 6d3816d

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/cpu/x87_ops.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,33 @@ typedef union {
113113
static __inline void
114114
x87_push(double i)
115115
{
116+
#ifdef X87_INLINE_ASM
117+
unsigned char buffer[10];
118+
#else
119+
x87_conv_t test;
120+
#endif
116121
#ifdef USE_NEW_DYNAREC
117122
cpu_state.TOP--;
118123
#else
119124
cpu_state.TOP = (cpu_state.TOP - 1) & 7;
120125
#endif
121126
cpu_state.ST[cpu_state.TOP & 7] = i;
127+
128+
#ifdef X87_INLINE_ASM
129+
__asm volatile(""
130+
:
131+
:
132+
: "memory");
133+
134+
__asm volatile("fldl %1\n"
135+
"fstpt %0\n" : "=m"(buffer) : "m"(i));
136+
137+
cpu_state.MM[cpu_state.TOP & 7].q = (*(uint64_t*)buffer);
138+
#else
139+
x87_to80(i, &test);
140+
cpu_state.MM[cpu_state.TOP & 7].q = test.eind.ll;
141+
#endif
142+
122143
#ifdef USE_NEW_DYNAREC
123144
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID;
124145
#else
@@ -129,6 +150,11 @@ x87_push(double i)
129150
static __inline void
130151
x87_push_u64(uint64_t i)
131152
{
153+
#ifdef X87_INLINE_ASM
154+
unsigned char buffer[10];
155+
#else
156+
x87_conv_t test;
157+
#endif
132158
union {
133159
double d;
134160
uint64_t ll;
@@ -142,6 +168,21 @@ x87_push_u64(uint64_t i)
142168
cpu_state.TOP = (cpu_state.TOP - 1) & 7;
143169
#endif
144170
cpu_state.ST[cpu_state.TOP & 7] = td.d;
171+
172+
#ifdef X87_INLINE_ASM
173+
__asm volatile(""
174+
:
175+
:
176+
: "memory");
177+
178+
__asm volatile("fldl %1\n"
179+
"fstpt %0\n" : "=m"(buffer) : "m"(td.d));
180+
181+
cpu_state.MM[cpu_state.TOP & 7].q = (*(uint64_t*)buffer);
182+
#else
183+
x87_to80(td.d, &test);
184+
cpu_state.MM[cpu_state.TOP & 7].q = test.eind.ll;
185+
#endif
145186
#ifdef USE_NEW_DYNAREC
146187
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID;
147188
#else

0 commit comments

Comments
 (0)