|
|
1.1 root 1: /*
2: MS-DOS Player for Win32 console
3:
4: Author : Takeda.Toshiya
5: Date : 2009.11.09-
6: */
7:
8: #ifndef _MSDOS_H_
9: #define _MSDOS_H_
10:
1.1.1.12 root 11: #ifndef _WIN32_WINNT
12: #define _WIN32_WINNT 0x501
13: #endif
1.1 root 14: #include <windows.h>
15: #include <winioctl.h>
16: #include <tchar.h>
1.1.1.13 root 17: #include <stddef.h>
1.1 root 18: #include <stdlib.h>
19: #include <stdio.h>
1.1.1.2 root 20: #include <assert.h>
1.1 root 21: #include <conio.h>
1.1.1.2 root 22: #include <math.h>
1.1 root 23: #include <dos.h>
24: #include <fcntl.h>
25: #include <sys/types.h>
26: #include <sys/stat.h>
27: #include <io.h>
28: #include <sys/locking.h>
29: #include <mbctype.h>
30: #include <direct.h>
31: #include <errno.h>
1.1.1.9 root 32: #include <tlhelp32.h>
33: #include <psapi.h>
1.1 root 34:
1.1.1.15 root 35: #ifdef _DEBUG
36: #define _CRTDBG_MAP_ALLOC
37: #include <crtdbg.h>
38: #define calloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
39: #define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
40: #define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
41: #endif
42:
1.1.1.9 root 43: // variable scope of 'for' loop for Microsoft Visual C++ 6.0
44: #if defined(_MSC_VER) && (_MSC_VER == 1200)
1.1 root 45: #define for if(0);else for
46: #endif
1.1.1.9 root 47:
48: // disable warnings for Microsoft Visual C++ 2005 or later
1.1 root 49: #if defined(_MSC_VER) && (_MSC_VER >= 1400)
50: #pragma warning( disable : 4819 )
51: #pragma warning( disable : 4995 )
52: #pragma warning( disable : 4996 )
1.1.1.9 root 53: // for MAME i86/i386
54: #pragma warning( disable : 4018 )
55: #pragma warning( disable : 4065 )
56: #pragma warning( disable : 4146 )
57: #pragma warning( disable : 4244 )
58: #pragma warning( disable : 4267 )
59: #endif
60:
61: // endian
62: #if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
63: #if defined(__BYTE_ORDER) && (defined(__LITTLE_ENDIAN) || defined(__BIG_ENDIAN))
64: #if __BYTE_ORDER == __LITTLE_ENDIAN
65: #define __LITTLE_ENDIAN__
66: #elif __BYTE_ORDER == __BIG_ENDIAN
67: #define __BIG_ENDIAN__
68: #endif
69: #elif defined(WORDS_LITTLEENDIAN)
70: #define __LITTLE_ENDIAN__
71: #elif defined(WORDS_BIGENDIAN)
72: #define __BIG_ENDIAN__
73: #endif
74: #endif
75: #if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
76: // Microsoft Visual C++
77: #define __LITTLE_ENDIAN__
1.1 root 78: #endif
1.1.1.9 root 79:
1.1 root 80: // compat for mingw32 headers
81: #ifndef COMMON_LVB_UNDERSCORE
82: #define COMMON_LVB_UNDERSCORE 0x8000
83: #endif
84:
85: // type definition
86: #ifndef UINT8
87: typedef unsigned char UINT8;
88: #endif
89: #ifndef UINT16
90: typedef unsigned short UINT16;
91: #endif
92: #ifndef UINT32
93: typedef unsigned int UINT32;
94: #endif
95: #ifndef INT8
96: typedef signed char INT8;
97: #endif
98: #ifndef INT16
99: typedef signed short INT16;
100: #endif
101: #ifndef INT32
102: typedef signed int INT32;
103: #endif
104:
105: #pragma pack(1)
106: typedef union {
107: UINT32 dw;
108: struct {
1.1.1.9 root 109: #ifdef __BIG_ENDIAN__
110: UINT16 h, l;
111: #else
1.1 root 112: UINT16 l, h;
1.1.1.9 root 113: #endif
1.1 root 114: } w;
115: } PAIR32;
116: #pragma pack()
117:
118: /* ----------------------------------------------------------------------------
119: FIFO buffer
120: ---------------------------------------------------------------------------- */
121:
122: #define MAX_FIFO 256
123:
124: class FIFO
125: {
126: private:
127: int buf[MAX_FIFO];
128: int cnt, rpt, wpt, stored[3];
129: public:
130: FIFO() {
131: cnt = rpt = wpt = 0;
132: }
133: void write(int val) {
134: if(cnt < MAX_FIFO) {
135: buf[wpt++] = val;
136: if(wpt >= MAX_FIFO) {
137: wpt = 0;
138: }
139: cnt++;
140: }
141: }
142: int read() {
143: int val = 0;
144: if(cnt) {
145: val = buf[rpt++];
146: if(rpt >= MAX_FIFO) {
147: rpt = 0;
148: }
149: cnt--;
150: }
151: return val;
152: }
153: int count() {
154: return cnt;
155: }
156: void store_buffer() {
157: stored[0] = cnt;
158: stored[1] = rpt;
159: stored[2] = wpt;
160: }
161: void restore_buffer() {
162: cnt = stored[0];
163: rpt = stored[1];
164: wpt = stored[2];
165: }
166: };
167:
168: /* ----------------------------------------------------------------------------
1.1.1.14 root 169: MAME i86/i386
170: ---------------------------------------------------------------------------- */
171:
172: #if defined(HAS_I86)
173: #define CPU_MODEL i8086
174: #elif defined(HAS_I186)
175: #define CPU_MODEL i80186
176: #elif defined(HAS_V30)
177: #define CPU_MODEL v30
178: #elif defined(HAS_I286)
179: #define CPU_MODEL i80286
180: #elif defined(HAS_I386)
181: #define CPU_MODEL i386
182: #else
183: // #if defined(HAS_I386SX)
184: // #define CPU_MODEL i386SX
185: // #else
186: #if defined(HAS_I486)
187: #define CPU_MODEL i486
188: #else
189: #if defined(HAS_PENTIUM)
190: #define CPU_MODEL pentium
191: #elif defined(HAS_MEDIAGX)
192: #define CPU_MODEL mediagx
193: #elif defined(HAS_PENTIUM_PRO)
194: #define CPU_MODEL pentium_pro
195: #elif defined(HAS_PENTIUM_MMX)
196: #define CPU_MODEL pentium_mmx
197: #elif defined(HAS_PENTIUM2)
198: #define CPU_MODEL pentium2
199: #elif defined(HAS_PENTIUM3)
200: #define CPU_MODEL pentium3
201: #elif defined(HAS_PENTIUM4)
202: #define CPU_MODEL pentium4
203: #endif
204: #define SUPPORT_RDTSC
205: #endif
206: #define SUPPORT_FPU
207: // #endif
208: #define HAS_I386
209: #endif
210:
211: /* ----------------------------------------------------------------------------
212: PC/AT hardware emulation
213: ---------------------------------------------------------------------------- */
214:
215: void hardware_init();
216: void hardware_finish();
217: void hardware_run();
218: void hardware_update();
219:
220: // memory
221:
222: #if defined(HAS_I386)
223: #define MAX_MEM 0x2000000 /* 32MB */
224: #elif defined(HAS_I286)
225: #define MAX_MEM 0x1000000 /* 16MB */
226: #else
227: #define MAX_MEM 0x100000 /* 1MB */
228: #endif
229: UINT8 mem[MAX_MEM + 3];
230:
231: // ems
232:
233: #define MAX_EMS_HANDLES 16
234: #define MAX_EMS_PAGES 2048 /* 32MB */
235:
236: struct {
237: char name[8];
238: UINT8* buffer;
239: int pages;
240: bool allocated;
241: } ems_handles[MAX_EMS_HANDLES];
242:
243: struct {
244: UINT16 handle;
245: UINT16 page;
246: bool mapped;
247: } ems_pages[4];
248:
249: int free_ems_pages;
250:
251: void ems_init();
252: void ems_finish();
253: void ems_allocate_pages(int handle, int pages);
254: void ems_reallocate_pages(int handle, int pages);
255: void ems_release_pages(int handle);
256: void ems_map_page(int physical, int handle, int logical);
257: void ems_unmap_page(int physical);
258:
259: // xms
260:
261: #if defined(HAS_I286) || defined(HAS_I386)
262: #define SUPPORT_XMS
263: #endif
264:
265: #ifdef SUPPORT_XMS
266: #define MAX_XMS_HANDLES 16
267: #define MAX_XMS_SIZE_KB 0x8000 // 32MB
268:
269: struct {
270: int seg;
271: int size_kb;
272: int lock;
273: bool allocated;
274: } xms_handles[MAX_XMS_HANDLES + 1];
1.1.1.16! root 275:
! 276: int xms_a20_local_enb_count = 0;
1.1.1.14 root 277: #endif
278:
279: // pic
280:
281: typedef struct {
282: UINT8 imr, isr, irr, prio;
283: UINT8 icw1, icw2, icw3, icw4;
284: UINT8 ocw3;
285: UINT8 icw2_r, icw3_r, icw4_r;
286: } pic_t;
287:
288: pic_t pic[2];
289: int pic_req_chip, pic_req_level;
290: UINT8 pic_req_bit;
291:
292: void pic_init();
293: void pic_write(int c, UINT32 addr, UINT8 data);
294: UINT8 pic_read(int c, UINT32 addr);
295: void pic_req(int c, int level, int signal);
296: int pic_ack();
297: void pic_update();
298:
299: // pit
300:
301: #define PIT_ALWAYS_RUNNING
302:
303: typedef struct {
304: INT32 count;
305: UINT16 latch;
306: UINT16 count_reg;
307: UINT8 ctrl_reg;
308: int count_latched;
309: int low_read, high_read;
310: int low_write, high_write;
311: int mode;
312: int status_latched;
313: UINT8 status;
314: // constant clock
315: UINT32 expired_time;
316: UINT32 prev_time;
317: } pit_t;
318:
319: pit_t pit[3];
320: #ifndef PIT_ALWAYS_RUNNING
321: int pit_active;
322: #endif
323:
324: void pit_init();
325: void pit_write(int ch, UINT8 val);
326: UINT8 pit_read(int ch);
327: int pit_run(int ch, UINT32 cur_time);
328: void pit_latch_count(int ch);
329: int pit_get_expired_time(int ch);
330:
331: UINT8 system_port = 0;
332:
333: // cmos
334:
335: UINT8 cmos[128];
336: UINT8 cmos_addr;
337:
338: void cmos_init();
339: void cmos_write(int addr, UINT8 val);
340: UINT8 cmos_read(int addr);
341:
342: // kbd (a20)
343:
344: UINT8 kbd_data;
345: UINT8 kbd_status;
346: UINT8 kbd_command;
347:
348: void kbd_init();
349: UINT8 kbd_read_data();
350: void kbd_write_data(UINT8 val);
351: UINT8 kbd_read_status();
352: void kbd_write_command(UINT8 val);
353:
354: /* ----------------------------------------------------------------------------
1.1 root 355: MS-DOS virtual machine
356: ---------------------------------------------------------------------------- */
357:
358: #define VECTOR_TOP 0
359: #define VECTOR_SIZE 0x400
360: #define BIOS_TOP (VECTOR_TOP + VECTOR_SIZE)
361: #define BIOS_SIZE 0x100
362: #define WORK_TOP (BIOS_TOP + BIOS_SIZE)
1.1.1.14 root 363: #define WORK_SIZE 0x200
364: #define DOS_INFO_TOP (WORK_TOP + WORK_SIZE)
365: #define DOS_INFO_BASE (DOS_INFO_TOP + 38)
1.1 root 366: #define DOS_INFO_SIZE 0x100
367: #define DPB_TOP (DOS_INFO_TOP + DOS_INFO_SIZE)
368: #define DPB_SIZE 0x400
1.1.1.16! root 369: #define SFT_TOP (DPB_TOP + DPB_SIZE)
! 370: #define SFT_SIZE 0x4b0 /* 6 + 0x3b * 20 */
! 371: #define DISK_BUF_TOP (SFT_TOP + SFT_SIZE)
1.1.1.14 root 372: #define DISK_BUF_SIZE 0x20
373: #define CDS_TOP (DISK_BUF_TOP + DISK_BUF_SIZE)
1.1 root 374: #define CDS_SIZE 0x80
375: #define FCB_TABLE_TOP (CDS_TOP + CDS_SIZE)
376: #define FCB_TABLE_SIZE 0x10
1.1.1.13 root 377: // nls tables
378: #define UPPERTABLE_TOP (FCB_TABLE_TOP + FCB_TABLE_SIZE)
379: #define UPPERTABLE_SIZE 0x82
380: #define FILENAME_UPPERTABLE_TOP (UPPERTABLE_TOP + UPPERTABLE_SIZE)
381: #define FILENAME_UPPERTABLE_SIZE 0x82
382: #define FILENAME_TERMINATOR_TOP (FILENAME_UPPERTABLE_TOP + FILENAME_UPPERTABLE_SIZE)
383: #define FILENAME_TERMINATOR_SIZE 0x20 /* requirement: 10 + 14(terminate chars) */
384: #define COLLATING_TABLE_TOP (FILENAME_TERMINATOR_TOP + FILENAME_TERMINATOR_SIZE)
385: #define COLLATING_TABLE_SIZE 0x102
386: #define DBCS_TOP (COLLATING_TABLE_TOP + COLLATING_TABLE_SIZE)
1.1 root 387: #define DBCS_TABLE (DBCS_TOP + 2)
388: #define DBCS_SIZE 0x10
1.1.1.13 root 389: #define MSDOS_SYSTEM_DATA_END (DBCS_TOP + DBCS_SIZE)
390: #define MEMORY_TOP ((MSDOS_SYSTEM_DATA_END + 15) & ~15U)
1.1.1.7 root 391: #define MEMORY_END 0xb8000
392: #define TEXT_VRAM_TOP 0xb8000
1.1.1.14 root 393: #define EMS_TOP 0xc0000
394: #define EMS_SIZE 0x10000
395: UINT32 UMB_TOP = EMS_TOP; // EMS is disabled
1.1.1.7 root 396: #define UMB_END 0xf8000
397: #define SHADOW_BUF_TOP 0xf8000
1.1.1.14 root 398: #define EMB_TOP 0x10fff0
399: #define EMB_END MAX_MEM
400:
401: UINT32 IRET_TOP = 0;
402: #define IRET_SIZE 0x100
403: UINT32 XMS_TOP = 0;
404: #define XMS_OFFSET 0x04
405: #define XMS_SIZE 0x20
1.1 root 406:
407: //#define ENV_SIZE 0x800
408: #define ENV_SIZE 0x2000
409: #define PSP_SIZE 0x100
410:
411: #define MAX_FILES 128
412: #define MAX_PROCESS 16
1.1.1.12 root 413: #define MAX_DTAINFO 128
1.1.1.11 root 414: #define LFN_DTA_LADDR 0x10FFF0
1.1.1.12 root 415: #define FIND_MAGIC 0x46696e64
1.1 root 416:
1.1.1.16! root 417: #define DUP_STDIN 27
! 418: #define DUP_STDOUT 28
! 419: #define DUP_STDERR 29
! 420: #define DUP_STDAUX 30
! 421: #define DUP_STDPRN 31
1.1 root 422:
1.1.1.16! root 423: //#define MAP_AUX_DEVICE_TO_FILE
! 424: //#define MAP_PRN_DEVICE_TO_FILE
1.1 root 425:
426: #pragma pack(1)
427: typedef struct {
428: UINT8 mz;
429: UINT16 psp;
1.1.1.14 root 430: union {
431: UINT8 reserved[5];
432: UINT16 paragraphs16;
433: UINT32 paragraphs32;
434: };
1.1.1.3 root 435: char prog_name[8];
1.1.1.14 root 436: // use 32bit paragraphs for emb
437: UINT32 paragraphs()
438: {
439: UINT32 offset = &(this->mz) - mem;
440: return (offset >= EMB_TOP) ? paragraphs32 : paragraphs16;
441: }
442: UINT32 size_kb()
443: {
444: return paragraphs() >> 6;
445: }
1.1 root 446: } mcb_t;
447: #pragma pack()
448:
449: #pragma pack(1)
450: typedef struct {
451: UINT16 env_seg;
452: PAIR32 cmd_line;
453: PAIR32 fcb1;
454: PAIR32 fcb2;
455: UINT16 sp;
456: UINT16 ss;
457: UINT16 ip;
458: UINT16 cs;
459: } param_block_t;
460: #pragma pack()
461:
462: #pragma pack(1)
463: typedef struct {
464: UINT8 len;
465: char cmd[127];
466: } cmd_line_t;
467: #pragma pack()
468:
469: #pragma pack(1)
470: typedef struct {
471: UINT8 exit[2];
472: UINT16 first_mcb;
473: UINT8 reserved_1;
474: UINT8 far_call;
475: PAIR32 cpm_entry;
476: PAIR32 int_22h;
477: PAIR32 int_23h;
478: PAIR32 int_24h;
479: UINT16 parent_psp;
480: UINT8 file_table[20];
481: UINT16 env_seg;
482: PAIR32 stack;
1.1.1.12 root 483: UINT16 file_table_size;
484: PAIR32 file_table_ptr;
485: UINT8 reserved_2[24];
1.1 root 486: UINT8 service[3];
487: UINT8 reserved_3[2];
488: UINT8 ex_fcb[7];
489: UINT8 fcb1[16];
490: UINT8 fcb2[20];
491: UINT8 buffer[128];
492: } psp_t;
493: #pragma pack()
494:
495: #pragma pack(1)
496: typedef struct {
497: UINT16 mz;
498: UINT16 extra_bytes;
499: UINT16 pages;
500: UINT16 relocations;
501: UINT16 header_size;
502: UINT16 min_alloc;
503: UINT16 max_alloc;
504: UINT16 init_ss;
505: UINT16 init_sp;
506: UINT16 check_sum;
507: UINT16 init_ip;
508: UINT16 init_cs;
509: UINT16 relocation_table;
510: UINT16 overlay;
511: } exe_header_t;
512: #pragma pack()
513:
514: #pragma pack(1)
515: typedef struct {
516: UINT8 flag;
517: UINT8 reserved[5];
518: UINT8 attribute;
519: } ext_fcb_t;
520: #pragma pack()
521:
522: #pragma pack(1)
523: typedef struct {
524: UINT8 drive;
525: UINT8 file_name[8 + 3];
526: UINT16 current_block;
527: UINT16 record_size;
528: UINT32 file_size;
529: UINT16 date;
530: UINT16 time;
1.1.1.12 root 531: union {
532: UINT8 reserved[8];
533: HANDLE handle;
534: };
1.1 root 535: UINT8 cur_record;
536: UINT32 rand_record;
537: } fcb_t;
538: #pragma pack()
539:
540: #pragma pack(1)
541: typedef struct {
542: UINT8 drive;
543: UINT8 file_name[8 + 3];
544: UINT8 attribute;
545: UINT8 nt_res;
546: UINT8 create_time_ms;
547: UINT16 creation_time;
548: UINT16 creation_date;
549: UINT16 last_access_date;
550: UINT16 cluster_hi;
551: UINT16 last_write_time;
552: UINT16 last_write_date;
553: UINT16 cluster_lo;
554: UINT32 file_size;
555: } find_fcb_t;
556: #pragma pack()
557:
558: #pragma pack(1)
559: typedef struct {
1.1.1.12 root 560: union {
561: UINT8 reserved[21];
562: struct {
563: UINT32 find_magic;
564: UINT32 dta_index;
565: };
566: };
1.1 root 567: UINT8 attrib;
568: UINT16 time;
569: UINT16 date;
570: UINT32 size;
571: char name[13];
572: } find_t;
573: #pragma pack()
574:
575: #pragma pack(1)
576: typedef struct {
577: UINT32 attrib;
578: PAIR32 ctime_lo;
579: PAIR32 ctime_hi;
580: PAIR32 atime_lo;
581: PAIR32 atime_hi;
582: PAIR32 mtime_lo;
583: PAIR32 mtime_hi;
584: UINT32 size_hi;
585: UINT32 size_lo;
586: UINT8 reserved[8];
587: char full_name[260];
588: char short_name[14];
589: } find_lfn_t;
590: #pragma pack()
591:
592: #pragma pack(1)
593: typedef struct {
594: UINT16 info_level;
595: UINT32 serial_number;
596: char volume_label[11];
597: char file_system[8];
598: } drive_info_t;
599: #pragma pack()
600:
601: #pragma pack(1)
602: typedef struct {
603: UINT16 size_of_structure;
604: UINT16 structure_version;
605: UINT32 sectors_per_cluster;
606: UINT32 bytes_per_sector;
607: UINT32 available_clusters_on_drive;
608: UINT32 total_clusters_on_drive;
609: UINT32 available_sectors_on_drive;
610: UINT32 total_sectors_on_drive;
611: UINT32 available_allocation_units;
612: UINT32 total_allocation_units;
613: UINT8 reserved[8];
614: } ext_space_info_t;
615: #pragma pack()
616:
617: #pragma pack(1)
618: typedef struct {
619: UINT8 drive_num;
620: UINT8 unit_num;
621: UINT16 bytes_per_sector;
622: UINT8 highest_sector_num;
623: UINT8 shift_count;
624: UINT16 reserved_sectors;
625: UINT8 fat_num;
626: UINT16 root_entries;
627: UINT16 first_data_sector;
628: UINT16 highest_cluster_num;
629: UINT16 sectors_per_fat;
630: UINT16 first_dir_sector;
631: UINT32 device_driver_header;
632: UINT8 media_type;
633: UINT8 drive_accessed;
634: UINT16 next_dpb_ofs;
635: UINT16 next_dpb_seg;
636: UINT16 first_free_cluster;
637: UINT16 free_clusters;
1.1.1.12 root 638: // extended
639: UINT16 fat_mirroring;
640: UINT16 info_sector;
641: UINT16 backup_boot_sector;
642: UINT32 first_cluster_sector;
643: UINT32 maximum_cluster_num;
644: UINT32 fat_sectors;
645: UINT32 root_cluster;
646: UINT32 free_search_cluster;
1.1 root 647: } dpb_t;
648: #pragma pack()
649:
650: #pragma pack(1)
651: typedef struct {
652: char path_name[67];
653: UINT16 drive_attrib;
654: UINT8 physical_drive_number;
655: } cds_t;
656: #pragma pack()
657:
658: #pragma pack(1)
659: typedef struct {
1.1.1.14 root 660: UINT8 reserved_0[4]; // -38
661: UINT16 magic_word; // -34 from DOSBox
662: UINT8 reserved_1[30]; // -32
1.1 root 663: UINT16 first_mcb; // -2
664: PAIR32 first_dpb; // +0
1.1.1.14 root 665: PAIR32 first_sft; // +4
666: UINT8 reserved_2[8]; // +8
667: UINT16 max_sector_len; // +16
668: PAIR32 disk_buf_info; // +18 from DOSBox
1.1 root 669: PAIR32 cds; // +22
670: PAIR32 fcb_table; // +26
1.1.1.14 root 671: UINT8 reserved_3[3]; // +30
1.1 root 672: UINT8 last_drive; // +33
1.1.1.14 root 673: struct {
674: UINT32 next_driver; // +34
675: UINT16 attributes; // +38
676: UINT16 strategy; // +40
677: UINT16 interrupt; // +42
678: char dev_name[8]; // +44
679: } nul_device;
680: UINT8 reserved_4[11]; // +52
1.1 root 681: UINT16 buffers_x; // +63
682: UINT16 buffers_y; // +65
683: UINT8 boot_drive; // +67
684: UINT8 i386_or_later; // +68
685: UINT16 ext_mem_size; // +69
1.1.1.14 root 686: PAIR32 disk_buf_heads; // +71 from DOSBox
687: UINT8 reserved_5[21]; // +75
1.1.1.5 root 688: UINT8 dos_flag; // +96
1.1.1.15 root 689: UINT8 reserved_6[2]; // +97
690: UINT8 umb_linked; // +99 from DOSBox
691: UINT8 reserved_7[2]; // +100
692: UINT16 first_umb_fcb; // +102 from DOSBox
693: UINT16 first_mcb_2; // +104 from DOSBox
1.1 root 694: } dos_info_t;
695: #pragma pack()
696:
1.1.1.14 root 697: #pragma pack(1)
698: typedef struct {
699: UINT16 date_format;
700: char currency_symbol[5];
701: char thou_sep[2];
702: char dec_sep[2];
703: char date_sep[2];
704: char time_sep[2];
705: char currency_format;
706: char currency_dec_digits;
707: char time_format;
708: PAIR32 case_map;
709: char list_sep[2];
710: char reserved[10];
711: } country_info_t;
712: #pragma pack()
713:
1.1 root 714: typedef struct {
715: char path[MAX_PATH];
716: int valid;
717: int id;
718: int atty;
719: int mode;
720: UINT16 info;
721: UINT16 psp;
722: } file_handler_t;
723:
724: static const struct {
725: int mode;
726: int in;
727: int out;
728: } file_mode[] = {
1.1.1.11 root 729: { _O_RDONLY | _O_BINARY, 1, 0 },
1.1 root 730: { _O_WRONLY | _O_BINARY, 0, 1 },
731: { _O_RDWR | _O_BINARY, 1, 1 },
732: };
733:
734: typedef struct {
735: UINT16 psp;
736: char module_dir[MAX_PATH];
737: PAIR32 dta;
738: UINT8 switchar;
739: UINT8 verify;
740: int max_files;
741: char volume_label[MAX_PATH];
742: bool parent_int_10h_feh_called;
743: bool parent_int_10h_ffh_called;
1.1.1.12 root 744: UINT16 parent_ds;
1.1.1.14 root 745: struct {
746: UINT16 handle;
747: UINT16 page;
748: bool mapped;
749: } ems_pages[4];
750: bool ems_pages_stored;
1.1 root 751: } process_t;
752:
1.1.1.11 root 753: typedef struct {
754: UINT16 psp;
755: UINT32 dta;
1.1.1.12 root 756: UINT8 allowable_mask;
757: UINT8 required_mask;
1.1.1.11 root 758: HANDLE find_handle;
759: } dtainfo_t;
760:
1.1.1.8 root 761: UINT8 major_version = 7;
762: UINT8 minor_version = 10;
763:
1.1.1.7 root 764: UINT16 first_mcb;
1.1 root 765: UINT16 current_psp;
766:
767: int retval = 0;
768: UINT16 error_code = 0;
769:
770: file_handler_t file_handler[MAX_FILES];
771: UINT8 file_buffer[0x100000];
772:
773: process_t process[MAX_PROCESS];
1.1.1.11 root 774: dtainfo_t dtalist[MAX_DTAINFO];
1.1 root 775:
1.1.1.6 root 776: UINT16 malloc_strategy = 0;
777:
1.1.1.12 root 778: char comspec_path[MAX_PATH] = "C:\\COMMAND.COM";
779:
1.1 root 780: void msdos_syscall(unsigned num);
781: int msdos_init(int argc, char *argv[], char *envp[], int standard_env);
782: void msdos_finish();
783:
784: // console
785:
1.1.1.12 root 786: #define SCR_BUF_WIDTH 256
787: #define SCR_BUF_HEIGHT 128
1.1 root 788:
789: #define SET_RECT(rect, l, t, r, b) { \
790: rect.Left = l; \
791: rect.Top = t; \
792: rect.Right = r; \
793: rect.Bottom = b; \
794: }
795:
796: HANDLE hStdin;
797: HANDLE hStdout;
1.1.1.12 root 798: CHAR_INFO scr_buf[SCR_BUF_WIDTH * SCR_BUF_HEIGHT];
799: char scr_char[SCR_BUF_WIDTH * SCR_BUF_HEIGHT];
800: WORD scr_attr[SCR_BUF_WIDTH * SCR_BUF_HEIGHT];
1.1 root 801: COORD scr_buf_size;
802: COORD scr_buf_pos;
803: int scr_width, scr_height;
1.1.1.12 root 804: int scr_top;
1.1.1.10 root 805: bool restore_console_on_exit = false;
1.1 root 806: bool cursor_moved;
807:
808: FIFO *key_buf_char;
809: FIFO *key_buf_scan;
1.1.1.7 root 810: int key_input = 0;
1.1.1.4 root 811: UINT32 key_code = 0;
1.1 root 812:
813: int active_code_page;
814: int system_code_page;
815:
1.1.1.12 root 816: UINT32 text_vram_top_address;
817: UINT32 text_vram_end_address;
818: UINT32 shadow_buffer_top_address;
819: UINT32 shadow_buffer_end_address;
820: int vram_pages;
1.1 root 821: bool int_10h_feh_called = false;
822: bool int_10h_ffh_called = false;
823:
824: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.