Annotation of msdos-player/source/msdos.h, revision 1.1.1.34

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.