--- Frodo4/Src/1541t64.h 2003/07/01 17:51:17 1.2 +++ Frodo4/Src/1541t64.h 2004/01/14 16:54:46 1.6 @@ -1,7 +1,7 @@ /* - * 1541t64.h - 1541 emulation in .t64/LYNX file + * 1541t64.h - 1541 emulation in archive-type files (.t64/LYNX/.p00) * - * Frodo (C) 1994-1997,2002-2003 Christian Bauer + * Frodo (C) 1994-1997,2002-2004 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,53 +24,61 @@ #include "IEC.h" -// Information for file inside a .t64 file -typedef struct { - char name[17]; // File name, PETSCII - uint8 type; // File type - uint8 sa_lo, sa_hi; // Start address - int offset; // Offset of first byte in .t64 file - int length; // Length of file -} FileInfo; +/* + * Definitions + */ +// Archive types +enum { + TYPE_T64, // C64S tape file + TYPE_LYNX, // C64 LYNX archive + TYPE_P00 // .p00 file +}; -class T64Drive : public Drive { +// Archive file drive class +class ArchDrive : public Drive { public: - T64Drive(IEC *iec, char *filepath); - virtual ~T64Drive(); - virtual uint8 Open(int channel, char *filename); + ArchDrive(IEC *iec, const char *filepath); + virtual ~ArchDrive(); + + virtual uint8 Open(int channel, const uint8 *name, int name_len); virtual uint8 Close(int channel); - virtual uint8 Read(int channel, uint8 *byte); + virtual uint8 Read(int channel, uint8 &byte); virtual uint8 Write(int channel, uint8 byte, bool eoi); virtual void Reset(void); private: - void open_close_t64_file(char *t64name); - bool parse_t64_file(void); - bool parse_lynx_file(void); - uint8 open_file(int channel, char *filename); - uint8 open_directory(int channel, char *filename); - void convert_filename(char *srcname, char *destname, int *filemode, int *filetype); - bool find_first_file(char *name, int type, int *num); + bool change_arch(const char *path); + + uint8 open_file(int channel, const uint8 *name, int name_len); + uint8 open_directory(int channel, const uint8 *pattern, int pattern_len); + bool find_first_file(const uint8 *pattern, int pattern_len, int &num); void close_all_channels(void); - void execute_command(char *command); - void cht64_cmd(char *t64path); - uint8 conv_from_64(uint8 c, bool map_slash); - FILE *the_file; // File pointer for .t64 file - bool is_lynx; // Flag: .t64 file is really a LYNX archive + virtual void rename_cmd(const uint8 *new_file, int new_file_len, const uint8 *old_file, int old_file_len); + virtual void initialize_cmd(void); + virtual void validate_cmd(void); + + FILE *the_file; // File pointer for archive file + int archive_type; // File/archive type (see defines above) + vector file_info; // Vector of file information structs for all files in the archive - char orig_t64_name[256]; // Original path of .t64 file char dir_title[16]; // Directory title FILE *file[16]; // File pointers for each of the 16 channels (all temporary files) - int num_files; // Number of files in .t64 file and in file_info array - FileInfo *file_info; // Pointer to array of file information structs for each file - - char cmd_buffer[44]; // Buffer for incoming command strings - int cmd_len; // Length of received command - uint8 read_char[16]; // Buffers for one-byte read-ahead }; + +/* + * Functions + */ + +// Check whether file with given header (64 bytes) and size looks like one +// of the file types supported by this module +extern bool IsArchFile(const char *path, const uint8 *header, long size); + +// Read directory of archive file into (empty) c64_dir_entry vector +extern bool ReadArchDirectory(const char *path, vector &vec); + #endif