OSDN Git Service

fixed an issue of bakapi.exe while in pan mode you cannot escape until you press...
[proj16/16.git] / 16 / portable.h
1 /*============================================================================\r
2 \r
3     portable.h   v1.00      Written by Scott Robert Ladd.\r
4 \r
5     _MSC_VER        Microsoft C 6.0 and later\r
6     _QC             Microsoft Quick C 2.51 and later\r
7     __TURBOC__      Borland Turbo C, Turbo C++, and Borland C++\r
8     __BORLANDC__    Borland C++\r
9     __ZTC__         Zortech C++ and Symantec C++\r
10     __SC__          Symantec C++\r
11     __WATCOM__      WATCOM C\r
12     __POWERC        Mix Power C\r
13 \r
14     Revised:\r
15     09/14/93  Fred Cole  Moved MK_FP() macro to end of file to avoid\r
16                          redefinition error when dos.h gets included\r
17                          at the in/outport definitions for __TURBOC__\r
18     09/15/93  Thad Smith Add conditional code for TC 2.01\r
19                          Fix findfirst/findnext support for ZTC 3.0\r
20     10/15/93  Bob Stout  Revise find first/next support\r
21     04/03/94  Bob Stout  Add Power C support, FAR\r
22 ============================================================================*/\r
23 \r
24 \r
25 /* prevent multiple inclusions of this header file */\r
26 \r
27 #if !defined(PORTABLE_H)\r
28 #define PORTABLE_H\r
29 \r
30 /*\r
31 **  Correct far pointer syntax\r
32 */\r
33 \r
34 #if defined(__POWERC) || (defined(__TURBOC__) && !defined(__BORLANDC__))\r
35  #define FAR far\r
36 #else\r
37  #define FAR _far\r
38 #endif\r
39 \r
40 /*----------------------------------------------------------------------------\r
41     Directory search macros and data structures\r
42 \r
43     DOSFileData         MS-DOS file data structure\r
44     FIND_FIRST          MS-DOS function 0x4E -- find first file matchine spec\r
45     FIND_NEXT           MS-DOS function 0x4F -- find subsequent files\r
46 ----------------------------------------------------------------------------*/\r
47 \r
48 /* make sure the structure is packed on byte boundary */\r
49 \r
50 #if defined(_MSC_VER) || defined(_QC) || defined(__WATCOM__)\r
51     #pragma pack(1)\r
52 #elif defined(__ZTC__)\r
53     #pragma ZTC align 1\r
54 #elif defined(__TURBOC__) && (__TURBOC__ > 0x202)\r
55     #pragma option -a-\r
56 #endif\r
57 \r
58 /* use this structure in place of compiler-defined file structure */\r
59 \r
60 typedef struct {\r
61       char        reserved[21];\r
62       char        attrib;\r
63       unsigned    time;\r
64       unsigned    date;\r
65       long        size;\r
66       char        name[13];\r
67       } DOSFileData;\r
68 \r
69 /* set structure alignment to default */\r
70 \r
71 #if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC__)\r
72  #pragma pack()\r
73 #elif defined (__ZTC__)\r
74  #pragma ZTC align\r
75 #elif defined(__TURBOC__) && (__TURBOC__ > 0x202)\r
76  #pragma option -a.\r
77 #endif\r
78 \r
79 /* include proper header files and create macros */\r
80 \r
81 #if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC)\r
82  #include "direct.h"\r
83  #define FIND_FIRST(spec,attr,buf) _dos_findfirst(spec,attr,\\r
84        (struct find_t *)buf)\r
85  #define FIND_NEXT(buf) _dos_findnext((struct find_t *)buf)\r
86 #elif defined (__TURBOC__)\r
87  #include "dir.h"\r
88  #define FIND_FIRST(spec,attr,buf) findfirst(spec,(struct ffblk *)buf,attr)\r
89  #define FIND_NEXT(buf) findnext((struct ffblk *)buf)\r
90 #elif defined (__ZTC__)\r
91  #include "dos.h"\r
92  #define FIND_FIRST(spec,attr,buf) _dos_findfirst(spec,attr,\\r
93        (struct find_t *)buf)\r
94  #define FIND_NEXT(buf) _dos_findnext((struct find_t *)buf)\r
95 #endif\r
96 \r
97 /*----------------------------------------------------------------------------\r
98     I/O Port Macros\r
99 \r
100     IN_PORT     read byte from I/O port\r
101     IN_PORTW    read word from I/O port\r
102     OUT_PORT    write byte to I/O port\r
103     OUT_PORTW   write word to I/O port\r
104 ----------------------------------------------------------------------------*/\r
105 \r
106 #if defined(__TURBOC__)\r
107  #include "dos.h"\r
108  #define IN_PORT(port)           inportb(port)\r
109  #define IN_PORTW(port)          inport(port)\r
110  #define OUT_PORT(port, val)     outportb(port, val)\r
111  #define OUT_PORTW(port, val)    outport(port, val)\r
112 #else\r
113  #include "conio.h"\r
114 \r
115  #define IN_PORT(port)           inp(port)\r
116  #define IN_PORTW(port)          inpw(port)\r
117  #define OUT_PORT(port, val)     outp(port, val)\r
118  #define OUT_PORTW(port, val)    outpw(port, val)\r
119 \r
120 /*----------------------------------------------------------------------------\r
121     Borland pseudo register macros\r
122 \r
123     These macros replace references to Borland's pseudo register\r
124     variables and geninterrup() funciton with traditional struct\r
125     REGS/int86 references.\r
126 ----------------------------------------------------------------------------*/\r
127 \r
128 #if !defined(__TURBOC__)\r
129  #include "dos.h"\r
130 \r
131  extern union REGS CPURegs;\r
132 \r
133  #define _AX CPURegs.x.ax\r
134  #define _BX CPURegs.x.bx\r
135  #define _CX CPURegs.x.cx\r
136  #define _DX CPURegs.x.dx\r
137 \r
138  #define _AH CPURegs.h.ah\r
139  #define _AL CPURegs.h.al\r
140  #define _BH CPURegs.h.bh\r
141  #define _BL CPURegs.h.bl\r
142  #define _CH CPURegs.h.ch\r
143  #define _CL CPURegs.h.cl\r
144  #define _DH CPURegs.h.dh\r
145  #define _DL CPURegs.h.dl\r
146 \r
147  #define geninterrupt(n) int86(n,&CPURegs,&CPURegs);\r
148  #define O_DENYALL   0x10\r
149  #define O_DENYWRITE 0x20\r
150  #define O_DENYREAD  0x30\r
151  #define O_DENYNONE  0x40\r
152 #endif\r
153 \r
154 #endif\r
155 \r
156 /*----------------------------------------------------------------------------\r
157     Pointer-related macros\r
158 \r
159     MK_FP   creates a far pointer from segment and offset values\r
160 ----------------------------------------------------------------------------*/\r
161 \r
162 #if !defined(MK_FP)\r
163     #define MK_FP(seg,off) ((void FAR *)(((long)(seg) << 16)|(unsigned)(off)))\r
164 #endif\r
165 \r
166 #endif\r