From ac90b9c2ef59a63f9ce49b8744db31a7e3abff9a Mon Sep 17 00:00:00 2001 From: fulivi Date: Tue, 22 Aug 2017 17:39:46 +0200 Subject: hp85: fixed a bug in tape gap detection --- src/devices/machine/1ma6.cpp | 4 ++-- src/lib/formats/hti_tape.cpp | 12 +++++++++++- src/lib/formats/hti_tape.h | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/devices/machine/1ma6.cpp b/src/devices/machine/1ma6.cpp index 3758321efc0..771fd0d9b1f 100644 --- a/src/devices/machine/1ma6.cpp +++ b/src/devices/machine/1ma6.cpp @@ -142,7 +142,7 @@ READ8_MEMBER(hp_1ma6_device::reg_r) case 0: // Status register update_tape_pos(); - if (m_cmd_state == CMD_IDLE || !m_cartridge_in) { + if (m_cmd_state == CMD_IDLE) { BIT_SET(m_status_reg , STS_READY_BIT); } else if (m_cmd_state == CMD_STOPPING || m_cmd_state == CMD_FAST_FWD_REV || @@ -291,7 +291,7 @@ void hp_1ma6_device::device_timer(emu_timer &timer, device_timer_id id, int para } LOG("WR T%u @ %d = %04x\n" , current_track() , m_rw_pos , m_next_word); if (m_cartridge_in) { - m_image.write_word(current_track() , m_rw_pos , m_next_word , length); + m_image.write_word(current_track() , m_rw_pos , m_next_word , length , is_moving_fwd()); m_image_dirty = true; } if (is_moving_fwd()) { 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); -- cgit v1.2.3