Debian Codegraph @

terps/c64diskimage/c64diskimage.h

raw symbols SCIP
1 /*
2 https://paradroid.automac.se/diskimage/
3
4 Copyright (c) 2003-2006, Per Olofsson
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8
9 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 */
13
14 #ifndef diskimage_h
15 #define diskimage_h
16
17 #include <stdlib.h>
18 #include <stdint.h>
19
20 /* constants for the supported disk formats */
21 #define MAXTRACKS 80
22 #define MAXSECTORS 40
23
24 #define D64SIZE 174848
25 #define D64ERRSIZE 175531
26 #define D71SIZE 349696
27 #define D71ERRSIZE 351062
28 #define D81SIZE 819200
29 #define D81ERRSIZE 822400
30
31 typedef enum imagetype { D64 = 1, D71, D81 } ImageType;
32
33 typedef enum filetype {
34 T_DEL = 0,
35 T_SEQ,
36 T_PRG = 0xc2,
37 T_USR,
38 T_REL,
39 T_CBM,
40 T_DIR
41 } FileType;
42
43 typedef struct ts {
44 unsigned char track;
45 unsigned char sector;
46 } TrackSector;
47
48 typedef struct diskimage {
49 char *filename;
50 int size;
51 ImageType type;
52 unsigned char *image;
53 unsigned char *errinfo;
54 TrackSector bam;
55 TrackSector bam2;
56 TrackSector dir;
57 int openfiles;
58 int blocksfree;
59 int modified;
60 int status;
61 int interleave;
62 TrackSector statusts;
63 } DiskImage;
64
65 typedef struct rawdirentry {
66 TrackSector nextts;
67 unsigned char type;
68 TrackSector startts;
69 unsigned char rawname[16];
70 TrackSector relsidets;
71 unsigned char relrecsize;
72 unsigned char unused[4];
73 TrackSector replacetemp;
74 unsigned char sizelo;
75 unsigned char sizehi;
76 } RawDirEntry;
77
78 typedef struct imagefile {
79 DiskImage *diskimage;
80 RawDirEntry *rawdirentry;
81 char mode;
82 int position;
83 TrackSector ts;
84 TrackSector nextts;
85 unsigned char *buffer;
86 int bufptr;
87 int buflen;
88 unsigned char visited[MAXTRACKS][MAXSECTORS];
89 } ImageFile;
90
91 ImageFile *di_open(DiskImage *di, unsigned char *rawname, FileType type,
92 char *mode);
93 ImageFile *di_create_file_from_ts(DiskImage *di, int track, int sector);
94 int di_read(ImageFile *imgfile, unsigned char *buffer, int len);
95 int di_rawname_from_name(unsigned char *rawname, const char *name);
96
97 RawDirEntry *find_largest_file_entry(DiskImage *di);
98 DiskImage *di_create_from_data(uint8_t *data, int length);
99
100 /* returns an array of strings containing all file names */
101 char **get_all_file_names(DiskImage *di, int *numfiles);
102
103 #endif /* diskimage_h */