1 |
|
/* |
2 |
< |
* 1541t64.h - 1541 emulation in .t64/LYNX file |
2 |
> |
* 1541t64.h - 1541 emulation in archive-type files (.t64/LYNX/.p00) |
3 |
|
* |
4 |
< |
* Frodo (C) 1994-1997,2002-2003 Christian Bauer |
4 |
> |
* Frodo (C) 1994-1997,2002-2005 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
24 |
|
#include "IEC.h" |
25 |
|
|
26 |
|
|
27 |
< |
// Information for file inside a .t64 file |
28 |
< |
typedef struct { |
29 |
< |
uint8 name[17]; // File name, PETSCII |
30 |
< |
uint8 type; // File type |
31 |
< |
uint8 sa_lo, sa_hi; // Start address |
32 |
< |
int offset; // Offset of first byte in .t64 file |
33 |
< |
int length; // Length of file |
34 |
< |
} FileInfo; |
27 |
> |
/* |
28 |
> |
* Definitions |
29 |
> |
*/ |
30 |
|
|
31 |
+ |
// Archive types |
32 |
+ |
enum { |
33 |
+ |
TYPE_T64, // C64S tape file |
34 |
+ |
TYPE_LYNX, // C64 LYNX archive |
35 |
+ |
TYPE_P00 // .p00 file |
36 |
+ |
}; |
37 |
|
|
38 |
< |
class T64Drive : public Drive { |
38 |
> |
// Archive file drive class |
39 |
> |
class ArchDrive : public Drive { |
40 |
|
public: |
41 |
< |
T64Drive(IEC *iec, char *filepath); |
42 |
< |
virtual ~T64Drive(); |
41 |
> |
ArchDrive(IEC *iec, const char *filepath); |
42 |
> |
virtual ~ArchDrive(); |
43 |
> |
|
44 |
|
virtual uint8 Open(int channel, const uint8 *name, int name_len); |
45 |
|
virtual uint8 Close(int channel); |
46 |
|
virtual uint8 Read(int channel, uint8 &byte); |
48 |
|
virtual void Reset(void); |
49 |
|
|
50 |
|
private: |
51 |
< |
void open_close_t64_file(char *t64name); |
49 |
< |
bool parse_t64_file(void); |
50 |
< |
bool parse_lynx_file(void); |
51 |
> |
bool change_arch(const char *path); |
52 |
|
|
53 |
|
uint8 open_file(int channel, const uint8 *name, int name_len); |
54 |
|
uint8 open_directory(int channel, const uint8 *pattern, int pattern_len); |
59 |
|
virtual void initialize_cmd(void); |
60 |
|
virtual void validate_cmd(void); |
61 |
|
|
62 |
< |
FILE *the_file; // File pointer for .t64 file |
63 |
< |
bool is_lynx; // Flag: .t64 file is really a LYNX archive |
62 |
> |
FILE *the_file; // File pointer for archive file |
63 |
> |
int archive_type; // File/archive type (see defines above) |
64 |
> |
vector<c64_dir_entry> file_info; // Vector of file information structs for all files in the archive |
65 |
|
|
64 |
– |
char orig_t64_name[256]; // Original path of .t64 file |
66 |
|
char dir_title[16]; // Directory title |
67 |
|
FILE *file[16]; // File pointers for each of the 16 channels (all temporary files) |
68 |
|
|
68 |
– |
int num_files; // Number of files in .t64 file and in file_info array |
69 |
– |
FileInfo *file_info; // Pointer to array of file information structs for each file |
70 |
– |
|
69 |
|
uint8 read_char[16]; // Buffers for one-byte read-ahead |
70 |
|
}; |
71 |
|
|
72 |
+ |
|
73 |
+ |
/* |
74 |
+ |
* Functions |
75 |
+ |
*/ |
76 |
+ |
|
77 |
+ |
// Check whether file with given header (64 bytes) and size looks like one |
78 |
+ |
// of the file types supported by this module |
79 |
+ |
extern bool IsArchFile(const char *path, const uint8 *header, long size); |
80 |
+ |
|
81 |
+ |
// Read directory of archive file into (empty) c64_dir_entry vector |
82 |
+ |
extern bool ReadArchDirectory(const char *path, vector<c64_dir_entry> &vec); |
83 |
+ |
|
84 |
|
#endif |