|
|
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
1.1.1.47 root 12: //#define _WIN32_WINNT 0x400 // Windows NT 4.0
13: #define _WIN32_WINNT 0x500 // Windows 2000
14: //#define _WIN32_WINNT 0x501 // Windows XP
1.1.1.12 root 15: #endif
1.1 root 16: #include <windows.h>
17: #include <winioctl.h>
1.1.1.47 root 18: #ifdef _MBCS
19: #include <mbstring.h>
20: #endif
1.1.1.13 root 21: #include <stddef.h>
1.1 root 22: #include <stdlib.h>
23: #include <stdio.h>
1.1.1.2 root 24: #include <assert.h>
1.1 root 25: #include <conio.h>
1.1.1.27 root 26: #include <locale.h>
1.1.1.2 root 27: #include <math.h>
1.1 root 28: #include <dos.h>
29: #include <fcntl.h>
30: #include <sys/types.h>
31: #include <sys/stat.h>
32: #include <io.h>
33: #include <sys/locking.h>
34: #include <mbctype.h>
35: #include <direct.h>
36: #include <errno.h>
1.1.1.9 root 37: #include <tlhelp32.h>
38: #include <psapi.h>
1.1.1.20 root 39: #include <setupapi.h>
1.1.1.27 root 40: #include <winsock.h>
1.1.1.42 root 41: #include <intrin.h>
1.1 root 42:
1.1.1.15 root 43: #ifdef _DEBUG
1.1.1.42 root 44: // _malloca is defined in both intrin.h and crtdbg.h
45: #ifdef _malloca
46: #undef _malloca
47: #endif
1.1.1.15 root 48: #define _CRTDBG_MAP_ALLOC
49: #include <crtdbg.h>
50: #define calloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
51: #define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
52: #define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
53: #endif
54:
1.1.1.9 root 55: // variable scope of 'for' loop for Microsoft Visual C++ 6.0
56: #if defined(_MSC_VER) && (_MSC_VER == 1200)
1.1 root 57: #define for if(0);else for
58: #endif
1.1.1.9 root 59:
60: // disable warnings for Microsoft Visual C++ 2005 or later
1.1 root 61: #if defined(_MSC_VER) && (_MSC_VER >= 1400)
62: #pragma warning( disable : 4819 )
63: #pragma warning( disable : 4995 )
64: #pragma warning( disable : 4996 )
1.1.1.9 root 65: // for MAME i86/i386
66: #pragma warning( disable : 4018 )
67: #pragma warning( disable : 4065 )
68: #pragma warning( disable : 4146 )
69: #pragma warning( disable : 4244 )
70: #pragma warning( disable : 4267 )
71: #endif
72:
73: // endian
74: #if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
75: #if defined(__BYTE_ORDER) && (defined(__LITTLE_ENDIAN) || defined(__BIG_ENDIAN))
76: #if __BYTE_ORDER == __LITTLE_ENDIAN
77: #define __LITTLE_ENDIAN__
78: #elif __BYTE_ORDER == __BIG_ENDIAN
79: #define __BIG_ENDIAN__
80: #endif
81: #elif defined(WORDS_LITTLEENDIAN)
82: #define __LITTLE_ENDIAN__
83: #elif defined(WORDS_BIGENDIAN)
84: #define __BIG_ENDIAN__
85: #endif
86: #endif
87: #if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
88: // Microsoft Visual C++
89: #define __LITTLE_ENDIAN__
1.1 root 90: #endif
1.1.1.9 root 91:
1.1 root 92: // compat for mingw32 headers
93: #ifndef COMMON_LVB_UNDERSCORE
94: #define COMMON_LVB_UNDERSCORE 0x8000
95: #endif
96:
97: // type definition
98: #ifndef UINT8
99: typedef unsigned char UINT8;
100: #endif
101: #ifndef UINT16
102: typedef unsigned short UINT16;
103: #endif
104: #ifndef UINT32
105: typedef unsigned int UINT32;
106: #endif
1.1.1.27 root 107: #ifndef UINT64
108: typedef unsigned long long UINT64;
109: #endif
1.1 root 110: #ifndef INT8
111: typedef signed char INT8;
112: #endif
113: #ifndef INT16
114: typedef signed short INT16;
115: #endif
116: #ifndef INT32
117: typedef signed int INT32;
118: #endif
1.1.1.27 root 119: #ifndef INT64
120: typedef signed long long INT64;
121: #endif
1.1 root 122:
123: #pragma pack(1)
124: typedef union {
125: UINT32 dw;
126: struct {
1.1.1.9 root 127: #ifdef __BIG_ENDIAN__
128: UINT16 h, l;
129: #else
1.1 root 130: UINT16 l, h;
1.1.1.9 root 131: #endif
1.1 root 132: } w;
133: } PAIR32;
134: #pragma pack()
135:
1.1.1.24 root 136: // MAME i86/i386
137:
138: // src/emu/devcpu.h
139: // offsets and addresses are 32-bit (for now...)
140: typedef UINT32 offs_t;
141:
1.1 root 142: /* ----------------------------------------------------------------------------
143: FIFO buffer
144: ---------------------------------------------------------------------------- */
145:
146: class FIFO
147: {
148: private:
1.1.1.20 root 149: int size;
150: int *buf;
1.1.1.29 root 151: int cnt, rpt, wpt;
1.1 root 152: public:
1.1.1.20 root 153: FIFO(int s) {
154: size = s;
155: buf = (int *)malloc(size * sizeof(int));
1.1 root 156: cnt = rpt = wpt = 0;
157: }
1.1.1.20 root 158: void release()
159: {
1.1.1.29 root 160: if(buf != NULL) {
161: free(buf);
162: buf = NULL;
163: }
1.1.1.20 root 164: }
1.1.1.27 root 165: void clear()
166: {
167: cnt = rpt = wpt = 0;
168: }
1.1 root 169: void write(int val) {
1.1.1.20 root 170: if(cnt < size) {
1.1 root 171: buf[wpt++] = val;
1.1.1.20 root 172: if(wpt >= size) {
1.1 root 173: wpt = 0;
174: }
175: cnt++;
176: }
177: }
178: int read() {
179: int val = 0;
180: if(cnt) {
181: val = buf[rpt++];
1.1.1.20 root 182: if(rpt >= size) {
1.1 root 183: rpt = 0;
184: }
185: cnt--;
186: }
1.1.1.20 root 187: return(val);
1.1 root 188: }
189: int count() {
1.1.1.20 root 190: return(cnt);
191: }
192: int remain() {
193: return(size - cnt);
194: }
195: bool full()
196: {
197: return(cnt == size);
198: }
199: bool empty()
200: {
201: return(cnt == 0);
1.1 root 202: }
203: };
204:
205: /* ----------------------------------------------------------------------------
1.1.1.14 root 206: MAME i86/i386
207: ---------------------------------------------------------------------------- */
208:
209: #if defined(HAS_I86)
210: #define CPU_MODEL i8086
211: #elif defined(HAS_I186)
212: #define CPU_MODEL i80186
213: #elif defined(HAS_V30)
214: #define CPU_MODEL v30
215: #elif defined(HAS_I286)
216: #define CPU_MODEL i80286
217: #elif defined(HAS_I386)
218: #define CPU_MODEL i386
219: #else
220: // #if defined(HAS_I386SX)
221: // #define CPU_MODEL i386SX
222: // #else
223: #if defined(HAS_I486)
224: #define CPU_MODEL i486
225: #else
226: #if defined(HAS_PENTIUM)
227: #define CPU_MODEL pentium
228: #elif defined(HAS_MEDIAGX)
229: #define CPU_MODEL mediagx
230: #elif defined(HAS_PENTIUM_PRO)
231: #define CPU_MODEL pentium_pro
232: #elif defined(HAS_PENTIUM_MMX)
233: #define CPU_MODEL pentium_mmx
234: #elif defined(HAS_PENTIUM2)
235: #define CPU_MODEL pentium2
236: #elif defined(HAS_PENTIUM3)
237: #define CPU_MODEL pentium3
238: #elif defined(HAS_PENTIUM4)
239: #define CPU_MODEL pentium4
240: #endif
241: #define SUPPORT_RDTSC
242: #endif
243: #define SUPPORT_FPU
244: // #endif
245: #define HAS_I386
246: #endif
247:
248: /* ----------------------------------------------------------------------------
1.1.1.27 root 249: debugger
250: ---------------------------------------------------------------------------- */
251:
252: //#define USE_DEBUGGER
253:
254: #ifdef USE_DEBUGGER
255: #define MAX_BREAK_POINTS 8
256:
257: bool now_debugging = false;
258: bool now_going = false;
259: bool now_suspended = false;
260: bool force_suspend = false;
261:
262: typedef struct {
263: struct {
264: UINT32 addr;
265: UINT32 seg;
266: UINT32 ofs;
267: int status; // 0 = none, 1 = enabled, other = disabled
268: } table[MAX_BREAK_POINTS];
269: int hit;
270: } break_point_t;
271:
272: break_point_t break_point = {0};
273: break_point_t rd_break_point = {0};
274: break_point_t wr_break_point = {0};
275: break_point_t in_break_point = {0};
276: break_point_t out_break_point = {0};
277:
278: typedef struct {
279: struct {
280: int int_num;
281: UINT8 ah, ah_registered;
282: UINT8 al, al_registered;
283: int status; // 0 = none, 1 = enabled, other = disabled
284: } table[MAX_BREAK_POINTS];
285: int hit;
286: } int_break_point_t;
287:
288: int_break_point_t int_break_point = {0};
289:
290: FILE *fp_debugger = NULL;
291: FILE *fi_debugger = NULL;
292:
293: // these read/write interfaces do not check break points,
294: // debugger should use them not to hit any break point mistakely
295: UINT8 debugger_read_byte(offs_t byteaddress);
296: UINT16 debugger_read_word(offs_t byteaddress);
297: UINT32 debugger_read_dword(offs_t byteaddress);
298: void debugger_write_byte(offs_t byteaddress, UINT8 data);
299: void debugger_write_word(offs_t byteaddress, UINT16 data);
300: void debugger_write_dword(offs_t byteaddress, UINT32 data);
301: UINT8 debugger_read_io_byte(offs_t addr);
302: UINT16 debugger_read_io_word(offs_t addr);
303: UINT32 debugger_read_io_dword(offs_t addr);
304: void debugger_write_io_byte(offs_t addr, UINT8 val);
305: void debugger_write_io_word(offs_t addr, UINT16 val);
306: void debugger_write_io_dword(offs_t addr, UINT32 val);
307: #endif
308:
309: /* ----------------------------------------------------------------------------
1.1.1.29 root 310: service thread
311: ---------------------------------------------------------------------------- */
312:
313: #define USE_SERVICE_THREAD
314:
315: #ifdef USE_SERVICE_THREAD
316: CRITICAL_SECTION input_crit_sect;
317: CRITICAL_SECTION key_buf_crit_sect;
318: CRITICAL_SECTION putch_crit_sect;
319: bool in_service = false;
320: bool service_exit = false;
1.1.1.39 root 321: DWORD main_thread_id;
1.1.1.29 root 322:
323: void start_service_loop(LPTHREAD_START_ROUTINE lpStartAddress);
324: void finish_service_loop();
325: #endif
326:
1.1.1.40 root 327: bool in_service_29h = false;
328:
1.1.1.29 root 329: /* ----------------------------------------------------------------------------
1.1.1.14 root 330: PC/AT hardware emulation
331: ---------------------------------------------------------------------------- */
332:
1.1.1.22 root 333: //#define SUPPORT_GRAPHIC_SCREEN
334:
1.1.1.14 root 335: void hardware_init();
336: void hardware_finish();
1.1.1.22 root 337: void hardware_release();
1.1.1.14 root 338: void hardware_run();
1.1.1.39 root 339: void hardware_run_cpu();
1.1.1.14 root 340: void hardware_update();
341:
1.1.1.32 root 342: // drive
343:
344: typedef struct {
345: int initialized;
346: int valid;
347: DISK_GEOMETRY geometry;
348:
349: int is_fdd()
350: {
351: if(initialized && valid) {
352: switch(geometry.MediaType) {
353: case F5_1Pt2_512:
354: case F3_1Pt44_512:
355: case F3_2Pt88_512:
356: case F3_20Pt8_512:
357: case F3_720_512:
358: case F5_360_512:
359: case F5_320_512:
360: case F5_320_1024:
361: case F5_180_512:
362: case F5_160_512:
363: case F3_120M_512:
364: case F3_640_512:
365: case F5_640_512:
366: case F5_720_512:
367: case F3_1Pt2_512:
368: case F3_1Pt23_1024:
369: case F5_1Pt23_1024:
370: case F3_128Mb_512:
371: case F3_230Mb_512:
372: case F8_256_128:
373: case F3_200Mb_512:
374: case F3_240M_512:
375: case F3_32M_512:
376: return(1);
377: }
378: }
379: return(0);
380: }
381: int head_num()
382: {
383: if(initialized && valid) {
384: switch(geometry.MediaType) {
385: case F5_1Pt2_512:
386: case F3_1Pt44_512:
387: case F3_2Pt88_512:
388: case F3_20Pt8_512:
389: case F3_720_512:
390: case F5_360_512:
391: case F5_320_512:
392: case F5_320_1024:
393: // case F5_180_512:
394: // case F5_160_512:
395: case F3_120M_512:
396: case F3_640_512:
397: case F5_640_512:
398: case F5_720_512:
399: case F3_1Pt2_512:
400: case F3_1Pt23_1024:
401: case F5_1Pt23_1024:
402: case F3_128Mb_512:
403: case F3_230Mb_512:
404: // case F8_256_128:
405: case F3_200Mb_512:
406: case F3_240M_512:
407: case F3_32M_512:
408: return(2);
409: default:
410: return(1);
411: }
412: }
413: return(0);
414: }
415: } drive_param_t;
416:
417: drive_param_t drive_params[26] = {0};
418:
1.1.1.14 root 419: // memory
420:
421: #if defined(HAS_I386)
1.1.1.27 root 422: #define ADDR_MASK 0xffffffff
423: #define MAX_MEM 0x2000000 /* 32MB */
1.1.1.14 root 424: #elif defined(HAS_I286)
1.1.1.27 root 425: #define ADDR_MASK 0xffffff
426: #define MAX_MEM 0x1000000 /* 16MB */
1.1.1.14 root 427: #else
1.1.1.27 root 428: #define ADDR_MASK 0xfffff
429: #define MAX_MEM 0x100000 /* 1MB */
1.1.1.14 root 430: #endif
1.1.1.27 root 431: UINT8 mem[MAX_MEM + 15];
1.1.1.14 root 432:
433: // ems
434:
435: #define MAX_EMS_HANDLES 16
436: #define MAX_EMS_PAGES 2048 /* 32MB */
437:
1.1.1.21 root 438: typedef struct {
1.1.1.14 root 439: char name[8];
440: UINT8* buffer;
441: int pages;
442: bool allocated;
1.1.1.21 root 443: } ems_handle_t;
1.1.1.14 root 444:
1.1.1.21 root 445: typedef struct {
1.1.1.14 root 446: UINT16 handle;
447: UINT16 page;
448: bool mapped;
1.1.1.21 root 449: } ems_page_t;
1.1.1.14 root 450:
1.1.1.25 root 451: ems_handle_t ems_handles[MAX_EMS_HANDLES + 1] = {0};
1.1.1.21 root 452: ems_page_t ems_pages[4];
1.1.1.14 root 453: int free_ems_pages;
454:
455: void ems_init();
456: void ems_finish();
1.1.1.22 root 457: void ems_release();
1.1.1.14 root 458: void ems_allocate_pages(int handle, int pages);
459: void ems_reallocate_pages(int handle, int pages);
460: void ems_release_pages(int handle);
461: void ems_map_page(int physical, int handle, int logical);
462: void ems_unmap_page(int physical);
463:
1.1.1.20 root 464: // dma
465:
466: typedef struct {
467: struct {
468: union {
469: UINT16 w;
470: struct {
471: #ifdef __BIG_ENDIAN__
472: UINT8 h, l;
473: #else
474: UINT8 l, h;
475: #endif
476: } b;
477: } areg, creg, bareg, bcreg;
478: UINT8 mode;
479: UINT8 pagereg;
480: UINT32 port;
481: } ch[4];
482:
483: bool low_high;
484: UINT8 cmd;
485: UINT8 req;
486: UINT8 mask;
487: UINT8 tc;
488: UINT16 tmp;
489: } dma_t;
490:
1.1.1.21 root 491: dma_t dma[2];
1.1.1.20 root 492:
493: void dma_init();
494: void dma_reset(int c);
495: void dma_write(int c, UINT32 addr, UINT8 data);
496: UINT8 dma_read(int c, UINT32 addr);
497: void dma_page_write(int c, int ch, UINT8 data);
498: UINT8 dma_page_read(int c, int ch);
499: void dma_run(int c, int ch);
500:
1.1.1.14 root 501: // pic
502:
503: typedef struct {
504: UINT8 imr, isr, irr, prio;
505: UINT8 icw1, icw2, icw3, icw4;
506: UINT8 ocw3;
507: UINT8 icw2_r, icw3_r, icw4_r;
508: } pic_t;
509:
510: pic_t pic[2];
511: int pic_req_chip, pic_req_level;
512: UINT8 pic_req_bit;
513:
514: void pic_init();
515: void pic_write(int c, UINT32 addr, UINT8 data);
516: UINT8 pic_read(int c, UINT32 addr);
517: void pic_req(int c, int level, int signal);
518: int pic_ack();
519: void pic_update();
520:
1.1.1.20 root 521: // pio
522:
523: typedef struct {
524: UINT8 data, stat, ctrl;
1.1.1.30 root 525: // code conversion
526: bool conv_mode;
527: bool jis_mode;
528: UINT8 sjis_hi;
529: UINT8 esc_buf[8];
530: UINT32 esc_len;
531: // printer to file
532: char path[MAX_PATH];
533: FILE *fp;
534: SYSTEMTIME time;
1.1.1.20 root 535: } pio_t;
536:
1.1.1.21 root 537: pio_t pio[2];
1.1.1.20 root 538:
539: void pio_init();
1.1.1.30 root 540: void pio_finish();
541: void pio_release();
1.1.1.20 root 542: void pio_write(int c, UINT32 addr, UINT8 data);
543: UINT8 pio_read(int c, UINT32 addr);
1.1.1.30 root 544: void printer_out(int c, UINT8 data);
545: void pcbios_printer_out(int c, UINT8 data);
1.1.1.20 root 546:
1.1.1.14 root 547: // pit
548:
549: #define PIT_ALWAYS_RUNNING
550:
551: typedef struct {
552: INT32 count;
553: UINT16 latch;
1.1.1.21 root 554: UINT16 prev_latch, next_latch;
1.1.1.14 root 555: UINT16 count_reg;
556: UINT8 ctrl_reg;
557: int count_latched;
558: int low_read, high_read;
559: int low_write, high_write;
560: int mode;
561: int status_latched;
562: UINT8 status;
563: // constant clock
564: UINT32 expired_time;
565: UINT32 prev_time;
1.1.1.17 root 566: UINT64 accum;
1.1.1.14 root 567: } pit_t;
568:
569: pit_t pit[3];
570: #ifndef PIT_ALWAYS_RUNNING
571: int pit_active;
572: #endif
573:
574: void pit_init();
575: void pit_write(int ch, UINT8 val);
576: UINT8 pit_read(int ch);
577: int pit_run(int ch, UINT32 cur_time);
578: void pit_latch_count(int ch);
579: int pit_get_expired_time(int ch);
580:
581: UINT8 system_port = 0;
582:
1.1.1.20 root 583: // sio
584:
585: #define SIO_BUFFER_SIZE 1024
586:
587: typedef struct {
588: int channel;
589:
590: FIFO *send_buffer;
591: FIFO *recv_buffer;
592:
593: union {
594: UINT16 w;
595: struct {
596: #ifdef __BIG_ENDIAN__
597: UINT8 h, l;
598: #else
599: UINT8 l, h;
600: #endif
601: } b;
602: } divisor;
603: UINT16 prev_divisor;
604: UINT8 line_ctrl, prev_line_ctrl;
605: UINT8 selector;
606:
607: UINT8 modem_ctrl;
1.1.1.21 root 608: bool set_brk, set_rts, set_dtr;
609: bool prev_set_brk;
610: // bool prev_set_rts, prev_set_dtr;
1.1.1.20 root 611:
612: UINT8 line_stat_buf, line_stat_err;
613: UINT8 modem_stat, prev_modem_stat;
614:
615: UINT8 irq_enable;
616: UINT8 irq_identify;
617:
618: UINT8 scratch;
619: } sio_t;
620:
621: typedef struct {
622: HANDLE hThread;
623: CRITICAL_SECTION csSendData;
624: CRITICAL_SECTION csRecvData;
625: CRITICAL_SECTION csLineCtrl;
626: CRITICAL_SECTION csLineStat;
627: CRITICAL_SECTION csModemCtrl;
628: CRITICAL_SECTION csModemStat;
629: } sio_mt_t;
630:
1.1.1.23 root 631: sio_t sio[4] = {0};
632: sio_mt_t sio_mt[4];
1.1.1.20 root 633:
634: void sio_init();
635: void sio_finish();
1.1.1.22 root 636: void sio_release();
1.1.1.20 root 637: void sio_write(int c, UINT32 addr, UINT8 data);
638: UINT8 sio_read(int c, UINT32 addr);
639: void sio_update(int c);
640: void sio_update_irq(int c);
641: DWORD WINAPI sio_thread(void *lpx);
642:
1.1.1.14 root 643: // cmos
644:
645: UINT8 cmos[128];
646: UINT8 cmos_addr;
647:
648: void cmos_init();
649: void cmos_write(int addr, UINT8 val);
650: UINT8 cmos_read(int addr);
651:
652: // kbd (a20)
653:
654: UINT8 kbd_data;
655: UINT8 kbd_status;
656: UINT8 kbd_command;
657:
658: void kbd_init();
659: UINT8 kbd_read_data();
660: void kbd_write_data(UINT8 val);
661: UINT8 kbd_read_status();
662: void kbd_write_command(UINT8 val);
663:
1.1.1.45 root 664: // crtc
665:
666: UINT8 crtc_addr = 0;
667: UINT8 crtc_regs[16] = {0};
668: UINT8 crtc_changed[16] = {0};
669:
1.1.1.14 root 670: /* ----------------------------------------------------------------------------
1.1 root 671: MS-DOS virtual machine
672: ---------------------------------------------------------------------------- */
673:
1.1.1.24 root 674: #if defined(HAS_I386)
1.1.1.49! root 675: #define SUPPORT_VCPI
1.1.1.24 root 676: #endif
1.1.1.23 root 677: #if defined(HAS_I286) || defined(HAS_I386)
678: #define SUPPORT_XMS
679: //#define SUPPORT_HMA
680: #endif
1.1.1.41 root 681: //#define SUPPORT_MSCDEX
1.1.1.23 root 682:
1.1 root 683: #define VECTOR_TOP 0
684: #define VECTOR_SIZE 0x400
685: #define BIOS_TOP (VECTOR_TOP + VECTOR_SIZE)
686: #define BIOS_SIZE 0x100
687: #define WORK_TOP (BIOS_TOP + BIOS_SIZE)
1.1.1.14 root 688: #define WORK_SIZE 0x200
1.1.1.20 root 689: // IO.SYS 0070:0000
690: #define DEVICE_TOP (WORK_TOP + WORK_SIZE)
1.1.1.21 root 691: #define DEVICE_SIZE 0x100 /* 22 + 18 * 12 + 7 */
1.1.1.20 root 692: #define DOS_INFO_TOP (DEVICE_TOP + DEVICE_SIZE)
1.1 root 693: #define DOS_INFO_SIZE 0x100
1.1.1.26 root 694: //#define EXT_BIOS_TOP (DOS_INFO_TOP + DOS_INFO_SIZE)
695: //#define EXT_BIOS_SIZE 0x400
696: #ifdef EXT_BIOS_TOP
1.1.1.20 root 697: #define DPB_TOP (EXT_BIOS_TOP + EXT_BIOS_SIZE)
1.1.1.26 root 698: #else
699: #define DPB_TOP (DOS_INFO_TOP + DOS_INFO_SIZE)
700: #endif
1.1.1.31 root 701: #define DPB_SIZE 0x600
1.1.1.16 root 702: #define SFT_TOP (DPB_TOP + DPB_SIZE)
703: #define SFT_SIZE 0x4b0 /* 6 + 0x3b * 20 */
704: #define DISK_BUF_TOP (SFT_TOP + SFT_SIZE)
1.1.1.14 root 705: #define DISK_BUF_SIZE 0x20
706: #define CDS_TOP (DISK_BUF_TOP + DISK_BUF_SIZE)
1.1.1.34 root 707: #define CDS_SIZE 0x8F0 /* 88 * 26 */
1.1 root 708: #define FCB_TABLE_TOP (CDS_TOP + CDS_SIZE)
709: #define FCB_TABLE_SIZE 0x10
1.1.1.26 root 710: #define SDA_TOP (FCB_TABLE_TOP + FCB_TABLE_SIZE)
1.1.1.18 root 711: #define SDA_SIZE 0xb0
1.1.1.13 root 712: // nls tables
1.1.1.18 root 713: #define UPPERTABLE_TOP (SDA_TOP + SDA_SIZE)
1.1.1.13 root 714: #define UPPERTABLE_SIZE 0x82
1.1.1.18 root 715: #define LOWERTABLE_TOP (UPPERTABLE_TOP + UPPERTABLE_SIZE)
716: #define LOWERTABLE_SIZE 0x82
717: #define FILENAME_UPPERTABLE_TOP (LOWERTABLE_TOP + LOWERTABLE_SIZE)
1.1.1.13 root 718: #define FILENAME_UPPERTABLE_SIZE 0x82
719: #define FILENAME_TERMINATOR_TOP (FILENAME_UPPERTABLE_TOP + FILENAME_UPPERTABLE_SIZE)
720: #define FILENAME_TERMINATOR_SIZE 0x20 /* requirement: 10 + 14(terminate chars) */
721: #define COLLATING_TABLE_TOP (FILENAME_TERMINATOR_TOP + FILENAME_TERMINATOR_SIZE)
722: #define COLLATING_TABLE_SIZE 0x102
723: #define DBCS_TOP (COLLATING_TABLE_TOP + COLLATING_TABLE_SIZE)
1.1 root 724: #define DBCS_TABLE (DBCS_TOP + 2)
725: #define DBCS_SIZE 0x10
1.1.1.13 root 726: #define MSDOS_SYSTEM_DATA_END (DBCS_TOP + DBCS_SIZE)
727: #define MEMORY_TOP ((MSDOS_SYSTEM_DATA_END + 15) & ~15U)
1.1.1.22 root 728: #ifdef SUPPORT_GRAPHIC_SCREEN
729: #define MEMORY_END 0xa0000
730: #define VGA_VRAM_TOP 0xa0000
731: #else
1.1.1.7 root 732: #define MEMORY_END 0xb8000
1.1.1.22 root 733: #endif
1.1.1.7 root 734: #define TEXT_VRAM_TOP 0xb8000
1.1.1.14 root 735: #define EMS_TOP 0xc0000
736: #define EMS_SIZE 0x10000
737: UINT32 UMB_TOP = EMS_TOP; // EMS is disabled
1.1.1.7 root 738: #define UMB_END 0xf8000
739: #define SHADOW_BUF_TOP 0xf8000
1.1.1.38 root 740: // text vram size: 80x25x2 = 4000 = 0fa0h
741: // fffa0h-fffefh can be used for dummy routines
742: #define DUMMY_TOP 0xfffc0
1.1.1.49! root 743: //#define EMB_TOP 0x10fff0
! 744: #define EMB_TOP 0x110000 // align to 4KB
1.1.1.14 root 745: #define EMB_END MAX_MEM
746:
747: UINT32 IRET_TOP = 0;
748: #define IRET_SIZE 0x100
749: UINT32 XMS_TOP = 0;
1.1.1.35 root 750: // XMS_TOP + 0x000 EMMXXXX0 driver
751: // XMS_TOP + 0x012 EMS dummy routine
752: // XMS_TOP + 0x015 XMS dummy routine
753: // XMS_TOP + 0x018 EMMXXXX0 ioctrl recv buffer
754: // XMS_TOP + 0x1b9 EMMXXXX0 driver dummy routine (at XMS_TOP + XMS_SIZE - 7)
755: #define XMS_SIZE 0x1c0 /* 18 + 6 + 413 + 7 */
1.1 root 756:
757: //#define ENV_SIZE 0x800
758: #define ENV_SIZE 0x2000
759: #define PSP_SIZE 0x100
1.1.1.27 root 760: #define PSP_SYSTEM 0x0008
1.1 root 761:
762: #define MAX_FILES 128
763: #define MAX_PROCESS 16
1.1.1.12 root 764: #define MAX_DTAINFO 128
1.1.1.11 root 765: #define LFN_DTA_LADDR 0x10FFF0
1.1.1.12 root 766: #define FIND_MAGIC 0x46696e64
1.1 root 767:
1.1.1.16 root 768: #define DUP_STDIN 27
769: #define DUP_STDOUT 28
770: #define DUP_STDERR 29
771: #define DUP_STDAUX 30
772: #define DUP_STDPRN 31
1.1 root 773:
1.1.1.16 root 774: //#define MAP_AUX_DEVICE_TO_FILE
1.1 root 775:
776: #pragma pack(1)
777: typedef struct {
778: UINT8 mz;
779: UINT16 psp;
1.1.1.24 root 780: UINT16 paragraphs;
781: UINT8 reserved[3];
1.1.1.3 root 782: char prog_name[8];
1.1 root 783: } mcb_t;
784: #pragma pack()
785:
1.1.1.23 root 786: #ifdef SUPPORT_HMA
787: #pragma pack(1)
788: typedef struct {
789: UINT8 ms[2];
790: UINT16 owner;
791: UINT16 size;
792: UINT16 next;
793: } hma_mcb_t;
794: #pragma pack()
795: #endif
796:
1.1 root 797: #pragma pack(1)
798: typedef struct {
799: UINT16 env_seg;
800: PAIR32 cmd_line;
801: PAIR32 fcb1;
802: PAIR32 fcb2;
803: UINT16 sp;
804: UINT16 ss;
805: UINT16 ip;
806: UINT16 cs;
807: } param_block_t;
808: #pragma pack()
809:
810: #pragma pack(1)
811: typedef struct {
812: UINT8 len;
813: char cmd[127];
814: } cmd_line_t;
815: #pragma pack()
816:
817: #pragma pack(1)
818: typedef struct {
819: UINT8 exit[2];
820: UINT16 first_mcb;
821: UINT8 reserved_1;
1.1.1.36 root 822: // UINT8 far_call;
823: // PAIR32 cpm_entry;
824: UINT8 call5[5];
1.1 root 825: PAIR32 int_22h;
826: PAIR32 int_23h;
827: PAIR32 int_24h;
828: UINT16 parent_psp;
829: UINT8 file_table[20];
830: UINT16 env_seg;
831: PAIR32 stack;
1.1.1.12 root 832: UINT16 file_table_size;
833: PAIR32 file_table_ptr;
834: UINT8 reserved_2[24];
1.1 root 835: UINT8 service[3];
836: UINT8 reserved_3[2];
837: UINT8 ex_fcb[7];
838: UINT8 fcb1[16];
839: UINT8 fcb2[20];
840: UINT8 buffer[128];
841: } psp_t;
842: #pragma pack()
843:
844: #pragma pack(1)
845: typedef struct {
846: UINT16 mz;
847: UINT16 extra_bytes;
848: UINT16 pages;
849: UINT16 relocations;
850: UINT16 header_size;
851: UINT16 min_alloc;
852: UINT16 max_alloc;
853: UINT16 init_ss;
854: UINT16 init_sp;
855: UINT16 check_sum;
856: UINT16 init_ip;
857: UINT16 init_cs;
858: UINT16 relocation_table;
859: UINT16 overlay;
860: } exe_header_t;
861: #pragma pack()
862:
863: #pragma pack(1)
864: typedef struct {
865: UINT8 flag;
866: UINT8 reserved[5];
867: UINT8 attribute;
868: } ext_fcb_t;
869: #pragma pack()
870:
871: #pragma pack(1)
872: typedef struct {
873: UINT8 drive;
874: UINT8 file_name[8 + 3];
875: UINT16 current_block;
876: UINT16 record_size;
877: UINT32 file_size;
878: UINT16 date;
879: UINT16 time;
1.1.1.12 root 880: union {
881: UINT8 reserved[8];
882: HANDLE handle;
883: };
1.1 root 884: UINT8 cur_record;
885: UINT32 rand_record;
886: } fcb_t;
887: #pragma pack()
888:
889: #pragma pack(1)
890: typedef struct {
891: UINT8 drive;
892: UINT8 file_name[8 + 3];
893: UINT8 attribute;
894: UINT8 nt_res;
895: UINT8 create_time_ms;
896: UINT16 creation_time;
897: UINT16 creation_date;
898: UINT16 last_access_date;
899: UINT16 cluster_hi;
900: UINT16 last_write_time;
901: UINT16 last_write_date;
902: UINT16 cluster_lo;
903: UINT32 file_size;
904: } find_fcb_t;
905: #pragma pack()
906:
907: #pragma pack(1)
908: typedef struct {
1.1.1.12 root 909: union {
910: UINT8 reserved[21];
911: struct {
912: UINT32 find_magic;
913: UINT32 dta_index;
914: };
915: };
1.1 root 916: UINT8 attrib;
917: UINT16 time;
918: UINT16 date;
919: UINT32 size;
920: char name[13];
921: } find_t;
922: #pragma pack()
923:
924: #pragma pack(1)
925: typedef struct {
926: UINT32 attrib;
927: PAIR32 ctime_lo;
928: PAIR32 ctime_hi;
929: PAIR32 atime_lo;
930: PAIR32 atime_hi;
931: PAIR32 mtime_lo;
932: PAIR32 mtime_hi;
933: UINT32 size_hi;
934: UINT32 size_lo;
935: UINT8 reserved[8];
936: char full_name[260];
937: char short_name[14];
938: } find_lfn_t;
939: #pragma pack()
940:
941: #pragma pack(1)
942: typedef struct {
943: UINT16 info_level;
944: UINT32 serial_number;
945: char volume_label[11];
946: char file_system[8];
947: } drive_info_t;
948: #pragma pack()
949:
950: #pragma pack(1)
951: typedef struct {
952: UINT16 size_of_structure;
953: UINT16 structure_version;
954: UINT32 sectors_per_cluster;
955: UINT32 bytes_per_sector;
956: UINT32 available_clusters_on_drive;
957: UINT32 total_clusters_on_drive;
958: UINT32 available_sectors_on_drive;
959: UINT32 total_sectors_on_drive;
960: UINT32 available_allocation_units;
961: UINT32 total_allocation_units;
962: UINT8 reserved[8];
963: } ext_space_info_t;
964: #pragma pack()
965:
966: #pragma pack(1)
967: typedef struct {
968: UINT8 drive_num;
969: UINT8 unit_num;
970: UINT16 bytes_per_sector;
971: UINT8 highest_sector_num;
972: UINT8 shift_count;
973: UINT16 reserved_sectors;
974: UINT8 fat_num;
975: UINT16 root_entries;
976: UINT16 first_data_sector;
977: UINT16 highest_cluster_num;
978: UINT16 sectors_per_fat;
979: UINT16 first_dir_sector;
980: UINT32 device_driver_header;
981: UINT8 media_type;
982: UINT8 drive_accessed;
983: UINT16 next_dpb_ofs;
984: UINT16 next_dpb_seg;
985: UINT16 first_free_cluster;
986: UINT16 free_clusters;
1.1.1.12 root 987: // extended
988: UINT16 fat_mirroring;
989: UINT16 info_sector;
990: UINT16 backup_boot_sector;
991: UINT32 first_cluster_sector;
992: UINT32 maximum_cluster_num;
993: UINT32 fat_sectors;
994: UINT32 root_cluster;
995: UINT32 free_search_cluster;
1.1 root 996: } dpb_t;
997: #pragma pack()
998:
999: #pragma pack(1)
1000: typedef struct {
1.1.1.33 root 1001: UINT16 bytes_per_sector;
1002: UINT8 sectors_per_cluster;
1003: UINT16 reserved_sectors;
1004: UINT8 fat_num;
1005: UINT16 root_entries;
1006: UINT16 total_sectors;
1007: UINT8 media_type;
1008: UINT16 sectors_per_fat;
1009: UINT16 sectors_per_track;
1010: UINT16 heads_num;
1011: UINT32 hidden_sectors;
1012: // extended
1013: UINT32 ext_total_sectors;
1014: UINT32 ext_sectors_per_fat;
1015: } bpb_t;
1016: #pragma pack()
1017:
1018: #pragma pack(1)
1019: typedef struct {
1.1 root 1020: char path_name[67];
1021: UINT16 drive_attrib;
1.1.1.34 root 1022: PAIR32 dpb_ptr;
1023: UINT16 word_1;
1024: UINT16 word_2;
1025: UINT16 word_3;
1026: UINT16 bs_offset;
1.1 root 1027: } cds_t;
1028: #pragma pack()
1029:
1030: #pragma pack(1)
1031: typedef struct {
1.1.1.37 root 1032: // UINT16 int21h_5d0ah_si; // -38
1033: // UINT16 int21h_5d0ah_ds; // -36
1.1.1.33 root 1034: // swappable data area
1035: UINT8 printer_cho_flag; // -34
1.1.1.37 root 1036: UINT16 int21h_5d0ah_dx; // -33
1.1.1.18 root 1037: UINT8 switchar; // -31 current switch character
1038: UINT8 malloc_strategy; // -30 current memory allocation strategy
1.1.1.37 root 1039: UINT8 int21h_5d0ah_cl; // -29
1040: UINT8 int21h_5e01h_counter; // -28
1041: UINT8 int21h_5e01h_name[16]; // -27
1.1.1.33 root 1042: UINT16 offset_lists[5]; // -11
1.1.1.37 root 1043: UINT8 int21h_5d0ah_called; // -1
1.1.1.18 root 1044: // ----- from DOSBox -----
1045: UINT8 crit_error_flag; // 0x00 Critical Error Flag
1046: UINT8 indos_flag; // 0x01 InDOS flag (count of active INT 21 calls)
1047: UINT8 drive_crit_error; // 0x02 Drive on which current critical error occurred or FFh
1048: UINT8 locus_of_last_error; // 0x03 locus of last error
1049: UINT16 extended_error_code; // 0x04 extended error code of last error
1050: UINT8 suggested_action; // 0x06 suggested action for last error
1051: UINT8 error_class; // 0x07 class of last error
1052: PAIR32 last_error_pointer; // 0x08 ES:DI pointer for last error
1053: PAIR32 current_dta; // 0x0C current DTA (Disk Transfer Address)
1054: UINT16 current_psp; // 0x10 current PSP
1055: UINT16 sp_int_23; // 0x12 stores SP across an INT 23
1056: UINT16 return_code; // 0x14 return code from last process termination (zerod after reading with AH=4Dh)
1057: UINT8 current_drive; // 0x16 current drive
1058: UINT8 extended_break_flag; // 0x17 extended break flag
1059: UINT8 fill[2]; // 0x18 flag: code page switching || flag: copy of previous byte in case of INT 24 Abort
1060: } sda_t;
1061: #pragma pack()
1062:
1063: #pragma pack(1)
1064: typedef struct {
1.1.1.14 root 1065: UINT8 reserved_0[4]; // -38
1066: UINT16 magic_word; // -34 from DOSBox
1067: UINT8 reserved_1[30]; // -32
1.1 root 1068: UINT16 first_mcb; // -2
1069: PAIR32 first_dpb; // +0
1.1.1.14 root 1070: PAIR32 first_sft; // +4
1.1.1.20 root 1071: PAIR32 clock_device; // +8
1072: PAIR32 con_device; // +12
1.1.1.14 root 1073: UINT16 max_sector_len; // +16
1074: PAIR32 disk_buf_info; // +18 from DOSBox
1.1 root 1075: PAIR32 cds; // +22
1076: PAIR32 fcb_table; // +26
1.1.1.20 root 1077: UINT8 reserved_2[3]; // +30
1.1 root 1078: UINT8 last_drive; // +33
1.1.1.14 root 1079: struct {
1.1.1.20 root 1080: PAIR32 next_driver; // +34
1.1.1.14 root 1081: UINT16 attributes; // +38
1082: UINT16 strategy; // +40
1083: UINT16 interrupt; // +42
1084: char dev_name[8]; // +44
1085: } nul_device;
1.1.1.20 root 1086: UINT8 reserved_3[11]; // +52
1.1 root 1087: UINT16 buffers_x; // +63
1088: UINT16 buffers_y; // +65
1089: UINT8 boot_drive; // +67
1090: UINT8 i386_or_later; // +68
1091: UINT16 ext_mem_size; // +69
1.1.1.14 root 1092: PAIR32 disk_buf_heads; // +71 from DOSBox
1.1.1.20 root 1093: UINT8 reserved_4[21]; // +75
1.1.1.5 root 1094: UINT8 dos_flag; // +96
1.1.1.20 root 1095: UINT8 reserved_5[2]; // +97
1.1.1.15 root 1096: UINT8 umb_linked; // +99 from DOSBox
1.1.1.20 root 1097: UINT8 reserved_6[2]; // +100
1.1.1.15 root 1098: UINT16 first_umb_fcb; // +102 from DOSBox
1099: UINT16 first_mcb_2; // +104 from DOSBox
1.1.1.21 root 1100: UINT8 nul_device_routine[7];
1.1 root 1101: } dos_info_t;
1102: #pragma pack()
1103:
1.1.1.14 root 1104: #pragma pack(1)
1105: typedef struct {
1.1.1.20 root 1106: PAIR32 next_driver;
1107: UINT16 attributes;
1108: UINT16 strategy;
1109: UINT16 interrupt;
1110: char dev_name[8];
1111: } device_t;
1112: #pragma pack()
1113:
1114: #pragma pack(1)
1115: typedef struct {
1.1.1.14 root 1116: UINT16 date_format;
1117: char currency_symbol[5];
1118: char thou_sep[2];
1119: char dec_sep[2];
1120: char date_sep[2];
1121: char time_sep[2];
1122: char currency_format;
1123: char currency_dec_digits;
1124: char time_format;
1125: PAIR32 case_map;
1126: char list_sep[2];
1127: char reserved[10];
1128: } country_info_t;
1129: #pragma pack()
1130:
1.1 root 1131: typedef struct {
1132: char path[MAX_PATH];
1133: int valid;
1134: int id;
1135: int atty;
1136: int mode;
1137: UINT16 info;
1138: UINT16 psp;
1.1.1.30 root 1139: int sio_port; // 1-4
1140: int lpt_port; // 1-3
1.1 root 1141: } file_handler_t;
1142:
1143: static const struct {
1144: int mode;
1145: int in;
1146: int out;
1147: } file_mode[] = {
1.1.1.11 root 1148: { _O_RDONLY | _O_BINARY, 1, 0 },
1.1 root 1149: { _O_WRONLY | _O_BINARY, 0, 1 },
1150: { _O_RDWR | _O_BINARY, 1, 1 },
1151: };
1152:
1153: typedef struct {
1154: UINT16 psp;
1155: char module_dir[MAX_PATH];
1.1.1.27 root 1156: #ifdef USE_DEBUGGER
1157: char module_path[MAX_PATH];
1158: #endif
1.1 root 1159: PAIR32 dta;
1160: UINT8 switchar;
1161: UINT8 verify;
1162: int max_files;
1163: char volume_label[MAX_PATH];
1164: bool parent_int_10h_feh_called;
1165: bool parent_int_10h_ffh_called;
1.1.1.12 root 1166: UINT16 parent_ds;
1.1.1.25 root 1167: UINT16 parent_es;
1.1.1.14 root 1168: struct {
1169: UINT16 handle;
1170: UINT16 page;
1171: bool mapped;
1172: } ems_pages[4];
1173: bool ems_pages_stored;
1.1.1.22 root 1174: bool called_by_int2eh;
1.1 root 1175: } process_t;
1176:
1.1.1.11 root 1177: typedef struct {
1178: UINT16 psp;
1179: UINT32 dta;
1.1.1.12 root 1180: UINT8 allowable_mask;
1181: UINT8 required_mask;
1.1.1.11 root 1182: HANDLE find_handle;
1183: } dtainfo_t;
1184:
1.1.1.24 root 1185: UINT8 dos_major_version = 7; // Windows 98 Second Edition
1186: UINT8 dos_minor_version = 10;
1187: UINT8 win_major_version = 4;
1188: UINT8 win_minor_version = 10;
1.1.1.8 root 1189:
1.1.1.7 root 1190: UINT16 first_mcb;
1.1 root 1191: UINT16 current_psp;
1192:
1193: int retval = 0;
1194: UINT16 error_code = 0;
1195:
1196: file_handler_t file_handler[MAX_FILES];
1197: UINT8 file_buffer[0x100000];
1198:
1199: process_t process[MAX_PROCESS];
1.1.1.11 root 1200: dtainfo_t dtalist[MAX_DTAINFO];
1.1 root 1201:
1.1.1.6 root 1202: UINT16 malloc_strategy = 0;
1203:
1.1.1.12 root 1204: char comspec_path[MAX_PATH] = "C:\\COMMAND.COM";
1205:
1.1 root 1206: void msdos_syscall(unsigned num);
1207: int msdos_init(int argc, char *argv[], char *envp[], int standard_env);
1208: void msdos_finish();
1209:
1210: // console
1211:
1.1.1.12 root 1212: #define SCR_BUF_WIDTH 256
1213: #define SCR_BUF_HEIGHT 128
1.1 root 1214:
1215: #define SET_RECT(rect, l, t, r, b) { \
1216: rect.Left = l; \
1217: rect.Top = t; \
1218: rect.Right = r; \
1219: rect.Bottom = b; \
1220: }
1221:
1.1.1.19 root 1222: DWORD dwConsoleMode = 0;
1223:
1.1.1.46 root 1224: CONSOLE_CURSOR_INFO ci_old;
1225: CONSOLE_CURSOR_INFO ci_new;
1.1.1.48 root 1226: int font_width = 10;
1227: int font_height = 18;
1.1.1.46 root 1228:
1.1.1.12 root 1229: CHAR_INFO scr_buf[SCR_BUF_WIDTH * SCR_BUF_HEIGHT];
1230: char scr_char[SCR_BUF_WIDTH * SCR_BUF_HEIGHT];
1231: WORD scr_attr[SCR_BUF_WIDTH * SCR_BUF_HEIGHT];
1.1 root 1232: COORD scr_buf_size;
1233: COORD scr_buf_pos;
1234: int scr_width, scr_height;
1.1.1.12 root 1235: int scr_top;
1.1.1.10 root 1236: bool restore_console_on_exit = false;
1.1 root 1237: bool cursor_moved;
1.1.1.46 root 1238: bool cursor_moved_by_crtc;
1.1 root 1239:
1.1.1.22 root 1240: FIFO *key_buf_char = NULL;
1241: FIFO *key_buf_scan = NULL;
1.1.1.44 root 1242: FIFO *key_buf_data = NULL;
1.1.1.19 root 1243: bool key_changed = false;
1.1.1.4 root 1244: UINT32 key_code = 0;
1.1.1.27 root 1245: UINT32 key_recv = 0;
1.1 root 1246:
1.1.1.43 root 1247: bool pcbios_is_key_buffer_empty();
1.1.1.40 root 1248: void pcbios_clear_key_buffer();
1249: void pcbios_set_key_buffer(int key_char, int key_scan);
1250: bool pcbios_get_key_buffer(int *key_char, int *key_scan);
1251:
1.1.1.27 root 1252: UINT8 ctrl_break_checking = 0x00; // ???
1253: bool ctrl_break_detected = false;
1254: bool ctrl_break_pressed = false;
1.1.1.21 root 1255: bool ctrl_c_pressed = false;
1.1.1.27 root 1256: bool raise_int_1bh = false;
1.1.1.21 root 1257:
1.1 root 1258: int active_code_page;
1259: int system_code_page;
1.1.1.26 root 1260: int console_code_page;
1.1 root 1261:
1.1.1.12 root 1262: UINT32 text_vram_top_address;
1263: UINT32 text_vram_end_address;
1264: UINT32 shadow_buffer_top_address;
1265: UINT32 shadow_buffer_end_address;
1.1.1.40 root 1266: UINT32 cursor_position_address;
1.1.1.12 root 1267: int vram_pages;
1.1 root 1268: bool int_10h_feh_called = false;
1269: bool int_10h_ffh_called = false;
1270:
1.1.1.28 root 1271: #define MAX_MOUSE_BUTTONS 2
1.1.1.19 root 1272:
1.1.1.21 root 1273: typedef struct {
1.1.1.28 root 1274: bool enabled; // from DOSBox
1.1.1.46 root 1275: bool enabled_ps2;
1.1.1.28 root 1276: int hidden;
1277: int old_hidden; // from DOSBox
1.1.1.19 root 1278: struct {
1279: int x, y;
1280: } position, prev_position, max_position, min_position, mickey;
1281: struct {
1282: bool status;
1283: int pressed_times;
1284: int released_times;
1285: struct {
1286: int x, y;
1287: } pressed_position;
1288: struct {
1289: int x, y;
1290: } released_position;
1291: } buttons[MAX_MOUSE_BUTTONS];
1292: int get_buttons()
1293: {
1294: int val = 0;
1295: for(int i = 0; i < MAX_MOUSE_BUTTONS; i++) {
1296: if(buttons[i].status) {
1297: val |= 1 << i;
1298: }
1299: }
1300: return(val);
1301: }
1.1.1.33 root 1302: UINT16 status, status_alt;
1.1.1.42 root 1303: UINT16 status_irq, status_irq_alt, status_irq_ps2;
1.1.1.19 root 1304: UINT16 call_mask;
1.1.1.42 root 1305: PAIR32 call_addr, call_addr_alt[8], call_addr_ps2;
1.1.1.19 root 1306: // dummy
1307: UINT16 sensitivity[3];
1308: UINT16 display_page;
1309: UINT16 language;
1310: UINT16 hot_spot[2];
1.1.1.38 root 1311: UINT16 screen_mask;
1312: UINT16 cursor_mask;
1.1.1.21 root 1313: } mouse_t;
1314:
1315: mouse_t mouse;
1.1.1.19 root 1316:
1317: UINT16 mouse_push_ax;
1318: UINT16 mouse_push_bx;
1319: UINT16 mouse_push_cx;
1320: UINT16 mouse_push_dx;
1321: UINT16 mouse_push_si;
1322: UINT16 mouse_push_di;
1323:
1.1.1.23 root 1324: // hma
1325:
1326: #ifdef SUPPORT_HMA
1327: bool is_hma_used_by_xms = false;
1328: bool is_hma_used_by_int_2fh = false;
1329: #endif
1330:
1331: // xms
1332:
1333: #ifdef SUPPORT_XMS
1.1.1.24 root 1334: typedef struct emb_handle_s {
1335: UINT32 handle; // 0=allocated
1336: offs_t address;
1.1.1.23 root 1337: int size_kb;
1338: int lock;
1.1.1.24 root 1339: struct emb_handle_s *prev;
1340: struct emb_handle_s *next;
1341: } emb_handle_t;
1.1.1.23 root 1342:
1.1.1.24 root 1343: emb_handle_t *emb_handle_top = NULL;
1.1.1.23 root 1344: int xms_a20_local_enb_count;
1345: UINT16 xms_dx_after_call_08h = 0;
1.1.1.26 root 1346:
1347: void msdos_xms_init();
1348: void msdos_xms_finish();
1349: void msdos_xms_release();
1350: emb_handle_t *msdos_xms_get_emb_handle(int handle);
1351: int msdos_xms_get_unused_emb_handle_id();
1352: int msdos_xms_get_unused_emb_handle_count();
1353: void msdos_xms_split_emb_handle(emb_handle_t *emb_handle, int size_kb);
1354: void msdos_xms_combine_emb_handles(emb_handle_t *emb_handle);
1355: emb_handle_t *msdos_xms_alloc_emb_handle(int size_kb);
1356: void msdos_xms_free_emb_handle(emb_handle_t *emb_handle);
1.1.1.23 root 1357: #endif
1358:
1.1 root 1359: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.