|
|
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;
1.1.1.17 root 317: UINT64 accum;
1.1.1.14 root 318: } pit_t;
319:
320: pit_t pit[3];
321: #ifndef PIT_ALWAYS_RUNNING
322: int pit_active;
323: #endif
324:
325: void pit_init();
326: void pit_write(int ch, UINT8 val);
327: UINT8 pit_read(int ch);
328: int pit_run(int ch, UINT32 cur_time);
329: void pit_latch_count(int ch);
330: int pit_get_expired_time(int ch);
331:
332: UINT8 system_port = 0;
333:
334: // cmos
335:
336: UINT8 cmos[128];
337: UINT8 cmos_addr;
338:
339: void cmos_init();
340: void cmos_write(int addr, UINT8 val);
341: UINT8 cmos_read(int addr);
342:
343: // kbd (a20)
344:
345: UINT8 kbd_data;
346: UINT8 kbd_status;
347: UINT8 kbd_command;
348:
349: void kbd_init();
350: UINT8 kbd_read_data();
351: void kbd_write_data(UINT8 val);
352: UINT8 kbd_read_status();
353: void kbd_write_command(UINT8 val);
354:
355: /* ----------------------------------------------------------------------------
1.1 root 356: MS-DOS virtual machine
357: ---------------------------------------------------------------------------- */
358:
359: #define VECTOR_TOP 0
360: #define VECTOR_SIZE 0x400
361: #define BIOS_TOP (VECTOR_TOP + VECTOR_SIZE)
362: #define BIOS_SIZE 0x100
363: #define WORK_TOP (BIOS_TOP + BIOS_SIZE)
1.1.1.14 root 364: #define WORK_SIZE 0x200
365: #define DOS_INFO_TOP (WORK_TOP + WORK_SIZE)
366: #define DOS_INFO_BASE (DOS_INFO_TOP + 38)
1.1 root 367: #define DOS_INFO_SIZE 0x100
368: #define DPB_TOP (DOS_INFO_TOP + DOS_INFO_SIZE)
369: #define DPB_SIZE 0x400
1.1.1.16 root 370: #define SFT_TOP (DPB_TOP + DPB_SIZE)
371: #define SFT_SIZE 0x4b0 /* 6 + 0x3b * 20 */
372: #define DISK_BUF_TOP (SFT_TOP + SFT_SIZE)
1.1.1.14 root 373: #define DISK_BUF_SIZE 0x20
374: #define CDS_TOP (DISK_BUF_TOP + DISK_BUF_SIZE)
1.1 root 375: #define CDS_SIZE 0x80
376: #define FCB_TABLE_TOP (CDS_TOP + CDS_SIZE)
377: #define FCB_TABLE_SIZE 0x10
1.1.1.17 root 378: #define ERR_TABLE_TOP (FCB_TABLE_TOP + FCB_TABLE_SIZE)
379: #define ERR_TABLE_SIZE 0x10
1.1.1.18! root 380: #define SDA_TOP (ERR_TABLE_TOP + ERR_TABLE_SIZE)
! 381: #define SDA_BASE (SDA_TOP + 34)
! 382: #define SDA_SIZE 0xb0
1.1.1.13 root 383: // nls tables
1.1.1.18! root 384: #define UPPERTABLE_TOP (SDA_TOP + SDA_SIZE)
1.1.1.13 root 385: #define UPPERTABLE_SIZE 0x82
1.1.1.18! root 386: #define LOWERTABLE_TOP (UPPERTABLE_TOP + UPPERTABLE_SIZE)
! 387: #define LOWERTABLE_SIZE 0x82
! 388: #define FILENAME_UPPERTABLE_TOP (LOWERTABLE_TOP + LOWERTABLE_SIZE)
1.1.1.13 root 389: #define FILENAME_UPPERTABLE_SIZE 0x82
390: #define FILENAME_TERMINATOR_TOP (FILENAME_UPPERTABLE_TOP + FILENAME_UPPERTABLE_SIZE)
391: #define FILENAME_TERMINATOR_SIZE 0x20 /* requirement: 10 + 14(terminate chars) */
392: #define COLLATING_TABLE_TOP (FILENAME_TERMINATOR_TOP + FILENAME_TERMINATOR_SIZE)
393: #define COLLATING_TABLE_SIZE 0x102
394: #define DBCS_TOP (COLLATING_TABLE_TOP + COLLATING_TABLE_SIZE)
1.1 root 395: #define DBCS_TABLE (DBCS_TOP + 2)
396: #define DBCS_SIZE 0x10
1.1.1.13 root 397: #define MSDOS_SYSTEM_DATA_END (DBCS_TOP + DBCS_SIZE)
398: #define MEMORY_TOP ((MSDOS_SYSTEM_DATA_END + 15) & ~15U)
1.1.1.7 root 399: #define MEMORY_END 0xb8000
400: #define TEXT_VRAM_TOP 0xb8000
1.1.1.14 root 401: #define EMS_TOP 0xc0000
402: #define EMS_SIZE 0x10000
403: UINT32 UMB_TOP = EMS_TOP; // EMS is disabled
1.1.1.7 root 404: #define UMB_END 0xf8000
405: #define SHADOW_BUF_TOP 0xf8000
1.1.1.14 root 406: #define EMB_TOP 0x10fff0
407: #define EMB_END MAX_MEM
408:
409: UINT32 IRET_TOP = 0;
410: #define IRET_SIZE 0x100
411: UINT32 XMS_TOP = 0;
412: #define XMS_OFFSET 0x04
413: #define XMS_SIZE 0x20
1.1 root 414:
415: //#define ENV_SIZE 0x800
416: #define ENV_SIZE 0x2000
417: #define PSP_SIZE 0x100
418:
419: #define MAX_FILES 128
420: #define MAX_PROCESS 16
1.1.1.12 root 421: #define MAX_DTAINFO 128
1.1.1.11 root 422: #define LFN_DTA_LADDR 0x10FFF0
1.1.1.12 root 423: #define FIND_MAGIC 0x46696e64
1.1 root 424:
1.1.1.16 root 425: #define DUP_STDIN 27
426: #define DUP_STDOUT 28
427: #define DUP_STDERR 29
428: #define DUP_STDAUX 30
429: #define DUP_STDPRN 31
1.1 root 430:
1.1.1.16 root 431: //#define MAP_AUX_DEVICE_TO_FILE
432: //#define MAP_PRN_DEVICE_TO_FILE
1.1 root 433:
434: #pragma pack(1)
435: typedef struct {
436: UINT8 mz;
437: UINT16 psp;
1.1.1.14 root 438: union {
439: UINT8 reserved[5];
440: UINT16 paragraphs16;
441: UINT32 paragraphs32;
442: };
1.1.1.3 root 443: char prog_name[8];
1.1.1.14 root 444: // use 32bit paragraphs for emb
445: UINT32 paragraphs()
446: {
447: UINT32 offset = &(this->mz) - mem;
448: return (offset >= EMB_TOP) ? paragraphs32 : paragraphs16;
449: }
450: UINT32 size_kb()
451: {
452: return paragraphs() >> 6;
453: }
1.1 root 454: } mcb_t;
455: #pragma pack()
456:
457: #pragma pack(1)
458: typedef struct {
459: UINT16 env_seg;
460: PAIR32 cmd_line;
461: PAIR32 fcb1;
462: PAIR32 fcb2;
463: UINT16 sp;
464: UINT16 ss;
465: UINT16 ip;
466: UINT16 cs;
467: } param_block_t;
468: #pragma pack()
469:
470: #pragma pack(1)
471: typedef struct {
472: UINT8 len;
473: char cmd[127];
474: } cmd_line_t;
475: #pragma pack()
476:
477: #pragma pack(1)
478: typedef struct {
479: UINT8 exit[2];
480: UINT16 first_mcb;
481: UINT8 reserved_1;
482: UINT8 far_call;
483: PAIR32 cpm_entry;
484: PAIR32 int_22h;
485: PAIR32 int_23h;
486: PAIR32 int_24h;
487: UINT16 parent_psp;
488: UINT8 file_table[20];
489: UINT16 env_seg;
490: PAIR32 stack;
1.1.1.12 root 491: UINT16 file_table_size;
492: PAIR32 file_table_ptr;
493: UINT8 reserved_2[24];
1.1 root 494: UINT8 service[3];
495: UINT8 reserved_3[2];
496: UINT8 ex_fcb[7];
497: UINT8 fcb1[16];
498: UINT8 fcb2[20];
499: UINT8 buffer[128];
500: } psp_t;
501: #pragma pack()
502:
503: #pragma pack(1)
504: typedef struct {
505: UINT16 mz;
506: UINT16 extra_bytes;
507: UINT16 pages;
508: UINT16 relocations;
509: UINT16 header_size;
510: UINT16 min_alloc;
511: UINT16 max_alloc;
512: UINT16 init_ss;
513: UINT16 init_sp;
514: UINT16 check_sum;
515: UINT16 init_ip;
516: UINT16 init_cs;
517: UINT16 relocation_table;
518: UINT16 overlay;
519: } exe_header_t;
520: #pragma pack()
521:
522: #pragma pack(1)
523: typedef struct {
524: UINT8 flag;
525: UINT8 reserved[5];
526: UINT8 attribute;
527: } ext_fcb_t;
528: #pragma pack()
529:
530: #pragma pack(1)
531: typedef struct {
532: UINT8 drive;
533: UINT8 file_name[8 + 3];
534: UINT16 current_block;
535: UINT16 record_size;
536: UINT32 file_size;
537: UINT16 date;
538: UINT16 time;
1.1.1.12 root 539: union {
540: UINT8 reserved[8];
541: HANDLE handle;
542: };
1.1 root 543: UINT8 cur_record;
544: UINT32 rand_record;
545: } fcb_t;
546: #pragma pack()
547:
548: #pragma pack(1)
549: typedef struct {
550: UINT8 drive;
551: UINT8 file_name[8 + 3];
552: UINT8 attribute;
553: UINT8 nt_res;
554: UINT8 create_time_ms;
555: UINT16 creation_time;
556: UINT16 creation_date;
557: UINT16 last_access_date;
558: UINT16 cluster_hi;
559: UINT16 last_write_time;
560: UINT16 last_write_date;
561: UINT16 cluster_lo;
562: UINT32 file_size;
563: } find_fcb_t;
564: #pragma pack()
565:
566: #pragma pack(1)
567: typedef struct {
1.1.1.12 root 568: union {
569: UINT8 reserved[21];
570: struct {
571: UINT32 find_magic;
572: UINT32 dta_index;
573: };
574: };
1.1 root 575: UINT8 attrib;
576: UINT16 time;
577: UINT16 date;
578: UINT32 size;
579: char name[13];
580: } find_t;
581: #pragma pack()
582:
583: #pragma pack(1)
584: typedef struct {
585: UINT32 attrib;
586: PAIR32 ctime_lo;
587: PAIR32 ctime_hi;
588: PAIR32 atime_lo;
589: PAIR32 atime_hi;
590: PAIR32 mtime_lo;
591: PAIR32 mtime_hi;
592: UINT32 size_hi;
593: UINT32 size_lo;
594: UINT8 reserved[8];
595: char full_name[260];
596: char short_name[14];
597: } find_lfn_t;
598: #pragma pack()
599:
600: #pragma pack(1)
601: typedef struct {
602: UINT16 info_level;
603: UINT32 serial_number;
604: char volume_label[11];
605: char file_system[8];
606: } drive_info_t;
607: #pragma pack()
608:
609: #pragma pack(1)
610: typedef struct {
611: UINT16 size_of_structure;
612: UINT16 structure_version;
613: UINT32 sectors_per_cluster;
614: UINT32 bytes_per_sector;
615: UINT32 available_clusters_on_drive;
616: UINT32 total_clusters_on_drive;
617: UINT32 available_sectors_on_drive;
618: UINT32 total_sectors_on_drive;
619: UINT32 available_allocation_units;
620: UINT32 total_allocation_units;
621: UINT8 reserved[8];
622: } ext_space_info_t;
623: #pragma pack()
624:
625: #pragma pack(1)
626: typedef struct {
627: UINT8 drive_num;
628: UINT8 unit_num;
629: UINT16 bytes_per_sector;
630: UINT8 highest_sector_num;
631: UINT8 shift_count;
632: UINT16 reserved_sectors;
633: UINT8 fat_num;
634: UINT16 root_entries;
635: UINT16 first_data_sector;
636: UINT16 highest_cluster_num;
637: UINT16 sectors_per_fat;
638: UINT16 first_dir_sector;
639: UINT32 device_driver_header;
640: UINT8 media_type;
641: UINT8 drive_accessed;
642: UINT16 next_dpb_ofs;
643: UINT16 next_dpb_seg;
644: UINT16 first_free_cluster;
645: UINT16 free_clusters;
1.1.1.12 root 646: // extended
647: UINT16 fat_mirroring;
648: UINT16 info_sector;
649: UINT16 backup_boot_sector;
650: UINT32 first_cluster_sector;
651: UINT32 maximum_cluster_num;
652: UINT32 fat_sectors;
653: UINT32 root_cluster;
654: UINT32 free_search_cluster;
1.1 root 655: } dpb_t;
656: #pragma pack()
657:
658: #pragma pack(1)
659: typedef struct {
660: char path_name[67];
661: UINT16 drive_attrib;
662: UINT8 physical_drive_number;
663: } cds_t;
664: #pragma pack()
665:
666: #pragma pack(1)
667: typedef struct {
1.1.1.18! root 668: UINT8 reserved_1[3]; // -34
! 669: UINT8 switchar; // -31 current switch character
! 670: UINT8 malloc_strategy; // -30 current memory allocation strategy
! 671: UINT8 reserved_2[29]; // -29
! 672: // ----- from DOSBox -----
! 673: UINT8 crit_error_flag; // 0x00 Critical Error Flag
! 674: UINT8 indos_flag; // 0x01 InDOS flag (count of active INT 21 calls)
! 675: UINT8 drive_crit_error; // 0x02 Drive on which current critical error occurred or FFh
! 676: UINT8 locus_of_last_error; // 0x03 locus of last error
! 677: UINT16 extended_error_code; // 0x04 extended error code of last error
! 678: UINT8 suggested_action; // 0x06 suggested action for last error
! 679: UINT8 error_class; // 0x07 class of last error
! 680: PAIR32 last_error_pointer; // 0x08 ES:DI pointer for last error
! 681: PAIR32 current_dta; // 0x0C current DTA (Disk Transfer Address)
! 682: UINT16 current_psp; // 0x10 current PSP
! 683: UINT16 sp_int_23; // 0x12 stores SP across an INT 23
! 684: UINT16 return_code; // 0x14 return code from last process termination (zerod after reading with AH=4Dh)
! 685: UINT8 current_drive; // 0x16 current drive
! 686: UINT8 extended_break_flag; // 0x17 extended break flag
! 687: UINT8 fill[2]; // 0x18 flag: code page switching || flag: copy of previous byte in case of INT 24 Abort
! 688: } sda_t;
! 689: #pragma pack()
! 690:
! 691: #pragma pack(1)
! 692: typedef struct {
1.1.1.14 root 693: UINT8 reserved_0[4]; // -38
694: UINT16 magic_word; // -34 from DOSBox
695: UINT8 reserved_1[30]; // -32
1.1 root 696: UINT16 first_mcb; // -2
697: PAIR32 first_dpb; // +0
1.1.1.14 root 698: PAIR32 first_sft; // +4
699: UINT8 reserved_2[8]; // +8
700: UINT16 max_sector_len; // +16
701: PAIR32 disk_buf_info; // +18 from DOSBox
1.1 root 702: PAIR32 cds; // +22
703: PAIR32 fcb_table; // +26
1.1.1.14 root 704: UINT8 reserved_3[3]; // +30
1.1 root 705: UINT8 last_drive; // +33
1.1.1.14 root 706: struct {
707: UINT32 next_driver; // +34
708: UINT16 attributes; // +38
709: UINT16 strategy; // +40
710: UINT16 interrupt; // +42
711: char dev_name[8]; // +44
712: } nul_device;
713: UINT8 reserved_4[11]; // +52
1.1 root 714: UINT16 buffers_x; // +63
715: UINT16 buffers_y; // +65
716: UINT8 boot_drive; // +67
717: UINT8 i386_or_later; // +68
718: UINT16 ext_mem_size; // +69
1.1.1.14 root 719: PAIR32 disk_buf_heads; // +71 from DOSBox
720: UINT8 reserved_5[21]; // +75
1.1.1.5 root 721: UINT8 dos_flag; // +96
1.1.1.15 root 722: UINT8 reserved_6[2]; // +97
723: UINT8 umb_linked; // +99 from DOSBox
724: UINT8 reserved_7[2]; // +100
725: UINT16 first_umb_fcb; // +102 from DOSBox
726: UINT16 first_mcb_2; // +104 from DOSBox
1.1 root 727: } dos_info_t;
728: #pragma pack()
729:
1.1.1.14 root 730: #pragma pack(1)
731: typedef struct {
732: UINT16 date_format;
733: char currency_symbol[5];
734: char thou_sep[2];
735: char dec_sep[2];
736: char date_sep[2];
737: char time_sep[2];
738: char currency_format;
739: char currency_dec_digits;
740: char time_format;
741: PAIR32 case_map;
742: char list_sep[2];
743: char reserved[10];
744: } country_info_t;
745: #pragma pack()
746:
1.1 root 747: typedef struct {
748: char path[MAX_PATH];
749: int valid;
750: int id;
751: int atty;
752: int mode;
753: UINT16 info;
754: UINT16 psp;
755: } file_handler_t;
756:
757: static const struct {
758: int mode;
759: int in;
760: int out;
761: } file_mode[] = {
1.1.1.11 root 762: { _O_RDONLY | _O_BINARY, 1, 0 },
1.1 root 763: { _O_WRONLY | _O_BINARY, 0, 1 },
764: { _O_RDWR | _O_BINARY, 1, 1 },
765: };
766:
767: typedef struct {
768: UINT16 psp;
769: char module_dir[MAX_PATH];
770: PAIR32 dta;
771: UINT8 switchar;
772: UINT8 verify;
773: int max_files;
774: char volume_label[MAX_PATH];
775: bool parent_int_10h_feh_called;
776: bool parent_int_10h_ffh_called;
1.1.1.12 root 777: UINT16 parent_ds;
1.1.1.14 root 778: struct {
779: UINT16 handle;
780: UINT16 page;
781: bool mapped;
782: } ems_pages[4];
783: bool ems_pages_stored;
1.1 root 784: } process_t;
785:
1.1.1.11 root 786: typedef struct {
787: UINT16 psp;
788: UINT32 dta;
1.1.1.12 root 789: UINT8 allowable_mask;
790: UINT8 required_mask;
1.1.1.11 root 791: HANDLE find_handle;
792: } dtainfo_t;
793:
1.1.1.8 root 794: UINT8 major_version = 7;
795: UINT8 minor_version = 10;
796:
1.1.1.7 root 797: UINT16 first_mcb;
1.1 root 798: UINT16 current_psp;
799:
800: int retval = 0;
801: UINT16 error_code = 0;
802:
803: file_handler_t file_handler[MAX_FILES];
804: UINT8 file_buffer[0x100000];
805:
806: process_t process[MAX_PROCESS];
1.1.1.11 root 807: dtainfo_t dtalist[MAX_DTAINFO];
1.1 root 808:
1.1.1.6 root 809: UINT16 malloc_strategy = 0;
810:
1.1.1.12 root 811: char comspec_path[MAX_PATH] = "C:\\COMMAND.COM";
812:
1.1 root 813: void msdos_syscall(unsigned num);
814: int msdos_init(int argc, char *argv[], char *envp[], int standard_env);
815: void msdos_finish();
816:
817: // console
818:
1.1.1.12 root 819: #define SCR_BUF_WIDTH 256
820: #define SCR_BUF_HEIGHT 128
1.1 root 821:
822: #define SET_RECT(rect, l, t, r, b) { \
823: rect.Left = l; \
824: rect.Top = t; \
825: rect.Right = r; \
826: rect.Bottom = b; \
827: }
828:
1.1.1.12 root 829: CHAR_INFO scr_buf[SCR_BUF_WIDTH * SCR_BUF_HEIGHT];
830: char scr_char[SCR_BUF_WIDTH * SCR_BUF_HEIGHT];
831: WORD scr_attr[SCR_BUF_WIDTH * SCR_BUF_HEIGHT];
1.1 root 832: COORD scr_buf_size;
833: COORD scr_buf_pos;
834: int scr_width, scr_height;
1.1.1.12 root 835: int scr_top;
1.1.1.10 root 836: bool restore_console_on_exit = false;
1.1 root 837: bool cursor_moved;
838:
839: FIFO *key_buf_char;
840: FIFO *key_buf_scan;
1.1.1.7 root 841: int key_input = 0;
1.1.1.4 root 842: UINT32 key_code = 0;
1.1 root 843:
844: int active_code_page;
845: int system_code_page;
846:
1.1.1.12 root 847: UINT32 text_vram_top_address;
848: UINT32 text_vram_end_address;
849: UINT32 shadow_buffer_top_address;
850: UINT32 shadow_buffer_end_address;
851: int vram_pages;
1.1 root 852: bool int_10h_feh_called = false;
853: bool int_10h_ffh_called = false;
854:
855: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.