Previous 15994 Revisions Next

r5802 Saturday 19th September, 2009 at 20:25:00 UTC by Miodrag Milanović
Made IMD support skeleton.
Moved FM7 to D88 disk support.
Made default floppy options block.
Fixed wimgtool crash.
[src/mess]mess.mak
[src/mess/drivers]amstrad.c einstein.c elwro800.c fm7.c mbee.c pc8801.c pcw.c samcoupe.c specpls3.c x1.c
[src/mess/formats]d88_dsk.c* d88_dsk.h* dsk_dsk.c dsk_dsk.h flopimg.c flopimg.h fm7_dsk.c fm7_dsk.h imd_dsk.c* td0_dsk.c td0_dsk.h
[src/mess/tools/imgtool]iflopimg.c imgtool.mak

src/mess/tools/imgtool/imgtool.mak
r5801r5802
4343   $(MESS_FORMATS)/basicdsk.o         \
4444   $(MESS_FORMATS)/coco_dsk.o         \
4545   $(MESS_FORMATS)/coco_cas.o         \
46   $(MESS_FORMATS)/imd_dsk.o         \
4647   $(MESS_FORMATS)/td0_dsk.o         \
48   $(MESS_FORMATS)/dsk_dsk.o         \
49   $(MESS_FORMATS)/d88_dsk.o         \
4750   $(MESS_FORMATS)/pc_dsk.o         \
4851   $(MESS_FORMATS)/ap2_dsk.o         \
4952   $(MESS_FORMATS)/ap_dsk35.o         \
src/mess/tools/imgtool/iflopimg.c
r5801r5802
267267            imgtool_get_info_string(&derived_class, IMGTOOLINFO_STR_DESCRIPTION));
268268         break;
269269      case IMGTOOLINFO_STR_FILE_EXTENSIONS:      strcpy(info->s = imgtool_temp_str(), format->extensions); break;
270      case IMGTOOLINFO_STR_CREATEIMAGE_OPTSPEC:   strcpy(info->s = imgtool_temp_str(), format->param_guidelines); break;
270      case IMGTOOLINFO_STR_CREATEIMAGE_OPTSPEC:   info->p = (void*)format->param_guidelines; break;
271271
272272      /* --- the following bits of info are returned as pointers to data or functions --- */
273273      case IMGTOOLINFO_PTR_OPEN:               info->open = imgtool_floppy_open; break;
src/mess/mess.mak
r5801r5802
396396   $(MESS_DEVICES)/cartslot.o   \
397397   $(MESS_DEVICES)/cassette.o   \
398398   $(MESS_DEVICES)/chd_cd.o   \
399   $(MESS_FORMATS)/imd_dsk.o   \
399400   $(MESS_FORMATS)/td0_dsk.o   \
400401   $(MESS_FORMATS)/dsk_dsk.o   \
402   $(MESS_FORMATS)/d88_dsk.o   \
401403   $(MESS_DEVICES)/flopdrv.o   \
402404   $(MESS_DEVICES)/harddriv.o   \
403405   $(MESS_DEVICES)/messram.o   \
r5801r5802
852854   $(MESS_DRIVERS)/fm7.o      \
853855   $(MESS_VIDEO)/fm7.o         \
854856   $(MESS_FORMATS)/fm7_cas.o   \
855   $(MESS_FORMATS)/fm7_dsk.o   \
856857
857858$(MESSOBJ)/galaxy.a:         \
858859   $(MESS_VIDEO)/galaxy.o      \
src/mess/formats/td0_dsk.h
r5801r5802
1/*********************************************************************
2
3   formats/td0_dsk.h
4
5   TD0 disk images
6
7*********************************************************************/
8
9#ifndef __TD0_DSK_H__
10#define __TD0_DSK_H__
11
12#include "formats/flopimg.h"
13
14#endif /* __TD0_DSK_H__ */
src/mess/formats/dsk_dsk.h
r5801r5802
1/*********************************************************************
2
3   formats/dsk_dsk.h
4
5   DSK disk images
6
7*********************************************************************/
8
9#ifndef __DSK_DSK_H__
10#define __DSK_DSK_H__
11
12#include "formats/flopimg.h"
13
14
15FLOPPY_OPTIONS_EXTERN(dsk);
16
17FLOPPY_IDENTIFY(dsk_dsk_identify);
18FLOPPY_CONSTRUCT(dsk_dsk_construct);
19
20
21#endif /* __DSK_DSK_H__ */
src/mess/formats/fm7_dsk.c
r5801r5802
1/*
2 *   Fujitsu FM-7 series D77 disk images
3 *
4 *
5 *   Header (total size = 0x2b0 bytes):
6 *     0x00 - Disk label
7 *     0x1a - Write protect (bit 3)
8 *     0x1b - 2D/2DD format (bit 3)
9 *     0x1c-1f - image size (should match file size)
10 *     0x20 - offsets for each track (max 164)
11 *
12 *   Sectors (0x110 bytes each, typically)
13 *     0x00 - Sector info
14 *          byte 0 - track number
15 *          byte 1 - side (0 or 1)
16 *          byte 2 - sector number
17 *     0x10 - sector data
18 *
19 *   Images can be concatenated together.
20 *   Sectors can be in any order.
21 *   Tracks are in the order:
22 *          Track 0 side 0
23 *          Track 0 side 1
24 *          Track 1 side 0
25 *          ...
26 *
27 *
28 */
29
30#include "driver.h"
31#include "formats/fm7_dsk.h"
32
33#define D77_HEADER_LEN 0x2b0
34
35struct d77_tag
36{
37   UINT32 image_size;
38   UINT32 trackoffset[164];
39   UINT8 write_protect;
40   UINT8 disk_type;
41};
42
43static struct d77_tag *get_d77_tag(floppy_image *floppy)
44{
45   return floppy_tag(floppy, "d77tag");
46}
47
48static int d77_get_sector_id(floppy_image *floppy, int head, int track, int sector_index)
49{
50   struct d77_tag* tag = get_d77_tag(floppy);
51   UINT32 offset;
52   UINT8 sector_hdr[16];
53   int x;
54   
55   offset = tag->trackoffset[(track*2)+head];
56
57   if(offset == 0)
58      return 0;
59
60   floppy_image_read(floppy,sector_hdr,offset,16);
61
62   // get to sector indexed
63   x=0;
64   while(x<sector_index)
65   {
66      offset += ((sector_hdr[15] << 8) | sector_hdr[14]);
67      offset += 16;
68      floppy_image_read(floppy,sector_hdr,offset,16);
69      x++;
70   }
71   
72   return sector_hdr[2];
73}
74
75static int d77_get_tracks_per_disk(floppy_image *floppy)
76{
77   return 82;  // 82 tracks per side
78}
79
80static int d77_get_heads_per_disk(floppy_image *floppy)
81{
82   return 2;  // 2 heads
83}
84
85static int d77_get_sectors_per_track(floppy_image *floppy, int head, int track)
86{
87   struct d77_tag* tag = get_d77_tag(floppy);
88   UINT32 offset;
89   UINT8 sector_hdr[16];
90   
91   offset = tag->trackoffset[(track*2)+head];
92
93   floppy_image_read(floppy,sector_hdr,offset,16);
94   
95   return sector_hdr[4];
96}
97   
98static floperr_t d77_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length)
99{
100   struct d77_tag* tag = get_d77_tag(floppy);
101   UINT32 offset;
102   UINT8 sector_hdr[16];
103   UINT32 len;
104   int count,secs;
105   
106   offset = tag->trackoffset[(track*2)+head];
107   
108   floppy_image_read(floppy,sector_hdr,offset,16);
109   secs = sector_hdr[4];
110   
111   for(count=0;count<secs;count++)
112   {
113      floppy_image_read(floppy,sector_hdr,offset,16);
114      if(sector == sector_hdr[2])
115      {
116         if(sector_length)
117            *sector_length = (sector_hdr[15] << 8) | sector_hdr[14];
118         return FLOPPY_ERROR_SUCCESS;
119      }
120      len = (sector_hdr[15] << 8) | sector_hdr[14];
121      len += 16;
122      offset += len;
123   }
124
125   return FLOPPY_ERROR_SEEKERROR;
126}
127
128static floperr_t d77_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen)
129{
130//   floperr_t err;
131   
132   return FLOPPY_ERROR_UNSUPPORTED;
133}
134
135static UINT32 d77_get_sector_offset(floppy_image* floppy, int head, int track, int sector)
136{
137   struct d77_tag* tag = get_d77_tag(floppy);
138   UINT32 offset = 0;
139   UINT8 sector_hdr[16];
140   UINT32 len;
141   UINT32 secs;
142   int count;
143   
144   // get offset of the beginning of the track
145   offset = tag->trackoffset[(track*2)+head];
146
147   floppy_image_read(floppy,sector_hdr,offset,16);
148   secs = sector_hdr[4];
149   
150   for(count=0;count<secs;count++)
151   {
152      floppy_image_read(floppy,sector_hdr,offset,16);
153      if(sector == sector_hdr[2])
154      {
155         logerror("d77_get_sector_offset - track %i, side %i, sector %02x, returns %08x\n",track,head,sector,offset+16);
156         return offset + 16;
157      }
158      len = (sector_hdr[15] << 8) | sector_hdr[14];
159      len += 16;
160      offset += len;
161   }
162   logerror("d77_get_sector_offset - track %i, side %i, sector %02x, not found\n",track,head,sector);
163   return 0;
164}
165
166static floperr_t d77_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)
167{
168   struct d77_tag* tag = get_d77_tag(floppy);
169   UINT32 offset;
170   UINT8 sector_hdr[16];
171   int x;
172   
173   offset = tag->trackoffset[(track*2)+head];
174
175   if(offset == 0)
176      return FLOPPY_ERROR_SEEKERROR;
177   
178
179   floppy_image_read(floppy,sector_hdr,offset,16);
180
181   if(sector_index >= sector_hdr[4])
182      return FLOPPY_ERROR_SEEKERROR;
183
184   // get to sector indexed
185   x=0;
186   while(x<sector_index)
187   {
188      offset += ((sector_hdr[15] << 8) | sector_hdr[14]);
189      offset += 16;
190      floppy_image_read(floppy,sector_hdr,offset,16);
191      x++;
192   }
193   
194   if(offset > tag->image_size || offset == 0)
195      return FLOPPY_ERROR_SEEKERROR;
196
197   if(sector_length)
198      *sector_length = (sector_hdr[15] << 8) | sector_hdr[14];
199   if(cylinder)
200      *cylinder = sector_hdr[0];
201   if(side)
202      *side = sector_hdr[1];
203   if(sector)
204      *sector = sector_hdr[2];
205   if(flags)
206      *flags = 0;
207   
208   return FLOPPY_ERROR_SUCCESS;
209}
210
211static floperr_t d77_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen)
212{
213   UINT64 offset;
214   UINT32 sector_length;
215   
216   offset = d77_get_sector_offset(floppy,head,track,sector);
217   
218   if(d77_get_sector_length(floppy,head,track,sector,&sector_length) != FLOPPY_ERROR_SUCCESS)
219      return FLOPPY_ERROR_SEEKERROR;
220     
221   if(offset == 0)
222      return FLOPPY_ERROR_SEEKERROR;
223     
224   if(buflen > sector_length)
225      return FLOPPY_ERROR_INTERNAL;
226   
227   floppy_image_read(floppy,buffer,offset,sector_length);
228   
229   return FLOPPY_ERROR_SUCCESS;
230}
231
232static floperr_t d77_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buffer_len)
233{
234   int sec;
235   
236   sec = d77_get_sector_id(floppy,head,track,sector);
237   return d77_read_sector(floppy,head,track,sec,buffer,buffer_len);
238}
239
240static void d77_get_header(floppy_image* floppy,UINT32* size, UINT8* prot, UINT8* type, UINT32* offsets)
241{
242   UINT8 header[D77_HEADER_LEN];
243   int x,s;
244   
245   floppy_image_read(floppy,header,0,D77_HEADER_LEN);
246
247   if(prot)
248      *prot = header[0x1a];
249   if(type)
250      *prot = header[0x1b];
251   if(size)
252   {
253      s = 0;
254      s |= header[0x1f] << 24;
255      s |= header[0x1e] << 16;
256      s |= header[0x1d] << 8;
257      s |= header[0x1c];
258      *size = s;
259   }
260   if(offsets)
261   {
262      for(x=0;x<164;x++)
263      {
264         s = 0;
265         s |= header[0x23 + (x*4)] << 24;
266         s |= header[0x22 + (x*4)] << 16;
267         s |= header[0x21 + (x*4)] << 8;
268         s |= header[0x20 + (x*4)];
269         *(offsets+x) = s;
270      }
271   }
272}
273
274FLOPPY_IDENTIFY(fm7_d77_identify)
275{
276   UINT32 size;
277   
278   d77_get_header(floppy,&size,NULL,NULL,NULL);   
279   
280   if(floppy_image_size(floppy) == size)
281   {
282      *vote = 100;
283      return FLOPPY_ERROR_SUCCESS;
284   }
285   else
286   {
287      *vote = 0;
288      return FLOPPY_ERROR_INVALIDIMAGE;
289   }
290}
291
292FLOPPY_CONSTRUCT(fm7_d77_construct)
293{
294   struct FloppyCallbacks *callbacks;
295   struct d77_tag *tag;
296   UINT32 size;
297   UINT8 prot,type = 0;
298   UINT32 offs[164];
299   int x;
300   
301   if(params)
302   {
303      // create
304      return FLOPPY_ERROR_UNSUPPORTED;
305   }
306   else
307   {
308      // load
309      d77_get_header(floppy,&size,&prot,&type,offs);
310   }
311   
312   tag = floppy_create_tag(floppy,"d77tag",sizeof(struct d77_tag));
313   if (!tag)
314      return FLOPPY_ERROR_OUTOFMEMORY;
315   
316   tag->write_protect = prot;
317   tag->disk_type = type;
318   tag->image_size = size;
319   for(x=0;x<164;x++)
320      tag->trackoffset[x] = offs[x];
321     
322   callbacks = floppy_callbacks(floppy);
323   callbacks->read_track = d77_read_track;
324   callbacks->get_heads_per_disk = d77_get_heads_per_disk;
325   callbacks->get_tracks_per_disk = d77_get_tracks_per_disk;
326   callbacks->get_sector_length = d77_get_sector_length;
327   callbacks->read_sector = d77_read_sector;
328   callbacks->read_indexed_sector = d77_read_indexed_sector;
329   callbacks->get_indexed_sector_info = d77_get_indexed_sector_info;
330   callbacks->get_sectors_per_track = d77_get_sectors_per_track;
331   
332     
333   return FLOPPY_ERROR_SUCCESS;
334}
335
336FLOPPY_OPTIONS_START( fm7 )
337   FLOPPY_OPTION( fm7_d77, "d77",   "XM7 FM-7 Floppy Disk image",   fm7_d77_identify,   fm7_d77_construct,
338      HEADS(1-[2])
339      TRACKS([82])
340      SECTORS(1-[17])
341      SECTOR_LENGTH(128/[256])
342      FIRST_SECTOR_ID(0-[1]))
343FLOPPY_OPTIONS_END
344
345
src/mess/formats/fm7_dsk.h
r5801r5802
1#ifndef FM7_DSK_H_
2#define FM7_DSK_H_
3
4/*
5 *   Fujitsu FM-7 series D77 disk images
6 *
7 */
8
9#include "formats/flopimg.h"
10
11FLOPPY_OPTIONS_EXTERN(fm7);
12
13FLOPPY_IDENTIFY(fm7_d77_identify);
14FLOPPY_CONSTRUCT(fm7_d77_construct);
15
16
17#endif /*FM7_DSK_H_*/
src/mess/formats/d88_dsk.c
r0r5802
1/*
2 *   D77 and D88 disk images
3 *
4 *
5 *   Header (total size = 0x2b0 bytes):
6 *     0x00 - Disk label
7 *     0x1a - Write protect (bit 3)
8 *     0x1b - 2D/2DD format (bit 3)
9 *     0x1c-1f - image size (should match file size)
10 *     0x20 - offsets for each track (max 164)
11 *
12 *   Sectors (0x110 bytes each, typically)
13 *     0x00 - Sector info
14 *          byte 0 - track number
15 *          byte 1 - side (0 or 1)
16 *          byte 2 - sector number
17 *     0x10 - sector data
18 *
19 *   Images can be concatenated together.
20 *   Sectors can be in any order.
21 *   Tracks are in the order:
22 *          Track 0 side 0
23 *          Track 0 side 1
24 *          Track 1 side 0
25 *          ...
26 *
27 *
28 */
29
30#include "driver.h"
31#include "formats/flopimg.h"
32#include "devices/flopdrv.h"
33
34#define D88_HEADER_LEN 0x2b0
35
36struct d88_tag
37{
38   UINT32 image_size;
39   UINT32 trackoffset[164];
40   UINT8 write_protect;
41   UINT8 disk_type;
42};
43
44static struct d88_tag *get_d88_tag(floppy_image *floppy)
45{
46   return floppy_tag(floppy, "d88tag");
47}
48
49static int d88_get_sector_id(floppy_image *floppy, int head, int track, int sector_index)
50{
51   struct d88_tag* tag = get_d88_tag(floppy);
52   UINT32 offset;
53   UINT8 sector_hdr[16];
54   int x;
55   
56   offset = tag->trackoffset[(track*2)+head];
57
58   if(offset == 0)
59      return 0;
60
61   floppy_image_read(floppy,sector_hdr,offset,16);
62
63   // get to sector indexed
64   x=0;
65   while(x<sector_index)
66   {
67      offset += ((sector_hdr[15] << 8) | sector_hdr[14]);
68      offset += 16;
69      floppy_image_read(floppy,sector_hdr,offset,16);
70      x++;
71   }
72   
73   return sector_hdr[2];
74}
75
76static int d88_get_tracks_per_disk(floppy_image *floppy)
77{
78   return 82;  // 82 tracks per side
79}
80
81static int d88_get_heads_per_disk(floppy_image *floppy)
82{
83   return 2;  // 2 heads
84}
85
86static int d88_get_sectors_per_track(floppy_image *floppy, int head, int track)
87{
88   struct d88_tag* tag = get_d88_tag(floppy);
89   UINT32 offset;
90   UINT8 sector_hdr[16];
91   
92   offset = tag->trackoffset[(track*2)+head];
93
94   floppy_image_read(floppy,sector_hdr,offset,16);
95   
96   return sector_hdr[4];
97}
98   
99static floperr_t d88_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length)
100{
101   struct d88_tag* tag = get_d88_tag(floppy);
102   UINT32 offset;
103   UINT8 sector_hdr[16];
104   UINT32 len;
105   int count,secs;
106   
107   offset = tag->trackoffset[(track*2)+head];
108   
109   floppy_image_read(floppy,sector_hdr,offset,16);
110   secs = sector_hdr[4];
111   
112   for(count=0;count<secs;count++)
113   {
114      floppy_image_read(floppy,sector_hdr,offset,16);
115      if(sector == sector_hdr[2])
116      {
117         if(sector_length)
118            *sector_length = (sector_hdr[15] << 8) | sector_hdr[14];
119         return FLOPPY_ERROR_SUCCESS;
120      }
121      len = (sector_hdr[15] << 8) | sector_hdr[14];
122      len += 16;
123      offset += len;
124   }
125
126   return FLOPPY_ERROR_SEEKERROR;
127}
128
129static floperr_t d88_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen)
130{
131//   floperr_t err;
132   
133   return FLOPPY_ERROR_UNSUPPORTED;
134}
135
136static UINT32 d88_get_sector_offset(floppy_image* floppy, int head, int track, int sector)
137{
138   struct d88_tag* tag = get_d88_tag(floppy);
139   UINT32 offset = 0;
140   UINT8 sector_hdr[16];
141   UINT32 len;
142   UINT32 secs;
143   int count;
144   
145   // get offset of the beginning of the track
146   offset = tag->trackoffset[(track*2)+head];
147
148   floppy_image_read(floppy,sector_hdr,offset,16);
149   secs = sector_hdr[4];
150   
151   for(count=0;count<secs;count++)
152   {
153      floppy_image_read(floppy,sector_hdr,offset,16);
154      if(sector == sector_hdr[2])
155      {
156         logerror("d88_get_sector_offset - track %i, side %i, sector %02x, returns %08x\n",track,head,sector,offset+16);
157         return offset + 16;
158      }
159      len = (sector_hdr[15] << 8) | sector_hdr[14];
160      len += 16;
161      offset += len;
162   }
163   logerror("d88_get_sector_offset - track %i, side %i, sector %02x, not found\n",track,head,sector);
164   return 0;
165}
166
167static floperr_t d88_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)
168{
169   struct d88_tag* tag = get_d88_tag(floppy);
170   UINT32 offset;
171   UINT8 sector_hdr[16];
172   int x;
173   
174   offset = tag->trackoffset[(track*2)+head];
175
176   if(offset == 0)
177      return FLOPPY_ERROR_SEEKERROR;
178   
179
180   floppy_image_read(floppy,sector_hdr,offset,16);
181
182   if(sector_index >= sector_hdr[4])
183      return FLOPPY_ERROR_SEEKERROR;
184
185   // get to sector indexed
186   x=0;
187   while(x<sector_index)
188   {
189      offset += ((sector_hdr[15] << 8) | sector_hdr[14]);
190      offset += 16;
191      floppy_image_read(floppy,sector_hdr,offset,16);
192      x++;
193   }
194   
195   if(offset > tag->image_size || offset == 0)
196      return FLOPPY_ERROR_SEEKERROR;
197
198   if(sector_length)
199      *sector_length = (sector_hdr[15] << 8) | sector_hdr[14];
200   if(cylinder)
201      *cylinder = sector_hdr[0];
202   if(side)
203      *side = sector_hdr[1];
204   if(sector)
205      *sector = sector_hdr[2];
206   if(flags)
207      *flags = 0;
208   
209   return FLOPPY_ERROR_SUCCESS;
210}
211
212static floperr_t d88_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen)
213{
214   UINT64 offset;
215   UINT32 sector_length;
216   
217   offset = d88_get_sector_offset(floppy,head,track,sector);
218   
219   if(d88_get_sector_length(floppy,head,track,sector,&sector_length) != FLOPPY_ERROR_SUCCESS)
220      return FLOPPY_ERROR_SEEKERROR;
221     
222   if(offset == 0)
223      return FLOPPY_ERROR_SEEKERROR;
224     
225   if(buflen > sector_length)
226      return FLOPPY_ERROR_INTERNAL;
227   
228   floppy_image_read(floppy,buffer,offset,sector_length);
229   
230   return FLOPPY_ERROR_SUCCESS;
231}
232
233static floperr_t d88_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buffer_len)
234{
235   int sec;
236   
237   sec = d88_get_sector_id(floppy,head,track,sector);
238   return d88_read_sector(floppy,head,track,sec,buffer,buffer_len);
239}
240
241static void d88_get_header(floppy_image* floppy,UINT32* size, UINT8* prot, UINT8* type, UINT32* offsets)
242{
243   UINT8 header[D88_HEADER_LEN];
244   int x,s;
245   
246   floppy_image_read(floppy,header,0,D88_HEADER_LEN);
247
248   if(prot)
249      *prot = header[0x1a];
250   if(type)
251      *prot = header[0x1b];
252   if(size)
253   {
254      s = 0;
255      s |= header[0x1f] << 24;
256      s |= header[0x1e] << 16;
257      s |= header[0x1d] << 8;
258      s |= header[0x1c];
259      *size = s;
260   }
261   if(offsets)
262   {
263      for(x=0;x<164;x++)
264      {
265         s = 0;
266         s |= header[0x23 + (x*4)] << 24;
267         s |= header[0x22 + (x*4)] << 16;
268         s |= header[0x21 + (x*4)] << 8;
269         s |= header[0x20 + (x*4)];
270         *(offsets+x) = s;
271      }
272   }
273}
274
275FLOPPY_IDENTIFY(d88_dsk_identify)
276{
277   UINT32 size;
278   
279   d88_get_header(floppy,&size,NULL,NULL,NULL);   
280   
281   if(floppy_image_size(floppy) == size)
282   {
283      *vote = 100;
284      return FLOPPY_ERROR_SUCCESS;
285   }
286   else
287   {
288      *vote = 0;
289      return FLOPPY_ERROR_INVALIDIMAGE;
290   }
291}
292
293FLOPPY_CONSTRUCT(d88_dsk_construct)
294{
295   struct FloppyCallbacks *callbacks;
296   struct d88_tag *tag;
297   UINT32 size;
298   UINT8 prot,type = 0;
299   UINT32 offs[164];
300   int x;
301   
302   if(params)
303   {
304      // create
305      return FLOPPY_ERROR_UNSUPPORTED;
306   }
307   else
308   {
309      // load
310      d88_get_header(floppy,&size,&prot,&type,offs);
311   }
312   
313   tag = floppy_create_tag(floppy,"d88tag",sizeof(struct d88_tag));
314   if (!tag)
315      return FLOPPY_ERROR_OUTOFMEMORY;
316   
317   tag->write_protect = prot;
318   tag->disk_type = type;
319   tag->image_size = size;
320   for(x=0;x<164;x++)
321      tag->trackoffset[x] = offs[x];
322     
323   callbacks = floppy_callbacks(floppy);
324   callbacks->read_track = d88_read_track;
325   callbacks->get_heads_per_disk = d88_get_heads_per_disk;
326   callbacks->get_tracks_per_disk = d88_get_tracks_per_disk;
327   callbacks->get_sector_length = d88_get_sector_length;
328   callbacks->read_sector = d88_read_sector;
329   callbacks->read_indexed_sector = d88_read_indexed_sector;
330   callbacks->get_indexed_sector_info = d88_get_indexed_sector_info;
331   callbacks->get_sectors_per_track = d88_get_sectors_per_track;
332   
333     
334   return FLOPPY_ERROR_SUCCESS;
335}
src/mess/formats/d88_dsk.h
r0r5802
1#ifndef FM7_DSK_H_
2#define FM7_DSK_H_
3
4/*
5 *   Fujitsu FM-7 series D77 disk images
6 *
7 */
8
9#include "formats/flopimg.h"
10
11
12
13#endif /*FM7_DSK_H_*/
src/mess/formats/flopimg.c
r5801r5802
949949}
950950
951951
952
952FLOPPY_OPTIONS_START(default)
953FLOPPY_OPTIONS_END
src/mess/formats/flopimg.h
r5801r5802
8484FLOPPY_IDENTIFY(td0_dsk_identify);
8585FLOPPY_CONSTRUCT(td0_dsk_construct);
8686
87FLOPPY_IDENTIFY(imd_dsk_identify);
88FLOPPY_CONSTRUCT(imd_dsk_construct);
89
90FLOPPY_IDENTIFY(dsk_dsk_identify);
91FLOPPY_CONSTRUCT(dsk_dsk_construct);
92
93FLOPPY_IDENTIFY(d88_dsk_identify);
94FLOPPY_CONSTRUCT(d88_dsk_construct);
95
8796#define FLOPPY_OPTIONS_NAME(name)   floppyoptions_##name
8897
8998#define FLOPPY_OPTIONS_START(name)                                    \
r5801r5802
99108
100109#define FLOPPY_OPTIONS_END                                          \
101110      FLOPPY_OPTION( td0, "td0", "TD0 floppy disk image",   td0_dsk_identify, td0_dsk_construct, NULL) \
102      { NULL }                                                \
111      FLOPPY_OPTION( imd, "imd", "IMD floppy disk image",   imd_dsk_identify, imd_dsk_construct, NULL) \
112      FLOPPY_OPTION( dsk, "dsk", "DSK floppy disk image",   dsk_dsk_identify, dsk_dsk_construct, NULL) \
113      FLOPPY_OPTION( d88, "d77,d88",   "D88 Floppy Disk image", d88_dsk_identify, d88_dsk_construct, NULL)\
114      { NULL }                     \
103115   };
104116
117FLOPPY_OPTIONS_EXTERN(default);
105118
106119#define PARAM_END            '\0'
107120#define PARAM_HEADS            'H'
src/mess/formats/td0_dsk.c
r5801r5802
88
99#include <string.h>
1010#include "driver.h"
11#include "formats/dsk_dsk.h"
11#include "formats/flopimg.h"
1212#include "devices/flopdrv.h"
1313
1414#define TD0_DSK_TAG   "td0tag"
r5801r5802
250250   int i;
251251   int track;
252252
253   if(params)
254   {
255      // create
256      return FLOPPY_ERROR_UNSUPPORTED;
257   }
258
253259   floppy_image_read(floppy, header, 0, 16);
254260
255261   tag = (struct td0dsk_tag *) floppy_create_tag(floppy, TD0_DSK_TAG, sizeof(struct td0dsk_tag));
src/mess/formats/imd_dsk.c
r0r5802
1/*********************************************************************
2
3   formats/imd_dsk.c
4
5   IMD disk images
6
7*********************************************************************/
8
9#include <string.h>
10#include "driver.h"
11#include "formats/flopimg.h"
12#include "devices/flopdrv.h"
13
14#define IMD_DSK_TAG   "imdtag"
15
16struct imddsk_tag
17{
18   int heads;
19   int tracks;
20   int sector_size;
21   UINT64 track_offsets[84*2]; /* offset within data for each track */
22};
23
24
25static struct imddsk_tag *get_tag(floppy_image *floppy)
26{
27   struct imddsk_tag *tag;
28   tag = floppy_tag(floppy, IMD_DSK_TAG);
29   return tag;
30}
31
32
33
34FLOPPY_IDENTIFY( imd_dsk_identify )
35{
36   UINT8 header[3];
37
38   floppy_image_read(floppy, header, 0, 3);
39   if (header[0]=='I' && header[1]=='M' && header[1]=='D') {
40      *vote = 100;
41   } else {
42      *vote = 0;
43   }
44   return FLOPPY_ERROR_SUCCESS;
45}
46
47static int imd_get_heads_per_disk(floppy_image *floppy)
48{
49   return get_tag(floppy)->heads;
50}
51
52static int imd_get_tracks_per_disk(floppy_image *floppy)
53{
54   return get_tag(floppy)->tracks;
55}
56
57/*static UINT64 imd_get_track_offset(floppy_image *floppy, int head, int track)
58{
59   return get_tag(floppy)->track_offsets[(track<<1) + head];
60}
61*/
62static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset)
63{
64   UINT64 offs;
65   UINT8 sectors_per_track = 0;   
66
67   if ((head < 0) || (head >= get_tag(floppy)->heads) || (track < 0) || (track >= get_tag(floppy)->tracks)
68         || (sector < 0) )
69      return FLOPPY_ERROR_SEEKERROR;
70
71   
72   if (!sector_is_index) {
73      // when taking ID's return seek error if number is over counter
74      if (sector > sectors_per_track) {
75         return FLOPPY_ERROR_SEEKERROR;
76      }
77   }
78   
79   if (offset)
80      *offset = offs;
81   return FLOPPY_ERROR_SUCCESS;
82}
83
84
85
86static floperr_t internal_imd_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen)
87{
88   UINT64 offset;
89   floperr_t err;
90   
91   // take sector offset
92   err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
93   if (err)
94      return err;
95     
96   return FLOPPY_ERROR_SUCCESS;
97}
98
99
100static floperr_t imd_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen)
101{
102   return internal_imd_read_sector(floppy, head, track, sector, FALSE, buffer, buflen);
103}
104
105static floperr_t imd_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen)
106{
107   return internal_imd_read_sector(floppy, head, track, sector, TRUE, buffer, buflen);
108}
109
110static floperr_t imd_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length)
111{
112   floperr_t err;
113   err = get_offset(floppy, head, track, sector, FALSE, NULL);
114   if (err)
115      return err;
116
117   if (sector_length) {     
118      *sector_length = get_tag(floppy)->sector_size;
119   }
120   return FLOPPY_ERROR_SUCCESS;
121}
122
123static floperr_t imd_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)
124{
125   floperr_t retVal;
126   UINT64 offset;
127
128   retVal = get_offset(floppy, head, track, sector_index, FALSE, &offset);
129
130   if (cylinder)
131      *cylinder = 0;
132   if (side)
133      *side = 0;
134   if (sector)
135      *sector = 0;
136   if (sector_length) {
137      *sector_length = 0;
138   }
139   if (flags)
140      *flags = 0;
141   return retVal;
142}
143
144
145FLOPPY_CONSTRUCT( imd_dsk_construct )
146{
147   struct FloppyCallbacks *callbacks;
148   
149   if(params)
150   {
151      // create
152      return FLOPPY_ERROR_UNSUPPORTED;
153   }
154
155   callbacks = floppy_callbacks(floppy);
156   callbacks->read_sector = imd_read_sector;
157   callbacks->read_indexed_sector = imd_read_indexed_sector;
158   callbacks->get_sector_length = imd_get_sector_length;
159   callbacks->get_heads_per_disk = imd_get_heads_per_disk;
160   callbacks->get_tracks_per_disk = imd_get_tracks_per_disk;
161   callbacks->get_indexed_sector_info = imd_get_indexed_sector_info;
162
163   return FLOPPY_ERROR_UNSUPPORTED;
164}
165
src/mess/formats/dsk_dsk.c
r5801r5802
88
99#include <string.h>
1010#include "driver.h"
11#include "formats/dsk_dsk.h"
11#include "formats/flopimg.h"
1212#include "devices/flopdrv.h"
1313
1414#define MV_CPC     "MV - CPC"
r5801r5802
7676   int i;
7777   /* translate the sector to a raw sector */
7878
79   if (!sector_is_index)
80   {
81      sector -= 1;
82   }
83
8479   /* check to see if we are out of range */
8580   if ((head < 0) || (head >= get_tag(floppy)->heads) || (track < 0) || (track >= get_tag(floppy)->tracks)
8681         || (sector < 0) )
r5801r5802
9186   floppy_image_read(floppy, track_info, track_offset, 0x100);
9287
9388   sectors_per_track = track_info[0x015];
94   if (sector >= sectors_per_track) {
95      return FLOPPY_ERROR_SEEKERROR;
89   if (!sector_is_index) {
90      if (sector >= sectors_per_track) {
91         return FLOPPY_ERROR_SEEKERROR;
92      }
9693   }
9794
9895   if (get_tag(floppy)->disk_image_type==0) {
r5801r5802
181178   UINT8 sector_info[0x100];
182179   int pos;
183180
184   retVal = get_offset(floppy, head, track, sector_index+1, FALSE, NULL);
181   retVal = get_offset(floppy, head, track, sector_index, FALSE, NULL);
185182   offset = dsk_get_track_offset(floppy,head,track);
186183   pos = 0x18 + (sector_index << 3);
187184   floppy_image_read(floppy, sector_info, offset, 0x100);
r5801r5802
209206   int i;
210207   int skip,cnt;
211208
209   if(params)
210   {
211      // create
212      return FLOPPY_ERROR_UNSUPPORTED;
213   }
214
212215   floppy_image_read(floppy, header, 0, 0x100);
213216
214217   tag = (struct dskdsk_tag *) floppy_create_tag(floppy, dskDSK_TAG, sizeof(struct dskdsk_tag));
r5801r5802
254257   callbacks->get_indexed_sector_info = dsk_get_indexed_sector_info;
255258   return FLOPPY_ERROR_SUCCESS;
256259}
257/* ----------------------------------------------------------------------- */
258
259FLOPPY_OPTIONS_START(dsk )
260   FLOPPY_OPTION( dsk, "dsk", "DSK floppy disk image",   dsk_dsk_identify, dsk_dsk_construct, NULL)
261FLOPPY_OPTIONS_END
src/mess/drivers/mbee.c
r5801r5802
6868#include "sound/wave.h"
6969#include "devices/flopdrv.h"
7070#include "formats/basicdsk.h"
71#include "formats/dsk_dsk.h"
7271#include "includes/mbee.h"
7372
7473size_t mbee_size;
r5801r5802
356355      TRACKS([84])
357356      SECTORS([10])
358357      SECTOR_LENGTH([512])
359      FIRST_SECTOR_ID([1]))   
360   FLOPPY_OPTION(dsk, "dsk", "DSK floppy disk image", dsk_dsk_identify, dsk_dsk_construct, NULL)   
358      FIRST_SECTOR_ID([1]))     
361359FLOPPY_OPTIONS_END
362360
363361static const floppy_config mbee_floppy_config =
src/mess/drivers/x1.c
r5801r5802
155155#include "machine/wd17xx.h"
156156#include "devices/cassette.h"
157157#include "devices/flopdrv.h"
158#include "formats/flopimg.h"
158159#include "formats/basicdsk.h"
159#include "formats/fm7_dsk.h"
160160#include "formats/x1_tap.h"
161161#include <ctype.h>
162162
r5801r5802
20202020}
20212021
20222022FLOPPY_OPTIONS_START( x1 )
2023   FLOPPY_OPTION( d88, "d88",   "D88 Floppy Disk image",   fm7_d77_identify,   fm7_d77_construct, NULL)
20242023   FLOPPY_OPTION( img2d, "2d", "2D disk image", basicdsk_identify_default, basicdsk_construct_default,
20252024      HEADS([2])
20262025      TRACKS([40])
src/mess/drivers/pcw.c
r5801r5802
9696#include "cpu/z80/z80.h"
9797// nec765 interface
9898#include "machine/nec765.h"
99#include "formats/dsk_dsk.h"
10099#include "devices/flopdrv.h"
101100// pcw video hardware
102101#include "includes/pcw.h"
r5801r5802
979978static const floppy_config pcw_floppy_config =
980979{
981980   FLOPPY_DRIVE_DS_80,
982   FLOPPY_OPTIONS_NAME(dsk)
981   FLOPPY_OPTIONS_NAME(default)
983982};
984983
985984/* PCW8256, PCW8512, PCW9256 */
src/mess/drivers/einstein.c
r5801r5802
5757#include "machine/wd17xx.h"
5858#include "machine/ctronics.h"
5959#include "machine/msm8251.h"
60#include "formats/dsk_dsk.h"
6160#include "devices/flopdrv.h"
6261#include "sound/ay8910.h"
6362#include "video/mc6845.h"
r5801r5802
852851static const floppy_config einstein_floppy_config =
853852{
854853   FLOPPY_DRIVE_SS_40,
855   FLOPPY_OPTIONS_NAME(dsk)
854   FLOPPY_OPTIONS_NAME(default)
856855};
857856
858857static MACHINE_DRIVER_START( einstein )
src/mess/drivers/amstrad.c
r5801r5802
9898#include "machine/ctronics.h"
9999
100100/* Devices */
101#include "formats/dsk_dsk.h"      /* for CPCEMU style disk images */
102101#include "devices/flopdrv.h"
103102#include "formats/basicdsk.h"
104103#include "includes/msx_slot.h"
r5801r5802
840839static const floppy_config cpc6128_floppy_config =
841840{
842841   FLOPPY_DRIVE_SS_40,
843   FLOPPY_OPTIONS_NAME(dsk)
842   FLOPPY_OPTIONS_NAME(default)
844843};
845844
846845static const floppy_config aleste_floppy_config =
src/mess/drivers/samcoupe.c
r5801r5802
4545#include "formats/tzx_cas.h"
4646#include "devices/flopdrv.h"
4747#include "formats/coupedsk.h"
48#include "formats/dsk_dsk.h"
4948
5049
5150/***************************************************************************
r5801r5802
547546      SECTORS(1-[10]-12)
548547      SECTOR_LENGTH(128/256/[512]/1024)
549548      FIRST_SECTOR_ID([1])
550   )
551   FLOPPY_OPTION(dsk, "dsk", "DSK floppy disk image", dsk_dsk_identify, dsk_dsk_construct, NULL)
549   )   
552550FLOPPY_OPTIONS_END
553551
554552static const floppy_config samcoupe_floppy_config =
src/mess/drivers/fm7.c
r5801r5802
4646#include "formats/fm7_cas.h"
4747#include "machine/wd17xx.h"
4848#include "devices/flopdrv.h"
49#include "formats/fm7_dsk.h"
5049#include "machine/ctronics.h"
5150
5251#include "includes/fm7.h"
r5801r5802
18471846static const floppy_config fm7_floppy_config =
18481847{
18491848   FLOPPY_DRIVE_DS_80,
1850   FLOPPY_OPTIONS_NAME(fm7)
1849   FLOPPY_OPTIONS_NAME(default)
18511850};
18521851
18531852static MACHINE_DRIVER_START( fm7 )
src/mess/drivers/specpls3.c
r5801r5802
156156
157157/* +3 hardware */
158158#include "machine/nec765.h"
159#include "formats/dsk_dsk.h"
160159#include "devices/flopdrv.h"
161160
162161
r5801r5802
366365static const floppy_config specpls3_floppy_config =
367366{
368367   FLOPPY_DRIVE_DS_80,
369   FLOPPY_OPTIONS_NAME(dsk)
368   FLOPPY_OPTIONS_NAME(default)
370369};
371370
372371static MACHINE_DRIVER_START( spectrum_plus3 )
src/mess/drivers/pc8801.c
r5801r5802
8989#include "includes/pc8801.h"
9090#include "machine/nec765.h"
9191#include "devices/flopdrv.h"
92#include "formats/fm7_dsk.h"
9392#include "sound/2203intf.h"
9493
9594static const gfx_layout char_layout_40L_h =
r5801r5802
571570   pc88sr_sound_interupt
572571};
573572
574FLOPPY_OPTIONS_START(pc88 )
575   FLOPPY_OPTION( d88, "d88",   "D88 Floppy Disk image",   fm7_d77_identify,   fm7_d77_construct, NULL)
576FLOPPY_OPTIONS_END
577
578573static const floppy_config pc88_floppy_config =
579574{
580575   FLOPPY_DRIVE_DS_80,
581   FLOPPY_OPTIONS_NAME(pc88)
576   FLOPPY_OPTIONS_NAME(default)
582577};
583578
584579static MACHINE_DRIVER_START( pc88srl )
src/mess/drivers/elwro800.c
r5801r5802
3232#include "machine/msm8251.h"
3333
3434/* Devices */
35#include "formats/dsk_dsk.h"
3635#include "devices/flopdrv.h"
3736#include "devices/cassette.h"
3837#include "formats/tzx_cas.h"
r5801r5802
477476static const floppy_config elwro800jr_floppy_config =
478477{
479478   FLOPPY_DRIVE_SS_40,
480   FLOPPY_OPTIONS_NAME(dsk)
479   FLOPPY_OPTIONS_NAME(default)
481480};
482481
483482static MACHINE_DRIVER_START( elwro800 )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team