Release 960516
[wine/multimedia.git] / miscemu / interrupts.c
blob308d69f2051c717cbc5729ebb7aca0d95d889226
1 /*
2 * Interrupt vectors emulation
4 * Copyright 1995 Alexandre Julliard
5 */
7 #include <sys/types.h>
9 #include "windows.h"
10 #include "drive.h"
11 #include "miscemu.h"
12 #include "msdos.h"
13 #include "module.h"
14 #include "registers.h"
15 #include "stackframe.h"
16 #include "stddebug.h"
17 #include "debug.h"
19 static SEGPTR INT_Vectors[256];
21 /* Ordinal number for interrupt 0 handler in WPROCS.DLL */
22 #define FIRST_INTERRUPT_ORDINAL 100
25 /**********************************************************************
26 * INT_Init
28 BOOL INT_Init(void)
30 WORD vector;
31 HMODULE hModule = GetModuleHandle( "WPROCS" );
33 for (vector = 0; vector < 256; vector++)
35 if (!(INT_Vectors[vector] = MODULE_GetEntryPoint( hModule,
36 FIRST_INTERRUPT_ORDINAL+vector )))
38 fprintf(stderr,"Internal error: no vector for int %02x\n",vector);
39 return FALSE;
42 return TRUE;
46 /**********************************************************************
47 * INT_GetHandler
49 * Return the interrupt vector for a given interrupt.
51 SEGPTR INT_GetHandler( BYTE intnum )
53 return INT_Vectors[intnum];
57 /**********************************************************************
58 * INT_SetHandler
60 * Set the interrupt handler for a given interrupt.
62 void INT_SetHandler( BYTE intnum, SEGPTR handler )
64 dprintf_int( stddeb, "Set interrupt vector %02x <- %04x:%04x\n",
65 intnum, HIWORD(handler), LOWORD(handler) );
66 INT_Vectors[intnum] = handler;
70 /**********************************************************************
71 * INT_DummyHandler
73 void INT_DummyHandler( struct sigcontext_struct context )
75 WORD ordinal;
76 char *name;
77 STACK16FRAME *frame = CURRENT_STACK16;
78 BUILTIN_GetEntryPoint( frame->entry_cs, frame->entry_ip, &ordinal, &name );
79 INT_BARF( &context, ordinal - FIRST_INTERRUPT_ORDINAL );
83 /**********************************************************************
84 * INT_Int11Handler
86 * Handler for int 11h (get equipment list).
88 void INT_Int11Handler( struct sigcontext_struct context )
90 int diskdrives = 0;
91 int parallelports = 0;
92 int serialports = 0;
93 int x;
95 /* borrowed from Ralph Brown's interrupt lists
97 bits 15-14: number of parallel devices
98 bit 13: [Conv] Internal modem
99 bit 12: reserved
100 bits 11- 9: number of serial devices
101 bit 8: reserved
102 bits 7- 6: number of diskette drives minus one
103 bits 5- 4: Initial video mode:
104 00b = EGA,VGA,PGA
105 01b = 40 x 25 color
106 10b = 80 x 25 color
107 11b = 80 x 25 mono
108 bit 3: reserved
109 bit 2: [PS] =1 if pointing device
110 [non-PS] reserved
111 bit 1: =1 if math co-processor
112 bit 0: =1 if diskette available for boot
114 /* Currently the only of these bits correctly set are:
115 bits 15-14 } Added by William Owen Smith,
116 bits 11-9 } wos@dcs.warwick.ac.uk
117 bits 7-6
118 bit 2 (always set)
121 if (DRIVE_IsValid(0)) diskdrives++;
122 if (DRIVE_IsValid(1)) diskdrives++;
123 if (diskdrives) diskdrives--;
125 for (x=0; x!=MAX_PORTS; x++)
127 if (COM[x].devicename)
128 serialports++;
129 if (LPT[x].devicename)
130 parallelports++;
132 if (serialports > 7) /* 3 bits -- maximum value = 7 */
133 serialports=7;
134 if (parallelports > 3) /* 2 bits -- maximum value = 3 */
135 parallelports=3;
137 AX_reg(&context) = (diskdrives << 6) | (serialports << 9) |
138 (parallelports << 14) | 0x02;
142 /**********************************************************************
143 * INT_Int12Handler
145 * Handler for int 12h (get memory size).
147 void INT_Int12Handler( struct sigcontext_struct context )
149 AX_reg(&context) = 640;
153 /**********************************************************************
154 * INT_Int15Handler
156 * Handler for int 15h.
158 void INT_Int15Handler( struct sigcontext_struct context )
160 INT_BARF( &context, 0x15 );
164 /**********************************************************************
165 * INT_Int16Handler
167 * Handler for int 16h (keyboard).
169 void INT_Int16Handler( struct sigcontext_struct context )
171 INT_BARF( &context, 0x16 );