diff options
Diffstat (limited to 'src/devices/machine/z80ctc.cpp')
-rw-r--r-- | src/devices/machine/z80ctc.cpp | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/src/devices/machine/z80ctc.cpp b/src/devices/machine/z80ctc.cpp index c3004b1fade..7f0049b28e8 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) + : 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) - , m_channel(*this, "ch%u", 0U) { } @@ -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,20 +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(); - m_zc_cb.resolve_all_safe(); -} - - -//------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -295,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) { } @@ -307,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)); @@ -495,7 +488,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); } } } @@ -529,10 +522,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); +} |