]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/hw/dos/dos9xvm.c
added a bunch of things~ and midi stuff~
[16.git] / src / lib / doslib / hw / dos / dos9xvm.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_MSDOS) && !defined(TARGET_WINDOWS) && !defined(TARGET_OS2)
32 /* Windows 9x/NT Close-awareness */
33 void dos_close_awareness_cancel() {
34         __asm {
35                 .386p
36                 mov     ax,0x168F
37                 mov     dx,0x0300
38                 int     0x2F
39         }
40 }
41
42 void dos_close_awareness_ack() {
43         __asm {
44                 .386p
45                 mov     ax,0x168F
46                 mov     dx,0x0200
47                 int     0x2F
48         }
49 }
50
51 int dos_close_awareness_enable(unsigned char en) {
52         uint16_t r=0;
53
54         en = (en != 0) ? 1 : 0;
55
56         __asm {
57                 .386p
58                 mov     ax,0x168F
59                 xor     dx,dx
60                 mov     dl,en
61                 int     0x2F
62                 mov     r,ax
63         }
64
65         return (int)r;
66 }
67
68 int dos_close_awareness_query() {
69         uint16_t r=0;
70
71         __asm {
72                 .386p
73                 mov     ax,0x168F
74                 mov     dx,0x0100
75                 int     0x2F
76                 mov     r,ax
77         }
78
79         if (r == 0x168F)
80                 return -1;
81
82         return (int)r;
83 }
84
85 int dos_close_awareness_available() {
86         /* "close-awareness" is provided by Windows */
87         return (windows_mode == WINDOWS_ENHANCED || windows_mode == WINDOWS_NT);
88 }
89
90 void dos_vm_yield() {
91         __asm {
92                 mov     ax,0x1680       /* RELEASE VM TIME SLICE */
93                         xor     bx,bx           /* THIS VM */
94                         int     0x2F
95         }
96 }
97 #endif
98