Moved VGA-emulating DirectX code from dispdib.c to a separate
[wine/multimedia.git] / miscemu / emulate.c
blob0d95dadf22873e266bbdb22eef90b0880c314d85
1 #include <stdlib.h>
2 #include "miscemu.h"
3 #include "debug.h"
5 struct Win87EmInfoStruct
7 unsigned short Version;
8 unsigned short SizeSaveArea;
9 unsigned short WinDataSeg;
10 unsigned short WinCodeSeg;
11 unsigned short Have80x87;
12 unsigned short Unused;
15 /* Implementing this is easy cause Linux and *BSD* ALWAYS have a numerical
16 * coprocessor. (either real or emulated on kernellevel)
18 /* win87em.dll also sets interrupt vectors: 2 (NMI), 0x34 - 0x3f (emulator
19 * calls of standard libraries, see Ralph Browns interrupt list), 0x75
20 * (int13 error reporting of coprocessor)
23 /* have a look at /usr/src/linux/arch/i386/math-emu/ *.[ch] for more info
24 * especially control_w.h and status_w.h
26 /* FIXME: Only skeletal implementation for now */
28 void WINAPI WIN87_fpmath( CONTEXT *context )
30 TRACE(int, "(cs:eip=%x:%lx es=%x bx=%04x ax=%04x dx==%04x)\n",
31 (WORD)CS_reg(context), EIP_reg(context),
32 (WORD)ES_reg(context), BX_reg(context),
33 AX_reg(context), DX_reg(context) );
35 switch(BX_reg(context))
37 case 0: /* install (increase instanceref) emulator, install NMI vector */
38 AX_reg(context) = 0;
39 break;
41 case 1: /* Init Emulator */
42 AX_reg(context) = 0;
43 break;
45 case 2: /* deinstall emulator (decrease instanceref), deinstall NMI vector
46 * if zero. Every '0' call should have a matching '2' call.
48 AX_reg(context) = 0;
49 break;
51 case 3:
52 /*INT_SetHandler(0x3E,MAKELONG(AX,DX));*/
53 break;
55 case 4: /* set control word (& ~(CW_Denormal|CW_Invalid)) */
56 /* OUT: newset control word in AX */
57 break;
59 case 5: /* return internal control word in AX */
60 break;
62 case 6: /* round top of stack to integer using method AX & 0x0C00 */
63 /* returns current controlword */
64 break;
66 case 7: /* POP top of stack as integer into DX:AX */
67 /* IN: AX&0x0C00 rounding protocol */
68 /* OUT: DX:AX variable popped */
70 DWORD dw=0;
71 /* I don't know much about asm() programming. This could be
72 * wrong.
74 /* FIXME: could someone who really understands asm() fix this please? --AJ */
75 /* __asm__("fistp %0;wait" : "=m" (dw) : : "memory"); */
76 TRACE(int,"On top of stack was %ld\n",dw);
77 AX_reg(context) = LOWORD(dw);
78 DX_reg(context) = HIWORD(dw);
80 break;
82 case 8: /* restore internal control words from emulator control word */
83 break;
85 case 9: /* clear emu control word and some other things */
86 break;
88 case 10: /* dunno. but looks like returning nr. of things on stack in AX */
89 AX_reg(context) = 0;
90 break;
92 case 11: /* just returns the installed flag in DX:AX */
93 DX_reg(context) = 0;
94 AX_reg(context) = 1;
95 break;
97 case 12: /* save AX in some internal state var */
98 break;
100 default: /* error. Say that loud and clear */
101 AX_reg(context) = DX_reg(context) = 0xFFFF;
102 break;
107 void WINAPI WIN87_WinEm87Info(struct Win87EmInfoStruct *pWIS,
108 int cbWin87EmInfoStruct)
110 TRACE(int, "(%p,%d)\n",pWIS,cbWin87EmInfoStruct);
113 void WINAPI WIN87_WinEm87Restore(void *pWin87EmSaveArea,
114 int cbWin87EmSaveArea)
116 TRACE(int, "(%p,%d)\n",
117 pWin87EmSaveArea,cbWin87EmSaveArea);
120 void WINAPI WIN87_WinEm87Save(void *pWin87EmSaveArea, int cbWin87EmSaveArea)
122 TRACE(int, "(%p,%d)\n",
123 pWin87EmSaveArea,cbWin87EmSaveArea);