--- Frodo4/Src/IEC.h 2004/01/11 14:03:29 1.4 +++ Frodo4/Src/IEC.h 2005/06/27 19:55:48 1.8 @@ -1,7 +1,7 @@ /* * IEC.h - IEC bus routines, 1541 emulation (DOS level) * - * Frodo (C) 1994-1997,2002-2003 Christian Bauer + * Frodo (C) 1994-1997,2002-2005 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 @@ -22,10 +22,13 @@ #define _IEC_H +/* + * Definitions + */ + // Maximum length of file names const int NAMEBUF_LENGTH = 256; - // C64 status codes enum { ST_OK = 0, // No error @@ -35,7 +38,6 @@ enum { ST_NOTPRESENT = 0x80 // Device not present }; - // 1541 error codes enum { ERR_OK, // 00 OK @@ -70,6 +72,11 @@ enum { ERR_NOTREADY // 74 DRIVE NOT READY }; +// Mountable file types +enum { + FILE_IMAGE, // Disk image, handled by ImageDrive + FILE_ARCH // Archive file, handled by ArchDrive +}; // 1541 file types enum { @@ -83,7 +90,6 @@ enum { static const char ftype_char[9] = "DSPUL "; - // 1541 file access modes enum { FMODE_READ, // Read @@ -92,24 +98,6 @@ enum { FMODE_M // Read open file }; - -// IEC command codes -enum { - CMD_DATA = 0x60, // Data transfer - CMD_CLOSE = 0xe0, // Close channel - CMD_OPEN = 0xf0 // Open channel -}; - - -// IEC ATN codes -enum { - ATN_LISTEN = 0x20, - ATN_UNLISTEN = 0x30, - ATN_TALK = 0x40, - ATN_UNTALK = 0x50 -}; - - // Drive LED states enum { DRVLED_OFF, // Inactive, LED off @@ -117,6 +105,26 @@ enum { DRVLED_ERROR // Error, blink LED }; +// Information about file in disk image/archive file +struct c64_dir_entry { + c64_dir_entry(const uint8 *n, int t, bool o, bool p, size_t s, off_t ofs = 0, uint8 sal = 0, uint8 sah = 0) + : type(t), is_open(o), is_protected(p), size(s), offset(ofs), sa_lo(sal), sa_hi(sah) + { + strncpy((char *)name, (const char *)n, 17); + name[16] = 0; + } + + // Basic information + uint8 name[17]; // File name (C64 charset, null-terminated) + int type; // File type (see defines above) + bool is_open; // Flag: file open + bool is_protected; // Flag: file protected + size_t size; // File size (may be approximated) + + // Special information + off_t offset; // Offset of file in archive file + uint8 sa_lo, sa_hi; // C64 start address +}; class Drive; class C64Display; @@ -142,6 +150,8 @@ public: void Release(void); private: + Drive *create_drive(const char *path); + uint8 listen(int device); uint8 talk(int device); uint8 unlisten(void); @@ -171,7 +181,6 @@ private: uint8 sec_addr; // Received secondary address ($0x) }; - // Abstract superclass for individual drives class Drive { public: @@ -224,16 +233,26 @@ private: }; +/* + * Functions + */ + // Convert ASCII character to PETSCII character -extern char ascii2petscii(char c); +extern uint8 ascii2petscii(char c); // Convert ASCII string to PETSCII string -extern void ascii2petscii(char *dest, const char *src, int max); +extern void ascii2petscii(uint8 *dest, const char *src, int max); // Convert PETSCII character to ASCII character extern char petscii2ascii(uint8 c); // Convert PETSCII string to ASCII string -extern void petscii2ascii(char *dest, const char *src, int max); +extern void petscii2ascii(char *dest, const uint8 *src, int max); + +// Check whether file is a mountable disk image or archive file, return type +extern bool IsMountableFile(const char *path, int &type); + +// Read directory of mountable disk image or archive file into c64_dir_entry vector +extern bool ReadDirectory(const char *path, int type, vector &vec); #endif