Previous 199869 Revisions Next

r33004 Monday 27th October, 2014 at 13:35:22 UTC by Olivier Galibert
ap2_dsk: edd support [O. Galibert]
[src/emu/bus/a2bus]a2diskiing.c
[src/emu/imagedev]floppy.c
[src/lib/formats]ap2_dsk.c ap2_dsk.h flopimg.c flopimg.h
[src/mess/drivers]apple3.c
[src/mess/tools/floptool]main.c

trunk/src/emu/bus/a2bus/a2diskiing.c
r241515r241516
4040ROM_END
4141
4242FLOPPY_FORMATS_MEMBER( a2bus_diskiing_device::floppy_formats )
43   FLOPPY_A216S_FORMAT, FLOPPY_RWTS18_FORMAT
43   FLOPPY_A216S_FORMAT, FLOPPY_RWTS18_FORMAT, FLOPPY_EDD_FORMAT
4444FLOPPY_FORMATS_END
4545
4646//-------------------------------------------------
trunk/src/emu/imagedev/floppy.c
r241515r241516
623623   if(!image || mon)
624624      return attotime::never;
625625
626   int cells = image->get_track_size(cyl, ss);
626   int cells = image->get_track_size(cyl, ss, subcyl);
627627   if(cells <= 1)
628628      return attotime::never;
629629
630630   attotime base;
631631   UINT32 position = find_position(base, from_when);
632632
633   const UINT32 *buf = image->get_buffer(cyl, ss);
633   const UINT32 *buf = image->get_buffer(cyl, ss, subcyl);
634634   int index = find_index(position, buf, cells);
635635
636636   if(index == -1)
r241515r241516
661661   for(int i=0; i != transition_count; i++)
662662      trans_pos[i] = find_position(base, transitions[i]);
663663
664   int cells = image->get_track_size(cyl, ss);
665   UINT32 *buf = image->get_buffer(cyl, ss);
664   int cells = image->get_track_size(cyl, ss, subcyl);
665   UINT32 *buf = image->get_buffer(cyl, ss, subcyl);
666666
667667   int index;
668668   if(cells)
669669      index = find_index(start_pos, buf, cells);
670670   else {
671671      index = 0;
672      image->set_track_size(cyl, ss, 1);
673      buf = image->get_buffer(cyl, ss);
672      image->set_track_size(cyl, ss, 1, subcyl);
673      buf = image->get_buffer(cyl, ss, subcyl);
674674      buf[cells++] = floppy_image::MG_N;
675675   }
676676
r241515r241516
684684   UINT32 pos = start_pos;
685685   int ti = 0;
686686   while(pos != end_pos) {
687      if(image->get_track_size(cyl, ss) < cells+10) {
688         image->set_track_size(cyl, ss, cells+200);
689         buf = image->get_buffer(cyl, ss);
687      if(image->get_track_size(cyl, ss, subcyl) < cells+10) {
688         image->set_track_size(cyl, ss, cells+200, subcyl);
689         buf = image->get_buffer(cyl, ss, subcyl);
690690      }
691691      UINT32 next_pos;
692692      if(ti != transition_count)
r241515r241516
704704      cur_mg = cur_mg == floppy_image::MG_A ? floppy_image::MG_B : floppy_image::MG_A;
705705   }
706706
707   image->set_track_size(cyl, ss, cells);
707   image->set_track_size(cyl, ss, cells, subcyl);
708708}
709709
710710void floppy_image_device::write_zone(UINT32 *buf, int &cells, int &index, UINT32 spos, UINT32 epos, UINT32 mg)
r241515r241516
812812      image_dirty = true;
813813      attotime base;
814814      int splice_pos = find_position(base, when);
815      image->set_write_splice_position(cyl, ss, splice_pos);
815      image->set_write_splice_position(cyl, ss, splice_pos, subcyl);
816816   }
817817}
818818
trunk/src/lib/formats/ap2_dsk.c
r241515r241516
15131513}
15141514
15151515const floppy_format_type FLOPPY_RWTS18_FORMAT = &floppy_image_format_creator<a2_rwts18_format>;
1516
1517a2_edd_format::a2_edd_format() : floppy_image_format_t()
1518{
1519}
1520
1521const char *a2_edd_format::name() const
1522{
1523   return "a2_edd";
1524}
1525
1526const char *a2_edd_format::description() const
1527{
1528   return "Apple II EDD Image";
1529}
1530
1531const char *a2_edd_format::extensions() const
1532{
1533   return "edd";
1534}
1535
1536bool a2_edd_format::supports_save() const
1537{
1538   return true;
1539}
1540
1541int a2_edd_format::identify(io_generic *io, UINT32 form_factor)
1542{
1543   return io_generic_size(io) == 2244608 ? 50 : 0;
1544}
1545
1546UINT8 a2_edd_format::pick(const UINT8 *data, int pos)
1547{
1548   return ((data[pos>>3] << 8) | data[(pos>>3)+1]) >> (8-(pos & 7));
1549}
1550
1551bool a2_edd_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
1552{
1553   UINT8 img[2244608];
1554   UINT8 nibble[16384], stream[16384];
1555   int npos[16384];
1556   io_generic_read(io, img, 0, 2244608);
1557
1558   for(int i=0; i<137; i++) {
1559      const UINT8 *trk = img + 16384*i;
1560      int pos = 0;
1561      int wpos = 0;
1562      while(pos < 16383*8) {
1563         UINT8 acc = pick(trk, pos);
1564         pos += 8;
1565         while(!(acc & 0x80) && pos < 16384*8) {
1566            acc <<= 1;
1567            if(trk[pos >> 3] & (0x80 >> (pos & 7)))
1568               acc |= 0x01;
1569            pos++;
1570         }
1571         if(acc & 0x80) {
1572            nibble[wpos] = acc;
1573            npos[wpos] = pos;
1574            wpos++;
1575         }
1576      }
1577      int nm = 0, nmj = 0, nmk = 0;
1578      for(int j=0; j<wpos-1; j++)
1579         for(int k=j+6200; k<wpos && k<j+6400; k++) {
1580            int m = 0;
1581            for(int l=0; k+l<wpos && nibble[j+l] == nibble[k+l]; l++)
1582               m++;
1583            if(m > nm) {
1584               nm = m;
1585               nmj = j;
1586               nmk = k;
1587            }
1588         }
1589      int delta = nmk - nmj;
1590      int spos = (wpos-delta)/2;
1591      int zpos = npos[spos];
1592      int epos = npos[spos+delta];
1593      int len = epos-zpos;
1594      int part1_size = zpos % len;
1595      int part1_bsize = part1_size >> 3;
1596      int part1_spos = epos-part1_size;
1597      int part2_offset = zpos - part1_size;
1598      int total_bsize = (len+7) >> 3;
1599
1600      for(int j=0; j<part1_bsize; j++)
1601         stream[j] = pick(trk, part1_spos + 8*j);
1602      stream[part1_bsize] =
1603         (pick(trk, part1_spos + 8*part1_bsize) & (0xff00 >> (part1_size & 7))) |
1604         (pick(trk, part2_offset + 8*part1_bsize) & (0x00ff >> (part1_size & 7)));
1605      for(int j=part1_bsize+1; j<total_bsize; j++)
1606         stream[j] = pick(trk, part2_offset + 8*j);
1607
1608      bool odd = false;
1609      for(int j=0; j<len; j++)
1610         if(stream[j>>3] & (0x80 >> (j & 7)))
1611            odd = !odd;
1612
1613      int splice_byte = spos;
1614      while(splice_byte < spos+delta && (npos[splice_byte+1] - npos[splice_byte] != 8 || npos[splice_byte+2] - npos[splice_byte+1] == 8 || npos[splice_byte+2] - npos[splice_byte+2] == 8))
1615         splice_byte++;
1616      int splice = (npos[splice_byte+2]-1) % len;
1617      if(odd)
1618         stream[splice >> 3] ^= 0x80 >> (splice & 7);
1619
1620      generate_track_from_bitstream(i >> 2, 0, stream, len, image, i & 3);
1621      image->set_write_splice_position(i >> 2, 0, UINT32(U64(200000000)*splice/len), i & 3);
1622   }
1623   return true;
1624}
1625
1626const floppy_format_type FLOPPY_EDD_FORMAT = &floppy_image_format_creator<a2_edd_format>;
trunk/src/lib/formats/ap2_dsk.h
r241515r241516
8080
8181extern const floppy_format_type FLOPPY_RWTS18_FORMAT;
8282
83
84class a2_edd_format : public floppy_image_format_t
85{
86public:
87      a2_edd_format();
88
89      virtual int identify(io_generic *io, UINT32 form_factor);
90      virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
91      virtual bool supports_save() const;
92
93      virtual const char *name() const;
94      virtual const char *description() const;
95      virtual const char *extensions() const;
96
97private:
98      static UINT8 pick(const UINT8 *data, int pos);
99};
100
101extern const floppy_format_type FLOPPY_EDD_FORMAT;
102
83103#endif /* AP2_DISK_H */
trunk/src/lib/formats/flopimg.c
r241515r241516
16471647   }
16481648}
16491649
1650void floppy_image_format_t::generate_track_from_bitstream(int track, int head, const UINT8 *trackbuf, int track_size, floppy_image *image)
1650void floppy_image_format_t::generate_track_from_bitstream(int track, int head, const UINT8 *trackbuf, int track_size, floppy_image *image, int subtrack)
16511651{
16521652   // Maximal number of cells which happens when the buffer is all 1
1653   image->set_track_size(track, head, track_size+1);
1654   UINT32 *dest = image->get_buffer(track, head);
1653   image->set_track_size(track, head, track_size+1, subtrack);
1654   UINT32 *dest = image->get_buffer(track, head, subtrack);
16551655   UINT32 *base = dest;
16561656
16571657   UINT32 cbit = floppy_image::MG_A;
r241515r241516
16691669
16701670   int size = dest - base;
16711671   normalize_times(base, size);
1672   image->set_track_size(track, head, size);
1673   image->set_write_splice_position(track, head, 0);
1672   image->set_track_size(track, head, size, subtrack);
1673   image->set_write_splice_position(track, head, 0, subtrack);
16741674}
16751675
16761676void floppy_image_format_t::generate_track_from_levels(int track, int head, UINT32 *trackbuf, int track_size, int splice_pos, floppy_image *image)
r241515r241516
21662166   { END }
21672167};
21682168
2169void floppy_image_format_t::generate_bitstream_from_track(int track, int head, int cell_size, UINT8 *trackbuf, int &track_size, floppy_image *image)
2169void floppy_image_format_t::generate_bitstream_from_track(int track, int head, int cell_size, UINT8 *trackbuf, int &track_size, floppy_image *image, int subtrack)
21702170{
2171   int tsize = image->get_track_size(track, head);
2171   int tsize = image->get_track_size(track, head, subtrack);
21722172   if(!tsize || tsize == 1) {
21732173      // Unformatted track
21742174      track_size = 200000000/cell_size;
r241515r241516
21772177   }
21782178
21792179   // Start at the write splice
2180   const UINT32 *tbuf = image->get_buffer(track, head);
2181   UINT32 splice = image->get_write_splice_position(track, head);
2180   const UINT32 *tbuf = image->get_buffer(track, head, subtrack);
2181   UINT32 splice = image->get_write_splice_position(track, head, subtrack);
21822182   int cur_pos = splice;
21832183   int cur_entry = 0;
21842184   while(cur_entry < tsize-1 && (tbuf[cur_entry+1] & floppy_image::TIME_MASK) < cur_pos)
trunk/src/lib/formats/flopimg.h
r241515r241516
381381       @param track_size in cells, not bytes.
382382       @param image
383383   */
384   void generate_track_from_bitstream(int track, int head, const UINT8 *trackbuf, int track_size, floppy_image *image);
384   void generate_track_from_bitstream(int track, int head, const UINT8 *trackbuf, int track_size, floppy_image *image, int subtrack = 0);
385385
386386   //! @brief Generate a track from cell level values (0/1/W/D/N).
387387
r241515r241516
477477    @endverbatim
478478    */
479479
480   void generate_bitstream_from_track(int track, int head, int cell_size, UINT8 *trackbuf, int &track_size, floppy_image *image);
480   void generate_bitstream_from_track(int track, int head, int cell_size, UINT8 *trackbuf, int &track_size, floppy_image *image, int subtrack = 0);
481481
482482   //! Defines a standard sector for extracting.
483483   struct desc_xs {
trunk/src/mess/drivers/apple3.c
r241515r241516
4141SLOT_INTERFACE_END
4242
4343FLOPPY_FORMATS_MEMBER( apple3_state::floppy_formats )
44   FLOPPY_A216S_FORMAT, FLOPPY_RWTS18_FORMAT
44   FLOPPY_A216S_FORMAT, FLOPPY_RWTS18_FORMAT, FLOPPY_EDD_FORMAT
4545FLOPPY_FORMATS_END
4646
4747static MACHINE_CONFIG_START( apple3, apple3_state )
trunk/src/mess/tools/floptool/main.c
r241515r241516
7070   FLOPPY_DC42_FORMAT,
7171   FLOPPY_A216S_FORMAT,
7272   FLOPPY_RWTS18_FORMAT,
73   FLOPPY_EDD_FORMAT,
7374
7475   FLOPPY_ORIC_DSK_FORMAT,
7576


Previous 199869 Revisions Next


© 1997-2024 The MAME Team