File: port.h

package info (click to toggle)
fte 0.50.2b6-20110708-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 3,768 kB
  • ctags: 6,761
  • sloc: cpp: 47,985; ansic: 2,795; sh: 112; makefile: 71; perl: 29
file content (287 lines) | stat: -rw-r--r-- 8,065 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#ifndef PORT_PORT_H
#define PORT_PORT_H

#ifdef	__cplusplus
extern "C" {
#endif

#ifndef ULONG
#	define	ULONG	unsigned long
#endif

#ifndef UWORD
#	define	UWORD	unsigned short
#endif

#ifndef UBYTE
#	define	UBYTE	unsigned char
#endif

#ifndef boolean
#	define	boolean int
#endif

#ifndef FALSE
#	define	FALSE	0
#endif

#ifndef TRUE
#	define	TRUE	1
#endif



/*--------------------------------------------------------------------------*/
/*	STRUCTURES: dosxEreg is a union containing all extended registers..	*/
/*--------------------------------------------------------------------------*/
#if defined(__32BIT__)
 #define PORT_FILLER(a) unsigned short a;
#else
 #define PORT_FILLER(a)
#endif

struct dosxEreg {
	unsigned long	eax, ebx, ecx, edx, ebp, esi, edi;
	unsigned short	ds, es, fs, gs;
	unsigned long	flags;
};

struct dosxBreg {
	unsigned char al, ah;	PORT_FILLER(_1)
	unsigned char bl, bh;	PORT_FILLER(_2)
	unsigned char cl, ch;	PORT_FILLER(_3)
	unsigned char dl, dh;	PORT_FILLER(_4)
};

struct dosxWreg {
	unsigned short ax;	PORT_FILLER(_1)
	unsigned short bx;	PORT_FILLER(_2)
	unsigned short cx;	PORT_FILLER(_3)
	unsigned short dx;	PORT_FILLER(_4)
	unsigned short bp;	PORT_FILLER(_5)
	unsigned short si;	PORT_FILLER(_6)
	unsigned short di;	PORT_FILLER(_7)
	unsigned short ds;
	unsigned short es;
	unsigned short fs;
	unsigned short gs;
	unsigned long	flags;
};

/*--------------------------------------------------------------------------*/
/*	STRUCTURES: dosxReg contains all usable registers.						*/
/*--------------------------------------------------------------------------*/
union dosxReg {
	struct dosxBreg 	h;
	struct dosxWreg 	w;
	struct dosxEreg 	x;
};


/*--------------------------------------------------------------------------*/
/*	DEFINES:	PLRF_* defines are the processor flags. 					*/
/*--------------------------------------------------------------------------*/
#define PLCPUF_C	0x0001	// Carry flag
#define PLCPUF_P	0x0004	// Parity
#define PLCPUF_A	0x0010	// Auxiliary carry
#define PLCPUF_Z	0x0040	// Zero flag,
#define PLCPUF_S	0x0080	// Sign flag
#define PLCPUF_T	0x0100	// Trace flag
#define PLCPUF_I	0x0200	// Interrupt
#define PLCPUF_D	0x0400	// Direction
#define PLCPUF_O	0x0800	// Overflow.


/*--------------------------------------------------------------------------*/
/*	DEFINES:	plFnsplit() defines.										*/
/*--------------------------------------------------------------------------*/
#define PL_WILDCARDS	0x01
#define PL_EXTENSION	0x02
#define PL_FILENAME	0x04
#define PL_DIRECTORY	0x08
#define PL_DRIVE		0x10

/*--------------------------------------------------------------------------*/
/*	DEFINES:	File attributes.											*/
/*--------------------------------------------------------------------------*/
#define PLFA_NORMAL	0x00		/* Normal file, no attributes */
#define PLFA_RDONLY	0x01		/* Read only attribute */
#define PLFA_HIDDEN	0x02		/* Hidden file */
#define PLFA_SYSTEM	0x04		/* System file */
#define PLFA_LABEL		0x08		/* Volume label */
#define PLFA_DIREC		0x10		/* Directory */
#define PLFA_ARCH		0x20		/* Archive */


/*--------------------------------------------------------------------------*/
/*	STRUCTURES: plFTime holds date/time for a file (plGetftime()).			*/
/*--------------------------------------------------------------------------*/
struct plFTime
{
	unsigned	ft_tsec  : 5;	// Two second interval
	unsigned	ft_min	 : 6;	// Minute
	unsigned	ft_hour  : 5;	// Hour
	unsigned	ft_day	 : 5;	// Day
	unsigned	ft_month : 4;	// Month
	unsigned	ft_year  : 7;	// Year
};


/*--------------------------------------------------------------------------*/
/*	STRUCTURES: plDFree holds "disk free space" info for plGetdfree().     
*/
/*--------------------------------------------------------------------------*/
struct plDFree
{
	unsigned	df_avail;
	unsigned	df_total;
	unsigned	df_bsec;
	unsigned	df_sclus;
};


/*--------------------------------------------------------------------------*/
/*	DEFINES:	plLocking() mode flags...									*/
/*--------------------------------------------------------------------------*/
#define PL_LK_UNLCK	0		// unlock the file region
#define PL_LK_LOCK		1		// lock the file region
#define PL_LK_NBLCK	2		// non-blocking lock
#define PL_LK_RLCK		3		// lock for writing
#define PL_LK_NBRLCK	4		// non-blocking lock for writing



//** Hardware interface: DOS & extended DOS only!!
void	dosxIntr(int inr, union dosxReg* r);

void	dosxMemRead(void* dest, ULONG ra, unsigned nbytes);
void	dosxMemWrite(ULONG ra, void* src, unsigned nbytes);
void	dosxPMemRead(void* dest, ULONG pa, unsigned nbytes);
void	dosxPMemWrite(ULONG pa, void* src, unsigned nbytes);

void	dosxDisable(void);
void	dosxEnable(void);

//** Disk stuff..
int	plGetdisk(void);
int	plSetdisk(int dnr);
int	plGetcurdir(int drive, char *dir);

//** Misc..
char	*plSearchpath(char *name);
int	plFnsplit(const char *pathp, char *drivep, char *dirp, char *namep,
char *extp); void	plFnmerge(char *out, char *drive, char *dir, char *name,
char *ext);


/****************************************************************************/
/*																			*/
/*	Hardware portability calls.											*/
/*																			*/
/****************************************************************************/

//** Mouse calls
//** ===========
boolean MOUSInit(void);
void	MOUSExit(void);
void	MOUSCursen(boolean enable);
void	MOUSPos(UWORD *x, UWORD *y, boolean *leftbutton, boolean
*rightbutton); void	MOUSSetpos(UWORD x, UWORD y);
void	MOUSSetTextCursor(UWORD screenmask, UWORD cursormask);
void	MOUSSaveCurs(void);
void	MOUSRestCurs(void);
boolean MOUSIsPresent(void);
ULONG	MOUSPressCount(void);

//** Timer calls
//** ===========
int			plTiAlloc(unsigned long cnt);
void			plTiSet(int t, unsigned long cnt);
void			plTiFree(int t);
unsigned long	plTiQValue(int t);

//** Thread/task based.
//** ==================
void			plDelay(unsigned int msecs);
unsigned long	plTmGet(void);					// Avoid using this.
void			plCpuRelease(void);


//** Thread interface!
//** =================
int plThrdStart(void (*exfn)(void*), unsigned long stksz, void* args);


//** FTE specific.
int fnmatch(char* pat, char* in, int vv);


#ifdef DOSP32

/*--------------------------------------------------------------------------*/
/*  ENUM:   ePlScnType defines a screen type.				    */
/*--------------------------------------------------------------------------*/
enum ePlScnType
{
	plsctUnknown,
	plsctMono,		    // Monochrome adapter / unknown type,
	plsctCGA,		    // Color graphics adapter
	plsctEGA,		    // EGA adapter,
	plsctVGA,		    // VGA adapter,
	plsctLast
};


//** Informational functions,
enum ePlScnType plScnType(void);
boolean 		plScnIsMono(void);
int			plScnWidth(void);
int			plScnHeight(void);
void			plScnCursorShapeGet(int* sp, int* ep);
void			plScnCursorPosGet(int* xp, int* yp);


//** Change parameters e.a.
void	plScnSetFlash(boolean on);
void	plScnCursorOn(boolean on);
void	plScnCursorShape(int start, int end);
void	plScnCursorPos(int x, int y);


//** Writing the screen.
void	plScnWrite(unsigned x, unsigned y, unsigned short* buf, unsigned nch);
void	plScnRead(unsigned x, unsigned y, unsigned short* buf, unsigned nch);
void	plScnSetCell(unsigned x, unsigned y, unsigned wid, unsigned hig, UWORD cell);
void	plScnScrollDown(int x, int y, int ex, int ey, int nlines, UWORD fill);
void	plScnScrollUp(int x, int y, int ex, int ey, int nlines, UWORD fill);


/****************************************************************************/
/*																			*/
/*  Keyboard interface..						    */
/*																			*/
/****************************************************************************/
struct plKbdInfo
{
	UBYTE	ki_scan;
	UBYTE	ki_ascii;
	ULONG	ki_flags;	    // PLKF_ defines, above;
};

#define PLKF_SHIFT		0x0001
#define PLKF_CTRL		0x0002
#define PLKF_ALT		0x0004
#define PLKF_SCROLLLOCK 	0x0008
#define PLKF_NUMLOCK		0x0010
#define PLKF_CAPSLOCK		0x0020


boolean plKbdReadF(struct plKbdInfo* ki);

#endif // DOSP32

#ifdef	__cplusplus
};
#endif

#endif // PORT_PORT_H