Previous 15994 Revisions Next

r7880 Wednesday 21st April, 2010 at 12:31:01 UTC by Curt Coder
Added skeleton for FDI disk image support.
[src/mess]mess.mak
[src/mess/formats]fdi_dsk.c* flopimg.h

src/mess/formats/flopimg.h
r7879r7880
9696FLOPPY_IDENTIFY(d88_dsk_identify);
9797FLOPPY_CONSTRUCT(d88_dsk_construct);
9898
99FLOPPY_IDENTIFY(fdi_dsk_identify);
100FLOPPY_CONSTRUCT(fdi_dsk_construct);
101
99102#define FLOPPY_OPTIONS_NAME(name)   floppyoptions_##name
100103
101104#define FLOPPY_OPTIONS_START(name)                                    \
r7879r7880
113116   { #name, extensions_, description_, identify_, construct_, ranges_ },            \
114117
115118#define FLOPPY_OPTIONS_END                                          \
119      FLOPPY_OPTION( fdi, "fdi", "Formatted Disk Image", fdi_dsk_identify, fdi_dsk_construct, NULL) \
116120      FLOPPY_OPTION( td0, "td0", "Teledisk floppy disk image",   td0_dsk_identify, td0_dsk_construct, NULL) \
117121      FLOPPY_OPTION( imd, "imd", "IMD floppy disk image",   imd_dsk_identify, imd_dsk_construct, NULL) \
118122      FLOPPY_OPTION( cqm, "cqm,dsk", "CopyQM floppy disk image",   cqm_dsk_identify, cqm_dsk_construct, NULL) \
119123      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) \
121125   FLOPPY_OPTIONS_END0
122126
123127FLOPPY_OPTIONS_EXTERN(default);
src/mess/formats/fdi_dsk.c
r0r7880
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 */
33enum
34{
35   TYPE_8_INCH = 0,
36   TYPE_5_25_INCH,
37   TYPE_3_5_INCH,
38   TYPE_3_INCH
39};
40
41static const char *const MEDIA_TYPE[] = { "8", "5.25", "3.5", "3" };
42
43/* tracks per inch */
44enum
45{
46   TPI_48 = 0,
47   TPI_67,
48   TPI_96,
49   TPI_100,
50   TPI_135,
51   TPI_192
52};
53
54static int TRACKS_PER_INCH[] = { 48, 67, 96, 100, 135, 192 };
55
56/* high level track types */
57enum
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
82struct 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
90struct 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
111INLINE struct fdidsk_tag *get_tag(floppy_image *floppy)
112{
113   return (fdidsk_tag *)floppy_tag(floppy);
114}
115
116/***************************************************************************
117    IMPLEMENTATION
118***************************************************************************/
119
120static int fdi_get_heads_per_disk(floppy_image *floppy)
121{
122   return get_tag(floppy)->heads;
123}
124
125static int fdi_get_tracks_per_disk(floppy_image *floppy)
126{
127   return get_tag(floppy)->tracks;
128}
129
130static int fdi_get_sectors_per_track(floppy_image *floppy, int head, int track)
131{
132   return 0;
133}
134
135static 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/*
140static UINT32 fdi_get_sector_offset(floppy_image* floppy, int head, int track, int sector)
141{
142   return 0;
143}
144*/
145static 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
150static 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
155static 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
160static 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
165static 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
170static 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
179FLOPPY_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
201FLOPPY_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}
src/mess/mess.mak
r7879r7880
420420   $(MESS_FORMATS)/cqm_dsk.o   \
421421   $(MESS_FORMATS)/dsk_dsk.o   \
422422   $(MESS_FORMATS)/d88_dsk.o   \
423   $(MESS_FORMATS)/fdi_dsk.o   \
423424   $(MESS_DEVICES)/flopdrv.o   \
424425   $(MESS_DEVICES)/harddriv.o   \
425426   $(MESS_DEVICES)/messram.o   \
r7879r7880
540541   $(MESS_DRIVERS)/z88.o      \
541542   $(MESS_VIDEO)/z88.o         \
542543   $(MESS_DRIVERS)/atom.o      \
543   $(MESS_MACHINE)/atom.o      \
544544   $(MESS_FORMATS)/atom_atm.o   \
545545   $(MESS_FORMATS)/atom_tap.o   \
546546   $(MESS_FORMATS)/uef_cas.o   \

Previous 15994 Revisions Next


© 1998-2018 The MESS Team