diff options
Diffstat (limited to 'src/devices/machine/mc6846.cpp')
-rw-r--r-- | src/devices/machine/mc6846.cpp | 56 |
1 files changed, 19 insertions, 37 deletions
diff --git a/src/devices/machine/mc6846.cpp b/src/devices/machine/mc6846.cpp index 31e562fd849..26c42d8a5ec 100644 --- a/src/devices/machine/mc6846.cpp +++ b/src/devices/machine/mc6846.cpp @@ -24,6 +24,8 @@ #include "mc6846.h" //#define VERBOSE 1 +//#define LOG_OUTPUT_STREAM std::cout + #include "logmacro.h" @@ -31,8 +33,7 @@ #define PORT \ ((m_pdr & m_ddr) | \ - ((!m_in_port_cb.isnull() ? m_in_port_cb( 0 ) : 0) & \ - ~m_ddr)) + (m_in_port_cb(0) & ~m_ddr)) #define CTO \ ((MODE == 0x30 || (m_tcr & 0x80)) ? m_cto : 0) @@ -46,12 +47,11 @@ DEFINE_DEVICE_TYPE(MC6846, mc6846_device, "mc6846", "MC6846 Programmable Timer") mc6846_device::mc6846_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, MC6846, tag, owner, clock), - m_out_port_cb(*this), - m_out_cp1_cb(*this), - m_out_cp2_cb(*this), - m_in_port_cb(*this), - m_out_cto_cb(*this), - m_irq_cb(*this) + m_out_port_cb(*this), // 8-bit output + m_out_cp2_cb(*this), // 1-bit output + m_in_port_cb(*this, 0), // CPU read from the outside through chip (8-bit input) + m_out_cto_cb(*this), // asynchronous timer output to output world (1-bit output) + m_irq_cb(*this) // timer interrupt { } @@ -61,21 +61,8 @@ mc6846_device::mc6846_device(const machine_config &mconfig, const char *tag, dev void mc6846_device::device_start() { - m_interval = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mc6846_device::timer_expire), this)); - m_one_shot = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mc6846_device::timer_one_shot), this)); - - m_out_port_cb.resolve(); /* 8-bit output */ - m_out_cp1_cb.resolve_safe(); /* 1-bit output */ - m_out_cp2_cb.resolve(); /* 1-bit output */ - - /* CPU read from the outside through chip */ - m_in_port_cb.resolve(); /* 8-bit input */ - - /* asynchronous timer output to outside world */ - m_out_cto_cb.resolve(); /* 1-bit output */ - - /* timer interrupt */ - m_irq_cb.resolve(); + m_interval = timer_alloc(FUNC(mc6846_device::timer_expire), this); + m_one_shot = timer_alloc(FUNC(mc6846_device::timer_one_shot), this); save_item(NAME(m_csr)); save_item(NAME(m_pcr)); @@ -155,14 +142,12 @@ inline void mc6846_device::update_irq() if ( cif ) { m_csr |= 0x80; - if ( !m_irq_cb.isnull() ) - m_irq_cb( 1 ); + m_irq_cb( 1 ); } else { m_csr &= ~0x80; - if ( !m_irq_cb.isnull() ) - m_irq_cb( 0 ); + m_irq_cb( 0 ); } } @@ -176,8 +161,7 @@ inline void mc6846_device::update_cto() LOG( "%f: mc6846 CTO set to %i\n", machine().time().as_double(), cto ); m_old_cto = cto; } - if ( !m_out_cto_cb.isnull() ) - m_out_cto_cb( cto ); + m_out_cto_cb( cto ); } @@ -283,7 +267,7 @@ TIMER_CALLBACK_MEMBER( mc6846_device::timer_one_shot ) /************************** CPU interface ****************************/ -READ8_MEMBER(mc6846_device::read) +uint8_t mc6846_device::read(offs_t offset) { switch ( offset ) { @@ -352,8 +336,9 @@ READ8_MEMBER(mc6846_device::read) -WRITE8_MEMBER(mc6846_device::write) +void mc6846_device::write(offs_t offset, uint8_t data) { + switch ( offset ) { case 0: @@ -394,8 +379,7 @@ WRITE8_MEMBER(mc6846_device::write) if (data & 0x10) { m_cp2_cpu = (data >> 3) & 1; - if ( !m_out_cp2_cb.isnull() ) - m_out_cp2_cb( m_cp2_cpu ); + m_out_cp2_cb( m_cp2_cpu ); } else logerror( "%s mc6846 acknowledge not implemented\n", machine().describe_context() ); @@ -407,8 +391,7 @@ WRITE8_MEMBER(mc6846_device::write) if ( ! (m_pcr & 0x80) ) { m_ddr = data; - if ( !m_out_port_cb.isnull() ) - m_out_port_cb( (offs_t) 0, m_pdr & m_ddr ); + m_out_port_cb( (offs_t) 0, m_pdr & m_ddr ); } break; @@ -417,8 +400,7 @@ WRITE8_MEMBER(mc6846_device::write) if ( ! (m_pcr & 0x80) ) { m_pdr = data; - if ( !m_out_port_cb.isnull() ) - m_out_port_cb( (offs_t) 0, m_pdr & m_ddr ); + m_out_port_cb( (offs_t) 0, m_pdr & m_ddr ); if ( m_csr1_to_be_cleared && (m_csr & 2) ) { m_csr &= ~2; |