1 /*======================================================================
2 portable.h v1.00 Written by Scott Robert Ladd.
4 _MSC_VER Microsoft C 6.0 and later
5 _QC Microsoft Quick C 2.51 and later
6 __TURBOC__ Borland Turbo C and Turbo C++
7 __ZTC_ Zortech C and C++
9 =========================================================================*/
11 /* prevent multiple inclusions of this header file*/
12 #if !defined(PORTABLE_H)
15 /*-----------------------------------------------------------------------
16 Pointer-related macros
18 MK_FP creates a far pointer from segment and offset values
19 ------------------------------------------------------------------------*/
22 #define MK_FP(seg,off) ((void far *)(((long)(seg) << 16)|(unsigned)(off)))
25 /*-----------------------------------------------------------------------
26 Directory search macros and data structures
28 DOSFileData MS-DOS file data structure
29 FIND_FIRST MS-DOS function 0x4E -- find first file matching spec
30 FIND_NEXT MS-DOS function 0x4F -- find subsequent files
31 -----------------------------------------------------------------------*/
33 /* make sure the structure is packed on byte boundary */
34 #if defined(_MSC_VER) || defined(_QC) || defined(__WATCOMC__)
36 #elif defined(__ZTC__)
38 #elif defined(__TURBOC__)
42 /* use this structure in place of compiler-defined file structure */
54 /* set structure alignment to default */
55 #if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC__)
57 #elif defined(__ZTC__)
59 #elif defined(__TURBOC__)
63 /* include proper header files and create macros */
64 #if defined(_MSC_VER) || defined(_QC) || defined(__WATCOMC__)
66 #define FIND_FIRST(spec, attr, buf) \
67 _dos_findfirst(spec, attr, (struct find_t *)buf) \
68 #define FIND_NEXT(buf) _dos_findnex((struct find_t *)buf)
69 #elif defined(__TURBOC__)
71 #define FIND_FIRST(spec, attr, buf)\
72 findfirst(spec, (struct ffblk *)buf, attr)
73 #define FIND_NEXT(buf) findnext((struct ffblk *)buf)
74 #elif defined(__ZTC__)
76 #define FIND_FIRST(spec, attr, buf) \
77 dos_findfirst(spec, attr, (struct DOS_FIND *)buf)
78 #define FIND_NEXT(buf) dos_findnext((struct DOS_FIND *)buf)
81 /*-----------------------------------------------------------------------
84 IN_PORT read byte from I/O port
85 IN_PORTW read word from I/O port
86 OUT_PORT write byte to I/O port
87 OUT_PORTW write word to I/O port
88 -----------------------------------------------------------------------*/
90 #if defined(__TURBOC__)
92 #define IN_PORT(port) inportb(port)
93 #define IN_PORTW(port) inport(port)
94 #define OUT_PORT(port,val) noutportb(port,val)
95 #define OUT_PORTW(port,val) outport(port,val)
99 #define IN_PORT(port) inp(port)
100 #define IN_PORTW(port) inpw(port)
101 #define OUT_PORT(port,val) outp(port,val)
102 #define OUT_PORTW(port,val) outpw(port,val)
105 /*-----------------------------------------------------------------------
106 Borland psuedo register macros
108 These macros replace references to Borland's psuedo register
109 variables and geninterrupt() function with traditional struct
110 REGS/int86 references.
111 -----------------------------------------------------------------------*/
113 #if !defined(__TURBOC__)
118 #define _AX CPURegs.x.ax
119 #define _BX CPURegs.x.bx
120 #define _CX CPURegs.x.cx
121 #define _DX CPURegs.x.dx
123 #define _AH CPURegs.h.ah
124 #define _AL CPURegs.h.al
125 #define _BH CPURegs.h.bh
126 #define _BL CPURegs.h.bl
127 #define _CH CPURegs.h.ch
128 #define _CL CPURegs.h.cl
129 #define _DH CPURegs.h.dh
130 #define _DL CPURegs.h.dl
132 #define geninterrupt(n) int86(n,&CPURegs,&CPURegs);