]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/hw/dos/tgusmega.c
added a bunch of things~ and midi stuff~
[16.git] / src / lib / doslib / hw / dos / tgusmega.c
1
2 #include <stdio.h>
3 #include <conio.h> /* this is where Open Watcom hides the outp() etc. functions */
4 #include <stdlib.h>
5 #include <string.h>
6 #include <stddef.h>
7 #include <unistd.h>
8 #include <malloc.h>
9 #include <assert.h>
10 #include <fcntl.h>
11 #include <dos.h>
12
13 #include <hw/cpu/cpu.h>
14 #include <hw/dos/dos.h>
15 #include <hw/dos/tgusmega.h>
16
17 #if !defined(TARGET_WINDOWS) && !defined(TARGET_OS2)
18 struct mega_em_info megaem_info={0};
19
20 int gravis_mega_em_detect(struct mega_em_info *x) {
21 /* TODO: Cache results, only need to scan once */
22     union REGS regs={0};
23     regs.w.ax = 0xFD12;
24     regs.w.bx = 0x3457;
25 #if TARGET_MSDOS == 32
26     int386(0x21,&regs,&regs);
27 #else
28     int86(0x21,&regs,&regs);
29 #endif
30     if (regs.w.ax == 0x5678) {
31         x->intnum = regs.h.cl;
32         x->version = regs.w.dx;
33         x->response = regs.w.bx;
34
35         if (x->version == 0) {
36             if (x->response == 0x1235)
37                 x->version = 0x200;
38             else if (x->response == 0x1237)
39                 x->version = 0x300;
40         }
41         return 1;
42     }
43     return 0;
44 }
45 #endif
46