]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/hw/dos/win16vec.c
added a bunch of things~ and midi stuff~
[16.git] / src / lib / doslib / hw / dos / win16vec.c
1 /* dos.c
2  *
3  * Code to detect the surrounding DOS/Windows environment and support routines to work with it
4  * (C) 2009-2012 Jonathan Campbell.
5  * Hackipedia DOS library.
6  *
7  * This code is licensed under the LGPL.
8  * <insert LGPL legal text here>
9  */
10
11 #ifdef TARGET_WINDOWS
12 # include <windows.h>
13 #endif
14
15 #include <stdio.h>
16 #include <conio.h> /* this is where Open Watcom hides the outp() etc. functions */
17 #include <stdlib.h>
18 #include <string.h>
19 #include <stddef.h>
20 #include <unistd.h>
21 #include <malloc.h>
22 #include <assert.h>
23 #include <fcntl.h>
24 #include <dos.h>
25
26 #include <hw/cpu/cpu.h>
27 #include <hw/dos/dos.h>
28 #include <hw/dos/doswin.h>
29 #include <hw/dos/dosntvdm.h>
30
31 /* Watcom C does not provide getvect/setvect for Win16, so we abuse the DPMI server within and provide one anyway */
32 #if defined(TARGET_WINDOWS) && TARGET_MSDOS == 16
33
34 /* NTS: This only allows for exception interrupts 0x00-0x1F */
35 void far *win16_getexhandler(unsigned char n) {
36         unsigned short s=0,o=0;
37
38         __asm {
39                 mov     ax,0x202
40                 mov     bl,n
41                 xor     cx,cx
42                 xor     dx,dx
43                 int     31h
44                 mov     s,cx
45                 mov     o,dx
46         }
47
48         return MK_FP(s,o);
49 }
50
51 /* NTS: This only allows for exception interrupts 0x00-0x1F */
52 int win16_setexhandler(unsigned char n,void far *x) {
53         unsigned short s=FP_SEG(x),o=FP_OFF(x);
54         int c=1;
55
56         __asm {
57                 mov     ax,0x203
58                 mov     bl,n
59                 mov     cx,s
60                 mov     dx,o
61                 int     31h
62                 jnc     ok
63                 mov     c,0
64 ok:
65         }
66
67         return c;
68 }
69
70 void far *win16_getvect(unsigned char n) {
71         unsigned short s=0,o=0;
72
73         __asm {
74                 mov     ax,0x204
75                 mov     bl,n
76                 xor     cx,cx
77                 xor     dx,dx
78                 int     31h
79                 mov     s,cx
80                 mov     o,dx
81         }
82
83         return MK_FP(s,o);
84 }
85
86 /* NTS: This only allows for exception interrupts 0x00-0x1F */
87 int win16_setvect(unsigned char n,void far *x) {
88         unsigned short s=FP_SEG(x),o=FP_OFF(x);
89         int c=1;
90
91         __asm {
92                 mov     ax,0x205
93                 mov     bl,n
94                 mov     cx,s
95                 mov     dx,o
96                 int     31h
97                 jnc     ok
98                 mov     c,0
99 ok:
100         }
101
102         return c;
103 }
104
105 #endif
106