Split off wingdi16.h from wingdi.h. Add many more #defines/typedefs
[wine.git] / miscemu / emulate.c
blob511f0b7d3e882e46487baab3469b478b98a3e8ce
1 #include <stdlib.h>
2 #include "miscemu.h"
3 #include "debug.h"
5 DEFAULT_DEBUG_CHANNEL(int)
7 struct Win87EmInfoStruct
9 unsigned short Version;
10 unsigned short SizeSaveArea;
11 unsigned short WinDataSeg;
12 unsigned short WinCodeSeg;
13 unsigned short Have80x87;
14 unsigned short Unused;
17 /* Implementing this is easy cause Linux and *BSD* ALWAYS have a numerical
18 * coprocessor. (either real or emulated on kernellevel)
20 /* win87em.dll also sets interrupt vectors: 2 (NMI), 0x34 - 0x3f (emulator
21 * calls of standard libraries, see Ralph Browns interrupt list), 0x75
22 * (int13 error reporting of coprocessor)
25 /* have a look at /usr/src/linux/arch/i386/math-emu/ *.[ch] for more info
26 * especially control_w.h and status_w.h
28 /* FIXME: Only skeletal implementation for now */
30 void WINAPI WIN87_fpmath( CONTEXT *context )
32 TRACE(int, "(cs:eip=%x:%lx es=%x bx=%04x ax=%04x dx==%04x)\n",
33 (WORD)CS_reg(context), EIP_reg(context),
34 (WORD)ES_reg(context), BX_reg(context),
35 AX_reg(context), DX_reg(context) );
37 switch(BX_reg(context))
39 case 0: /* install (increase instanceref) emulator, install NMI vector */
40 AX_reg(context) = 0;
41 break;
43 case 1: /* Init Emulator */
44 AX_reg(context) = 0;
45 break;
47 case 2: /* deinstall emulator (decrease instanceref), deinstall NMI vector
48 * if zero. Every '0' call should have a matching '2' call.
50 AX_reg(context) = 0;
51 break;
53 case 3:
54 /*INT_SetHandler(0x3E,MAKELONG(AX,DX));*/
55 break;
57 case 4: /* set control word (& ~(CW_Denormal|CW_Invalid)) */
58 /* OUT: newset control word in AX */
59 break;
61 case 5: /* return internal control word in AX */
62 break;
64 case 6: /* round top of stack to integer using method AX & 0x0C00 */
65 /* returns current controlword */
67 DWORD dw=0;
68 /* I don't know much about asm() programming. This could be
69 * wrong.
71 __asm__ __volatile__("frndint");
72 __asm__ __volatile__("fist %0;wait" : "=m" (dw) : : "memory");
73 TRACE(int,"On top of stack is %ld\n",dw);
75 break;
77 case 7: /* POP top of stack as integer into DX:AX */
78 /* IN: AX&0x0C00 rounding protocol */
79 /* OUT: DX:AX variable popped */
81 DWORD dw=0;
82 /* I don't know much about asm() programming. This could be
83 * wrong.
85 /* FIXME: could someone who really understands asm() fix this please? --AJ */
86 /* __asm__("fistp %0;wait" : "=m" (dw) : : "memory"); */
87 TRACE(int,"On top of stack was %ld\n",dw);
88 AX_reg(context) = LOWORD(dw);
89 DX_reg(context) = HIWORD(dw);
91 break;
93 case 8: /* restore internal control words from emulator control word */
94 break;
96 case 9: /* clear emu control word and some other things */
97 break;
99 case 10: /* dunno. but looks like returning nr. of things on stack in AX */
100 AX_reg(context) = 0;
101 break;
103 case 11: /* just returns the installed flag in DX:AX */
104 DX_reg(context) = 0;
105 AX_reg(context) = 1;
106 break;
108 case 12: /* save AX in some internal state var */
109 break;
111 default: /* error. Say that loud and clear */
112 FIXME(int,"unhandled switch %d\n",BX_reg(context));
113 AX_reg(context) = DX_reg(context) = 0xFFFF;
114 break;
119 void WINAPI WIN87_WinEm87Info(struct Win87EmInfoStruct *pWIS,
120 int cbWin87EmInfoStruct)
122 TRACE(int, "(%p,%d)\n",pWIS,cbWin87EmInfoStruct);
125 void WINAPI WIN87_WinEm87Restore(void *pWin87EmSaveArea,
126 int cbWin87EmSaveArea)
128 TRACE(int, "(%p,%d)\n",
129 pWin87EmSaveArea,cbWin87EmSaveArea);
132 void WINAPI WIN87_WinEm87Save(void *pWin87EmSaveArea, int cbWin87EmSaveArea)
134 TRACE(int, "(%p,%d)\n",
135 pWin87EmSaveArea,cbWin87EmSaveArea);