Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

1541d64.h

Go to the documentation of this file.
00001 /*
00002  *  1541d64.h - 1541 emulation in .d64 file
00003  *
00004  *  Frodo (C) 1994-1997 Christian Bauer
00005  */
00006 
00007 #ifndef _1541D64_H
00008 #define _1541D64_H
00009 
00010 #include "IEC.h"
00011 
00012 
00013 // BAM structure
00014 typedef struct {
00015         uint8   dir_track;              // Track...
00016         uint8   dir_sector;             // ...and sector of first directory block
00017         int8    fmt_type;               // Format type
00018         int8    pad0;
00019         uint8   bitmap[4*35];   // Sector allocation
00020         uint8   disk_name[18];  // Disk name
00021         uint8   id[2];                  // Disk ID
00022         int8    pad1;
00023         uint8   fmt_char[2];    // Format characters
00024         int8    pad2[4];
00025         int8    pad3[85];
00026 } BAM;
00027 
00028 // Directory entry structure
00029 typedef struct {
00030         uint8   type;                   // File type
00031         uint8   track;                  // Track...
00032         uint8   sector;                 // ...and sector of first data block
00033         uint8   name[16];               // File name
00034         uint8   side_track;             // Track...
00035         uint8   side_sector;    // ...and sector of first side sector
00036         uint8   rec_len;                // Record length
00037         int8    pad0[4];
00038         uint8   ovr_track;              // Track...
00039         uint8   ovr_sector;             // ...and sector on overwrite
00040         uint8   num_blocks_l;   // Number of blocks, LSB
00041         uint8   num_blocks_h;   // Number of blocks, MSB
00042         int8    pad1[2];
00043 } DirEntry;
00044 
00045 // Directory block structure
00046 typedef struct {
00047         uint8           padding[2];             // Keep DirEntry word-aligned
00048         uint8           next_track;
00049         uint8           next_sector;
00050         DirEntry        entry[8];
00051 } Directory;
00052 
00053 
00054 class D64Drive : public Drive {
00055 public:
00056         D64Drive(IEC *iec, char *filepath);
00057         virtual ~D64Drive();
00058         virtual uint8 Open(int channel, char *filename);
00059         virtual uint8 Close(int channel);
00060         virtual uint8 Read(int channel, uint8 *byte);
00061         virtual uint8 Write(int channel, uint8 byte, bool eoi);
00062         virtual void Reset(void);
00063 
00064 private:
00065         void open_close_d64_file(char *d64name);
00066         uint8 open_file(int channel, char *filename);
00067         void convert_filename(char *srcname, char *destname, int *filemode, int *filetype);
00068         bool find_file(char *filename, int *track, int *sector);
00069         uint8 open_file_ts(int channel, int track, int sector);
00070         uint8 open_directory(char *pattern);
00071         uint8 open_direct(int channel, char *filename);
00072         void close_all_channels();
00073         void execute_command(char *command);
00074         void block_read_cmd(char *command);
00075         void buffer_ptr_cmd(char *command);
00076         bool parse_bcmd(char *cmd, int *arg1, int *arg2, int *arg3, int *arg4);
00077         void chd64_cmd(char *d64name);
00078         int alloc_buffer(int want);
00079         void free_buffer(int buf);
00080         bool read_sector(int track, int sector, uint8 *buffer);
00081         int offset_from_ts(int track, int sector);
00082         uint8 conv_from_64(uint8 c, bool map_slash);
00083 
00084         char orig_d64_name[256]; // Original path of .d64 file
00085 
00086         FILE *the_file;                 // File pointer for .d64 file
00087 
00088         uint8 *ram;                             // 2KB 1541 RAM
00089         BAM *bam;                               // Pointer to BAM
00090         Directory dir;                  // Buffer for directory blocks
00091 
00092         int chan_mode[16];              // Channel mode
00093         int chan_buf_num[16];   // Buffer number of channel (for direct access channels)
00094         uint8 *chan_buf[16];    // Pointer to buffer
00095         uint8 *buf_ptr[16];             // Pointer in buffer
00096         int buf_len[16];                // Remaining bytes in buffer
00097 
00098         bool buf_free[4];               // Buffer 0..3 free?
00099 
00100         char cmd_buffer[44];    // Buffer for incoming command strings
00101         int cmd_len;                    // Length of received command
00102 
00103         int image_header;               // Length of .d64 file header
00104 
00105         uint8 error_info[683];  // Sector error information (1 byte/sector)
00106 };
00107 
00108 #endif

Generated on Tue Feb 8 04:07:11 2005 for E32frodo by doxygen 1.3.3