mirror of
https://github.com/holub/mame
synced 2025-10-06 09:00:04 +03:00
mc6854_device: converted to devcb2 and delegates (nw)
This commit is contained in:
parent
2c653877d0
commit
dac6c70216
@ -157,16 +157,6 @@ WRITE_LINE_MEMBER( e01_device::econet_data_w )
|
||||
m_econet->data_w(this, state);
|
||||
}
|
||||
|
||||
static const mc6854_interface adlc_intf =
|
||||
{
|
||||
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, e01_device, adlc_irq_w),
|
||||
DEVCB_DEVICE_LINE_MEMBER(DEVICE_SELF_OWNER, e01_device, econet_data_w),
|
||||
NULL,
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
|
||||
WRITE_LINE_MEMBER( e01_device::via_irq_w )
|
||||
{
|
||||
m_via_irq = state;
|
||||
@ -265,7 +255,9 @@ static MACHINE_CONFIG_FRAGMENT( e01 )
|
||||
MCFG_VIA6522_WRITEPA_HANDLER(DEVWRITE8("cent_data_out", output_latch_device, write))
|
||||
MCFG_VIA6522_IRQ_HANDLER(WRITELINE(e01_device, via_irq_w))
|
||||
|
||||
MCFG_MC6854_ADD(MC6854_TAG, adlc_intf)
|
||||
MCFG_DEVICE_ADD(MC6854_TAG, MC6854, 0)
|
||||
MCFG_MC6854_OUT_IRQ_CB(WRITELINE(e01_device, adlc_irq_w))
|
||||
MCFG_MC6854_OUT_TXD_CB(WRITELINE(e01_device, econet_data_w))
|
||||
MCFG_WD2793x_ADD(WD2793_TAG, XTAL_8MHz/4)
|
||||
MCFG_WD_FDC_INTRQ_CALLBACK(WRITELINE(e01_device, fdc_irq_w))
|
||||
MCFG_WD_FDC_DRQ_CALLBACK(WRITELINE(e01_device, fdc_drq_w))
|
||||
|
@ -167,6 +167,10 @@ const device_type MC6854 = &device_creator<mc6854_device>;
|
||||
|
||||
mc6854_device::mc6854_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, MC6854, "MC6854 ADLC", tag, owner, clock, "mc6854", __FILE__),
|
||||
m_out_irq_cb(*this),
|
||||
m_out_txd_cb(*this),
|
||||
m_out_rts_cb(*this),
|
||||
m_out_dtr_cb(*this),
|
||||
m_cr1(0),
|
||||
m_cr2(0),
|
||||
m_cr3(0),
|
||||
@ -197,39 +201,17 @@ mc6854_device::mc6854_device(const machine_config &mconfig, const char *tag, dev
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void mc6854_device::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const mc6854_interface *intf = reinterpret_cast<const mc6854_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<mc6854_interface *>(this) = *intf;
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
memset(&m_out_irq_cb, 0, sizeof(m_out_irq_cb));
|
||||
memset(&m_out_txd_cb, 0, sizeof(m_out_txd_cb));
|
||||
memset(&m_out_rts_cb, 0, sizeof(m_out_rts_cb));
|
||||
memset(&m_out_dtr_cb, 0, sizeof(m_out_dtr_cb));
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void mc6854_device::device_start()
|
||||
{
|
||||
m_out_irq_func.resolve(m_out_irq_cb, *this);
|
||||
m_out_txd_func.resolve(m_out_txd_cb, *this);
|
||||
m_out_rts_func.resolve(m_out_rts_cb, *this);
|
||||
m_out_dtr_func.resolve(m_out_dtr_cb, *this);
|
||||
m_out_irq_cb.resolve_safe();
|
||||
m_out_txd_cb.resolve();
|
||||
m_out_frame_cb.bind_relative_to(*owner());
|
||||
m_out_rts_cb.resolve_safe();
|
||||
m_out_dtr_cb.resolve_safe();
|
||||
|
||||
m_ttimer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mc6854_device::tfifo_cb), this));
|
||||
|
||||
@ -310,10 +292,10 @@ void mc6854_device::send_bits( UINT32 data, int len, int zi )
|
||||
m_tones = 0;
|
||||
|
||||
/* send bits */
|
||||
if ( !m_out_txd_func.isnull() )
|
||||
if ( !m_out_txd_cb.isnull() )
|
||||
{
|
||||
for ( i = 0; i < len; i++, data >>= 1 )
|
||||
m_out_txd_func( data & 1 );
|
||||
m_out_txd_cb( data & 1 );
|
||||
}
|
||||
|
||||
/* schedule when to ask the MC6854 for more bits */
|
||||
@ -376,8 +358,6 @@ void mc6854_device::tfifo_terminate( )
|
||||
/* call-back to refill the bit-stream from the FIFO */
|
||||
TIMER_CALLBACK_MEMBER(mc6854_device::tfifo_cb)
|
||||
{
|
||||
device_t* device = (device_t*) ptr;
|
||||
|
||||
int i, data = m_tfifo[ MC6854_FIFO_SIZE - 1 ];
|
||||
|
||||
if ( ! m_tstate )
|
||||
@ -472,8 +452,8 @@ TIMER_CALLBACK_MEMBER(mc6854_device::tfifo_cb)
|
||||
m_tstate = 0;
|
||||
|
||||
m_flen = 0;
|
||||
if ( m_out_frame )
|
||||
m_out_frame( device, m_frame, len );
|
||||
if ( !m_out_frame_cb.isnull() )
|
||||
m_out_frame_cb( m_frame, len );
|
||||
}
|
||||
}
|
||||
|
||||
@ -823,7 +803,7 @@ void mc6854_device::update_sr1( )
|
||||
m_sr1 |= IRQ;
|
||||
}
|
||||
|
||||
m_out_irq_func((m_sr1 & IRQ) ? ASSERT_LINE : CLEAR_LINE);
|
||||
m_out_irq_cb((m_sr1 & IRQ) ? ASSERT_LINE : CLEAR_LINE);
|
||||
}
|
||||
|
||||
|
||||
@ -923,7 +903,7 @@ WRITE8_MEMBER( mc6854_device::write )
|
||||
if ( TST )
|
||||
logerror( "%s mc6854 test mode not handled (CR3=$%02X)\n", machine().describe_context(), m_cr3 );
|
||||
|
||||
m_out_dtr_func( DTR ? 1 : 0 );
|
||||
m_out_dtr_cb( DTR ? 1 : 0 );
|
||||
|
||||
}
|
||||
else
|
||||
@ -956,7 +936,7 @@ WRITE8_MEMBER( mc6854_device::write )
|
||||
m_sr1 |= CTS;
|
||||
}
|
||||
|
||||
m_out_rts_func( RTS ? 1 : 0 );
|
||||
m_out_rts_cb( RTS ? 1 : 0 );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -16,32 +16,38 @@
|
||||
#define MC6854_FIFO_SIZE 3
|
||||
/* hardcoded size of the 6854 FIFO (this is a hardware limit) */
|
||||
|
||||
|
||||
/* ---------- configuration ------------ */
|
||||
|
||||
struct mc6854_interface
|
||||
{
|
||||
devcb_write_line m_out_irq_cb; /* interrupt request */
|
||||
|
||||
/* low-level, bit-based interface */
|
||||
devcb_write_line m_out_txd_cb; /* transmit bit */
|
||||
|
||||
/* high-level, frame-based interface */
|
||||
void ( * m_out_frame ) ( device_t *device, UINT8* data, int length );
|
||||
|
||||
/* control lines */
|
||||
devcb_write_line m_out_rts_cb; /* 1 = transmitting, 0 = idle */
|
||||
devcb_write_line m_out_dtr_cb; /* 1 = data transmit ready, 0 = busy */
|
||||
};
|
||||
typedef device_delegate<void (UINT8 *data, int length)> mc6854_out_frame_delegate;
|
||||
#define MC6854_OUT_FRAME_CB(name) void name(UINT8 * data, int length)
|
||||
|
||||
|
||||
class mc6854_device : public device_t,
|
||||
public mc6854_interface
|
||||
#define MCFG_MC6854_OUT_IRQ_CB(_devcb) \
|
||||
devcb = &mc6854_device::set_out_irq_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_MC6854_OUT_TXD_CB(_devcb) \
|
||||
devcb = &mc6854_device::set_out_txd_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_MC6854_OUT_FRAME_CB(_class, _method) \
|
||||
mc6854_device::set_out_frame_callback(*device, mc6854_out_frame_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner)));
|
||||
|
||||
#define MCFG_MC6854_OUT_RTS_CB(_devcb) \
|
||||
devcb = &mc6854_device::set_out_rts_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_MC6854_OUT_DTR_CB(_devcb) \
|
||||
devcb = &mc6854_device::set_out_dtr_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
|
||||
class mc6854_device : public device_t
|
||||
{
|
||||
public:
|
||||
mc6854_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
~mc6854_device() {}
|
||||
|
||||
template<class _Object> static devcb2_base &set_out_irq_callback(device_t &device, _Object object) { return downcast<mc6854_device &>(device).m_out_irq_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_out_txd_callback(device_t &device, _Object object) { return downcast<mc6854_device &>(device).m_out_txd_cb.set_callback(object); }
|
||||
static void set_out_frame_callback(device_t &device, mc6854_out_frame_delegate callback) { downcast<mc6854_device &>(device).m_out_frame_cb = callback; }
|
||||
template<class _Object> static devcb2_base &set_out_rts_callback(device_t &device, _Object object) { return downcast<mc6854_device &>(device).m_out_rts_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_out_dtr_callback(device_t &device, _Object object) { return downcast<mc6854_device &>(device).m_out_dtr_cb.set_callback(object); }
|
||||
|
||||
/* interface to CPU via address/data bus*/
|
||||
DECLARE_READ8_MEMBER( read );
|
||||
DECLARE_WRITE8_MEMBER( write );
|
||||
@ -62,16 +68,22 @@ public:
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
private:
|
||||
// internal state
|
||||
devcb_resolved_write_line m_out_irq_func;
|
||||
devcb_resolved_write_line m_out_txd_func;
|
||||
devcb_resolved_write_line m_out_rts_func;
|
||||
devcb_resolved_write_line m_out_dtr_func;
|
||||
devcb2_write_line m_out_irq_cb; /* interrupt request */
|
||||
|
||||
/* low-level, bit-based interface */
|
||||
devcb2_write_line m_out_txd_cb; /* transmit bit */
|
||||
|
||||
/* high-level, frame-based interface */
|
||||
mc6854_out_frame_delegate m_out_frame_cb;
|
||||
|
||||
/* control lines */
|
||||
devcb2_write_line m_out_rts_cb; /* 1 = transmitting, 0 = idle */
|
||||
devcb2_write_line m_out_dtr_cb; /* 1 = data transmit ready, 0 = busy */
|
||||
|
||||
/* registers */
|
||||
UINT8 m_cr1, m_cr2, m_cr3, m_cr4; /* control registers */
|
||||
@ -144,13 +156,4 @@ extern const device_type MC6854;
|
||||
full frames are accepted.
|
||||
*/
|
||||
|
||||
|
||||
#define MCFG_MC6854_ADD(_tag, _intrf) \
|
||||
MCFG_DEVICE_ADD(_tag, MC6854, 0) \
|
||||
MCFG_DEVICE_CONFIG(_intrf)
|
||||
|
||||
#define MCFG_MC6854_REMOVE(_tag) \
|
||||
MCFG_DEVICE_REMOVE(_tag)
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -623,15 +623,6 @@ static const floppy_interface bbc_floppy_interface =
|
||||
NULL
|
||||
};
|
||||
|
||||
static const mc6854_interface adlc_intf =
|
||||
{
|
||||
DEVCB_NULL,
|
||||
DEVCB_DEVICE_LINE_MEMBER(ECONET_TAG, econet_device, data_w),
|
||||
NULL,
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
WRITE_LINE_MEMBER(bbc_state::econet_clk_w)
|
||||
{
|
||||
m_adlc->rxc_w(state);
|
||||
@ -999,7 +990,8 @@ static MACHINE_CONFIG_START( bbcm, bbc_state )
|
||||
MCFG_FRAGMENT_ADD(bbc_cartslot)
|
||||
|
||||
/* econet */
|
||||
MCFG_MC6854_ADD("mc6854", adlc_intf)
|
||||
MCFG_DEVICE_ADD("mc6854", MC6854, 0)
|
||||
MCFG_MC6854_OUT_TXD_CB(DEVWRITELINE(ECONET_TAG, econet_device, data_w))
|
||||
MCFG_ECONET_ADD()
|
||||
MCFG_ECONET_CLK_CALLBACK(WRITELINE(bbc_state, econet_clk_w))
|
||||
MCFG_ECONET_DATA_CALLBACK(DEVWRITELINE("mc6854", mc6854_device, set_rx))
|
||||
|
@ -126,15 +126,6 @@ static const ptm6840_interface poly_ptm_intf =
|
||||
DEVCB_CPU_INPUT_LINE("maincpu", M6809_IRQ_LINE)
|
||||
};
|
||||
|
||||
static const mc6854_interface adlc_intf =
|
||||
{
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL,
|
||||
NULL,
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
READ8_MEMBER( poly_state::videoram_r )
|
||||
{
|
||||
return m_videoram[offset];
|
||||
@ -196,7 +187,7 @@ static MACHINE_CONFIG_START( poly, poly_state )
|
||||
//MCFG_DEVICE_ADD("acia_clock", CLOCK, 1)
|
||||
//MCFG_CLOCK_SIGNAL_HANDLER(WRITELINE(poly_state, write_acia_clock))
|
||||
|
||||
MCFG_MC6854_ADD("adlc", adlc_intf)
|
||||
MCFG_DEVICE_ADD("adlc", MC6854, 0)
|
||||
|
||||
MCFG_DEVICE_ADD(KEYBOARD_TAG, GENERIC_KEYBOARD, 0)
|
||||
MCFG_GENERIC_KEYBOARD_CB(WRITE8(poly_state, kbd_put))
|
||||
|
@ -717,7 +717,9 @@ static MACHINE_CONFIG_START( to7, thomson_state )
|
||||
MCFG_DEVICE_CONFIG(thomson_floppy_interface_3)
|
||||
|
||||
/* network */
|
||||
MCFG_MC6854_ADD( "mc6854", to7_network_iface )
|
||||
MCFG_DEVICE_ADD( "mc6854", MC6854, 0 )
|
||||
MCFG_MC6854_OUT_FRAME_CB(thomson_state, to7_network_got_frame)
|
||||
|
||||
|
||||
/* pia */
|
||||
MCFG_DEVICE_ADD(THOM_PIA_SYS, PIA6821, 0)
|
||||
|
@ -314,6 +314,8 @@ public:
|
||||
|
||||
int m_centronics_busy;
|
||||
int m_centronics_perror;
|
||||
|
||||
MC6854_OUT_FRAME_CB(to7_network_got_frame);
|
||||
|
||||
protected:
|
||||
required_device<cpu_device> m_maincpu;
|
||||
|
@ -1639,27 +1639,25 @@ TIMER_CALLBACK_MEMBER( thomson_state::ans )
|
||||
|
||||
*/
|
||||
|
||||
static void to7_network_got_frame( device_t *device, UINT8* data, int length )
|
||||
MC6854_OUT_FRAME_CB(thomson_state::to7_network_got_frame)
|
||||
{
|
||||
int i;
|
||||
LOG(( "%f to7_network_got_frame:", device->machine().time().as_double() ));
|
||||
for ( i = 0; i < length; i++ )
|
||||
LOG(( "%f to7_network_got_frame:", machine().time().as_double() ));
|
||||
for ( int i = 0; i < length; i++ )
|
||||
LOG(( " $%02X", data[i] ));
|
||||
LOG(( "\n" ));
|
||||
|
||||
if ( data[1] == 0xff )
|
||||
{
|
||||
thomson_state *state = device->machine().driver_data<thomson_state>();
|
||||
LOG(( "to7_network_got_frame: %i phones %i\n", data[2], data[0] ));
|
||||
device->machine().scheduler().timer_set( attotime::from_usec( 100 ), timer_expired_delegate(FUNC(thomson_state::ans),state));
|
||||
state->m_mc6854->set_cts( 0 );
|
||||
machine().scheduler().timer_set( attotime::from_usec( 100 ), timer_expired_delegate(FUNC(thomson_state::ans), this));
|
||||
m_mc6854->set_cts( 0 );
|
||||
}
|
||||
else if ( ! data[1] )
|
||||
{
|
||||
char name[33];
|
||||
memcpy( name, data + 12, 32 );
|
||||
name[32] = 0;
|
||||
for (i=0;i<32;i++)
|
||||
for (int i=0;i<32;i++)
|
||||
{
|
||||
if ( name[i]<32 || name[i]>=127 )
|
||||
name[i]=' ';
|
||||
@ -1671,16 +1669,6 @@ static void to7_network_got_frame( device_t *device, UINT8* data, int length )
|
||||
}
|
||||
|
||||
|
||||
const mc6854_interface to7_network_iface =
|
||||
{
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL,
|
||||
to7_network_got_frame,
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
|
||||
void thomson_state::to7_network_init()
|
||||
{
|
||||
LOG(( "to7_network_init: NR 07-005 network extension\n" ));
|
||||
|
@ -14,8 +14,6 @@
|
||||
#include "machine/mc6843.h"
|
||||
#include "machine/mc6854.h"
|
||||
|
||||
extern const mc6854_interface to7_network_iface;
|
||||
|
||||
extern UINT8 to7_controller_type; /* set during init */
|
||||
extern UINT8 to7_floppy_bank;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user