diff options
author | 2018-05-23 07:04:22 +0200 | |
---|---|---|
committer | 2018-05-26 22:06:40 +0200 | |
commit | de919271fef7b0378e7d3a4baa800bc8d3952244 (patch) | |
tree | bc1163e80691a2ea42c5541899197fa642251927 | |
parent | 5291d140218339dff4fa471b1f8f1cfab3eb3fa1 (diff) |
Floppy robustification, better bitstream handling [John Keoni Morris, Peter Ferrie, Olivier Galibert]
-rw-r--r-- | src/devices/imagedev/floppy.cpp | 22 | ||||
-rw-r--r-- | src/lib/formats/flopimg.cpp | 25 |
2 files changed, 23 insertions, 24 deletions
diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp index 5ef5668b741..a18308b5f36 100644 --- a/src/devices/imagedev/floppy.cpp +++ b/src/devices/imagedev/floppy.cpp @@ -771,9 +771,10 @@ attotime floppy_image_device::get_next_index_time(std::vector<uint32_t> &buf, in { uint32_t next_position; int cells = buf.size(); - if(index+delta < cells) + if(index+delta < cells) { next_position = buf[index+delta] & floppy_image::TIME_MASK; - else { + + } else { if((buf[cells-1]^buf[0]) & floppy_image::MG_MASK) delta--; index = index + delta - cells + 1; @@ -788,14 +789,6 @@ attotime floppy_image_device::get_next_transition(const attotime &from_when) if(!image || mon) return attotime::never; - // If the drive is still spinning up, pretend that no transitions will come - // TODO: Implement a proper spin-up ramp for transition times, also in order - // to cover potential copy protection measures that have direct device - // access (mz) - // MORE TODO: this breaks the tandy2k and pcjr. needs investigation. - //if (ready_counter > 0) - // return attotime::never; - std::vector<uint32_t> &buf = image->get_buffer(cyl, ss, subcyl); uint32_t cells = buf.size(); if(cells <= 1) @@ -809,10 +802,11 @@ attotime floppy_image_device::get_next_transition(const attotime &from_when) if(index == -1) return attotime::never; - attotime result = get_next_index_time(buf, index, 1, base); - if(result > from_when) - return result; - return get_next_index_time(buf, index, 2, base); + for(unsigned int i=1;; i++) { + attotime result = get_next_index_time(buf, index, i, base); + if(result > from_when) + return result; + } } void floppy_image_device::write_flux(const attotime &start, const attotime &end, int transition_count, const attotime *transitions) diff --git a/src/lib/formats/flopimg.cpp b/src/lib/formats/flopimg.cpp index 4ffe3e720ad..e6890ea7af3 100644 --- a/src/lib/formats/flopimg.cpp +++ b/src/lib/formats/flopimg.cpp @@ -1681,9 +1681,6 @@ void floppy_image_format_t::normalize_times(std::vector<uint32_t> &buffer) void floppy_image_format_t::generate_track_from_bitstream(int track, int head, const uint8_t *trackbuf, int track_size, floppy_image *image, int subtrack, int splice) { - if(splice >= track_size) - splice = 0; - std::vector<uint32_t> &dest = image->get_buffer(track, head, subtrack); dest.clear(); @@ -1691,24 +1688,32 @@ void floppy_image_format_t::generate_track_from_bitstream(int track, int head, c for(int i=0; i != track_size; i++) if(trackbuf[i >> 3] & (0x80 >> (i & 7))) inversions++; - int invert_splice = inversions & 1 ? splice : -1; + bool need_flux = inversions & 1; uint32_t cbit = floppy_image::MG_A; uint32_t count = 0; for(int i=0; i != track_size; i++) - if((i == invert_splice) ^ !!(trackbuf[i >> 3] & (0x80 >> (i & 7)))) { - dest.push_back(cbit | (count+1)); + if(trackbuf[i >> 3] & (0x80 >> (i & 7))) { + dest.push_back(cbit | (count+2)); cbit = cbit == floppy_image::MG_A ? floppy_image::MG_B : floppy_image::MG_A; - count = 1; + if(need_flux) { + dest.push_back(cbit | 1); + cbit = cbit == floppy_image::MG_A ? floppy_image::MG_B : floppy_image::MG_A; + count = 1; + } else + count = 2; } else - count += 2; + count += 4; if(count) dest.push_back(cbit | count); normalize_times(dest); - int splpos = uint64_t(200000000) * splice / track_size; - image->set_write_splice_position(track, head, splpos, subtrack); + + if(splice >= 0 || splice < track_size) { + int splpos = uint64_t(200000000) * splice / track_size; + image->set_write_splice_position(track, head, splpos, subtrack); + } } void floppy_image_format_t::generate_track_from_levels(int track, int head, std::vector<uint32_t> &trackbuf, int splice_pos, floppy_image *image) |