aboutsummaryrefslogtreecommitdiff
path: root/ksiders/atdos.h
blob: 34849b62a4d3b67c6027ba070042687adde60913 (plain)
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
/* Copyright 1997 Ken Siders */

/* dos compatability types */
#define DOS_ATARI 1
#define DOS_MYDOS 2
#define DOS_SPARTADOS 3
#define DOS_LJK 4

#define MAX_ATARI_FILES 64

/* disk format types */
#define FORMAT_SD 1
#define FORMAT_ED 2
#define FORMAT_DD 3
#define FORMAT_SD_CUSTOM 4
#define FORMAT_DD_CUSTOM 5
#define FORMAT_DEFAULT 6

/* open modes */
#define ATARI_OPEN_READ 4
#define ATARI_OPEN_WRITE 8
#define ATARI_OPEN_DIR 6

/* these will be in variables later */
#define firstDirSector 361
#define lastDirSector 368
#define vtocSector 360
#define vtocSector2 0
#define dirEntrySize 16
#define dirEntriesPerSector 8

#define DELETED_FLAG    0x80
#define INUSE_FLAG      0x40
#define LOCKED_FLAG     0x20
#define MYDOSDIR_FLAG   0x10
#define OPENOUTPUT_FLAG 0x01
#define DOS25EXT_FLAGS  0x03

struct S_AtariDosDirEntry
   {
   char flag;
   unsigned short sectorCount;
   unsigned short startSector;
   char fileName[8];
   char extender[3];
   };

typedef struct S_AtariDosDirEntry AtariDosDirEntry;
typedef AtariDosDirEntry *AtariDosDirEntryPtr;

/* 20070518 bkw:
	Nothing actually uses this struct, and it's got endianness
	issues... */
#if 0
struct S_AtariDosLink
   {
   int fileNo:6;
   int nextSector:10;
   int shortSector:1;
   int bytesInSector:7;

   };

typedef struct S_AtariDosLink AtariDosLink;
typedef AtariDosLink *AtariDosLinkPtr;
#endif

struct S_AtariVtoc
   {
   byte reserved[10];
   byte vtoc[118];
   };




struct S_AtariFile
   {
   AtrFilePtr atr;
   unsigned short startSector;
   unsigned short currentSector;
   unsigned short sectorSize;
   unsigned short numberOfSectors;  /* no. of sectors in file */
   unsigned long fileSize ; /* not used yet */
   byte openFlag;
   byte eofFlag;
   short currentOffset;
   short bytesData;
   short sectorLinkOffset;
   short fileNo;
   unsigned char sectorBuffer[256];

   };

typedef struct S_AtariFile AtariFile;
typedef AtariFile * AtariFilePtr;




struct S_AtariFileInfo
   {
   unsigned long fileSize; /* not implemented */
   unsigned short startSector;
   unsigned short sectorCount;
   char fileName[13];
   int locked;
   int attrib;        /* internal */
   int dirSector;     /* internal */
   int dirEntry;      /* internal */
   char *pattern;     /* internal */
   char *atrName;     /* internal */
   int dosType;
   short fileNo;
   int flag;    /* from dos */
   };

typedef struct S_AtariFileInfo AtariFileInfo;
typedef AtariFileInfo *AtariFileInfoPtr;



/* function prototypes */

void MakeFileName( char *result, char *fileName, char *extender );
int PatternMatch( char *pattern, char *fileName, char *extender);
int AtariFindFirst( char *atrName, unsigned attrib,
    char *pattern, AtariFileInfoPtr fileInfo );
int AtariFindNext( AtariFileInfoPtr fileInfo );
AtariFilePtr OpenAtariFile( char *atrName, char *fileName, byte mode);
int AtariDirectory( char *atrName, char *pattern);
long ReadAtariFile( AtariFilePtr atFile, char *buffer, long bytes );
int CloseAtariFile( AtariFilePtr atFile );
int EofAtariFile( AtariFilePtr atFile );
long AtariFileSize( char *atrFile, char *fileName );
int FixAtariFileNo( char *atrName, char *fileName, int fileNo );