]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/hw/dos/dpmiexcp.c
added a bunch of things~ and midi stuff~
[16.git] / src / lib / doslib / hw / dos / dpmiexcp.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 #if !defined(TARGET_WINDOWS) && TARGET_MSDOS == 16
32
33 /* NTS: This only allows for exception interrupts 0x00-0x1F */
34 void far *dpmi_getexhandler(unsigned char n) {
35         unsigned short s=0,o=0;
36
37         __asm {
38                 mov     ax,0x202
39                 mov     bl,n
40                 xor     cx,cx
41                 xor     dx,dx
42                 int     31h
43                 mov     s,cx
44                 mov     o,dx
45         }
46
47         return MK_FP(s,o);
48 }
49
50 /* NTS: This only allows for exception interrupts 0x00-0x1F */
51 int dpmi_setexhandler(unsigned char n,void far *x) {
52         unsigned short s=FP_SEG(x),o=FP_OFF(x);
53         int c=1;
54
55         __asm {
56                 mov     ax,0x203
57                 mov     bl,n
58                 mov     cx,s
59                 mov     dx,o
60                 int     31h
61                 jnc     ok
62                 mov     c,0
63 ok:
64         }
65
66         return c;
67 }
68
69 #endif
70
71 #if !defined(TARGET_WINDOWS) && TARGET_MSDOS == 32
72
73 /* NTS: This only allows for exception interrupts 0x00-0x1F */
74 void far *dpmi_getexhandler(unsigned char n) {
75         unsigned short s=0;
76         unsigned int o=0;
77
78         __asm {
79                 mov     ax,0x202
80                 mov     bl,n
81                 xor     cx,cx
82                 xor     dx,dx
83                 int     31h
84                 mov     s,cx
85                 mov     o,edx
86         }
87
88         return MK_FP(s,o);
89 }
90
91 /* NTS: This only allows for exception interrupts 0x00-0x1F */
92 int dpmi_setexhandler(unsigned char n,void far *x) {
93         unsigned short s=FP_SEG(x);
94         unsigned int o=FP_OFF(x);
95         int c=1;
96
97         __asm {
98                 mov     ax,0x203
99                 mov     bl,n
100                 mov     cx,s
101                 mov     edx,o
102                 int     31h
103                 jnc     ok
104                 mov     c,0
105 ok:
106         }
107
108         return c;
109 }
110
111 #endif
112