aboutsummaryrefslogtreecommitdiff
path: root/ksiders/atr.h
blob: 53ca6be06d77c36eb181032a0359cdf93b282740 (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
/* Copyright 1997 Ken Siders */

#ifndef ATR_H_INCLUDED
#define ATR_H_INCLUDED

/* constants */
#define ATR_HEADER_SIZE 16


/* typedefs */
typedef unsigned char byte;


/* structure definitions */

struct S_HDR
{
byte idLow, idHigh;
byte paraLow, paraHigh;
byte secSizeLow, secSizeHigh;
byte paraHigher;
byte crc1, crc2, crc3, crc4;
byte unused1, unused2, unused3, unused4;
byte flags;
};

typedef struct S_HDR AtrHeader;

struct S_AtrFile {
   FILE *atrIn;
   unsigned long  imageSize;
   unsigned short secSize;
   unsigned long crc;
   unsigned long sectorCount;
   byte flags;
   byte writeProtect;
   byte authenticated;
   unsigned short currentSector;
   unsigned char dosType;
};

typedef struct S_AtrFile AtrFile;
typedef AtrFile *AtrFilePtr; 


/* function prototypes */
AtrFilePtr OpenAtr(char *file );

int CloseAtr( AtrFilePtr atr );
int ReadSector(AtrFilePtr atr, unsigned short sector, char *buffer);
int WriteSector(AtrFilePtr atr, unsigned short sector, char *buffer);
int CreateAtr( char *file, unsigned short sectors, 
               unsigned short sectorSize );
int GetAtrInfo( AtrFilePtr atr, unsigned short *sectorSize,
                unsigned short *sectorCount, byte  *protected);
int CreateBootAtr( char *atrName, char *fileName);
long ExtractExeFromBootAtr(char *, char *);

int SortAtariDir( char *atrName );
int SetVerbose( int verb );
int ExtractAtariFile( char *atrFile, char *fileName, char *dosPath );

#endif