Previous 15994 Revisions Next

r14973 Friday 20th April, 2012 at 04:58:47 UTC by Jonathan Gevaryahu
Add multiread support (behind a define for now pending heuristics) to the dfi import support. Fix some inaccuracies regarding index decode position in dfi files. [Lord Nightmare]
[src/lib/formats]dfi_dsk.c

src/lib/formats/dfi_dsk.c
r14972r14973
3434#include "emu.h"
3535#include "dfi_dsk.h"
3636#include <zlib.h>
37#define NUMBER_OF_MULTIREADS 1
3738
3839dfi_format::dfi_format() : floppy_image_format_t()
3940{
r14972r14973
4647
4748const char *dfi_format::description() const
4849{
49   return "DiskFerret flux dump format";
50   return "DiscFerret flux dump format";
5051}
5152
5253const char *dfi_format::extensions() const
r14972r14973
99100      tsize--; // Drop the extra 0x00 at the end
100101
101102      int index_time = 0;
103      int index_count = 0;
102104      int total_time = 0;
103105      for(int i=0; i<tsize; i++) {
104106         UINT8 v = data[i];
r14972r14973
106108            total_time += 0x7f;
107109         else {
108110            total_time += v & 0x7f;
109            if((v & 0x80) && !index_time)
110               index_time = total_time;
111            if((v & 0x80) && (index_count<NUMBER_OF_MULTIREADS)) {
112               index_time = total_time;///NUMBER_OF_MULTIREADS;
113               index_count++;
114            }
111115         }
112116      }
113117
r14972r14973
120124      image->set_track_size(track, head, tsize);
121125
122126      int cur_time = 0;
127      index_count = 0;
128      int index_polarity = 0;
123129      UINT32 mg = floppy_image::MG_A;
124130      UINT32 *buf = image->get_buffer(track, head);
125131      int tpos = 0;
126132      buf[tpos++] = mg;
127133      for(int i=0; i<tsize; i++) {
128134         UINT8 v = data[i];
129         if((v & 0x7f) == 0x7f)
135         if((v & 0x7f) == 0x7f) // 0x7F or 0xFF: no transition, but a carry
130136            cur_time += 0x7f;
131         else {
137         else if((v & 0x80) == 0) { // 0x00-0x7E: not an index or carry, add the number and store transition
132138            cur_time += v & 0x7f;
133            if(v & 0x80)
134               break;
135139            mg = mg == floppy_image::MG_A ? floppy_image::MG_B : floppy_image::MG_A;
136140            buf[tpos++] = mg | UINT32(200000000ULL*cur_time/index_time);
141         } else if(v & 0x80) { // 0x80-0xFF an index, note the index (TODO: actually do this!) and do not add number
142            index_polarity ^= 1;
143            index_count += index_polarity;
144            if (index_count == NUMBER_OF_MULTIREADS) break;
137145         }
138146      }
139147      image->set_track_size(track, head, tpos);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team