-
Notifications
You must be signed in to change notification settings - Fork 6
/
IO.H
154 lines (133 loc) · 4.8 KB
/
IO.H
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
#ifndef _IO_H_
#define _IO_H_
/* header file for MSX-DOS I/O routines for Z-80 C */
/* get basic definitions */
#define MAXFILE 8 /* max number of files open */
char bdos(int, ...);
short bdoshl(int, ...); /* bdos call returning value in hl */
unsigned char msx_bdos(unsigned int,...); /* bdos call returning value in a */
unsigned short msx_bdosh(unsigned int,...); /* bdos call returning value in hl */
#ifdef DOS2ONLY
/* FCB controls not required on MSX-DOS2 */
#else
/* for CP/M & MSX-DOS */
#define SECSIZE 128 /* no. of bytes per sector */
struct fcb
{
/* 13 Bytes */
unsigned char dr; /* drive code */
char name[8]; /* file name */
char ft[3]; /* file type */
unsigned char ex; /* file extent */
/* 19 Bytes */
char fil; /* not used */
unsigned int recsiz; /* record size */
long filesize;
unsigned short fcbdate;
unsigned short fcbtime;
char dm[8]; /* CP/M disk map */
/* 10 Bytes */
char nr; /* next record to read or write */
unsigned char ranrec[3]; /* CP/M random record number (24 bit no. ) */
long rwp; /* read/write pointer in bytes */
unsigned char use; /* use flag */
unsigned char uid; /* user id belonging to this file */
};
extern struct fcb _fcb[MAXFILE];
struct fcb * getfcb(void);
unsigned char getuid(void);
void setuid(int);
unsigned char setfcb(struct fcb *, char *);
/* flag values in fcb.use */
#define U_READ 1 /* file open for reading */
#define U_WRITE 2 /* file open for writing */
#define U_RDWR 3 /* open for read and write */
#define U_CON 4 /* device is console */
#define U_RDR 5 /* device is reader */
#define U_PUN 6 /* device is punch */
#define U_LST 7 /* list device */
/* special character values */
#define CPMETX 032 /* ctrl-Z, CP/M end of file for text */
#define CPMRBT 003 /* ctrl-C, reboot CPM */
#define MPM 0x100 /* bit to test for MP/M */
#define CCPM 0x400 /* bit to test for CCP/M */
#define ISMPM() (bdoshl(CPMVERS)&MPM) /* macro to test for MPM */
/* what to do after you hit return */
#define EXIT (*(int (*)())0) /* where to go to reboot CP/M */
/* BDOS calls */
#define CPMRCON 1 /* read console */
#define CPMWCON 2 /* write console */
#define CPMRRDR 3 /* read reader */
#define CPMWPUN 4 /* write punch */
#define CPMWLST 5 /* write list */
#define CPMDCIO 6 /* direct console I/O */
#define CPMGIOB 7 /* get I/O byte */
#define CPMSIOB 8 /* set I/O byte */
#define CPMRCOB 10 /* read console buffered */
#define CPMICON 11 /* interrogate console ready */
#define CPMVERS 12 /* return version number */
#define CPMRDS 13 /* reset disk system */
#define CPMLGIN 14 /* log in and select disk */
#define CPMOPN 15 /* open file */
#define CPMCLS 16 /* close file */
#define CPMFFST 17 /* find first */
#define CPMFNXT 18 /* find next */
#define CPMDEL 19 /* delete file */
#define CPMREAD 20 /* read next record */
#define CPMWRIT 21 /* write next record */
#define CPMMAKE 22 /* create file */
#define CPMREN 23 /* rename file */
#define CPMILOG 24 /* get bit map of logged in disks */
#define CPMIDRV 25 /* interrogate drive number */
#define CPMSDMA 26 /* set DMA address for i/o */
#define CPMSUID 32 /* set/get user id */
#define CPMRRAN 33 /* read random record */
#define CPMWRAN 34 /* write random record */
#define CPMCFS 35 /* compute file size */
#endif /* DOS2ONLY */
/* first 64bytes of struct fileinfo is equal with DOS2 file infoblock */
struct fileinfo
{
unsigned char ff; /* Always 0xFF */
unsigned char name[13]; /* File name with extension */
unsigned char attr;
unsigned int time;
unsigned int date;
unsigned int cl;
unsigned long size; /* Upto 4GB */
unsigned char drive; /* Logical drive A=1, B=2, ...Default=0 */
unsigned char internal[38]; /* Should not be touched! */
#ifdef DOS2ONLY
#else
struct fcb tfcb;
#endif
};
int findfirst(char *path, unsigned int attr, struct fileinfo *pfi);
int findnext(struct fileinfo *pfi);
unsigned setfileattr(char *path, unsigned int attr);
/*
* Declarations for Unix style low-level I/O functions.
*/
int open(char *, int);
int close(int);
int creat(char *,...); /* Creat for writing only */
int dup(int);
long lseek(int, long, int);
int read(int, void *, unsigned short);
int unlink(char *);
#define remove(f) unlink(f)
int write(int, void *, unsigned short);
int isatty(int);
int chmod(char *, int);
int rename(char *,char *);
int move(char *,char *);
int delete(char *);
int mkdir(char *);
void setattr(char *, unsigned char);
unsigned char getattr(char *);
#define O_RDONLY 0x00 /* Open for reading only */
#define O_WRONLY 0x01 /* Open for writing only */
#define O_RDWR 0x02 /* Open for reading and writing */
/* Additional Function for MSX only */
#define DOSVER (*(char *)0xf313) /* MSX: 0=DOS1 */
#endif /* _IO_H_ */