]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/hw/dos/lol.c
added a bunch of things~ and midi stuff~
[16.git] / src / lib / doslib / hw / dos / lol.c
1 /* lol.c
2  *
3  * Test program: Make use of the MS-DOS "List of Lists" to print various things
4  * (C) 2011-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 /* FIXME: MS-DOS 6.22 under QEMU: This hangs, or causes QEMU to crash? */
12
13 #include <stdlib.h>
14 #include <string.h>
15 #include <stdint.h>
16 #include <assert.h>
17 #include <stdio.h>
18 #include <conio.h>
19 #include <dos.h>
20
21 #include <hw/cpu/cpu.h>
22 #include <hw/dos/dos.h>
23 #include <hw/dos/doswin.h>
24 #include <hw/dos/dosbox.h>
25
26 int main() {
27         int i,c,line = 0;
28         unsigned char FAR *LOL;
29
30         probe_dos();
31         printf("DOS version %x.%02u\n",dos_version>>8,dos_version&0xFF);
32         if (detect_windows()) {
33                 printf("I am running under Windows.\n");
34                 printf("    Mode: %s\n",windows_mode_str(windows_mode));
35                 printf("    Ver:  %x.%02u\n",windows_version>>8,windows_version&0xFF);
36                 printf("    Flavor: '%s'\n",dos_flavor_str(dos_flavor));
37         }
38         else {
39                 printf("Not running under Windows or OS/2\n");
40         }
41
42         if (detect_dosbox_emu())
43                 printf("I am also running under DOSBox\n");
44
45         if ((LOL = dos_list_of_lists()) != NULL) {
46                 printf("DOS List of Lists at ");
47 #if TARGET_MSDOS == 32
48                 printf("0x%08lX\n",(unsigned long)LOL);
49 #else
50                 printf("%04x:%04x\n",FP_SEG(LOL),FP_OFF(LOL));
51 #endif
52         }
53         else {
54                 printf("Unable to locate the DOS 'list of lists'\n");
55                 return 0;
56         }
57
58         /* ENTER for next, ESC to stop */
59         while ((c=getch()) != 13) {
60                 if (c == 27) return 0;
61         }
62
63         /* list MCBs */
64         {
65                 struct dos_psp_cooked pspnfo;
66                 struct dos_mcb_enum men;
67
68                 if (dos_mcb_first(&men)) {
69                         printf("Resident MCBs\n"); line++;
70                         do {
71                                 mcb_filter_name(&men);
72
73                                 printf("[%04x]: %02x PSP=%04x size=%04x %-8s  ",
74                                         men.cur_segment,men.type,men.psp,men.size,men.name);
75                                 for (i=0;i < 32;i++) {
76                                         c = men.ptr[i];
77                                         if (c >= 32 && c <= 126) printf("%c",c);
78                                         else printf(".");
79                                 }
80                                 printf("\n");
81
82                                 if (men.psp >= 0x80 && men.psp < 0xFFFFU && dos_parse_psp(men.psp,&pspnfo)) {
83                                         printf("    PSP memsize=%04xh callpsp=%04xh env=%04xh command='%s'\n",
84                                                 pspnfo.memsize,pspnfo.callpsp,pspnfo.env,pspnfo.cmd);
85
86                                         if (++line >= 20) {
87                                                 line -= 20;
88
89                                                 /* ENTER for next, ESC to stop */
90                                                 while ((c=getch()) != 13) {
91                                                         if (c == 27) return 0;
92                                                 }
93                                         }
94                                 }
95
96                                 if (++line >= 20) {
97                                         line -= 20;
98
99                                         /* ENTER for next, ESC to stop */
100                                         while ((c=getch()) != 13) {
101                                                 if (c == 27) return 0;
102                                         }
103                                 }
104                         } while (dos_mcb_next(&men));
105
106                 /* ENTER for next, ESC to stop */
107                 while ((c=getch()) != 13) {
108                         if (c == 27) return 0;
109                 }
110                 }
111         }
112
113         /* list devices */
114         {
115                 struct dos_device_enum denu;
116
117                 if (dos_device_first(&denu)) {
118                 printf("Device drivers\n"); line++;
119                 do {
120                         printf("    ATTR=%04Xh entry=%04Xh int=%04Xh %s\n",denu.attr,denu.entry,denu.intent,denu.name);
121
122                         if (++line >= 20) {
123                                 line -= 20;
124
125                                 /* ENTER for next, ESC to stop */
126                                 while ((c=getch()) != 13) {
127                                         if (c == 27) return 0;
128                                 }
129                         }
130                 } while (dos_device_next(&denu));
131
132                 /* ENTER for next, ESC to stop */
133                 while ((c=getch()) != 13) {
134                         if (c == 27) return 0;
135                 }
136                 }
137         }
138
139         return 0;
140 }
141