Release 961023
[wine/multimedia.git] / miscemu / int2f.c
blobb8b62778fffa25a6fd7d87c6a1f74c2d3065f20a
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <unistd.h>
5 #include "ldt.h"
6 #include "drive.h"
7 #include "msdos.h"
8 #include "miscemu.h"
9 #include "module.h"
10 #include "options.h"
11 #include "stddebug.h"
12 /* #define DEBUG_INT */
13 #include "debug.h"
15 /* base WPROCS.DLL ordinal number for VxDs */
16 #define VXD_BASE 400
18 static void do_int2f_16( SIGCONTEXT *context );
19 void do_mscdex( SIGCONTEXT *context );
21 /**********************************************************************
22 * INT_Int2fHandler
24 * Handler for int 2fh (multiplex).
26 void INT_Int2fHandler( SIGCONTEXT *context )
28 switch(AH_reg(context))
30 case 0x10:
31 AL_reg(context) = 0xff; /* share is installed */
32 break;
34 case 0x15: /* mscdex */
35 do_mscdex(context);
36 break;
38 case 0x16:
39 do_int2f_16( context );
40 break;
42 case 0x4a:
43 switch(AL_reg(context))
45 case 0x10: /* smartdrv */
46 break; /* not installed */
47 case 0x11: /* dblspace */
48 break; /* not installed */
49 case 0x12: /* realtime compression interface */
50 break; /* not installed */
51 default:
52 INT_BARF( context, 0x2f );
54 break;
55 case 0xb7: /* append */
56 AL_reg(context) = 0; /* not installed */
57 break;
58 default:
59 INT_BARF( context, 0x2f );
60 break;
65 /**********************************************************************
66 * do_int2f_16
68 static void do_int2f_16( SIGCONTEXT *context )
70 DWORD addr;
72 switch(AL_reg(context))
74 case 0x00: /* Windows enhanced mode installation check */
75 AX_reg(context) = (Options.mode == MODE_ENHANCED) ? WINVERSION : 0;
76 break;
78 case 0x0a: /* Get Windows version and type */
79 AX_reg(context) = 0;
80 BX_reg(context) = (WINVERSION >> 8) | ((WINVERSION << 8) & 0xff00);
81 CX_reg(context) = (Options.mode == MODE_ENHANCED) ? 3 : 2;
82 break;
84 case 0x80: /* Release time-slice */
85 AL_reg(context) = 0;
86 /* FIXME: We need to do something that lets some other process run
87 here. */
88 sleep(0);
89 break;
91 case 0x83: /* Return Current Virtual Machine ID */
92 /* Virtual Machines are usually created/destroyed when Windows runs
93 * DOS programs. Since we never do, we are always in the System VM.
94 * According to Ralf Brown's Interrupt List, never return 0. But it
95 * seems to work okay (returning 0), just to be sure we return 1.
97 BX_reg(context) = 1; /* VM 1 is probably the System VM */
98 break;
100 case 0x84: /* Get device API entry point */
101 addr = (DWORD)MODULE_GetEntryPoint( GetModuleHandle("WPROCS"),
102 VXD_BASE + BX_reg(context) );
103 if (!addr) /* not supported */
105 fprintf( stderr,"Application attempted to access VxD %04x\n",
106 BX_reg(context) );
107 fprintf( stderr,"This device is not known to Wine.");
108 fprintf( stderr,"Expect a failure now\n");
110 ES_reg(context) = SELECTOROF(addr);
111 DI_reg(context) = OFFSETOF(addr);
112 break;
114 case 0x86: /* DPMI detect mode */
115 AX_reg(context) = 0; /* Running under DPMI */
116 break;
118 /* FIXME: is this right? Specs say that this should only be callable
119 in real (v86) mode which we never enter. */
120 case 0x87: /* DPMI installation check */
121 AX_reg(context) = 0x0000; /* DPMI Installed */
122 BX_reg(context) = 0x0001; /* 32bits available */
123 CL_reg(context) = runtime_cpu();
124 DX_reg(context) = 0x005a; /* DPMI major/minor 0.90 */
125 SI_reg(context) = 0; /* # of para. of DOS extended private data */
126 ES_reg(context) = 0; /* ES:DI is DPMI switch entry point */
127 DI_reg(context) = 0;
128 break;
130 case 0x8a: /* DPMI get vendor-specific API entry point. */
131 /* The 1.0 specs say this should work with all 0.9 hosts. */
132 break;
134 default:
135 INT_BARF( context, 0x2f );
139 void do_mscdex( SIGCONTEXT *context )
141 int drive, count;
142 char *p;
144 switch(AL_reg(context))
146 case 0x00: /* Installation check */
147 /* Count the number of contiguous CDROM drives
149 for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++)
151 if (DRIVE_GetType(drive) == TYPE_CDROM)
153 while (DRIVE_GetType(drive + count) == TYPE_CDROM) count++;
154 break;
158 BX_reg(context) = count;
159 CX_reg(context) = (drive < MAX_DOS_DRIVES) ? drive : 0;
160 break;
162 case 0x0B: /* drive check */
163 AX_reg(context) = (DRIVE_GetType(CX_reg(context)) == TYPE_CDROM);
164 BX_reg(context) = 0xADAD;
165 break;
167 case 0x0C: /* get version */
168 BX_reg(context) = 0x020a;
169 break;
171 case 0x0D: /* get drive letters */
172 p = PTR_SEG_OFF_TO_LIN(ES_reg(context), BX_reg(context));
173 memset( p, 0, MAX_DOS_DRIVES );
174 for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
176 if (DRIVE_GetType(drive) == TYPE_CDROM) *p++ = drive;
178 break;
180 default:
181 fprintf(stderr, "Unimplemented MSCDEX function 0x%02.2X.\n", AL_reg(context));
182 break;