]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/hw/dos/dos_lol.c
added a bunch of things~ and midi stuff~
[16.git] / src / lib / doslib / hw / dos / dos_lol.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 /* DOS "list of lists" pointer */
32 unsigned char FAR *dos_LOL=NULL;
33
34 /* MS-DOS "list of lists" secret call */
35 #if TARGET_MSDOS == 32
36 # ifdef WIN386
37 unsigned char *dos_list_of_lists() {
38         return NULL;/*not implemented*/
39 }
40 # else
41 static void dos_realmode_call(struct dpmi_realmode_call *rc) {
42         __asm {
43                 mov     ax,0x0300
44                 mov     bx,0x0021
45                 xor     cx,cx
46                 mov     edi,rc          ; we trust Watcom has left ES == DS
47                 int     0x31            ; call DPMI
48         }
49 }
50
51 unsigned char *dos_list_of_lists() {
52         struct dpmi_realmode_call rc={0};
53
54         rc.eax = 0x5200;
55         dos_realmode_call(&rc);
56         if (rc.flags & 1) return NULL; /* CF */
57         return (dos_LOL = ((unsigned char*)((rc.es << 4) + (rc.ebx & 0xFFFFUL))));
58 }
59 # endif
60 #else
61 unsigned char far *dos_list_of_lists() {
62         unsigned int s=0,o=0;
63
64         __asm {
65                 mov     ah,0x52
66                 int     21h
67                 jc      notwork
68                 mov     s,es
69                 mov     o,bx
70 notwork:
71         }
72
73         return (dos_LOL = ((unsigned char far*)MK_FP(s,o)));
74 }
75 #endif
76