src/lib/formats/dfi_dsk.c
| r14972 | r14973 | |
| 34 | 34 | #include "emu.h" |
| 35 | 35 | #include "dfi_dsk.h" |
| 36 | 36 | #include <zlib.h> |
| 37 | #define NUMBER_OF_MULTIREADS 1 |
| 37 | 38 | |
| 38 | 39 | dfi_format::dfi_format() : floppy_image_format_t() |
| 39 | 40 | { |
| r14972 | r14973 | |
| 46 | 47 | |
| 47 | 48 | const char *dfi_format::description() const |
| 48 | 49 | { |
| 49 | | return "DiskFerret flux dump format"; |
| 50 | return "DiscFerret flux dump format"; |
| 50 | 51 | } |
| 51 | 52 | |
| 52 | 53 | const char *dfi_format::extensions() const |
| r14972 | r14973 | |
| 99 | 100 | tsize--; // Drop the extra 0x00 at the end |
| 100 | 101 | |
| 101 | 102 | int index_time = 0; |
| 103 | int index_count = 0; |
| 102 | 104 | int total_time = 0; |
| 103 | 105 | for(int i=0; i<tsize; i++) { |
| 104 | 106 | UINT8 v = data[i]; |
| r14972 | r14973 | |
| 106 | 108 | total_time += 0x7f; |
| 107 | 109 | else { |
| 108 | 110 | 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 | } |
| 111 | 115 | } |
| 112 | 116 | } |
| 113 | 117 | |
| r14972 | r14973 | |
| 120 | 124 | image->set_track_size(track, head, tsize); |
| 121 | 125 | |
| 122 | 126 | int cur_time = 0; |
| 127 | index_count = 0; |
| 128 | int index_polarity = 0; |
| 123 | 129 | UINT32 mg = floppy_image::MG_A; |
| 124 | 130 | UINT32 *buf = image->get_buffer(track, head); |
| 125 | 131 | int tpos = 0; |
| 126 | 132 | buf[tpos++] = mg; |
| 127 | 133 | for(int i=0; i<tsize; i++) { |
| 128 | 134 | UINT8 v = data[i]; |
| 129 | | if((v & 0x7f) == 0x7f) |
| 135 | if((v & 0x7f) == 0x7f) // 0x7F or 0xFF: no transition, but a carry |
| 130 | 136 | cur_time += 0x7f; |
| 131 | | else { |
| 137 | else if((v & 0x80) == 0) { // 0x00-0x7E: not an index or carry, add the number and store transition |
| 132 | 138 | cur_time += v & 0x7f; |
| 133 | | if(v & 0x80) |
| 134 | | break; |
| 135 | 139 | mg = mg == floppy_image::MG_A ? floppy_image::MG_B : floppy_image::MG_A; |
| 136 | 140 | 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; |
| 137 | 145 | } |
| 138 | 146 | } |
| 139 | 147 | image->set_track_size(track, head, tpos); |