ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/Frodo4/Src/1541d64.h
Revision: 1.3
Committed: 2004-01-11T00:09:51Z (20 years, 3 months ago) by cebix
Content type: text/plain
Branch: MAIN
Changes since 1.2: +13 -15 lines
Log Message:
some cleanups and refactoring

File Contents

# Content
1 /*
2 * 1541d64.h - 1541 emulation in .d64 file
3 *
4 * Frodo (C) 1994-1997,2002-2003 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
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #ifndef _1541D64_H
22 #define _1541D64_H
23
24 #include "IEC.h"
25
26
27 // BAM structure
28 typedef struct {
29 uint8 dir_track; // Track...
30 uint8 dir_sector; // ...and sector of first directory block
31 int8 fmt_type; // Format type
32 int8 pad0;
33 uint8 bitmap[4*35]; // Sector allocation
34 uint8 disk_name[18]; // Disk name
35 uint8 id[2]; // Disk ID
36 int8 pad1;
37 uint8 fmt_char[2]; // Format characters
38 int8 pad2[4];
39 int8 pad3[85];
40 } BAM;
41
42 // Directory entry structure
43 typedef struct {
44 uint8 type; // File type
45 uint8 track; // Track...
46 uint8 sector; // ...and sector of first data block
47 uint8 name[16]; // File name
48 uint8 side_track; // Track...
49 uint8 side_sector; // ...and sector of first side sector
50 uint8 rec_len; // Record length
51 int8 pad0[4];
52 uint8 ovr_track; // Track...
53 uint8 ovr_sector; // ...and sector on overwrite
54 uint8 num_blocks_l; // Number of blocks, LSB
55 uint8 num_blocks_h; // Number of blocks, MSB
56 int8 pad1[2];
57 } DirEntry;
58
59 // Directory block structure
60 typedef struct {
61 uint8 padding[2]; // Keep DirEntry word-aligned
62 uint8 next_track;
63 uint8 next_sector;
64 DirEntry entry[8];
65 } Directory;
66
67
68 class D64Drive : public Drive {
69 public:
70 D64Drive(IEC *iec, char *filepath);
71 virtual ~D64Drive();
72 virtual uint8 Open(int channel, const uint8 *name, int name_len);
73 virtual uint8 Close(int channel);
74 virtual uint8 Read(int channel, uint8 *byte);
75 virtual uint8 Write(int channel, uint8 byte, bool eoi);
76 virtual void Reset(void);
77
78 private:
79 void open_close_d64_file(char *d64name);
80
81 uint8 open_file(int channel, const uint8 *name, int name_len);
82 bool find_file(const uint8 *pattern, int *track, int *sector);
83 uint8 open_file_ts(int channel, int track, int sector);
84 uint8 open_directory(const uint8 *pattern, int pattern_len);
85 uint8 open_direct(int channel, const uint8 *name);
86 void close_all_channels();
87
88 void block_read_cmd(int channel, int track, int sector, bool user_cmd = false);
89 void buffer_pointer_cmd(int channel, int pos);
90 void mem_read_cmd(uint16 adr, uint8 len);
91 void mem_write_cmd(uint16 adr, uint8 len, uint8 *p);
92 void initialize_cmd(void);
93
94 int alloc_buffer(int want);
95 void free_buffer(int buf);
96 bool read_sector(int track, int sector, uint8 *buffer);
97 int offset_from_ts(int track, int sector);
98
99 char orig_d64_name[256]; // Original path of .d64 file
100
101 FILE *the_file; // File pointer for .d64 file
102
103 uint8 *ram; // 2KB 1541 RAM
104 BAM *bam; // Pointer to BAM
105 Directory dir; // Buffer for directory blocks
106
107 int chan_mode[16]; // Channel mode
108 int chan_buf_num[16]; // Buffer number of channel (for direct access channels)
109 uint8 *chan_buf[16]; // Pointer to buffer
110 uint8 *buf_ptr[16]; // Pointer in buffer
111 int buf_len[16]; // Remaining bytes in buffer
112
113 bool buf_free[4]; // Buffer 0..3 free?
114
115 int image_header; // Length of .d64 file header
116
117 uint8 error_info[683]; // Sector error information (1 byte/sector)
118 };
119
120 #endif