src/mess/formats/flopimg.h
| r7879 | r7880 | |
| 96 | 96 | FLOPPY_IDENTIFY(d88_dsk_identify); |
| 97 | 97 | FLOPPY_CONSTRUCT(d88_dsk_construct); |
| 98 | 98 | |
| 99 | FLOPPY_IDENTIFY(fdi_dsk_identify); |
| 100 | FLOPPY_CONSTRUCT(fdi_dsk_construct); |
| 101 | |
| 99 | 102 | #define FLOPPY_OPTIONS_NAME(name) floppyoptions_##name |
| 100 | 103 | |
| 101 | 104 | #define FLOPPY_OPTIONS_START(name) \ |
| r7879 | r7880 | |
| 113 | 116 | { #name, extensions_, description_, identify_, construct_, ranges_ }, \ |
| 114 | 117 | |
| 115 | 118 | #define FLOPPY_OPTIONS_END \ |
| 119 | FLOPPY_OPTION( fdi, "fdi", "Formatted Disk Image", fdi_dsk_identify, fdi_dsk_construct, NULL) \ |
| 116 | 120 | FLOPPY_OPTION( td0, "td0", "Teledisk floppy disk image", td0_dsk_identify, td0_dsk_construct, NULL) \ |
| 117 | 121 | FLOPPY_OPTION( imd, "imd", "IMD floppy disk image", imd_dsk_identify, imd_dsk_construct, NULL) \ |
| 118 | 122 | FLOPPY_OPTION( cqm, "cqm,dsk", "CopyQM floppy disk image", cqm_dsk_identify, cqm_dsk_construct, NULL) \ |
| 119 | 123 | FLOPPY_OPTION( dsk, "dsk", "DSK floppy disk image", dsk_dsk_identify, dsk_dsk_construct, NULL) \ |
| 120 | | FLOPPY_OPTION( d88, "d77,d88", "D88 Floppy Disk image", d88_dsk_identify, d88_dsk_construct, NULL)\ |
| 124 | FLOPPY_OPTION( d88, "d77,d88", "D88 Floppy Disk image", d88_dsk_identify, d88_dsk_construct, NULL) \ |
| 121 | 125 | FLOPPY_OPTIONS_END0 |
| 122 | 126 | |
| 123 | 127 | FLOPPY_OPTIONS_EXTERN(default); |
src/mess/formats/fdi_dsk.c
| r0 | r7880 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | formats/fdi_dsk.h |
| 4 | |
| 5 | Floppy format code for Formatted Disk Image (FDI) v2.0 images |
| 6 | |
| 7 | *********************************************************************/ |
| 8 | |
| 9 | /* |
| 10 | |
| 11 | TODO: |
| 12 | |
| 13 | - everything |
| 14 | |
| 15 | */ |
| 16 | |
| 17 | #include "emu.h" |
| 18 | #include "formats/flopimg.h" |
| 19 | #include "devices/flopdrv.h" |
| 20 | |
| 21 | /*************************************************************************** |
| 22 | PARAMETERS |
| 23 | ***************************************************************************/ |
| 24 | |
| 25 | #define LOG 1 |
| 26 | |
| 27 | #define MAX_TRACKS 180 |
| 28 | |
| 29 | #define FLAGS_WRITE_PROTECTED 0x01 |
| 30 | #define FLAGS_INDEX_SYNC 0x02 |
| 31 | |
| 32 | /* media type */ |
| 33 | enum |
| 34 | { |
| 35 | TYPE_8_INCH = 0, |
| 36 | TYPE_5_25_INCH, |
| 37 | TYPE_3_5_INCH, |
| 38 | TYPE_3_INCH |
| 39 | }; |
| 40 | |
| 41 | static const char *const MEDIA_TYPE[] = { "8", "5.25", "3.5", "3" }; |
| 42 | |
| 43 | /* tracks per inch */ |
| 44 | enum |
| 45 | { |
| 46 | TPI_48 = 0, |
| 47 | TPI_67, |
| 48 | TPI_96, |
| 49 | TPI_100, |
| 50 | TPI_135, |
| 51 | TPI_192 |
| 52 | }; |
| 53 | |
| 54 | static int TRACKS_PER_INCH[] = { 48, 67, 96, 100, 135, 192 }; |
| 55 | |
| 56 | /* high level track types */ |
| 57 | enum |
| 58 | { |
| 59 | TRACK_BLANK = 0, /* not supported */ |
| 60 | TRACK_AMIGA_DD, /* not supported */ |
| 61 | TRACK_AMIGA_HD, /* not supported */ |
| 62 | TRACK_ST_DD_9, /* not supported */ |
| 63 | TRACK_ST_DD_10, /* not supported */ |
| 64 | TRACK_PC_DD_8, /* not supported */ |
| 65 | TRACK_PC_DD_9, /* not supported */ |
| 66 | TRACK_PC_HD_15, /* not supported */ |
| 67 | TRACK_IBM_HD_18, /* not supported */ |
| 68 | TRACK_IBM_ED_36, /* not supported */ |
| 69 | TRACK_CBM_1541, /* not supported */ |
| 70 | TRACK_APPLE_DOS_32, /* not supported */ |
| 71 | TRACK_APPLE_DOS_33, /* not supported */ |
| 72 | TRACK_APPLE_GCR, /* not supported */ |
| 73 | TRACK_IBM_SD_10 /* not supported */ |
| 74 | }; |
| 75 | |
| 76 | //static int SECTORS_PER_TRACK[] = { 0, 11, 22, 9, 10, 8, 9, 15, 18, 36, -1, -1, -1, -1, 10 }; |
| 77 | |
| 78 | /*************************************************************************** |
| 79 | TYPE DEFINITIONS |
| 80 | ***************************************************************************/ |
| 81 | |
| 82 | struct fdidsk_tag |
| 83 | { |
| 84 | int version; |
| 85 | int heads; /* number of physical heads */ |
| 86 | int tracks; /* number of physical tracks */ |
| 87 | UINT32 track_offset[MAX_TRACKS]; /* offset within data for each track */ |
| 88 | }; |
| 89 | |
| 90 | struct fdi_header |
| 91 | { |
| 92 | UINT8 signature[27]; |
| 93 | UINT8 creator[32]; |
| 94 | UINT8 comment[80]; |
| 95 | UINT8 eof; |
| 96 | UINT8 version[2]; |
| 97 | UINT8 ltrack[2]; |
| 98 | UINT8 lhead; |
| 99 | UINT8 type; |
| 100 | UINT8 rotspeed; |
| 101 | UINT8 flags; |
| 102 | UINT8 tpi; |
| 103 | UINT8 headwidth; |
| 104 | UINT8 reserved[2]; |
| 105 | }; |
| 106 | |
| 107 | /*************************************************************************** |
| 108 | INLINE FUNCTIONS |
| 109 | ***************************************************************************/ |
| 110 | |
| 111 | INLINE struct fdidsk_tag *get_tag(floppy_image *floppy) |
| 112 | { |
| 113 | return (fdidsk_tag *)floppy_tag(floppy); |
| 114 | } |
| 115 | |
| 116 | /*************************************************************************** |
| 117 | IMPLEMENTATION |
| 118 | ***************************************************************************/ |
| 119 | |
| 120 | static int fdi_get_heads_per_disk(floppy_image *floppy) |
| 121 | { |
| 122 | return get_tag(floppy)->heads; |
| 123 | } |
| 124 | |
| 125 | static int fdi_get_tracks_per_disk(floppy_image *floppy) |
| 126 | { |
| 127 | return get_tag(floppy)->tracks; |
| 128 | } |
| 129 | |
| 130 | static int fdi_get_sectors_per_track(floppy_image *floppy, int head, int track) |
| 131 | { |
| 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | static floperr_t fdi_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 136 | { |
| 137 | return FLOPPY_ERROR_SUCCESS; |
| 138 | } |
| 139 | /* |
| 140 | static UINT32 fdi_get_sector_offset(floppy_image* floppy, int head, int track, int sector) |
| 141 | { |
| 142 | return 0; |
| 143 | } |
| 144 | */ |
| 145 | static floperr_t fdi_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 146 | { |
| 147 | return FLOPPY_ERROR_UNSUPPORTED; |
| 148 | } |
| 149 | |
| 150 | static floperr_t fdi_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 151 | { |
| 152 | return FLOPPY_ERROR_UNSUPPORTED; |
| 153 | } |
| 154 | |
| 155 | static floperr_t fdi_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 156 | { |
| 157 | return FLOPPY_ERROR_UNSUPPORTED; |
| 158 | } |
| 159 | |
| 160 | static floperr_t fdi_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buffer_len) |
| 161 | { |
| 162 | return FLOPPY_ERROR_UNSUPPORTED; |
| 163 | } |
| 164 | |
| 165 | static floperr_t fdi_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 166 | { |
| 167 | return FLOPPY_ERROR_UNSUPPORTED; |
| 168 | } |
| 169 | |
| 170 | static floperr_t fdi_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 171 | { |
| 172 | return FLOPPY_ERROR_UNSUPPORTED; |
| 173 | } |
| 174 | |
| 175 | /*------------------------------------------------- |
| 176 | FLOPPY_IDENTIFY( fdi_dsk_identify ) |
| 177 | -------------------------------------------------*/ |
| 178 | |
| 179 | FLOPPY_IDENTIFY( fdi_dsk_identify ) |
| 180 | { |
| 181 | UINT8 header[25]; |
| 182 | |
| 183 | floppy_image_read(floppy, header, 0, 25); |
| 184 | |
| 185 | if (!strncmp((const char *)header, "Formatted Disk Image file", 25)) |
| 186 | { |
| 187 | *vote = 100; |
| 188 | } |
| 189 | else |
| 190 | { |
| 191 | *vote = 0; |
| 192 | } |
| 193 | |
| 194 | return FLOPPY_ERROR_SUCCESS; |
| 195 | } |
| 196 | |
| 197 | /*------------------------------------------------- |
| 198 | FLOPPY_CONSTRUCT( fdi_dsk_construct ) |
| 199 | -------------------------------------------------*/ |
| 200 | |
| 201 | FLOPPY_CONSTRUCT( fdi_dsk_construct ) |
| 202 | { |
| 203 | if (params) |
| 204 | { |
| 205 | /* create not supported */ |
| 206 | return FLOPPY_ERROR_UNSUPPORTED; |
| 207 | } |
| 208 | |
| 209 | struct fdidsk_tag *tag = (struct fdidsk_tag *) floppy_create_tag(floppy, sizeof(struct fdidsk_tag)); |
| 210 | |
| 211 | if (!tag) return FLOPPY_ERROR_OUTOFMEMORY; |
| 212 | |
| 213 | /* read header */ |
| 214 | struct fdi_header header; |
| 215 | floppy_image_read(floppy, &header, 0, sizeof(header)); |
| 216 | |
| 217 | tag->version = header.version[0]; |
| 218 | tag->tracks = ((header.ltrack[0] << 8) | header.ltrack[1]) + 1; |
| 219 | tag->heads = header.lhead + 1; |
| 220 | |
| 221 | if (LOG) |
| 222 | { |
| 223 | logerror("FDI creator: %s\n", header.creator); |
| 224 | logerror("FDI comment: %s\n", header.comment); |
| 225 | logerror("FDI version: %u\n", tag->version); |
| 226 | logerror("FDI tracks: %u\n", tag->tracks); |
| 227 | logerror("FDI heads: %u\n", tag->heads); |
| 228 | logerror("FDI media type: %s\"\n", MEDIA_TYPE[header.type]); |
| 229 | logerror("FDI rotation speed: %u\n", header.rotspeed + 128); |
| 230 | if (header.flags & FLAGS_WRITE_PROTECTED) logerror("FDI is write protected\n"); |
| 231 | if (header.flags & FLAGS_INDEX_SYNC) logerror("FDI is index synchronized\n"); |
| 232 | logerror("FDI media TPI: %u\n", TRACKS_PER_INCH[header.tpi]); |
| 233 | logerror("FDI head TPI: %u\n", TRACKS_PER_INCH[header.headwidth]); |
| 234 | } |
| 235 | |
| 236 | /* find track offsets */ |
| 237 | |
| 238 | /* set callbacks */ |
| 239 | struct FloppyCallbacks *callbacks = floppy_callbacks(floppy); |
| 240 | |
| 241 | callbacks->read_track = fdi_read_track; |
| 242 | callbacks->get_heads_per_disk = fdi_get_heads_per_disk; |
| 243 | callbacks->get_tracks_per_disk = fdi_get_tracks_per_disk; |
| 244 | callbacks->get_sector_length = fdi_get_sector_length; |
| 245 | callbacks->read_sector = fdi_read_sector; |
| 246 | callbacks->read_indexed_sector = fdi_read_indexed_sector; |
| 247 | // callbacks->write_track = fdi_write_track; |
| 248 | callbacks->write_sector = fdi_write_sector; |
| 249 | callbacks->write_indexed_sector = fdi_write_indexed_sector; |
| 250 | callbacks->get_indexed_sector_info = fdi_get_indexed_sector_info; |
| 251 | callbacks->get_sectors_per_track = fdi_get_sectors_per_track; |
| 252 | |
| 253 | return FLOPPY_ERROR_SUCCESS; |
| 254 | } |