Moved handlers for int11, int15 and int5c to winedos.
[wine] / dlls / winedos / int11.c
1 /*
2  * BIOS interrupt 11h handler
3  *
4  * Copyright 1996 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27
28 #include "windef.h"
29 #include "winreg.h"
30 #include "miscemu.h"
31 #include "msdos.h"
32 #include "file.h"
33 #include "wine/unicode.h"
34 #include "wine/debug.h"
35
36
37 /**********************************************************************
38  *          DOSVM_Int11Handler (WINEDOS16.117)
39  *
40  * Handler for int 11h (get equipment list).
41  *
42  *
43  * Borrowed from Ralph Brown's interrupt lists:
44  *
45  *   bits 15-14: number of parallel devices
46  *   bit     13: [Conv] Internal modem
47  *   bit     12: reserved
48  *   bits 11- 9: number of serial devices
49  *   bit      8: reserved
50  *   bits  7- 6: number of diskette drives minus one
51  *   bits  5- 4: Initial video mode:
52  *                 00b = EGA,VGA,PGA
53  *                 01b = 40 x 25 color
54  *                 10b = 80 x 25 color
55  *                 11b = 80 x 25 mono
56  *   bit      3: reserved
57  *   bit      2: [PS] =1 if pointing device
58  *               [non-PS] reserved
59  *   bit      1: =1 if math co-processor
60  *   bit      0: =1 if diskette available for boot
61  *
62  *
63  * Currently the only of these bits correctly set are:
64  *
65  *   bits 15-14   } Added by William Owen Smith,
66  *   bits 11-9    } wos@dcs.warwick.ac.uk
67  *   bits 7-6
68  *   bit  2       (always set)  ( bit 2 = 4 )
69  *   bit  1       } Robert 'Admiral' Coeyman
70  *                  All *nix systems either have a math processor or
71  *                   emulate one.
72  */
73 void WINAPI DOSVM_Int11Handler( CONTEXT86 *context )
74 {
75     int diskdrives = 0;
76     int parallelports = 0;
77     int serialports = 0;
78     int x;
79
80     if (GetDriveTypeA("A:\\") == DRIVE_REMOVABLE) diskdrives++;
81     if (GetDriveTypeA("B:\\") == DRIVE_REMOVABLE) diskdrives++;
82     if (diskdrives) diskdrives--;
83
84     for (x=0; x < 9; x++)
85     {        
86         HKEY hkey;
87         char option[10];
88         char temp[256];
89
90         /* serial port name */
91         strcpy( option, "COMx" );
92         option[3] = '1' + x;
93         option[4] = '\0';
94
95         /* default value */
96         strcpy( temp, "*" );
97
98         if (!RegOpenKeyA(HKEY_LOCAL_MACHINE, 
99                          "Software\\Wine\\Wine\\Config\\serialports", 
100                          &hkey))
101         {
102             DWORD type;
103             DWORD count = sizeof(temp);
104             RegQueryValueExA( hkey, option, 0, &type, temp, &count );
105             RegCloseKey( hkey );
106         }
107
108         if (strcmp(temp, "*") && *temp != '\0')
109             serialports++;
110
111         /* parallel port name */
112         strcpy( option, "LPTx" );
113         option[3] = '1' + x;
114         option[4] = '\0';
115
116         /* default value */
117         strcpy( temp, "*" );
118
119         if (!RegOpenKeyA(HKEY_LOCAL_MACHINE,
120                          "Software\\Wine\\Wine\\Config\\parallelports", 
121                          &hkey))
122         {
123             DWORD type;
124             DWORD count = sizeof(temp);
125             RegQueryValueExA( hkey, option, 0, &type, temp, &count );
126             RegCloseKey( hkey );
127         }
128
129         if (strcmp(temp, "*") && *temp != '\0')
130             parallelports++;
131     }
132
133     if (serialports > 7) /* 3 bits -- maximum value = 7 */
134         serialports = 7;
135
136     if (parallelports > 3) /* 2 bits -- maximum value = 3 */
137         parallelports = 3;
138
139     SET_AX( context, 
140             (diskdrives << 6) | (serialports << 9) | (parallelports << 14) | 0x06 );
141 }