diff options
author | fulivi <fulivi@users.noreply.github.com> | 2017-08-22 17:39:46 +0200 |
---|---|---|
committer | Vas Crabb <cuavas@users.noreply.github.com> | 2017-08-23 19:33:27 +1000 |
commit | ac90b9c2ef59a63f9ce49b8744db31a7e3abff9a (patch) | |
tree | 8365e82afa299cf69c7f7cca34295de0ac76ef96 /src/lib | |
parent | a35673c3182547e1f007f09ba0f12ae52a4ba048 (diff) |
hp85: fixed a bug in tape gap detection
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/formats/hti_tape.cpp | 12 | ||||
-rw-r--r-- | src/lib/formats/hti_tape.h | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/formats/hti_tape.cpp b/src/lib/formats/hti_tape.cpp index 4b26f9778f8..a0dafb46277 100644 --- a/src/lib/formats/hti_tape.cpp +++ b/src/lib/formats/hti_tape.cpp @@ -171,7 +171,7 @@ hti_format_t::tape_pos_t hti_format_t::next_hole(tape_pos_t pos , bool forward) } } -void hti_format_t::write_word(unsigned track_no , tape_pos_t start , tape_word_t word , tape_pos_t& length) +void hti_format_t::write_word(unsigned track_no , tape_pos_t start , tape_word_t word , tape_pos_t& length , bool forward) { tape_track_t& track = m_tracks[ track_no ]; track_iterator_t it_low = track.lower_bound(start); @@ -182,6 +182,16 @@ void hti_format_t::write_word(unsigned track_no , tape_pos_t start , tape_word_t track.erase(it_low , it_high); + // A 0 word is inserted after the word being written, if space allows. + // This is meant to avoid fragmentation of the slack space at the end of a record + // as the record expands & contracts when re-written with different content. + // Without this fix, a gap could form in the slack big enough to cause + // false gap detections. + if (forward && it_high != track.end() && (it_high->first - end_pos) >= (ZERO_BIT_LEN * 16 + ONE_BIT_LEN)) { + track.insert(it_high, std::make_pair(end_pos, 0)); + it_high--; + } + track.insert(it_high , std::make_pair(start, word)); } diff --git a/src/lib/formats/hti_tape.h b/src/lib/formats/hti_tape.h index cb8b1a39262..469866d5f5b 100644 --- a/src/lib/formats/hti_tape.h +++ b/src/lib/formats/hti_tape.h @@ -57,7 +57,7 @@ public: static tape_pos_t next_hole(tape_pos_t pos , bool forward); // Write a data word on tape - void write_word(unsigned track_no , tape_pos_t start , tape_word_t word , tape_pos_t& length); + void write_word(unsigned track_no , tape_pos_t start , tape_word_t word , tape_pos_t& length , bool forward = true); // Write a gap on tape void write_gap(unsigned track_no , tape_pos_t a , tape_pos_t b); |