-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdiskimage.h
89 lines (76 loc) · 2.12 KB
/
diskimage.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
typedef enum imagetype {
D64 = 1,
D71,
D81
} ImageType;
typedef enum filetype {
T_DEL = 0,
T_SEQ,
T_PRG,
T_USR,
T_REL,
T_CBM,
T_DIR
} FileType;
typedef struct ts {
unsigned char track;
unsigned char sector;
} TrackSector;
typedef struct diskimage {
char *filename;
int size;
ImageType type;
unsigned char *image;
TrackSector bam;
TrackSector bam2;
TrackSector dir;
int openfiles;
int blocksfree;
int modified;
int status;
TrackSector statusts;
} DiskImage;
typedef struct rawdirentry {
TrackSector nextts;
unsigned char type;
TrackSector startts;
unsigned char rawname[16];
TrackSector relsidets;
unsigned char relrecsize;
unsigned char unused[4];
TrackSector replacetemp;
unsigned char sizelo;
unsigned char sizehi;
} RawDirEntry;
typedef struct imagefile {
DiskImage *diskimage;
RawDirEntry *rawdirentry;
char mode;
int position;
TrackSector ts;
TrackSector nextts;
unsigned char *buffer;
int bufptr;
int buflen;
} ImageFile;
DiskImage *di_load_image(char *name);
DiskImage *di_create_image(char *name, int size);
void di_free_image(DiskImage *di);
void di_sync(DiskImage *di);
int di_status(DiskImage *di, char *status);
ImageFile *di_open(DiskImage *di, unsigned char *rawname, FileType type, char *mode);
void di_close(ImageFile *imgfile);
int di_read(ImageFile *imgfile, unsigned char *buffer, int len);
int di_write(ImageFile *imgfile, unsigned char *buffer, int len);
int di_format(DiskImage *di, unsigned char *rawname, unsigned char *rawid);
int di_delete(DiskImage *di, unsigned char *rawpattern, FileType type);
int di_rename(DiskImage *di, unsigned char *oldrawname, unsigned char *newrawname, FileType type);
int di_sectors_per_track(ImageType type, int track);
int di_tracks(ImageType type);
unsigned char *di_title(DiskImage *di);
int di_track_blocks_free(DiskImage *di, int track);
int di_is_ts_free(DiskImage *di, TrackSector ts);
void di_alloc_ts(DiskImage *di, TrackSector ts);
void di_free_ts(DiskImage *di, TrackSector ts);
int di_rawname_from_name(unsigned char *rawname, char *name);
int di_name_from_rawname(char *name, unsigned char *rawname);