Release 960225
[wine/multimedia.git] / miscemu / int2f.c
blob86ff140f4c7c6ac283c18fbefdb7585a310ef1ec
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <unistd.h>
5 #include "registers.h"
6 #include "ldt.h"
7 #include "wine.h"
8 #include "drive.h"
9 #include "msdos.h"
10 #include "miscemu.h"
11 #include "module.h"
12 #include "options.h"
13 #include "stddebug.h"
14 /* #define DEBUG_INT */
15 #include "debug.h"
17 /* base WINPROC module number for VxDs */
18 #define VXD_BASE 400
20 static void do_int2f_16(struct sigcontext_struct *context);
21 void do_mscdex(struct sigcontext_struct *context);
23 /**********************************************************************
24 * INT_Int2fHandler
26 * Handler for int 2fh (multiplex).
28 void INT_Int2fHandler( struct sigcontext_struct context )
30 switch(AH_reg(&context))
32 case 0x10:
33 AL_reg(&context) = 0xff; /* share is installed */
34 break;
36 case 0x15: /* mscdex */
37 do_mscdex(&context);
38 break;
40 case 0x16:
41 do_int2f_16( &context );
42 break;
44 case 0x4a:
45 switch(AL_reg(&context))
47 case 0x10: /* smartdrv */
48 break; /* not installed */
49 case 0x11: /* dblspace */
50 break; /* not installed */
51 case 0x12: /* realtime compression interface */
52 break; /* not installed */
53 default:
54 INT_BARF( &context, 0x2f );
56 break;
57 default:
58 INT_BARF( &context, 0x2f );
59 break;
64 /**********************************************************************
65 * do_int2f_16
67 static void do_int2f_16(struct sigcontext_struct *context)
69 DWORD addr;
71 switch(AL_reg(context))
73 case 0x00: /* Windows enhanced mode installation check */
74 AX_reg(context) = (Options.mode == MODE_ENHANCED) ? WINVERSION : 0;
75 break;
77 case 0x0a: /* Get Windows version and type */
78 AX_reg(context) = 0;
79 BX_reg(context) = (WINVERSION >> 8) | ((WINVERSION << 8) & 0xff00);
80 CX_reg(context) = (Options.mode == MODE_ENHANCED) ? 3 : 2;
81 break;
83 case 0x80: /* Release time-slice */
84 AL_reg(context) = 0;
85 /* FIXME: We need to do something that lets some other process run
86 here. */
87 sleep(0);
88 break;
90 case 0x83: /* Return Current Virtual Machine ID */
91 /* Virtual Machines are usually created/destroyed when Windows runs
92 * DOS programs. Since we never do, we are always in the System VM.
93 * According to Ralf Brown's Interrupt List, never return 0. But it
94 * seems to work okay (returning 0), just to be sure we return 1.
96 BX_reg(context) = 1; /* VM 1 is probably the System VM */
97 break;
99 case 0x84: /* Get device API entry point */
100 addr = MODULE_GetEntryPoint( GetModuleHandle("WINPROCS"),
101 VXD_BASE + BX_reg(context) );
102 if (!addr) /* not supported */
104 fprintf( stderr,"Application attempted to access VxD %04x\n",
105 BX_reg(context) );
106 fprintf( stderr,"This device is not known to Wine.");
107 fprintf( stderr,"Expect a failure now\n");
109 ES_reg(context) = SELECTOROF(addr);
110 DI_reg(context) = OFFSETOF(addr);
111 break;
113 case 0x86: /* DPMI detect mode */
114 AX_reg(context) = 0; /* Running under DPMI */
115 break;
117 /* FIXME: is this right? Specs say that this should only be callable
118 in real (v86) mode which we never enter. */
119 case 0x87: /* DPMI installation check */
120 AX_reg(context) = 0x0000; /* DPMI Installed */
121 BX_reg(context) = 0x0001; /* 32bits available */
122 CL_reg(context) = runtime_cpu();
123 DX_reg(context) = 0x005a; /* DPMI major/minor 0.90 */
124 SI_reg(context) = 0; /* # of para. of DOS extended private data */
125 ES_reg(context) = 0; /* ES:DI is DPMI switch entry point */
126 DI_reg(context) = 0;
127 break;
129 case 0x8a: /* DPMI get vendor-specific API entry point. */
130 /* The 1.0 specs say this should work with all 0.9 hosts. */
131 break;
133 default:
134 INT_BARF( context, 0x2f );
138 void do_mscdex(struct sigcontext_struct *context)
140 int drive, count;
141 char *p;
143 switch(AL_reg(context))
145 case 0x00: /* Installation check */
146 /* Count the number of contiguous CDROM drives
148 for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++)
150 if (DRIVE_GetType(drive) == TYPE_CDROM)
152 while (DRIVE_GetType(drive + count) == TYPE_CDROM) count++;
153 break;
157 BX_reg(context) = count;
158 CX_reg(context) = (drive < MAX_DOS_DRIVES) ? drive : 0;
159 break;
161 case 0x0B: /* drive check */
162 AX_reg(context) = (DRIVE_GetType(CX_reg(context)) == TYPE_CDROM);
163 BX_reg(context) = 0xADAD;
164 break;
166 case 0x0C: /* get version */
167 BX_reg(context) = 0x020a;
168 break;
170 case 0x0D: /* get drive letters */
171 p = PTR_SEG_OFF_TO_LIN(ES_reg(context), BX_reg(context));
172 memset( p, 0, MAX_DOS_DRIVES );
173 for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
175 if (DRIVE_GetType(drive) == TYPE_CDROM) *p++ = drive;
177 break;
179 default:
180 fprintf(stderr, "Unimplemented MSCDEX function 0x%02.2X.\n", AL_reg(context));
181 break;