diff options
Diffstat (limited to 'src/devices/machine/z80ctc.cpp')
-rw-r--r-- | src/devices/machine/z80ctc.cpp | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/src/devices/machine/z80ctc.cpp b/src/devices/machine/z80ctc.cpp index 307da7d534a..1ee73a25b3c 100644 --- a/src/devices/machine/z80ctc.cpp +++ b/src/devices/machine/z80ctc.cpp @@ -77,12 +77,17 @@ DEFINE_DEVICE_TYPE(Z80CTC_CHANNEL, z80ctc_channel_device, "z80ctc_channel", "Z80 //------------------------------------------------- z80ctc_device::z80ctc_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : device_t(mconfig, Z80CTC, tag, owner, clock), - device_z80daisy_interface(mconfig, *this), - m_intr_cb(*this), - m_zc_cb{*this, *this, *this, *this}, - m_vector(0), - m_channel(*this, "ch%u", 0U) + : z80ctc_device(mconfig, Z80CTC, tag, owner, clock) +{ +} + +z80ctc_device::z80ctc_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) + : device_t(mconfig, type, tag, owner, clock) + , device_z80daisy_interface(mconfig, *this) + , m_channel(*this, "ch%u", 0U) + , m_intr_cb(*this) + , m_zc_cb(*this) + , m_vector(0) { } @@ -112,10 +117,10 @@ void z80ctc_device::write(offs_t offset, uint8_t data) // trigger //------------------------------------------------- -WRITE_LINE_MEMBER( z80ctc_device::trg0 ) { m_channel[0]->trigger(state != 0); } -WRITE_LINE_MEMBER( z80ctc_device::trg1 ) { m_channel[1]->trigger(state != 0); } -WRITE_LINE_MEMBER( z80ctc_device::trg2 ) { m_channel[2]->trigger(state != 0); } -WRITE_LINE_MEMBER( z80ctc_device::trg3 ) { m_channel[3]->trigger(state != 0); } +void z80ctc_device::trg0(int state) { m_channel[0]->trigger(state != 0); } +void z80ctc_device::trg1(int state) { m_channel[1]->trigger(state != 0); } +void z80ctc_device::trg2(int state) { m_channel[2]->trigger(state != 0); } +void z80ctc_device::trg3(int state) { m_channel[3]->trigger(state != 0); } //------------------------------------------------- @@ -136,21 +141,6 @@ void z80ctc_device::device_add_mconfig(machine_config &config) //------------------------------------------------- -// device_resolve_objects - resolve objects that -// may be needed for other devices to set -// initial conditions at start time -//------------------------------------------------- - -void z80ctc_device::device_resolve_objects() -{ - // resolve callbacks - m_intr_cb.resolve_safe(); - for (auto &cb : m_zc_cb) - cb.resolve_safe(); -} - - -//------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -296,7 +286,8 @@ z80ctc_channel_device::z80ctc_channel_device(const machine_config &mconfig, cons m_down(0), m_extclk(0), m_timer(nullptr), - m_int_state(0) + m_int_state(0), + m_zc_to_timer(nullptr) { } @@ -308,7 +299,8 @@ z80ctc_channel_device::z80ctc_channel_device(const machine_config &mconfig, cons void z80ctc_channel_device::device_start() { // initialize state - m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(z80ctc_channel_device::timer_callback), this)); + m_timer = timer_alloc(FUNC(z80ctc_channel_device::timer_callback), this); + m_zc_to_timer = timer_alloc(FUNC(z80ctc_channel_device::zc_to_callback), this); // register for save states save_item(NAME(m_mode)); @@ -376,7 +368,11 @@ u8 z80ctc_channel_device::read() if(!m_timer->remaining().is_never()) return u8((m_timer->remaining().as_double() / period.as_double()) + 1.0); else - return 0; + { + // value read-back is required by x1turbo for YM internal board detection. + // cfr. x1turbo40 argus wpiset 0x704,1,rw + return m_down; + } } } @@ -496,7 +492,7 @@ void z80ctc_channel_device::trigger(bool state) { // if we hit zero, do the same thing as for a timer interrupt if (--m_down == 0) - timer_callback(nullptr,0); + timer_callback(0); } } } @@ -530,10 +526,15 @@ TIMER_CALLBACK_MEMBER(z80ctc_channel_device::timer_callback) m_device->interrupt_check(); } - // generate the clock pulse (FIXME: pulse width is based on bus clock) + // generate the clock pulse m_device->m_zc_cb[m_index](1); - m_device->m_zc_cb[m_index](0); + m_zc_to_timer->adjust(m_device->clocks_to_attotime(1)); // reset the down counter m_down = m_tconst; } + +TIMER_CALLBACK_MEMBER(z80ctc_channel_device::zc_to_callback) +{ + m_device->m_zc_cb[m_index](0); +} |