]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/hw/dos/test.c
added a bunch of things~ and midi stuff~
[16.git] / src / lib / doslib / hw / dos / test.c
1 /* test.c
2  *
3  * Test program: Various info about DOS
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 #include <stdlib.h>
12 #include <string.h>
13 #include <stdint.h>
14 #include <assert.h>
15 #include <stdlib.h>
16 #include <stdarg.h>
17 #include <unistd.h>
18 #include <stdio.h>
19 #include <conio.h>
20 #include <fcntl.h>
21 #include <dos.h>
22
23 #include <hw/cpu/cpu.h>
24 #include <hw/dos/dos.h>
25 #include <hw/dos/doswin.h>
26 #include <hw/dos/dosbox.h>
27 #include <hw/dos/dosntvdm.h>
28
29 #ifdef TARGET_WINDOWS
30 # define WINFCON_STOCK_WIN_MAIN
31 # include <hw/dos/winfcon.h>
32 #endif
33
34 int main() {
35         probe_dos();
36         printf("DOS version %x.%02u\n",dos_version>>8,dos_version&0xFF);
37         printf("    Method: '%s'\n",dos_version_method);
38         printf("    Flavor: '%s'\n",dos_flavor_str(dos_flavor));
39         if (dos_flavor == DOS_FLAVOR_FREEDOS) {
40                 printf("    FreeDOS kernel %u.%u.%u (%lX)\n",
41                         (unsigned int)((freedos_kernel_version >> 16UL) & 0xFFUL),
42                         (unsigned int)((freedos_kernel_version >> 8UL) & 0xFFUL),
43                         (unsigned int)((freedos_kernel_version) & 0xFFUL),
44                         (unsigned long)freedos_kernel_version);
45                 if (freedos_kernel_version_str != NULL) {
46 #if TARGET_MSDOS == 32
47                         printf("    FreeDOS kernel version string: %s\n",
48                                 freedos_kernel_version_str);
49 #else
50                         printf("    FreeDOS kernel version string: %Fs\n",
51                                 freedos_kernel_version_str);
52 #endif
53                 }
54         }
55
56         if (detect_windows()) {
57                 printf("I am running under Windows.\n");
58                 printf("    Mode: %s\n",windows_mode_str(windows_mode));
59                 printf("    Ver:  %x.%u\n",windows_version>>8,windows_version&0xFF);
60                 printf("    Method: '%s'\n",windows_version_method);
61                 if (windows_emulation != WINEMU_NONE)
62                         printf("    Emulation: '%s'\n",windows_emulation_str(windows_emulation));
63                 if (windows_emulation_comment_str != NULL)
64                         printf("    Emulation comment: '%s'\n",windows_emulation_comment_str);
65         }
66         else {
67                 printf("Not running under Windows or OS/2\n");
68         }
69
70 #if defined(NTVDM_CLIENT) && !defined(TARGET_WINDOWS)
71         if (ntvdm_dosntast_handle != DOSNTAST_HANDLE_UNASSIGNED) {
72                 OSVERSIONINFO o;
73                 WAVEOUTCAPS woc;
74                 unsigned int i,j;
75                 uint32_t dw;
76
77                 printf("This program is using the DOSNTAST.VDD driver (handle=%u io=0x%03X)\n",ntvdm_dosntast_handle,ntvdm_dosntast_io_base);
78
79                 printf("GetTickCount() = %lu\n",ntvdm_dosntast_GetTickCount());
80                 printf("waveOutGetNumDevs() = %d\n",j=ntvdm_dosntast_waveOutGetNumDevs());
81                 for (i=0;i < j;i++) {
82                         memset(&woc,0,sizeof(woc));
83                         if ((dw=ntvdm_dosntast_waveOutGetDevCaps(i,&woc,sizeof(woc))) == 0) {
84                                 printf("  [%u]: %s v%u.%u\n",i,woc.szPname,woc.vDriverVersion>>8,woc.vDriverVersion&0xFF);
85                                 printf("        MID=0x%04lX PID=0x%04lX FMTS=0x%08lX chan=%u\n",
86                                         (unsigned long)woc.wMid,
87                                         (unsigned long)woc.wPid,
88                                         (unsigned long)woc.dwFormats,
89                                         woc.wChannels);
90                                 printf("        CAPS: ");
91                                 if (woc.dwSupport & WAVECAPS_LRVOLUME) printf("LRVOL ");
92                                 if (woc.dwSupport & WAVECAPS_PITCH) printf("PITCH ");
93                                 if (woc.dwSupport & WAVECAPS_PLAYBACKRATE) printf("PLAYRATE ");
94                                 if (woc.dwSupport & WAVECAPS_SYNC) printf("SYNC ");
95                                 if (woc.dwSupport & WAVECAPS_VOLUME) printf("VOL ");
96                                 if (woc.dwSupport & WAVECAPS_SAMPLEACCURATE) printf("SAMPLEACCURATE ");
97                                 printf("\n");
98                         }
99                         else {
100                                 printf("  [%u]: Cannot read err=0x%08lX\n",i,dw);
101                         }
102                 }
103
104                 printf("GetVersionEx() = ");
105                 o.dwOSVersionInfoSize = sizeof(o);
106                 if (ntvdm_dosntast_getversionex(&o)) {
107                         printf("v%lu.%lu build #%lu platform=%lu '%s'",
108                                 o.dwMajorVersion,
109                                 o.dwMinorVersion,
110                                 o.dwBuildNumber,
111                                 o.dwPlatformId,
112                                 o.szCSDVersion);
113                 }
114                 else {
115                         printf("failed?");
116                 }
117                 printf("\n");
118
119                 ntvdm_dosntast_MessageBox("Hello!\n\nIf you can read this, DOS programs are able to use the driver successfully!");
120         }
121 #endif
122
123         if (detect_dosbox_emu())
124                 printf("I am also running under DOSBox\n");
125         if (detect_virtualbox_emu())
126                 printf("I am also running under Sun/Oracle VirtualBox %s\n",virtualbox_version_str);
127
128         probe_dpmi();
129 #if dpmi_present != 0
130         if (dpmi_present) {
131                 printf("DPMI present:\n");
132 # if TARGET_MSDOS == 16 || (TARGET_MSDOS == 32 && !defined(TARGET_WINDOWS))
133                 if (dpmi_no_0301h > 0) printf(" - DPMI function 0301H: Call real-mode far routine NOT AVAILABLE\n");
134                 printf(" - Flags: 0x%04x\n",dpmi_flags);
135                 printf(" - Entry: %04x:%04x (real mode)\n",(unsigned int)(dpmi_entry_point>>16UL),(unsigned int)(dpmi_entry_point & 0xFFFFUL));
136                 printf(" - Processor type: %02x\n",dpmi_processor_type);
137                 printf(" - Version: %u.%u\n",dpmi_version>>8,dpmi_version&0xFF);
138                 printf(" - Private data length: %u paras\n",dpmi_private_data_length_paragraphs);
139 # endif
140         }
141 #endif
142
143         if (probe_vcpi()) {
144                 printf("VCPI present (v%d.%d)\n",
145                         vcpi_major_version,
146                         vcpi_minor_version);
147         }
148
149 #ifdef WINFCON_STOCK_WIN_MAIN
150         {
151                 char c;
152
153                 printf("---------[Type junk here]---------\n");
154                 do {
155                         c = getch();
156                         if (c == 27) break;
157                         else if (c == 13) printf("\n");
158                         else printf("%c",c);
159                 } while (1);
160         }
161 #endif
162
163         return 0;
164 }
165