Previous 199869 Revisions Next

r19189 Wednesday 28th November, 2012 at 15:53:32 UTC by Curt Coder
Added some more floppy types. (nw)
[src/emu/imagedev]floppy.c floppy.h
[src/emu/machine]wd_fdc.h
[src/lib/formats]flopimg.c flopimg.h

trunk/src/lib/formats/flopimg.c
r19188r19189
2020#include "pool.h"
2121#include "imageutl.h"
2222
23#define TRACK_LOADED      0x01
24#define TRACK_DIRTY         0x02
23#define TRACK_LOADED        0x01
24#define TRACK_DIRTY         0x02
2525
2626
2727struct floppy_image_legacy
r19188r19189
5757static floperr_t floppy_track_unload(floppy_image_legacy *floppy);
5858
5959OPTION_GUIDE_START(floppy_option_guide)
60   OPTION_INT('H', "heads",         "Heads")
61   OPTION_INT('T', "tracks",         "Tracks")
62   OPTION_INT('S', "sectors",         "Sectors")
63   OPTION_INT('L', "sectorlength",      "Sector Bytes")
64   OPTION_INT('I', "interleave",      "Interleave")
65   OPTION_INT('F', "firstsectorid",   "First Sector")
60   OPTION_INT('H', "heads",            "Heads")
61   OPTION_INT('T', "tracks",           "Tracks")
62   OPTION_INT('S', "sectors",          "Sectors")
63   OPTION_INT('L', "sectorlength",     "Sector Bytes")
64   OPTION_INT('I', "interleave",       "Interleave")
65   OPTION_INT('F', "firstsectorid",    "First Sector")
6666OPTION_GUIDE_END
6767
6868
r19188r19189
485485         if ((offset > 0) || (buffer_len < sector_length))
486486         {
487487            /* we will be doing an partial read/write; in other words we
488                * will not be reading/writing a full sector */
488            * will not be reading/writing a full sector */
489489            if (alloc_buf) free(alloc_buf);
490490            alloc_buf = (UINT8*)malloc(sector_length);
491491            if (!alloc_buf)
r19188r19189
550550
551551
552552
553floperr_t floppy_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int offset,   void *buffer, size_t buffer_len)
553floperr_t floppy_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int offset,  void *buffer, size_t buffer_len)
554554{
555555   return floppy_readwrite_sector(floppy, head, track, sector, offset, buffer, buffer_len, FALSE, FALSE, 0);
556556}
r19188r19189
564564
565565
566566
567floperr_t floppy_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector_index, int offset,   void *buffer, size_t buffer_len)
567floperr_t floppy_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector_index, int offset,    void *buffer, size_t buffer_len)
568568{
569569   return floppy_readwrite_sector(floppy, head, track, sector_index, offset, buffer, buffer_len, FALSE, TRUE, 0);
570570}
r19188r19189
10151015            goto track_done;
10161016      maxt--;
10171017   }
1018 track_done:
1018   track_done:
10191019   if(maxt >= 0)
10201020      while(maxh >= 0) {
10211021         for(int i=0; i<=maxt; i++)
r19188r19189
10231023               goto head_done;
10241024         maxh--;
10251025      }
1026 head_done:
1026   head_done:
10271027   _tracks = maxt+1;
10281028   _heads = maxh+1;
10291029}
r19188r19189
13731373         raw_w(buffer, offset, 8, gcr6fw_tb[(track & 0x40 ? 1 : 0) | (head ? 0x20 : 0)]);
13741374         break;
13751375
1376        case SECTOR_ID:
1376      case SECTOR_ID:
13771377         mfm_w(buffer, offset, 8, sect[sector_idx].sector_id);
13781378         break;
13791379
r19188r19189
21312131
21322132      // Wrap around
21332133      if(cur_entry == tsize-1 &&
2134         (tbuf[cur_entry] & floppy_image::TIME_MASK) < cur_pos) {
2134         (tbuf[cur_entry] & floppy_image::TIME_MASK) < cur_pos) {
21352135         // Wrap to index 0 or 1 depending on whether there is a transition exactly at the index hole
21362136         cur_entry = (tbuf[tsize-1] & floppy_image::MG_MASK) != (tbuf[0] & floppy_image::MG_MASK) ?
21372137            0 : 1;
r19188r19189
25242524      crc = calc_crc_ccitt(track_data, cpos, tpos);
25252525      fm_w (track_data, tpos, 16, crc);
25262526      for(int j=0; j<gap_2; j++) fm_w(track_data, tpos, 8, 0xff);
2527         
2527
25282528      if(!sects[i].data)
25292529         for(int j=0; j<6+1+sects[i].actual_size+2+gap_3; j++) fm_w(track_data, tpos, 8, 0xff);
25302530
r19188r19189
25432543   }
25442544
25452545   // Gap 4b
2546     
2546
25472547   while(tpos < cell_count-15) fm_w(track_data, tpos, 8, 0xff);
25482548   raw_w(track_data, tpos, cell_count-tpos, 0xffff >> (16+tpos-cell_count));
25492549
r19188r19189
25862586      for(int j=0; j<12; j++) mfm_w(track_data, tpos, 8, 0x00);
25872587      cpos = tpos;
25882588      for(int j=0; j< 3; j++) raw_w(track_data, tpos, 16, 0x4489);
2589      mfm_w(track_data, tpos, 8, 0xfe);   
2589      mfm_w(track_data, tpos, 8, 0xfe);
25902590      mfm_w(track_data, tpos, 8, sects[i].track);
25912591      mfm_w(track_data, tpos, 8, sects[i].head);
25922592      mfm_w(track_data, tpos, 8, sects[i].sector);
r19188r19189
26032603         for(int j=0; j<12; j++) mfm_w(track_data, tpos, 8, 0x00);
26042604         cpos = tpos;
26052605         for(int j=0; j< 3; j++) raw_w(track_data, tpos, 16, 0x4489);
2606         mfm_w(track_data, tpos, 8, sects[i].deleted ? 0xf8 : 0xfb);   
2606         mfm_w(track_data, tpos, 8, sects[i].deleted ? 0xf8 : 0xfb);
26072607         for(int j=0; j<sects[i].actual_size; j++) mfm_w(track_data, tpos, 8, sects[i].data[j]);
26082608         crc = calc_crc_ccitt(track_data, cpos, tpos);
26092609         if(sects[i].bad_crc)
r19188r19189
26212621   generate_track_from_levels(track, head, track_data, cell_count, 0, image);
26222622   global_free(track_data);
26232623}
2624
trunk/src/lib/formats/flopimg.h
r19188r19189
2424
2525***************************************************************************/
2626
27#define FLOPPY_FLAGS_READWRITE      0
28#define FLOPPY_FLAGS_READONLY      1
27#define FLOPPY_FLAGS_READWRITE      0
28#define FLOPPY_FLAGS_READONLY       1
2929
3030/* sector has a deleted data address mark */
31#define ID_FLAG_DELETED_DATA   0x0001
31#define ID_FLAG_DELETED_DATA    0x0001
3232/* CRC error in id field */
3333#define ID_FLAG_CRC_ERROR_IN_ID_FIELD 0x0002
3434/* CRC error in data field */
r19188r19189
4343
4444enum floperr_t
4545{
46   FLOPPY_ERROR_SUCCESS,         /* no error */
47   FLOPPY_ERROR_INTERNAL,         /* fatal internal error */
48   FLOPPY_ERROR_UNSUPPORTED,      /* this operation is unsupported */
49   FLOPPY_ERROR_OUTOFMEMORY,      /* ran out of memory */
50   FLOPPY_ERROR_SEEKERROR,         /* attempted to seek to nonexistant location */
51   FLOPPY_ERROR_INVALIDIMAGE,      /* this image in invalid */
52   FLOPPY_ERROR_READONLY,         /* attempt to write to read-only image */
46   FLOPPY_ERROR_SUCCESS,           /* no error */
47   FLOPPY_ERROR_INTERNAL,          /* fatal internal error */
48   FLOPPY_ERROR_UNSUPPORTED,       /* this operation is unsupported */
49   FLOPPY_ERROR_OUTOFMEMORY,       /* ran out of memory */
50   FLOPPY_ERROR_SEEKERROR,         /* attempted to seek to nonexistant location */
51   FLOPPY_ERROR_INVALIDIMAGE,      /* this image in invalid */
52   FLOPPY_ERROR_READONLY,          /* attempt to write to read-only image */
5353   FLOPPY_ERROR_NOSPACE,
5454   FLOPPY_ERROR_PARAMOUTOFRANGE,
5555   FLOPPY_ERROR_PARAMNOTSPECIFIED
r19188r19189
8989   const char *param_guidelines;
9090};
9191
92#define FLOPPY_IDENTIFY(name)   floperr_t name(floppy_image_legacy *floppy, const struct FloppyFormat *format, int *vote)
93#define FLOPPY_CONSTRUCT(name)   floperr_t name(floppy_image_legacy *floppy, const struct FloppyFormat *format, option_resolution *params)
94#define FLOPPY_DESTRUCT(name)   floperr_t name(floppy_image_legacy *floppy, const struct FloppyFormat *format)
92#define FLOPPY_IDENTIFY(name)   floperr_t name(floppy_image_legacy *floppy, const struct FloppyFormat *format, int *vote)
93#define FLOPPY_CONSTRUCT(name)  floperr_t name(floppy_image_legacy *floppy, const struct FloppyFormat *format, option_resolution *params)
94#define FLOPPY_DESTRUCT(name)   floperr_t name(floppy_image_legacy *floppy, const struct FloppyFormat *format)
9595
9696FLOPPY_IDENTIFY(td0_dsk_identify);
9797FLOPPY_CONSTRUCT(td0_dsk_construct);
r19188r19189
112112FLOPPY_IDENTIFY(fdi_dsk_identify);
113113FLOPPY_CONSTRUCT(fdi_dsk_construct);
114114
115#define LEGACY_FLOPPY_OPTIONS_NAME(name)   floppyoptions_##name
115#define LEGACY_FLOPPY_OPTIONS_NAME(name)    floppyoptions_##name
116116
117#define LEGACY_FLOPPY_OPTIONS_START(name)                                    \
118   const struct FloppyFormat floppyoptions_##name[] =                        \
119   {                                                         \
117#define LEGACY_FLOPPY_OPTIONS_START(name)                                               \
118   const struct FloppyFormat floppyoptions_##name[] =                              \
119   {                                                                           \
120120
121121#define LEGACY_FLOPPY_OPTIONS_END0 \
122      { NULL }                     \
122      { NULL }                            \
123123   };
124124
125#define LEGACY_FLOPPY_OPTIONS_EXTERN(name)                                    \
126   extern const struct FloppyFormat floppyoptions_##name[]                     \
125#define LEGACY_FLOPPY_OPTIONS_EXTERN(name)                                              \
126   extern const struct FloppyFormat floppyoptions_##name[]                         \
127127
128128#define LEGACY_FLOPPY_OPTION(name, extensions_, description_, identify_, construct_, destruct_, ranges_)\
129   { #name, extensions_, description_, identify_, construct_, destruct_, ranges_ },            \
129   { #name, extensions_, description_, identify_, construct_, destruct_, ranges_ },                \
130130
131#define LEGACY_FLOPPY_OPTIONS_END                                          \
131#define LEGACY_FLOPPY_OPTIONS_END                                                       \
132132      LEGACY_FLOPPY_OPTION( fdi, "fdi", "Formatted Disk Image", fdi_dsk_identify, fdi_dsk_construct, NULL, NULL) \
133      LEGACY_FLOPPY_OPTION( td0, "td0", "Teledisk floppy disk image",   td0_dsk_identify, td0_dsk_construct, td0_dsk_destruct, NULL) \
134      LEGACY_FLOPPY_OPTION( imd, "imd", "IMD floppy disk image",   imd_dsk_identify, imd_dsk_construct, NULL, NULL) \
135      LEGACY_FLOPPY_OPTION( cqm, "cqm,dsk", "CopyQM floppy disk image",   cqm_dsk_identify, cqm_dsk_construct, NULL, NULL) \
136      LEGACY_FLOPPY_OPTION( dsk, "dsk", "DSK floppy disk image",   dsk_dsk_identify, dsk_dsk_construct, NULL, NULL) \
133      LEGACY_FLOPPY_OPTION( td0, "td0", "Teledisk floppy disk image", td0_dsk_identify, td0_dsk_construct, td0_dsk_destruct, NULL) \
134      LEGACY_FLOPPY_OPTION( imd, "imd", "IMD floppy disk image",  imd_dsk_identify, imd_dsk_construct, NULL, NULL) \
135      LEGACY_FLOPPY_OPTION( cqm, "cqm,dsk", "CopyQM floppy disk image",   cqm_dsk_identify, cqm_dsk_construct, NULL, NULL) \
136      LEGACY_FLOPPY_OPTION( dsk, "dsk", "DSK floppy disk image",  dsk_dsk_identify, dsk_dsk_construct, NULL, NULL) \
137137      LEGACY_FLOPPY_OPTION( d88, "d77,d88,1dd", "D88 Floppy Disk image", d88_dsk_identify, d88_dsk_construct, NULL, NULL) \
138138   LEGACY_FLOPPY_OPTIONS_END0
139139
140140LEGACY_FLOPPY_OPTIONS_EXTERN(default);
141141
142#define PARAM_END            '\0'
143#define PARAM_HEADS            'H'
144#define PARAM_TRACKS         'T'
145#define PARAM_SECTORS         'S'
146#define PARAM_SECTOR_LENGTH      'L'
147#define PARAM_INTERLEAVE      'I'
148#define PARAM_FIRST_SECTOR_ID   'F'
142#define PARAM_END               '\0'
143#define PARAM_HEADS             'H'
144#define PARAM_TRACKS            'T'
145#define PARAM_SECTORS           'S'
146#define PARAM_SECTOR_LENGTH     'L'
147#define PARAM_INTERLEAVE        'I'
148#define PARAM_FIRST_SECTOR_ID   'F'
149149
150#define HEADS(range)         "H" #range
151#define TRACKS(range)         "T" #range
152#define SECTORS(range)         "S" #range
153#define SECTOR_LENGTH(range)   "L" #range
154#define INTERLEAVE(range)      "I" #range
155#define FIRST_SECTOR_ID(range)   "F" #range
150#define HEADS(range)            "H" #range
151#define TRACKS(range)           "T" #range
152#define SECTORS(range)          "S" #range
153#define SECTOR_LENGTH(range)    "L" #range
154#define INTERLEAVE(range)       "I" #range
155#define FIRST_SECTOR_ID(range)  "F" #range
156156
157157
158158/***************************************************************************
r19188r19189
227227   virtual ~floppy_image_format_t();
228228
229229   /*! @brief Identify an image.
230      The identify function tests if the image is valid
231      for this particular format.
232      @param io buffer containing the image data.
233      @param form_factor Physical form factor of disk, from the enum
234      in floppy_image
235      @return 1 if image valid, 0 otherwise.
236    */
230     The identify function tests if the image is valid
231     for this particular format.
232     @param io buffer containing the image data.
233     @param form_factor Physical form factor of disk, from the enum
234     in floppy_image
235     @return 1 if image valid, 0 otherwise.
236   */
237237   virtual int identify(io_generic *io, UINT32 form_factor) = 0;
238238
239239   /*! @brief Load an image.
240      The load function opens an image file and converts it to the
241      internal MESS floppy representation.
242      @param io source buffer containing the image data.
243      @param form_factor Physical form factor of disk, from the enum
244      in floppy_image
245      @param image output buffer for data in MESS internal format.
246      @return true on success, false otherwise.
247    */
248    virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image) = 0;
240     The load function opens an image file and converts it to the
241     internal MESS floppy representation.
242     @param io source buffer containing the image data.
243     @param form_factor Physical form factor of disk, from the enum
244     in floppy_image
245     @param image output buffer for data in MESS internal format.
246     @return true on success, false otherwise.
247   */
248   virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image) = 0;
249249
250    /*! @brief Save an image.
251      The save function writes back an image from the MESS internal
252      floppy representation to the appropriate format on disk.
253      @param io output buffer for the data in the on-disk format.
254      @param image source buffer containing data in MESS internal format.
255      @return true on success, false otherwise.
256    */
250   /*! @brief Save an image.
251     The save function writes back an image from the MESS internal
252     floppy representation to the appropriate format on disk.
253     @param io output buffer for the data in the on-disk format.
254     @param image source buffer containing data in MESS internal format.
255     @return true on success, false otherwise.
256   */
257257   virtual bool save(io_generic *io, floppy_image *image);
258258
259259   //! @returns string containing name of format.
r19188r19189
293293   //! A vector of these structures describes one track.
294294
295295   struct desc_e {
296      int type,   //!< An opcode
297         p1,    //!< first param
298         p2;    //!< second param
296      int type,   //!< An opcode
297         p1,     //!< first param
298         p2;     //!< second param
299299   };
300300
301301   //! Opcodes of the format description language used by generate_track()
r19188r19189
346346
347347
348348   /*! @brief Generate one track according to the description vector.
349        @param desc track data description
350        @param track
351        @param head
352        @param sect a vector indexed by sector id.
353        @param sect_count number of sectors.
354        @param track_size in _cells_, i.e. 100000 for a usual 2us-per-cell track at 300rpm.
355        @param image
356    */
349       @param desc track data description
350       @param track
351       @param head
352       @param sect a vector indexed by sector id.
353       @param sect_count number of sectors.
354       @param track_size in _cells_, i.e. 100000 for a usual 2us-per-cell track at 300rpm.
355       @param image
356   */
357357   void generate_track(const desc_e *desc, int track, int head, const desc_s *sect, int sect_count, int track_size, floppy_image *image);
358358
359359   /*! @brief Generate a track from cell binary values, MSB-first.
360        @param track
361        @param head
362        @param trackbuf track input buffer.
363        @param track_size in cells, not bytes.
364        @param image
365    */
360       @param track
361       @param head
362       @param trackbuf track input buffer.
363       @param track_size in cells, not bytes.
364       @param image
365   */
366366   void generate_track_from_bitstream(int track, int head, const UINT8 *trackbuf, int track_size, floppy_image *image);
367367
368368   //! @brief Generate a track from cell level values (0/1/W/D/N).
369369
370370   /*! Note that this function needs to be able to split cells in two,
371        so no time value should be less than 2, and even values are a
372        good idea.
373    */
371       so no time value should be less than 2, and even values are a
372       good idea.
373   */
374374   /*! @param track
375        @param head
376        @param trackbuf track input buffer.
377        @param track_size in cells, not bytes.
378        @param splice_pos is the position of the track splice.  For normal
379        formats, use -1.  For protected formats, you're supposed to
380        know. trackbuf may be modified at that position or after.
381        @param image
382    */
375       @param head
376       @param trackbuf track input buffer.
377       @param track_size in cells, not bytes.
378       @param splice_pos is the position of the track splice.  For normal
379       formats, use -1.  For protected formats, you're supposed to
380       know. trackbuf may be modified at that position or after.
381       @param image
382   */
383383   void generate_track_from_levels(int track, int head, UINT32 *trackbuf, int track_size, int splice_pos, floppy_image *image);
384384
385385   //! Normalize the times in a cell buffer to sum up to 200000000
r19188r19189
421421   // **** Writer helpers ****
422422
423423   /*! @brief Rebuild a cell bitstream for a track.
424        Takes the cell standard
425        angular size as a parameter, gives out a msb-first bitstream.
424       Takes the cell standard
425       angular size as a parameter, gives out a msb-first bitstream.
426426
427        Beware that fuzzy bits will always give out the same value.
428        @param track
429        @param head
430        @param cell_size
431        @param trackbuf Output buffer size should be 34% more than the nominal number
432        of cells (the dpll tolerates a cell size down to 75% of the
433        nominal one, with gives a cell count of 1/0.75=1.333... times
434        the nominal one).
435        @param track_size Output size is given in bits (cells).
436        @param image
437    */
427       Beware that fuzzy bits will always give out the same value.
428       @param track
429       @param head
430       @param cell_size
431       @param trackbuf Output buffer size should be 34% more than the nominal number
432       of cells (the dpll tolerates a cell size down to 75% of the
433       nominal one, with gives a cell count of 1/0.75=1.333... times
434       the nominal one).
435       @param track_size Output size is given in bits (cells).
436       @param image
437   */
438438   /*! @verbatim
439     Computing the standard angular size of a cell is
440     simple. Noting:
441       d = standard cell duration in microseconds
442       r = motor rotational speed in rpm
443     then:
444       a = r * d * 10 / 3.
445     Some values:
446       Type           Cell    RPM    Size
439    Computing the standard angular size of a cell is
440    simple. Noting:
441      d = standard cell duration in microseconds
442      r = motor rotational speed in rpm
443    then:
444      a = r * d * 10 / 3.
445    Some values:
446      Type           Cell    RPM    Size
447447
448     C1541 tr  1-17   3.25    300    3250
449     C1541 tr 18-24   3.50    300    3500
450     C1541 tr 25-30   3.75    300    3750
451     C1541 tr 31+     4.00    300    4000
452     5.25" SD         4       300    4000
453     5.25" DD         2       300    2000
454     5.25" HD         1       360    1200
455     3.5" SD          4       300    4000
456     3.5" DD          2       300    2000
457     3.5" HD          1       300    1000
458     3.5" ED          0.5     300     500
459     @endverbatim
460     */
448    C1541 tr  1-17   3.25    300    3250
449    C1541 tr 18-24   3.50    300    3500
450    C1541 tr 25-30   3.75    300    3750
451    C1541 tr 31+     4.00    300    4000
452    5.25" SD         4       300    4000
453    5.25" DD         2       300    2000
454    5.25" HD         1       360    1200
455    3.5" SD          4       300    4000
456    3.5" DD          2       300    2000
457    3.5" HD          1       300    1000
458    3.5" ED          0.5     300     500
459    @endverbatim
460    */
461461
462462   void generate_bitstream_from_track(int track, int head, int cell_size,  UINT8 *trackbuf, int &track_size, floppy_image *image);
463463
464464   //! Defines a standard sector for extracting.
465465   struct desc_xs {
466      int track,   //!< Track for this sector
467          head,   //!< Head for this sector
468          size;   //!< Size of this sector
466      int track,  //!< Track for this sector
467         head,   //!< Head for this sector
468         size;   //!< Size of this sector
469469      const UINT8 *data; //!< Data within this sector
470470   };
471471
r19188r19189
501501
502502   //! @brief Get a geometry (including sectors) from an image.
503503
504    //!   PC-type sectors with MFM encoding
504   //!   PC-type sectors with MFM encoding
505505   void get_geometry_mfm_pc(floppy_image *image, int cell_size, int &track_count, int &head_count, int &sector_count);
506506   //!   PC-type sectors with FM encoding
507507   void get_geometry_fm_pc(floppy_image *image, int cell_size, int &track_count, int &head_count, int &sector_count);
r19188r19189
621621   enum {
622622      TIME_MASK = 0x0fffffff,
623623      MG_MASK   = 0xf0000000,
624      MG_SHIFT  = 28,   //!< Bitshift constant for magnetic orientation data
625      MG_A      = (0 << MG_SHIFT),   //!< - 0, MG_A -> Magnetic orientation A
626      MG_B      = (1 << MG_SHIFT),   //!< - 1, MG_B -> Magnetic orientation B
627      MG_N      = (2 << MG_SHIFT),   //!< - 2, MG_N -> Non-magnetized zone (neutral)
628      MG_D      = (3 << MG_SHIFT)    //!< - 3, MG_D -> Damaged zone, reads as neutral but cannot be changed by writing
624      MG_SHIFT  = 28, //!< Bitshift constant for magnetic orientation data
625      MG_A      = (0 << MG_SHIFT),    //!< - 0, MG_A -> Magnetic orientation A
626      MG_B      = (1 << MG_SHIFT),    //!< - 1, MG_B -> Magnetic orientation B
627      MG_N      = (2 << MG_SHIFT),    //!< - 2, MG_N -> Non-magnetized zone (neutral)
628      MG_D      = (3 << MG_SHIFT)     //!< - 3, MG_D -> Damaged zone, reads as neutral but cannot be changed by writing
629629   };
630630
631631
r19188r19189
643643      SSSD  = 0x44535353, //!< "SSSD", Single-sided single-density
644644      SSDD  = 0x44445353, //!< "SSDD", Single-sided double-density
645645      SSQD  = 0x44515353, //!< "SSQD", Single-sided quad-density
646      DSSD  = 0x44535344, //!< "DSSD", Double-sided single-density
646647      DSDD  = 0x44445344, //!< "DSDD", Double-sided double-density (720K in 3.5, 360K in 5.25)
647648      DSQD  = 0x44515344, //!< "DSQD", Double-sided quad-density (720K in 5.25, means DD+80 tracks)
648649      DSHD  = 0x44485344, //!< "DSHD", Double-sided high-density (1440K)
r19188r19189
654655
655656   //! floppy_image constructor
656657   /*!
657      @param _tracks number of tracks.
658      @param _heads number of heads.
659      @param _form_factor form factor of drive (from enum)
660    */
658     @param _tracks number of tracks.
659     @param _heads number of heads.
660     @param _form_factor form factor of drive (from enum)
661   */
661662   floppy_image(int tracks, int heads, UINT32 form_factor);
662663   virtual ~floppy_image();
663664
r19188r19189
669670   void set_variant(UINT32 v) { variant = v; }
670671
671672   /*!
672      @param track
673      @param head
674      @param size size of this track
675    */
673     @param track
674     @param head
675     @param size size of this track
676   */
676677   void set_track_size(int track, int head, UINT32 size) { track_size[track][head] = size; ensure_alloc(track, head); }
677678
678    /*!
679      @param track track number
680      @param head head number
681      @return a pointer to the data buffer for this track and head
682    */
679   /*!
680     @param track track number
681     @param head head number
682     @return a pointer to the data buffer for this track and head
683   */
683684   UINT32 *get_buffer(int track, int head) { return cell_data[track][head]; }
684685   //! @return the track size
685686   //! @param track
r19188r19189
694695   //! representation is the angular position relative to the index.
695696
696697   /*! @param track
697        @param head
698        @param pos the position
699    */
698       @param head
699       @param pos the position
700   */
700701   void set_write_splice_position(int track, int head, UINT32 pos) { write_splice[track][head] = pos; }
701702   //! @return the current write splice position.
702703   UINT32 get_write_splice_position(int track, int head) const { return write_splice[track][head]; }
r19188r19189
732733};
733734
734735#endif /* FLOPIMG_H */
735
trunk/src/emu/machine/wd_fdc.h
r19188r19189
6666#define MCFG_FD1797x_ADD(_tag, _clock)  \
6767   MCFG_DEVICE_ADD(_tag, FD1797x, _clock)
6868
69#define MCFG_MB866x_ADD(_tag, _clock)  \
69#define MCFG_MB8866x_ADD(_tag, _clock)  \
7070   MCFG_DEVICE_ADD(_tag, MB8866x, _clock)
7171
72#define MCFG_MB876x_ADD(_tag, _clock)  \
72#define MCFG_MB8876x_ADD(_tag, _clock)  \
7373   MCFG_DEVICE_ADD(_tag, MB8876x, _clock)
7474
75#define MCFG_MB877x_ADD(_tag, _clock)  \
75#define MCFG_MB8877x_ADD(_tag, _clock)  \
7676   MCFG_DEVICE_ADD(_tag, MB8877x, _clock)
7777
7878#define MCFG_FD1761x_ADD(_tag, _clock)  \
trunk/src/emu/imagedev/floppy.c
r19188r19189
1919const device_type FLOPPY_35_HD = &device_creator<floppy_35_hd>;
2020const device_type FLOPPY_35_ED = &device_creator<floppy_35_ed>;
2121const device_type FLOPPY_525_SSSD_35T = &device_creator<floppy_525_sssd_35t>;
22const device_type FLOPPY_525_SD_35T = &device_creator<floppy_525_sd_35t>;
2223const device_type FLOPPY_525_SSSD = &device_creator<floppy_525_sssd>;
24const device_type FLOPPY_525_SD = &device_creator<floppy_525_sd>;
2325const device_type FLOPPY_525_SSDD = &device_creator<floppy_525_ssdd>;
2426const device_type FLOPPY_525_DD = &device_creator<floppy_525_dd>;
2527const device_type FLOPPY_525_QD = &device_creator<floppy_525_qd>;
r19188r19189
7476//-------------------------------------------------
7577
7678floppy_image_device::floppy_image_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock)
77    : device_t(mconfig, type, name, tag, owner, clock),
78     device_image_interface(mconfig, *this),
79     device_slot_card_interface(mconfig, *this),
80     image(NULL)
79   : device_t(mconfig, type, name, tag, owner, clock),
80      device_image_interface(mconfig, *this),
81      device_slot_card_interface(mconfig, *this),
82      image(NULL)
8183{
8284   extension_list[0] = '\0';
8385}
r19188r19189
108110void floppy_image_device::set_formats(const floppy_format_type *formats)
109111{
110112   image_device_format **formatptr;
111    image_device_format *format;
112    formatptr = &m_formatlist;
113   image_device_format *format;
114   formatptr = &m_formatlist;
113115   extension_list[0] = '\0';
114116   fif_list = 0;
115117   for(int cnt=0; formats[cnt]; cnt++)
r19188r19189
390392
391393   if (image) image->get_actual_geometry(tracks, heads);
392394
393   return heads == 2;
395   return heads == 1;
394396}
395397
396398void floppy_image_device::stp_w(int state)
397399{
398    if ( stp != state ) {
400   if ( stp != state ) {
399401      stp = state;
400       if ( stp == 0 ) {
402      if ( stp == 0 ) {
401403         int ocyl = cyl;
402404         if ( dir ) {
403405            if ( cyl ) cyl--;
r19188r19189
966968   variants[var_count++] = floppy_image::SSSD;
967969}
968970
971floppy_525_sd_35t::floppy_525_sd_35t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
972   floppy_image_device(mconfig, FLOPPY_525_SD_35T, "5.25\" single density 35-track floppy drive", tag, owner, clock)
973{
974}
975
976floppy_525_sd_35t::~floppy_525_sd_35t()
977{
978}
979
980void floppy_525_sd_35t::setup_characteristics()
981{
982   form_factor = floppy_image::FF_525;
983   tracks = 35;
984   sides = 2;
985   set_rpm(300);
986}
987
988void floppy_525_sd_35t::handled_variants(UINT32 *variants, int &var_count) const
989{
990   var_count = 0;
991   variants[var_count++] = floppy_image::SSSD;
992}
993
969994floppy_525_sssd::floppy_525_sssd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
970995   floppy_image_device(mconfig, FLOPPY_525_SSSD, "5.25\" single-sided single density floppy drive", tag, owner, clock)
971996{
r19188r19189
9891014   variants[var_count++] = floppy_image::SSSD;
9901015}
9911016
1017floppy_525_sd::floppy_525_sd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
1018   floppy_image_device(mconfig, FLOPPY_525_SD, "5.25\" single density floppy drive", tag, owner, clock)
1019{
1020}
1021
1022floppy_525_sd::~floppy_525_sd()
1023{
1024}
1025
1026void floppy_525_sd::setup_characteristics()
1027{
1028   form_factor = floppy_image::FF_525;
1029   tracks = 42;
1030   sides = 2;
1031   set_rpm(300);
1032}
1033
1034void floppy_525_sd::handled_variants(UINT32 *variants, int &var_count) const
1035{
1036   var_count = 0;
1037   variants[var_count++] = floppy_image::SSSD;
1038}
1039
9921040floppy_525_ssdd::floppy_525_ssdd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
9931041   floppy_image_device(mconfig, FLOPPY_525_SSDD, "5.25\" single-sided double density floppy drive", tag, owner, clock)
9941042{
trunk/src/emu/imagedev/floppy.h
r19188r19189
1515#include "formats/ipf_dsk.h"
1616#include "formats/mfi_dsk.h"
1717
18#define MCFG_FLOPPY_DRIVE_ADD(_tag, _slot_intf, _def_slot, _def_inp, _formats)   \
18#define MCFG_FLOPPY_DRIVE_ADD(_tag, _slot_intf, _def_slot, _def_inp, _formats)  \
1919   MCFG_DEVICE_ADD(_tag, FLOPPY_CONNECTOR, 0) \
2020   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp, false) \
2121   static_cast<floppy_connector *>(device)->set_formats(_formats);
r19188r19189
4141    TYPE DEFINITIONS
4242***************************************************************************/
4343
44class floppy_image_device :   public device_t,
44class floppy_image_device : public device_t,
4545                     public device_image_interface,
4646                     public device_slot_card_interface
4747{
r19188r19189
126126   image_device_format   format;
127127   floppy_image_format_t *input_format;
128128   floppy_image_format_t *output_format;
129   floppy_image        *image;
130   char              extension_list[256];
129   floppy_image          *image;
130   char                  extension_list[256];
131131   floppy_image_format_t *fif_list;
132132   emu_timer             *index_timer;
133133
r19188r19189
142142   int stp;  /* step */
143143   int wtg;  /* write gate */
144144   int mon;  /* motor on */
145   int ss;   /* side select */
145   int ss; /* side select */
146146
147147   /* state of output lines */
148148   int idx;  /* index pulse */
149149   int wpt;  /* write protect */
150150   int rdy;  /* ready */
151   int dskchg;      /* disk changed */
151   int dskchg;     /* disk changed */
152152
153153   /* rotation per minute => gives index pulse frequency */
154154   float rpm;
r19188r19189
264264   virtual void setup_characteristics();
265265};
266266
267class floppy_525_sd_35t : public floppy_image_device {
268public:
269   floppy_525_sd_35t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
270   virtual ~floppy_525_sd_35t();
271   virtual void handled_variants(UINT32 *variants, int &var_count) const;
272   virtual void device_config_complete() { m_shortname = "floppy_525_sd_35t"; }
273   virtual const char *image_interface() const { return "floppy_5_25"; }
274protected:
275   virtual void setup_characteristics();
276};
277
267278class floppy_525_sssd : public floppy_image_device {
268279public:
269280   floppy_525_sssd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
r19188r19189
275286   virtual void setup_characteristics();
276287};
277288
289class floppy_525_sd : public floppy_image_device {
290public:
291   floppy_525_sd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
292   virtual ~floppy_525_sd();
293   virtual void handled_variants(UINT32 *variants, int &var_count) const;
294   virtual void device_config_complete() { m_shortname = "floppy_525_sd"; }
295   virtual const char *image_interface() const { return "floppy_5_25"; }
296protected:
297   virtual void setup_characteristics();
298};
299
278300class floppy_525_ssdd : public floppy_image_device {
279301public:
280302   floppy_525_ssdd(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
r19188r19189
380402extern const device_type FLOPPY_35_HD;
381403extern const device_type FLOPPY_35_ED;
382404extern const device_type FLOPPY_525_SSSD_35T;
405extern const device_type FLOPPY_525_SD_35T;
383406extern const device_type FLOPPY_525_SSSD;
407extern const device_type FLOPPY_525_SD;
384408extern const device_type FLOPPY_525_SSDD;
385409extern const device_type FLOPPY_525_DD;
386410extern const device_type FLOPPY_525_QD;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team