hp85: fixed a bug in tape gap detection

This commit is contained in:
fulivi 2017-08-22 17:39:46 +02:00 committed by Vas Crabb
parent a35673c318
commit ac90b9c2ef
3 changed files with 14 additions and 4 deletions

View File

@ -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()) {

View File

@ -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));
}

View File

@ -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);