Previous 15994 Revisions Next

r13735 Tuesday 27th December, 2011 at 11:29:52 UTC by Olivier Galibert
floppy: Add media type and write splice information to the internal representation, and start handling HD [O. Galibert]
[src/emu/imagedev]floppy.c floppy.h
[src/lib/formats]ami_dsk.c ami_dsk.h coupedsk.c coupedsk.h dsk_dsk.c dsk_dsk.h flopimg.c flopimg.h hxcmfm_dsk.c hxcmfm_dsk.h ipf_dsk.c ipf_dsk.h mfi_dsk.c mfi_dsk.h pasti_dsk.c pasti_dsk.h st_dsk.c st_dsk.h

src/emu/imagedev/floppy.c
r13734r13735
1212const device_type FLOPPY_CONNECTOR = &device_creator<floppy_connector>;
1313const device_type FLOPPY_35_DD = &device_creator<floppy_35_dd>;
1414const device_type FLOPPY_35_HD = &device_creator<floppy_35_hd>;
15const device_type FLOPPY_35_ED = &device_creator<floppy_35_ed>;
1516const device_type FLOPPY_525_DD = &device_creator<floppy_525_dd>;
1617
1718floppy_connector::floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
r13734r13735
136137void floppy_image_device::device_start()
137138{
138139   rpm = 0;
139   setup_limits();
140   setup_characteristics();
140141
141142   idx = 0;
142143
r13734r13735
174175   int best = 0;
175176   floppy_image_format_t *best_format = 0;
176177   for(floppy_image_format_t *format = fif_list; format; format = format->next) {
177      int score = format->identify(&io);
178      int score = format->identify(&io, form_factor);
178179      if(score > best) {
179180         best = score;
180181         best_format = format;
r13734r13735
184185   if(!best_format)
185186      return IMAGE_INIT_FAIL;
186187
187   image = global_alloc(floppy_image(tracks, sides));
188   best_format->load(&io, image);
188   image = global_alloc(floppy_image(tracks, sides, form_factor));
189   best_format->load(&io, form_factor, image);
189190
190191   revolution_start_time = attotime::never;
191192   revolution_count = 0;
r13734r13735
538539{
539540}
540541
541void floppy_35_dd::setup_limits()
542void floppy_35_dd::setup_characteristics()
542543{
544   form_factor = floppy_image::FF_35;
543545   tracks = 84;
544546   sides = 2;
545547   set_rpm(300);
r13734r13735
554556{
555557}
556558
557void floppy_35_hd::setup_limits()
559void floppy_35_hd::setup_characteristics()
558560{
561   form_factor = floppy_image::FF_35;
559562   tracks = 84;
560563   sides = 2;
561564   set_rpm(300);
562565}
563566
567floppy_35_ed::floppy_35_ed(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
568   floppy_image_device(mconfig, FLOPPY_35_ED, "3.5\" extended density floppy drive", tag, owner, clock)
569{
570}
564571
572floppy_35_ed::~floppy_35_ed()
573{
574}
575
576void floppy_35_ed::setup_characteristics()
577{
578   form_factor = floppy_image::FF_35;
579   tracks = 84;
580   sides = 2;
581   set_rpm(300);
582}
583
584
565585floppy_525_dd::floppy_525_dd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
566586   floppy_image_device(mconfig, FLOPPY_525_DD, "5.25\" double density floppy drive", tag, owner, clock)
567587{
r13734r13735
571591{
572592}
573593
574void floppy_525_dd::setup_limits()
594void floppy_525_dd::setup_characteristics()
575595{
596   form_factor = floppy_image::FF_525;
576597   tracks = 42;
577598   sides = 1;
578599   set_rpm(300);
src/emu/imagedev/floppy.h
r13734r13735
7575   attotime time_next_index();
7676   attotime get_next_transition(attotime from_when);
7777   void write_flux(attotime start, attotime end, int transition_count, const attotime *transitions);
78   void set_write_splice(attotime when);
79   UINT32 get_form_factor() const;
80   UINT32 get_variant() const;
7881
7982protected:
8083   // device-level overrides
r13734r13735
8386   virtual void device_reset();
8487   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
8588
86   virtual void setup_limits() = 0;
89   virtual void setup_characteristics() = 0;
8790
8891   image_device_format   format;
8992   floppy_image        *image;
r13734r13735
9194   floppy_image_format_t *fif_list;
9295   emu_timer             *index_timer;
9396
94   /* Physical characteristics, filled by setup_limits */
97   /* Physical characteristics, filled by setup_characteristics */
9598   int tracks; /* addressable tracks */
9699   int sides;  /* number of heads */
100   UINT32 form_factor; /* 3"5, 5"25, etc */
97101
98102   /* state of input lines */
99103   int dir;  /* direction */
r13734r13735
130134   virtual ~floppy_35_dd();
131135
132136protected:
133   virtual void setup_limits();
137   virtual void setup_characteristics();
134138};
135139
136140class floppy_35_hd : public floppy_image_device {
r13734r13735
139143   virtual ~floppy_35_hd();
140144
141145protected:
142   virtual void setup_limits();
146   virtual void setup_characteristics();
143147};
144148
149class floppy_35_ed : public floppy_image_device {
150public:
151   floppy_35_ed(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
152   virtual ~floppy_35_ed();
153
154protected:
155   virtual void setup_characteristics();
156};
157
145158class floppy_525_dd : public floppy_image_device {
146159public:
147160   floppy_525_dd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
148161   virtual ~floppy_525_dd();
149162
150163protected:
151   virtual void setup_limits();
164   virtual void setup_characteristics();
152165};
153166
154167class floppy_connector: public device_t,
r13734r13735
174187extern const device_type FLOPPY_CONNECTOR;
175188extern const device_type FLOPPY_35_DD;
176189extern const device_type FLOPPY_35_HD;
190extern const device_type FLOPPY_35_ED;
177191extern const device_type FLOPPY_525_DD;
178192
179193#endif /* FLOPPY_H */
src/lib/formats/hxcmfm_dsk.c
r13734r13735
5454   return true;
5555}
5656
57int mfm_format::identify(io_generic *io)
57int mfm_format::identify(io_generic *io, UINT32 form_factor)
5858{
5959   UINT8 header[7];
6060
r13734r13735
6565   return 0;
6666}
6767
68bool mfm_format::load(io_generic *io, floppy_image *image)
68bool mfm_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
6969{
7070   MFMIMG header;
7171   MFMTRACKIMG trackdesc;
r13734r13735
9898   if(trackbuf)
9999      global_free(trackbuf);
100100
101   image->set_variant(floppy_image::DSDD);
101102   return true;
102103}
103104
src/lib/formats/hxcmfm_dsk.h
r13734r13735
1616public:
1717   mfm_format();
1818
19   virtual int identify(io_generic *io);
20   virtual bool load(io_generic *io, floppy_image *image);
19   virtual int identify(io_generic *io, UINT32 form_factor);
20   virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
2121   virtual bool save(io_generic *io, floppy_image *image);
2222
2323   virtual const char *name() const;
src/lib/formats/flopimg.c
r13734r13735
942942/// New implementation
943943//////////////////////////////////////////////////////////
944944
945floppy_image::floppy_image(int _tracks, int _heads)
945floppy_image::floppy_image(int _tracks, int _heads, UINT32 _form_factor)
946946{
947947   tracks = _tracks;
948948   heads = _heads;
949949
950   form_factor = _form_factor;
951   variant = 0;
952
950953   memset(cell_data, 0, sizeof(cell_data));
951954   memset(track_size, 0, sizeof(track_size));
952955   memset(track_alloc_size, 0, sizeof(track_alloc_size));
956   memset(write_splice, 0, sizeof(write_splice));
953957}
954958
955959floppy_image::~floppy_image()
r13734r13735
992996
993997void floppy_image::ensure_alloc(int track, int head)
994998{
995   int idx = (track << 1) + head;
996   if(track_size[idx] > track_alloc_size[idx]) {
997      UINT32 new_size = track_size[idx]*11/10;
999   if(track_size[track][head] > track_alloc_size[track][head]) {
1000      UINT32 new_size = track_size[track][head]*11/10;
9981001      UINT32 *new_array = global_alloc_array(UINT32, new_size);
999      if(track_alloc_size[idx]) {
1000         memcpy(new_array, cell_data[idx], track_alloc_size[idx]*4);
1001         global_free(cell_data[idx]);
1002      if(track_alloc_size[track][head]) {
1003         memcpy(new_array, cell_data[track][head], track_alloc_size[track][head]*4);
1004         global_free(cell_data[track][head]);
10021005      }
1003      cell_data[idx] = new_array;
1004      track_alloc_size[idx] = new_size;
1006      cell_data[track][head] = new_array;
1007      track_alloc_size[track][head] = new_size;
10051008   }
10061009}
10071010
r13734r13735
13751378   int size = dest - base;
13761379   normalize_times(base, size);
13771380   image->set_track_size(track, head, size);
1381   image->set_write_splice_position(track, head, 0);
13781382}
13791383
13801384void floppy_image_format_t::generate_track_from_levels(int track, int head, UINT32 *trackbuf, int track_size, int splice_pos, floppy_image *image)
13811385{
1386   // Retrieve the angular splice pos before messing with the data
1387   splice_pos = splice_pos % track_size;
1388   UINT32 splice_angular_pos = trackbuf[splice_pos] & floppy_image::TIME_MASK;
1389
13821390   // Check if we need to invert a cell to get an even number of
13831391   // transitions on the whole track
13841392   //
r13734r13735
14061414   }
14071415
14081416   if(transition_count & 1) {
1409      splice_pos = splice_pos % track_size;
14101417      int pos = splice_pos;
14111418      while((trackbuf[pos] & floppy_image::MG_MASK) != MG_0 && (trackbuf[pos] & floppy_image::MG_MASK) != MG_1) {
14121419         pos++;
r13734r13735
14571464   int size = dest - base;
14581465   normalize_times(base, size);
14591466   image->set_track_size(track, head, size);
1467   image->set_write_splice_position(track, head, splice_angular_pos);
14601468}
14611469
14621470//  Atari ST Fastcopy Pro layouts
r13734r13735
17921800   { END }
17931801};
17941802
1803const floppy_image_format_t::desc_e floppy_image_format_t::amiga_22[] = {
1804   { SECTOR_LOOP_START, 0, 21 },
1805   {   MFM, 0x00, 2 },
1806   {   RAW, 0x4489, 2 },
1807   {   CRC_AMIGA_START, 1 },
1808   {     MFMBITS, 0xf, 4 },
1809   {     OFFSET_ID_O },
1810   {     SECTOR_ID_O },
1811   {     REMAIN_O, 11 },
1812   {     MFMBITS, 0xf, 4 },
1813   {     OFFSET_ID_E },
1814   {     SECTOR_ID_E },
1815   {     REMAIN_E, 11 },
1816   {     MFM, 0x00, 16 },
1817   {   CRC_END, 1 },
1818   {   CRC, 1 },
1819   {   CRC, 2 },
1820   {   CRC_AMIGA_START, 2 },
1821   {     SECTOR_DATA_O, -1 },
1822   {     SECTOR_DATA_E, -1 },
1823   {   CRC_END, 2 },
1824   { SECTOR_LOOP_END },
1825   { MFM, 0x00, 532 },
1826   { END }
1827};
1828
17951829void floppy_image_format_t::generate_bitstream_from_track(int track, int head, int cell_size, UINT8 *trackbuf, int &track_size, floppy_image *image)
17961830{
17971831   int tsize = image->get_track_size(track, head);
r13734r13735
18021836      return;
18031837   }
18041838
1805   // Start a little before the end of the track to pre-synchronize
1806   // the pll
1839   // Start at the write splice
18071840   const UINT32 *tbuf = image->get_buffer(track, head);
1808   int cur_pos = 190000000;
1809   int cur_entry = tsize-1;
1810   while((tbuf[cur_entry] & floppy_image::TIME_MASK) > cur_pos)
1811      cur_entry--;
1812   cur_entry++;
1813   if(cur_entry == tsize)
1814      cur_entry = 0;
1841   UINT32 splice = image->get_write_splice_position(track, head);
1842   int cur_pos = splice;
1843   int cur_entry = 0;
1844   while(cur_entry < tsize-1 && (tbuf[cur_entry+1] & floppy_image::TIME_MASK) < cur_pos)
1845      cur_entry++;
18151846
1816   int cur_bit = -1;
1847   int cur_bit = 0;
18171848
18181849   int period = cell_size;
18191850   int period_adjust_base = period * 0.05;
r13734r13735
18231854   int phase_adjust = 0;
18241855   int freq_hist = 0;
18251856
1826   for(;;) {
1857   UINT32 scanned = 0;
1858   while(scanned < 200000000) {
18271859      // Note that all magnetic cell type changes are considered
18281860      // edges.  No randomness added for neutral/damaged cells
18291861      int edge = tbuf[cur_entry] & floppy_image::TIME_MASK;
18301862      if(edge < cur_pos)
18311863         edge += 200000000;
18321864      int next = cur_pos + period + phase_adjust;
1865      scanned += period + phase_adjust;
18331866
18341867      if(edge >= next) {
18351868         // No transition in the window means 0 and pll in free run mode
1836         if(cur_bit >= 0) {
1837            trackbuf[cur_bit >> 3] &= ~(0x80 >> (cur_bit & 7));
1838            cur_bit++;
1839         }
1869         trackbuf[cur_bit >> 3] &= ~(0x80 >> (cur_bit & 7));
1870         cur_bit++;
18401871         phase_adjust = 0;
18411872
18421873      } else {
18431874         // Transition in the window means 1, and the pll is adjusted
1844         if(cur_bit >= 0) {
1845            trackbuf[cur_bit >> 3] |= 0x80 >> (cur_bit & 7);
1846            cur_bit++;
1847         }
1875         trackbuf[cur_bit >> 3] |= 0x80 >> (cur_bit & 7);
1876         cur_bit++;
18481877
18491878         int delta = edge - (next - period/2);
18501879
r13734r13735
18811910
18821911      cur_pos = next;
18831912      if(cur_pos >= 200000000) {
1884         if(cur_bit >= 0)
1885            break;
1886         cur_bit = 0;
18871913         cur_pos -= 200000000;
18881914         cur_entry = 0;
18891915      }
src/lib/formats/flopimg.h
r13734r13735
225225   floppy_image_format_t();
226226   virtual ~floppy_image_format_t();
227227
228   virtual int identify(io_generic *io) = 0;
229   virtual bool load(io_generic *io, floppy_image *image) = 0;
228   virtual int identify(io_generic *io, UINT32 form_factor) = 0;
229   virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image) = 0;
230230   virtual bool save(io_generic *io, floppy_image *image);
231231
232232   virtual const char *name() const = 0;
r13734r13735
346346   //   Standard 11 sectors per track format
347347   static const desc_e amiga_11[];
348348
349   //   Standard 22 sectors per track format (guessed, to check w.r.t the real thing)
350   static const desc_e amiga_22[];
349351
352
350353   // **** Writer helpers ****
351354
352355   // Rebuild a cell bitstream for a track.  Takes the cell standard
r13734r13735
473476   // The last cell implicit end position is of course 200,000,000.
474477   //
475478   // Unformatted tracks are encoded as zero-size.
479   //
480   // The "track splice" information indicates where to start writing
481   // if you try to rewrite a physical disk with the data.  Some
482   // preservation formats encode that information, it is guessed for
483   // others.  The write track function of fdcs should set it.  The
484   // representation is the angular position relative to the index.
485   //
486   // The media type is divided in two parts.  The first half
487   // indicate the physical form factor, i.e. all medias with that
488   // form factor can be physically inserted in a reader that handles
489   // it.  The second half indicates the variants which are usually
490   // detectable by the reader, such as density and number of sides.
476491
477492   enum {
478493      TIME_MASK = 0x0fffffff,
r13734r13735
485500      MG_D      = (3 << MG_SHIFT)
486501   };
487502
503   // Form factors
504   enum {
505      FF_35   = 0x20203533, // "35  "
506      FF_525  = 0x20353235, // "525 "
507   };
508
509   // Variants
510   enum {
511      DSDD  = 0x44445344, // "DSDD",
512      DSHD  = 0x44485344, // "DSHD",
513      DSED  = 0x44455344, // "DSED",
514   };
515
488516   // construction/destruction
489   floppy_image(int tracks, int heads);
517   floppy_image(int tracks, int heads, UINT32 form_factor);
490518   virtual ~floppy_image();
491519
492   void set_track_size(int track, int head, UINT32 size) { track_size[(track << 1) + head] = size; ensure_alloc(track, head); }
493   UINT32 *get_buffer(int track, int head) { return cell_data[(track << 1) + head]; }
494   UINT32 get_track_size(int track, int head) { return track_size[(track << 1) + head]; }
520   UINT32 get_form_factor() { return form_factor; }
521   UINT32 get_variant() { return variant; }
522   void set_variant(UINT32 v) { variant = v; }
495523
524   void set_track_size(int track, int head, UINT32 size) { track_size[track][head] = size; ensure_alloc(track, head); }
525   UINT32 *get_buffer(int track, int head) { return cell_data[track][head]; }
526   UINT32 get_track_size(int track, int head) { return track_size[track][head]; }
527   void set_write_splice_position(int track, int head, UINT32 pos) { write_splice[track][head] = pos; }
528   UINT32 get_write_splice_position(int track, int head) const { return write_splice[track][head]; }
496529   void get_maximal_geometry(int &tracks, int &heads);
497530   void get_actual_geometry(int &tracks, int &heads);
498531
r13734r13735
504537
505538   int tracks, heads;
506539
507   UINT32 *cell_data[MAX_FLOPPY_HEADS * MAX_FLOPPY_TRACKS];
508   UINT32 track_size[MAX_FLOPPY_HEADS * MAX_FLOPPY_TRACKS];
509   UINT32 track_alloc_size[MAX_FLOPPY_HEADS * MAX_FLOPPY_TRACKS];
540   UINT32 form_factor, variant;
510541
542   UINT32 *cell_data[MAX_FLOPPY_TRACKS][MAX_FLOPPY_HEADS];
543   UINT32 track_size[MAX_FLOPPY_TRACKS][MAX_FLOPPY_HEADS];
544   UINT32 track_alloc_size[MAX_FLOPPY_TRACKS][MAX_FLOPPY_HEADS];
545   UINT32 write_splice[MAX_FLOPPY_TRACKS][MAX_FLOPPY_HEADS];
546
511547   void ensure_alloc(int track, int head);
512548};
513549
src/lib/formats/dsk_dsk.c
r13734r13735
293293   return false;
294294}
295295
296int dsk_format::identify(io_generic *io)
296int dsk_format::identify(io_generic *io, UINT32 form_factor)
297297{
298298   UINT8 header[16];
299299
r13734r13735
338338
339339#pragma pack()
340340
341bool dsk_format::load(io_generic *io, floppy_image *image)
341bool dsk_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
342342{
343343   UINT8 header[100];
344344   bool extendformat = FALSE;
src/lib/formats/dsk_dsk.h
r13734r13735
1616public:
1717   dsk_format();
1818
19   virtual int identify(io_generic *io);
20   virtual bool load(io_generic *io, floppy_image *image);
19   virtual int identify(io_generic *io, UINT32 form_factor);
20   virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
2121
2222   virtual const char *name() const;
2323   virtual const char *description() const;
src/lib/formats/mfi_dsk.c
r13734r13735
4848  An unformatted track is equivalent to one big MG_N cell covering a
4949  whole turn, but is encoded as zero-size.
5050
51  TODO: big-endian support, cleanup pll, move it where it belongs.
51  The "track splice" information indicates where to start writing
52  if you try to rewrite a physical disk with the data.  Some
53  preservation formats encode that information, it is guessed for
54  others.  The write track function of fdcs should set it.  The
55  representation is the angular position relative to the index.
56 
57  The media type is divided in two parts.  The first half
58  indicate the physical form factor, i.e. all medias with that
59  form factor can be physically inserted in a reader that handles
60  it.  The second half indicates the variants which are usually
61  detectable by the reader, such as density and number of sides.
62
63  TODO: big-endian support
5264*/
5365
5466const char mfi_format::sign[16] = "MESSFLOPPYIMAGE"; // Includes the final \0
r13734r13735
7789   return true;
7890}
7991
80int mfi_format::identify(io_generic *io)
92int mfi_format::identify(io_generic *io, UINT32 form_factor)
8193{
8294   header h;
8395
8496   io_generic_read(io, &h, 0, sizeof(header));
8597   if(memcmp( h.sign, sign, 16 ) == 0 &&
8698      h.cyl_count > 0 && h.cyl_count <= 84 &&
87      h.head_count > 0 && h.head_count <= 2)
99      h.head_count > 0 && h.head_count <= 2 &&
100      h.form_factor == form_factor)
88101      return 100;
89102   return 0;
90103}
91104
92bool mfi_format::load(io_generic *io, floppy_image *image)
105bool mfi_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
93106{
94107   header h;
95108   entry entries[84*2];
96109   io_generic_read(io, &h, 0, sizeof(header));
97110   io_generic_read(io, &entries, sizeof(header), h.cyl_count*h.head_count*sizeof(entry));
98111
112   image->set_variant(h.variant);
113
99114   UINT8 *compressed = 0;
100115   int compressed_size = 0;
101116
r13734r13735
161176   memcpy(h.sign, sign, 16);
162177   h.cyl_count = tracks;
163178   h.head_count = heads;
179   h.form_factor = image->get_form_factor();
180   h.variant = image->get_variant();
164181
165182   io_generic_write(io, &h, 0, sizeof(header));
166183
r13734r13735
194211         entries[epos].offset = pos;
195212         entries[epos].uncompressed_size = tsize*4;
196213         entries[epos].compressed_size = csize;
214         entries[epos].write_splice = image->get_write_splice_position(track, head);
197215         epos++;
198216
199217         io_generic_write(io, postcomp, pos, csize);
src/lib/formats/coupedsk.c
r13734r13735
6161   return true;
6262}
6363
64int mgt_format::identify(io_generic *io)
64int mgt_format::identify(io_generic *io, UINT32 form_factor)
6565{
6666   int size = io_generic_size(io);
6767
r13734r13735
7171   return 0;
7272}
7373
74bool mgt_format::load(io_generic *io, floppy_image *image)
74bool mgt_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
7575{
7676   int size = io_generic_size(io);
7777   int sector_count = size == 737280 ? 9 : 10;
r13734r13735
9292      }
9393   }
9494
95   image->set_variant(floppy_image::DSDD);
9596   return true;
9697}
9798
src/lib/formats/mfi_dsk.h
r13734r13735
88public:
99   mfi_format();
1010
11   virtual int identify(io_generic *io);
12   virtual bool load(io_generic *io, floppy_image *image);
11   virtual int identify(io_generic *io, UINT32 form_factor);
12   virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
1313   virtual bool save(io_generic *io, floppy_image *image);
1414
1515   virtual const char *name() const;
r13734r13735
3434   struct header {
3535      char sign[16];
3636      unsigned int cyl_count, head_count;
37      unsigned int form_factor, variant;
3738   };
3839
3940   struct entry {
40      unsigned int offset, compressed_size, uncompressed_size;
41      unsigned int offset, compressed_size, uncompressed_size, write_splice;
4142   };
4243};
4344
src/lib/formats/coupedsk.h
r13734r13735
1616public:
1717   mgt_format();
1818
19   virtual int identify(io_generic *io);
20   virtual bool load(io_generic *io, floppy_image *image);
19   virtual int identify(io_generic *io, UINT32 form_factor);
20   virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
2121   virtual bool save(io_generic *io, floppy_image *image);
2222
2323   virtual const char *name() const;
src/lib/formats/ami_dsk.c
r13734r13735
3232   return true;
3333}
3434
35int adf_format::identify(io_generic *io)
35int adf_format::identify(io_generic *io, UINT32 form_factor)
3636{
3737   UINT64 size = io_generic_size(io);
3838   if ((size == 901120) || (size == 1802240))
r13734r13735
4242   return 0;
4343}
4444
45bool adf_format::load(io_generic *io, floppy_image *image)
45bool adf_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
4646{
47   desc_s sectors[11];
48   UINT8 sectdata[512*11];
49   for(int i=0; i<11; i++) {
47   desc_s sectors[22];
48   UINT8 sectdata[512*22];
49   for(int i=0; i<22; i++) {
5050      sectors[i].data = sectdata + 512*i;
5151      sectors[i].size = 512;
5252      sectors[i].sector_id = i;
5353   }
5454
55   for(int track=0; track < 80; track++) {
56      for(int side=0; side < 2; side++) {
57         io_generic_read(io, sectdata, (track*2 + side)*512*11, 512*11);
58         generate_track(amiga_11, track, side, sectors, 11, 100000, image);
55   UINT64 size = io_generic_size(io);
56   if(size == 901120) {
57      image->set_variant(floppy_image::DSDD);
58      for(int track=0; track < 80; track++) {
59         for(int side=0; side < 2; side++) {
60            io_generic_read(io, sectdata, (track*2 + side)*512*11, 512*11);
61            generate_track(amiga_11, track, side, sectors, 11, 100000, image);
62         }
5963      }
64   } else {
65      image->set_variant(floppy_image::DSHD);
66      for(int track=0; track < 80; track++) {
67         for(int side=0; side < 2; side++) {
68            io_generic_read(io, sectdata, (track*2 + side)*512*22, 512*22);
69            generate_track(amiga_22, track, side, sectors, 22, 200000, image);
70         }
71      }
6072   }
6173
6274   return true;
r13734r13735
94106
95107bool adf_format::save(io_generic *io, floppy_image *image)
96108{
97   // TODO: HD support
98   UINT8 sectdata[512*11];
99   UINT8 trackbuf[150000/8];
109   UINT8 sectdata[512*22];
110   UINT8 trackbuf[300000/8];
111
112   bool hd = image->get_variant() == floppy_image::DSHD;
113
114   fprintf(stderr, "format is %s\n", hd ? "hd" : "dd");
115
116   int data_track_size = hd ? 512*22 : 512*11;
117
100118   for(int track=0; track < 80; track++) {
101119      for(int side=0; side < 2; side++) {
102120         int track_size;
103         generate_bitstream_from_track(track, side, 2000, trackbuf, track_size, image);
121         generate_bitstream_from_track(track, side, hd ? 1000 : 2000, trackbuf, track_size, image);
104122
105123         for(int i=0; i<track_size; i++)
106124            if(g32(trackbuf, track_size, i) == 0x44894489 &&
r13734r13735
109127
110128               UINT32 head = ((g32(trackbuf, track_size, i+32) & 0x55555555) << 1) | (g32(trackbuf, track_size, i+64) & 0x55555555);
111129               int sect = (head >> 8) & 0xff;
112               if(sect > 11)
130               if(sect > (hd ? 22 : 11))
113131                  continue;
114132
115133               UINT8 *dest = sectdata + 512*sect;
r13734r13735
121139                  *dest++ = val;
122140               }
123141
124               io_generic_write(io, sectdata, (track*2 + side)*512*11, 512*11);
142               io_generic_write(io, sectdata, (track*2 + side)*data_track_size, data_track_size);
125143            }
126144      }
127145   }
src/lib/formats/ami_dsk.h
r13734r13735
1616public:
1717   adf_format();
1818
19   virtual int identify(io_generic *io);
20   virtual bool load(io_generic *io, floppy_image *image);
19   virtual int identify(io_generic *io, UINT32 form_factor);
20   virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
2121   virtual bool save(io_generic *io, floppy_image *image);
2222
2323   virtual const char *name() const;
src/lib/formats/pasti_dsk.c
r13734r13735
3535   return false;
3636}
3737
38int pasti_format::identify(io_generic *io)
38int pasti_format::identify(io_generic *io, UINT32 form_factor)
3939{
4040   UINT8 h[16];
4141   io_generic_read(io, h, 0, 16);
r13734r13735
5757   }
5858}
5959
60bool pasti_format::load(io_generic *io, floppy_image *image)
60bool pasti_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
6161{
6262   UINT8 fh[16];
6363   io_generic_read(io, fh, 0, 16);
r13734r13735
159159      }
160160   }
161161
162   image->set_variant(floppy_image::DSDD);
162163   return true;
163164}
164165
src/lib/formats/pasti_dsk.h
r13734r13735
88public:
99   pasti_format();
1010
11   virtual int identify(io_generic *io);
12   virtual bool load(io_generic *io, floppy_image *image);
11   virtual int identify(io_generic *io, UINT32 form_factor);
12   virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
1313
1414   virtual const char *name() const;
1515   virtual const char *description() const;
src/lib/formats/st_dsk.c
r13734r13735
4444   track_count = head_count = sector_count = 0;
4545}
4646
47int st_format::identify(io_generic *io)
47int st_format::identify(io_generic *io, UINT32 form_factor)
4848{
4949   int track_count, head_count, sector_count;
5050   find_size(io, track_count, head_count, sector_count);
r13734r13735
5454   return 0;
5555}
5656
57bool st_format::load(io_generic *io, floppy_image *image)
57bool st_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
5858{
5959   int track_count, head_count, sector_count;
6060   find_size(io, track_count, head_count, sector_count);
r13734r13735
7676      }
7777   }
7878
79   image->set_variant(floppy_image::DSDD);
80
7981   return true;
8082}
8183
r13734r13735
201203   return dst < usize;
202204}
203205
204int msa_format::identify(io_generic *io)
206int msa_format::identify(io_generic *io, UINT32 form_factor)
205207{
206208   UINT16 sign, sect, head, strack, etrack;
207209   read_header(io, sign, sect, head, strack, etrack);
r13734r13735
215217   return 0;
216218}
217219
218bool msa_format::load(io_generic *io, floppy_image *image)
220bool msa_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
219221{
220222   UINT16 sign, sect, heads, strack, etrack;
221223   read_header(io, sign, sect, heads, strack, etrack);
r13734r13735
248250      }
249251   }
250252
253   image->set_variant(floppy_image::DSDD);
251254   return true;
252255}
253256
src/lib/formats/st_dsk.h
r13734r13735
1616public:
1717   st_format();
1818
19   virtual int identify(io_generic *io);
20   virtual bool load(io_generic *io, floppy_image *image);
19   virtual int identify(io_generic *io, UINT32 form_factor);
20   virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
2121   virtual bool save(io_generic *io, floppy_image *image);
2222
2323   virtual const char *name() const;
r13734r13735
3434public:
3535   msa_format();
3636
37   virtual int identify(io_generic *io);
38   virtual bool load(io_generic *io, floppy_image *image);
37   virtual int identify(io_generic *io, UINT32 form_factor);
38   virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
3939   virtual bool save(io_generic *io, floppy_image *image);
4040
4141   virtual const char *name() const;
src/lib/formats/ipf_dsk.c
r13734r13735
2727   return false;
2828}
2929
30int ipf_format::identify(io_generic *io)
30int ipf_format::identify(io_generic *io, UINT32 form_factor)
3131{
3232   static const UINT8 refh[12] = { 0x43, 0x41, 0x50, 0x53, 0x00, 0x00, 0x00, 0x0c, 0x1c, 0xd5, 0x73, 0xba };
3333   UINT8 h[12];
r13734r13735
3939   return 0;
4040}
4141
42bool ipf_format::load(io_generic *io, floppy_image *image)
42bool ipf_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
4343{
4444   UINT32 size = io_generic_size(io);
4545   UINT8 *data = global_alloc_array(UINT8, size);
r13734r13735
8080
8181bool ipf_format::parse(UINT8 *data, UINT32 size, floppy_image *image)
8282{
83   image->set_variant(floppy_image::DSDD); // Not handling anything else yet
8384   tcount = 84*2+1; // Usual max
8485   tinfos = global_alloc_array_clear(track_info, tcount);
8586   bool res = scan_all_tags(data, size);
src/lib/formats/ipf_dsk.h
r13734r13735
88public:
99   ipf_format();
1010
11   virtual int identify(io_generic *io);
12   virtual bool load(io_generic *io, floppy_image *image);
11   virtual int identify(io_generic *io, UINT32 form_factor);
12   virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
1313
1414   virtual const char *name() const;
1515   virtual const char *description() const;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team