diff options
Diffstat (limited to 'src/devices/machine/hp_dc100_tape.cpp')
-rw-r--r-- | src/devices/machine/hp_dc100_tape.cpp | 347 |
1 files changed, 182 insertions, 165 deletions
diff --git a/src/devices/machine/hp_dc100_tape.cpp b/src/devices/machine/hp_dc100_tape.cpp index 807d4305bda..75e4778f2c5 100644 --- a/src/devices/machine/hp_dc100_tape.cpp +++ b/src/devices/machine/hp_dc100_tape.cpp @@ -30,17 +30,21 @@ #include "emu.h" #include "hp_dc100_tape.h" +#include "util/ioprocsfilter.h" + // Debugging -#include "logmacro.h" + #define LOG_TMR_MASK (LOG_GENERAL << 1) -#define LOG_TMR(...) LOGMASKED(LOG_TMR_MASK, __VA_ARGS__) #define LOG_DBG_MASK (LOG_TMR_MASK << 1) -#define LOG_DBG(...) LOGMASKED(LOG_DBG_MASK, __VA_ARGS__) #define LOG_RW_MASK (LOG_DBG_MASK << 1) + +#define LOG_TMR(...) LOGMASKED(LOG_TMR_MASK, __VA_ARGS__) +#define LOG_DBG(...) LOGMASKED(LOG_DBG_MASK, __VA_ARGS__) #define LOG_RW(...) LOGMASKED(LOG_RW_MASK, __VA_ARGS__) -#undef VERBOSE + //#define VERBOSE (LOG_GENERAL | LOG_TMR_MASK | LOG_DBG_MASK | LOG_RW_MASK) #define VERBOSE (LOG_GENERAL) +#include "logmacro.h" // Bit manipulation namespace { @@ -49,12 +53,12 @@ namespace { return (T)1U << n; } - template<typename T> void BIT_CLR(T& w , unsigned n) + template<typename T> void BIT_CLR(T& w, unsigned n) { w &= ~BIT_MASK<T>(n); } - template<typename T> void BIT_SET(T& w , unsigned n) + template<typename T> void BIT_SET(T& w, unsigned n) { w |= BIT_MASK<T>(n); } @@ -63,55 +67,47 @@ namespace { // Device type definition DEFINE_DEVICE_TYPE(HP_DC100_TAPE, hp_dc100_tape_device, "hp_dc100_tape", "HP DC100 tape drive") -// Timers -enum { - BIT_TMR_ID, - TACHO_TMR_ID, - HOLE_TMR_ID, - MOTION_TMR_ID -}; - // Constants constexpr double MOTION_MARGIN = 1e-5; // Margin to ensure motion events have passed when timer expires (10 µs) constexpr hti_format_t::tape_pos_t TAPE_INIT_POS = 80 * hti_format_t::ONE_INCH_POS; // Initial tape position: 80" from beginning (just past the punched part) hp_dc100_tape_device::hp_dc100_tape_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig , HP_DC100_TAPE , tag , owner , clock) - , device_image_interface(mconfig , *this) + : microtape_image_device(mconfig, HP_DC100_TAPE, tag, owner, clock) , m_cart_out_handler(*this) , m_hole_handler(*this) , m_tacho_tick_handler(*this) , m_motion_handler(*this) , m_rd_bit_handler(*this) - , m_wr_bit_handler(*this) + , m_wr_bit_handler(*this, 0) + , m_unit_name() , m_image() , m_image_dirty(false) { } -image_init_result hp_dc100_tape_device::call_load() +std::pair<std::error_condition, std::string> hp_dc100_tape_device::call_load() { return internal_load(false); } -image_init_result hp_dc100_tape_device::call_create(int format_type, util::option_resolution *format_options) +std::pair<std::error_condition, std::string> hp_dc100_tape_device::call_create(int format_type, util::option_resolution *format_options) { return internal_load(true); } void hp_dc100_tape_device::call_unload() { - LOG("call_unload dirty=%d\n" , m_image_dirty); + LOG("call_unload dirty=%d\n", m_image_dirty); device_reset(); if (m_image_dirty) { - io_generic io; - io.file = (device_image_interface *)this; - io.procs = &image_ioprocs; - io.filler = 0; - m_image.save_tape(&io); - m_image_dirty = false; + check_for_file(); + auto io = util::random_read_write_fill(image_core_file(), 0); + if (io) { + m_image.save_tape(*io); + m_image_dirty = false; + } } m_image.clear_tape(); @@ -128,7 +124,14 @@ std::string hp_dc100_tape_device::call_display() return buffer; } - char track = m_track ? 'B' : 'A'; + if (!m_unit_name.empty()) { + buffer += m_unit_name; + buffer += " "; + } + + if (m_image.no_of_tracks() > 1) { + buffer += m_track ? "B " : "A "; + } char r_w = m_current_op == OP_WRITE || m_current_op == OP_ERASE ? 'W' : 'R'; char m1; char m2; @@ -143,12 +146,12 @@ std::string hp_dc100_tape_device::call_display() int pos_in = get_approx_pos() / hti_format_t::ONE_INCH_POS; - buffer = string_format("%c %c %c%c [%04d/1824]" , track , r_w , m1 , m2 , pos_in); + buffer += string_format("%c %c%c [%04d/1824]", r_w, m1, m2, pos_in); return buffer; } -const char *hp_dc100_tape_device::file_extensions() const +const char *hp_dc100_tape_device::file_extensions() const noexcept { return "hti"; } @@ -158,7 +161,7 @@ void hp_dc100_tape_device::set_acceleration(double accel) m_acceleration = accel; } -void hp_dc100_tape_device::set_set_points(double slow_sp , double fast_sp) +void hp_dc100_tape_device::set_set_points(double slow_sp, double fast_sp) { m_slow_set_point = slow_sp; m_fast_set_point = fast_sp; @@ -169,9 +172,9 @@ void hp_dc100_tape_device::set_tick_size(hti_format_t::tape_pos_t size) m_tick_size = size; } -void hp_dc100_tape_device::set_bits_per_word(unsigned bits) +void hp_dc100_tape_device::set_image_format(hti_format_t::image_format_t fmt) { - m_image.set_bits_per_word(bits); + m_image.set_image_format(fmt); } void hp_dc100_tape_device::set_go_threshold(double threshold) @@ -179,10 +182,15 @@ void hp_dc100_tape_device::set_go_threshold(double threshold) m_go_threshold = threshold; } +void hp_dc100_tape_device::set_name(const std::string& name) +{ + m_unit_name = name; +} + void hp_dc100_tape_device::set_track_no(unsigned track) { - if (m_track != track) { - LOG_DBG("Setting track %u (op=%d)\n" , track , static_cast<int>(m_current_op)); + if (m_track != track && track < m_image.no_of_tracks()) { + LOG_DBG("Setting track %u (op=%d)\n", track, static_cast<int>(m_current_op)); auto saved_op = m_current_op; if (m_current_op != OP_IDLE) { // Close current op on old track @@ -196,7 +204,7 @@ void hp_dc100_tape_device::set_track_no(unsigned track) } } -bool hp_dc100_tape_device::set_speed_setpoint(tape_speed_t speed , bool fwd) +bool hp_dc100_tape_device::set_speed_setpoint(tape_speed_t speed, bool fwd) { if (!m_present) { return false; @@ -206,7 +214,7 @@ bool hp_dc100_tape_device::set_speed_setpoint(tape_speed_t speed , bool fwd) if (m_set_point != new_setpoint) { update_speed_pos(); - LOG_DBG("Speed SP changed %f->%f %.6f p=%d\n" , m_set_point , new_setpoint , machine().time().as_double() , m_tape_pos); + LOG_DBG("Speed SP changed %f->%f %.6f p=%d\n", m_set_point, new_setpoint, machine().time().as_double(), m_tape_pos); m_tape_speed = speed; m_set_point = new_setpoint; // Speed set point changed, accelerate/decelerate @@ -226,13 +234,13 @@ bool hp_dc100_tape_device::set_speed_setpoint(tape_speed_t speed , bool fwd) } } -void hp_dc100_tape_device::set_op(tape_op_t op , bool force) +void hp_dc100_tape_device::set_op(tape_op_t op, bool force) { if (!m_present || m_start_time.is_never()) { return; } if (!m_in_set_op && (op != m_current_op || force)) { - LOG_DBG("Op %d->%d (f=%d)\n" , m_current_op , op , force); + LOG_DBG("Op %d->%d (f=%d)\n", m_current_op, op, force); m_in_set_op = true; update_speed_pos(); auto prev_op = m_current_op; @@ -251,21 +259,21 @@ void hp_dc100_tape_device::set_op(tape_op_t op , bool force) LOG("Starting RD after WR?\n"); } if (fabs(m_speed) < m_slow_set_point) { - LOG("Starting RD at %f speed?\n" , m_speed); + LOG("Starting RD at %f speed?\n", m_speed); } - m_rd_it_valid = m_image.next_data(get_track_no() , m_tape_pos , is_moving_fwd() , false , m_rd_it); + m_rd_it_valid = m_image.next_data(get_track_no(), m_tape_pos, is_moving_fwd(), false, m_rd_it); load_rd_word(); m_gap_detect_start = m_tape_pos; break; case OP_WRITE: if (m_accelerating || fabs(m_speed) != m_slow_set_point) { - LOG("Starting WR at %f speed (acc=%d)?\n" , m_speed , m_accelerating); + LOG("Starting WR at %f speed (acc=%d)?\n", m_speed, m_accelerating); } if (prev_op == OP_READ) { // Switching from RD to WR // Clear out the part of m_rw_word that is going to be written - LOG_RW("Switch RD->WR @%d, idx=%d, w=%04x\n" , m_rw_pos , m_bit_idx , m_rw_word); + LOG_RW("Switch RD->WR @%d, idx=%d, w=%04x\n", m_rw_pos, m_bit_idx, m_rw_word); if (is_moving_fwd()) { if (--m_bit_idx >= 0) { m_rw_word &= 0xffffU << (m_bit_idx + 1); @@ -297,7 +305,7 @@ void hp_dc100_tape_device::set_op(tape_op_t op , bool force) break; case OP_ERASE: - LOG_DBG("Start GAP @%d\n" , m_tape_pos); + LOG_DBG("Start GAP @%d\n", m_tape_pos); m_rw_pos = m_tape_pos; break; @@ -337,11 +345,11 @@ void hp_dc100_tape_device::update_speed_pos() double acceleration = m_set_point > m_speed ? m_acceleration : -m_acceleration; bool retrigger_motion = false; if (delta_time_double < time_to_const_v) { - space_const_a = const_a_space(acceleration , delta_time_double); + space_const_a = const_a_space(acceleration, delta_time_double); m_speed += delta_time_double * acceleration; time_const_v = 0.0; } else { - space_const_a = const_a_space(acceleration , time_to_const_v); + space_const_a = const_a_space(acceleration, time_to_const_v); time_const_v = delta_time_double - time_to_const_v; LOG_DBG("Acceleration ends\n"); m_accelerating = false; @@ -357,13 +365,13 @@ void hp_dc100_tape_device::update_speed_pos() (fabs(prev_speed) - m_go_threshold) * (fabs(m_speed) - m_go_threshold) < 0.0) { // Slow speed threshold crossed // In-motion threshold crossed - LOG_DBG("Thr crossed %f->%f\n" , prev_speed , m_speed); + LOG_DBG("Thr crossed %f->%f\n", prev_speed, m_speed); motion_event = true; retrigger_motion = true; } if (prev_speed * m_speed < 0.0) { // Direction inverted (speed sign flipped) - LOG_DBG("Dir inverted s=%f\n" , m_speed); + LOG_DBG("Dir inverted s=%f\n", m_speed); inverted = true; retrigger_motion = true; } @@ -376,8 +384,8 @@ void hp_dc100_tape_device::update_speed_pos() } hti_format_t::tape_pos_t delta_pos = (hti_format_t::tape_pos_t)((space_const_a + m_speed * time_const_v) * hti_format_t::ONE_INCH_POS); - LOG_DBG("dp=%d\n" , delta_pos); - if (!hti_format_t::pos_offset(m_tape_pos , true , delta_pos)) { + LOG_DBG("dp=%d\n", delta_pos); + if (!hti_format_t::pos_offset(m_tape_pos, true, delta_pos)) { LOG("Tape unspooled!\n"); } @@ -404,7 +412,7 @@ hti_format_t::tape_pos_t hp_dc100_tape_device::get_approx_pos() const attotime delta_time{ machine().time() - m_start_time }; hti_format_t::tape_pos_t delta_pos = (hti_format_t::tape_pos_t)(delta_time.as_double() * m_speed * hti_format_t::ONE_INCH_POS); auto tape_pos = m_tape_pos; - hti_format_t::pos_offset(tape_pos , true , delta_pos); + hti_format_t::pos_offset(tape_pos, true, delta_pos); return tape_pos; } @@ -415,15 +423,15 @@ bool hp_dc100_tape_device::gap_reached(hti_format_t::tape_pos_t min_gap_size) if (m_gap_detect_start != hti_format_t::NULL_TAPE_POS && abs(m_gap_detect_start - m_tape_pos) >= min_gap_size) { auto tmp = m_tape_pos; - hti_format_t::pos_offset(tmp , is_moving_fwd() , -min_gap_size); - if (m_image.just_gap(get_track_no() , tmp , m_tape_pos)) { + hti_format_t::pos_offset(tmp, is_moving_fwd(), -min_gap_size); + if (m_image.just_gap(get_track_no(), tmp, m_tape_pos)) { return true; } } return false; } -void hp_dc100_tape_device::time_to_next_gap(hti_format_t::tape_pos_t min_gap_size , bool new_gap , emu_timer *target_timer) +void hp_dc100_tape_device::time_to_next_gap(hti_format_t::tape_pos_t min_gap_size, bool new_gap, emu_timer *target_timer) { update_speed_pos(); @@ -432,30 +440,23 @@ void hp_dc100_tape_device::time_to_next_gap(hti_format_t::tape_pos_t min_gap_siz bool found = true; if (new_gap) { hti_format_t::track_iterator_t it; - found = m_image.next_data(get_track_no() , tmp , fwd , true , it); + found = m_image.next_data(get_track_no(), tmp, fwd, true, it); if (found) { - tmp = hti_format_t::farthest_end(it , !fwd); + tmp = m_image.farthest_end(it, !fwd); } } - if (found && m_image.next_gap(get_track_no() , tmp , fwd , min_gap_size)) { + if (found && m_image.next_gap(get_track_no(), tmp, fwd, min_gap_size)) { hti_format_t::tape_pos_t dummy; - LOG_DBG("TTNG T%u S%d N%d %d->%d\n" , get_track_no() , min_gap_size , new_gap , m_tape_pos , tmp); + LOG_DBG("TTNG T%u S%d N%d %d->%d\n", get_track_no(), min_gap_size, new_gap, m_tape_pos, tmp); time_to_distance(tmp - m_tape_pos, dummy, target_timer); } else { - LOG_DBG("TTNG T%u S%d N%d %d->X\n" , get_track_no() , min_gap_size , new_gap , m_tape_pos); + LOG_DBG("TTNG T%u S%d N%d %d->X\n", get_track_no(), min_gap_size, new_gap, m_tape_pos); target_timer->reset(); } } void hp_dc100_tape_device::device_start() { - m_cart_out_handler.resolve_safe(); - m_hole_handler.resolve_safe(); - m_tacho_tick_handler.resolve_safe(); - m_motion_handler.resolve_safe(); - m_rd_bit_handler.resolve_safe(); - m_wr_bit_handler.resolve_safe(0); - save_item(NAME(m_acceleration)); save_item(NAME(m_slow_set_point)); save_item(NAME(m_fast_set_point)); @@ -479,10 +480,10 @@ void hp_dc100_tape_device::device_start() save_item(NAME(m_next_hole_pos)); save_item(NAME(m_image_dirty)); - m_bit_timer = timer_alloc(BIT_TMR_ID); - m_tacho_timer = timer_alloc(TACHO_TMR_ID); - m_hole_timer = timer_alloc(HOLE_TMR_ID); - m_motion_timer = timer_alloc(MOTION_TMR_ID); + m_bit_timer = timer_alloc(FUNC(hp_dc100_tape_device::bit_timer_tick), this); + m_tacho_timer = timer_alloc(FUNC(hp_dc100_tape_device::tacho_timer_tick), this); + m_hole_timer = timer_alloc(FUNC(hp_dc100_tape_device::hole_timer_tick), this); + m_motion_timer = timer_alloc(FUNC(hp_dc100_tape_device::motion_timer_tick), this); } void hp_dc100_tape_device::device_reset() @@ -490,71 +491,76 @@ void hp_dc100_tape_device::device_reset() clear_state(); } -void hp_dc100_tape_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(hp_dc100_tape_device::bit_timer_tick) { - LOG_TMR("%.6f TMR %d p=%d s=%.3f(%.3f) a=%d\n" , machine().time().as_double() , id , m_tape_pos , m_speed , m_set_point , m_accelerating); + LOG_TMR("%.6f TMR 0 p=%d s=%.3f(%.3f) a=%d\n", machine().time().as_double(), m_tape_pos, m_speed, m_set_point, m_accelerating); update_speed_pos(); - switch (id) { - case BIT_TMR_ID: - m_tape_pos = m_next_bit_pos; - if (m_current_op == OP_READ) { - bool bit = BIT(m_rd_it->second , m_bit_idx); - m_rd_bit_handler(bit); - if (is_moving_fwd()) { - if (--m_bit_idx >= 0) { - time_to_distance(m_image.bit_length(BIT(m_rd_it->second , m_bit_idx)), m_next_bit_pos, m_bit_timer); - } else { - m_rd_it_valid = m_image.adv_it(get_track_no() , true , m_rd_it) != hti_format_t::ADV_NO_MORE_DATA; - load_rd_word(); - } + m_tape_pos = m_next_bit_pos; + if (m_current_op == OP_READ) { + bool bit = BIT(m_rd_it->second, m_bit_idx); + m_rd_bit_handler(bit); + if (is_moving_fwd()) { + if (--m_bit_idx >= 0) { + time_to_distance(m_image.bit_length(BIT(m_rd_it->second, m_bit_idx)), m_next_bit_pos, m_bit_timer); } else { - if (++m_bit_idx < 16) { - time_to_distance(-m_image.bit_length(BIT(m_rd_it->second , m_bit_idx)), m_next_bit_pos, m_bit_timer); - } else { - m_rd_it_valid = m_image.adv_it(get_track_no() , false , m_rd_it) != hti_format_t::ADV_NO_MORE_DATA; - load_rd_word(); - } + m_rd_it_valid = m_image.adv_it(get_track_no(), true, m_rd_it) != hti_format_t::ADV_NO_MORE_DATA; + load_rd_word(); } - } else if (m_current_op == OP_WRITE) { - bool bit = m_wr_bit_handler(); - hti_format_t::tape_pos_t bit_len = m_image.bit_length(bit); - if (bit) { - BIT_SET(m_rw_word , m_bit_idx); - } - if (is_moving_fwd()) { - if (--m_bit_idx < 0) { - store_wr_word(); - } + } else { + if (++m_bit_idx < 16) { + time_to_distance(-m_image.bit_length(BIT(m_rd_it->second, m_bit_idx)), m_next_bit_pos, m_bit_timer); } else { - if (++m_bit_idx >= 16) { - store_wr_word(); - } - bit_len = -bit_len; + m_rd_it_valid = m_image.adv_it(get_track_no(), false, m_rd_it) != hti_format_t::ADV_NO_MORE_DATA; + load_rd_word(); + } + } + } else if (m_current_op == OP_WRITE) { + bool bit = m_wr_bit_handler(); + hti_format_t::tape_pos_t bit_len = m_image.bit_length(bit); + if (bit) { + BIT_SET(m_rw_word, m_bit_idx); + } + if (is_moving_fwd()) { + if (--m_bit_idx < 0) { + store_wr_word(); } - time_to_distance(bit_len, m_next_bit_pos, m_bit_timer); + } else { + if (++m_bit_idx >= 16) { + store_wr_word(); + } + bit_len = -bit_len; } - break; + time_to_distance(bit_len, m_next_bit_pos, m_bit_timer); + } +} - case TACHO_TMR_ID: - m_tape_pos = m_next_tacho_pos; - m_tacho_tick_handler(1); - adjust_tacho_timer(); - break; +TIMER_CALLBACK_MEMBER(hp_dc100_tape_device::tacho_timer_tick) +{ + LOG_TMR("%.6f TMR 1 p=%d s=%.3f(%.3f) a=%d\n", machine().time().as_double(), m_tape_pos, m_speed, m_set_point, m_accelerating); + update_speed_pos(); - case HOLE_TMR_ID: - m_tape_pos = m_next_hole_pos; - m_hole_handler(1); - adjust_hole_timer(); - break; + m_tape_pos = m_next_tacho_pos; + m_tacho_tick_handler(1); + adjust_tacho_timer(); +} - case MOTION_TMR_ID: - // In itself it does nothing (all work is in update_speed_pos) - break; +TIMER_CALLBACK_MEMBER(hp_dc100_tape_device::hole_timer_tick) +{ + LOG_TMR("%.6f TMR 2 p=%d s=%.3f(%.3f) a=%d\n", machine().time().as_double(), m_tape_pos, m_speed, m_set_point, m_accelerating); + update_speed_pos(); - default: - break; - } + m_tape_pos = m_next_hole_pos; + m_hole_handler(1); + adjust_hole_timer(); +} + +TIMER_CALLBACK_MEMBER(hp_dc100_tape_device::motion_timer_tick) +{ + LOG_TMR("%.6f TMR 2 p=%d s=%.3f(%.3f) a=%d\n", machine().time().as_double(), m_tape_pos, m_speed, m_set_point, m_accelerating); + update_speed_pos(); + + // All work is in update_speed_pos } void hp_dc100_tape_device::clear_state() @@ -583,31 +589,42 @@ void hp_dc100_tape_device::clear_state() set_tape_present(is_loaded()); } -image_init_result hp_dc100_tape_device::internal_load(bool is_create) +std::pair<std::error_condition, std::string> hp_dc100_tape_device::internal_load(bool is_create) { - LOG("load %d\n" , is_create); + LOG("load %d\n", is_create); device_reset(); - io_generic io; - io.file = (device_image_interface *)this; - io.procs = &image_ioprocs; - io.filler = 0; + check_for_file(); if (is_create) { + auto io = util::random_read_write_fill(image_core_file(), 0); + if (!io) { + LOG("out of memory\n"); + set_tape_present(false); + return std::make_pair(std::errc::not_enough_memory, std::string()); + } m_image.clear_tape(); - m_image.save_tape(&io); - } else if (!m_image.load_tape(&io)) { - LOG("load failed\n"); - seterror(IMAGE_ERROR_INVALIDIMAGE , "Wrong format"); - set_tape_present(false); - return image_init_result::FAIL; + m_image.save_tape(*io); + } else { + auto io = util::random_read_fill(image_core_file(), 0); + if (!io) { + LOG("out of memory\n"); + set_tape_present(false); + return std::make_pair(std::errc::not_enough_memory, std::string()); + } + if (!m_image.load_tape(*io)) { + LOG("load failed\n"); + //seterror(image_error::INVALIDIMAGE, "Wrong format"); + set_tape_present(false); + return std::make_pair(image_error::INVALIDIMAGE, std::string()); + } } LOG("load OK\n"); m_image_dirty = false; set_tape_present(true); - return image_init_result::PASS; + return std::make_pair(std::error_condition(), std::string()); } void hp_dc100_tape_device::set_tape_present(bool present) @@ -618,7 +635,7 @@ void hp_dc100_tape_device::set_tape_present(bool present) } } -double hp_dc100_tape_device::compute_set_point(tape_speed_t speed , bool fwd) const +double hp_dc100_tape_device::compute_set_point(tape_speed_t speed, bool fwd) const { double sp; @@ -639,7 +656,7 @@ double hp_dc100_tape_device::compute_set_point(tape_speed_t speed , bool fwd) co void hp_dc100_tape_device::start_tape() { - LOG_DBG("Tape started %.6f p=%d\n" , machine().time().as_double() , m_tape_pos); + LOG_DBG("Tape started %.6f p=%d\n", machine().time().as_double(), m_tape_pos); m_start_time = machine().time(); m_accelerating = true; m_speed = 0; @@ -647,7 +664,7 @@ void hp_dc100_tape_device::start_tape() void hp_dc100_tape_device::stop_tape() { - LOG_DBG("Tape stops %.6f p=%d\n" , machine().time().as_double() , m_tape_pos); + LOG_DBG("Tape stops %.6f p=%d\n", machine().time().as_double(), m_tape_pos); m_start_time = attotime::never; m_accelerating = false; m_speed = 0; @@ -657,34 +674,34 @@ void hp_dc100_tape_device::stop_tape() stop_op(); } -double hp_dc100_tape_device::const_a_space(double a , double t) const +double hp_dc100_tape_device::const_a_space(double a, double t) const { // Space traveled in time 't' at constant acceleration 'a' starting with 'm_speed' speed return t * (m_speed + a / 2 * t); } -attotime hp_dc100_tape_device::time_to_threshold(double threshold , bool zero_allowed) const +attotime hp_dc100_tape_device::time_to_threshold(double threshold, bool zero_allowed) const { attotime time{ attotime::never }; auto delta_sp = m_set_point - m_speed; auto delta_t = threshold - m_speed; - LOG_DBG("Dsp=%.6f D+th=%.6f\n" , delta_sp , delta_t); + LOG_DBG("Dsp=%.6f D+th=%.6f\n", delta_sp, delta_t); if ((delta_sp * delta_t > 0.0 && fabs(delta_t) <= fabs(delta_sp)) || (zero_allowed && delta_t == 0.0)) { time = attotime::from_double(fabs(delta_t) / m_acceleration); - LOG_DBG("Time to +th: %.6f\n" , time.as_double()); + LOG_DBG("Time to +th: %.6f\n", time.as_double()); } delta_t = -threshold - m_speed; - LOG_DBG("Dsp=%.6f D-th=%.6f\n" , delta_sp , delta_t); + LOG_DBG("Dsp=%.6f D-th=%.6f\n", delta_sp, delta_t); if ((delta_sp * delta_t > 0.0 && fabs(delta_t) <= fabs(delta_sp)) || (zero_allowed && delta_t == 0.0)) { double tm = fabs(delta_t) / m_acceleration; if (tm < time.as_double()) { time = attotime::from_double(tm); - LOG_DBG("Time to -th: %.6f\n" , time.as_double()); + LOG_DBG("Time to -th: %.6f\n", time.as_double()); } } return time; @@ -701,16 +718,16 @@ void hp_dc100_tape_device::set_motion_timer() // 3. Tape direction reverses // 4. Set point is reached // Motion timer is set to expire at the event that occurs first - attotime time{ time_to_threshold(m_slow_set_point , true) }; + attotime time{ time_to_threshold(m_slow_set_point, true) }; - attotime tmp{ time_to_threshold(m_go_threshold , false) }; + attotime tmp{ time_to_threshold(m_go_threshold, false) }; if (tmp < time) { time = tmp; } // Time to the moment when tape inverts its motion // (i.e. when m_speed crosses 0) - tmp = time_to_threshold(0.0 , false); + tmp = time_to_threshold(0.0, false); if (tmp < time) { time = tmp; } @@ -733,7 +750,7 @@ void hp_dc100_tape_device::set_motion_timer() } } -void hp_dc100_tape_device::time_to_distance(hti_format_t::tape_pos_t distance , hti_format_t::tape_pos_t& target_pos , emu_timer *target_timer) const +void hp_dc100_tape_device::time_to_distance(hti_format_t::tape_pos_t distance, hti_format_t::tape_pos_t& target_pos, emu_timer *target_timer) const { if (m_start_time.is_never()) { // If tape is stopped we'll never get there.. @@ -742,7 +759,7 @@ void hp_dc100_tape_device::time_to_distance(hti_format_t::tape_pos_t distance , } target_pos = m_tape_pos; - if (!hti_format_t::pos_offset(target_pos , true , distance)) { + if (!hti_format_t::pos_offset(target_pos, true, distance)) { // Beyond end of tape target_timer->reset(); return; @@ -765,11 +782,11 @@ void hp_dc100_tape_device::time_to_distance(hti_format_t::tape_pos_t distance , if (has_root) { double time_in_const_a_pos = (sqrt(delta) - m_speed) / acceleration; double time_in_const_a_neg = -(sqrt(delta) + m_speed) / acceleration; - LOG_DBG("TTD %.6f %.6f\n" , time_in_const_a_pos , time_in_const_a_neg); + LOG_DBG("TTD %.6f %.6f\n", time_in_const_a_pos, time_in_const_a_neg); if (time_in_const_a_pos >= 0.0) { if (time_in_const_a_neg >= 0.0) { // pos + neg + - time_in_const_a = std::min(time_in_const_a_pos , time_in_const_a_neg); + time_in_const_a = std::min(time_in_const_a_pos, time_in_const_a_neg); } else { // pos + neg - time_in_const_a = time_in_const_a_pos; @@ -784,14 +801,14 @@ void hp_dc100_tape_device::time_to_distance(hti_format_t::tape_pos_t distance , } } } - LOG_DBG("TTD %d %d %.6f %.6f %.6f\n" , distance , has_root , m_speed , time_to_const_v , time_in_const_a); + LOG_DBG("TTD %d %d %.6f %.6f %.6f\n", distance, has_root, m_speed, time_to_const_v, time_in_const_a); if (has_root && time_in_const_a <= time_to_const_v) { // Entirely in the constant A phase time_const_a = time_in_const_a; space = 0.0; } else { // Partly in const A & partly in const V - double space_in_const_a = const_a_space(acceleration , time_to_const_v); + double space_in_const_a = const_a_space(acceleration, time_to_const_v); space -= space_in_const_a; time_const_a = time_to_const_v; } @@ -816,7 +833,7 @@ void hp_dc100_tape_device::time_to_distance(hti_format_t::tape_pos_t distance , } else { time_const_v = 0.0; } - LOG_DBG("TTD %.6f %.6f\n" , time_const_a , time_const_v); + LOG_DBG("TTD %.6f %.6f\n", time_const_a, time_const_v); target_timer->adjust(attotime::from_double(time_const_a + time_const_v)); } @@ -837,13 +854,13 @@ void hp_dc100_tape_device::adjust_tacho_timer() // on a tick (tick_fract == 0) dist_to_next = -m_tick_size; } - LOG_DBG("Next tick @%d (pos=%d)\n" , dist_to_next , m_tape_pos); + LOG_DBG("Next tick @%d (pos=%d)\n", dist_to_next, m_tape_pos); time_to_distance(dist_to_next, m_next_tacho_pos, m_tacho_timer); } void hp_dc100_tape_device::adjust_hole_timer() { - auto hole_pos = m_image.next_hole(m_tape_pos , is_moving_fwd()); + auto hole_pos = m_image.next_hole(m_tape_pos, is_moving_fwd()); if (hole_pos == hti_format_t::NULL_TAPE_POS) { m_hole_timer->reset(); } else { @@ -856,8 +873,8 @@ void hp_dc100_tape_device::stop_op() if (m_current_op == OP_WRITE) { store_wr_word(); } else if (m_current_op == OP_ERASE) { - LOG_DBG("Wr gap from %d to %d\n" , m_rw_pos , m_tape_pos); - m_image.write_gap(get_track_no() , m_rw_pos , m_tape_pos); + LOG_DBG("Wr gap from %d to %d\n", m_rw_pos, m_tape_pos); + m_image.write_gap(get_track_no(), m_rw_pos, m_tape_pos); m_image_dirty = true; } m_bit_timer->reset(); @@ -875,16 +892,16 @@ void hp_dc100_tape_device::load_rd_word() m_bit_idx = 0; } // This is actually the nearest end (dir is inverted) - m_rw_pos = m_next_bit_pos = hti_format_t::farthest_end(m_rd_it , !fwd); + m_rw_pos = m_next_bit_pos = m_image.farthest_end(m_rd_it, !fwd); // Compute end of bit cell - hti_format_t::tape_pos_t bit_len = m_image.bit_length(BIT(m_rd_it->second , m_bit_idx)); + hti_format_t::tape_pos_t bit_len = m_image.bit_length(BIT(m_rd_it->second, m_bit_idx)); if (!fwd) { bit_len = -bit_len; } - time_to_distance(m_next_bit_pos + bit_len - m_tape_pos , m_next_bit_pos , m_bit_timer); - LOG_RW("RD %04x @%d\n" , m_rd_it->second , m_next_bit_pos); + time_to_distance(m_next_bit_pos + bit_len - m_tape_pos, m_next_bit_pos, m_bit_timer); + LOG_RW("RD %04x @%d\n", m_rd_it->second, m_next_bit_pos); } else { - LOG_RW("End of RD data @%d\n" , m_tape_pos); + LOG_RW("End of RD data @%d\n", m_tape_pos); stop_op(); m_gap_detect_start = m_tape_pos; } @@ -901,8 +918,8 @@ void hp_dc100_tape_device::store_wr_word() if (!fwd) { m_rw_pos -= word_length; } - LOG_RW("WR %04x @%d\n" , m_rw_word , m_rw_pos); - m_image.write_word(get_track_no() , m_rw_pos , m_rw_word , word_length , fwd); + LOG_RW("WR %04x @%d\n", m_rw_word, m_rw_pos); + m_image.write_word(get_track_no(), m_rw_pos, m_rw_word, word_length, fwd); m_image_dirty = true; m_rw_word = 0; if (fwd) { |