mirror of
https://github.com/holub/mame
synced 2025-04-24 09:20:02 +03:00
ay31015_device: converted to devcb2 (nw)
This commit is contained in:
parent
da49f5bbde
commit
f895dd6a79
@ -96,12 +96,20 @@ const device_type AY31015 = &device_creator<ay31015_device>;
|
||||
const device_type AY51013 = &device_creator<ay51013_device>;
|
||||
|
||||
ay31015_device::ay31015_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
|
||||
: device_t(mconfig, type, name, tag, owner, clock, shortname, source)
|
||||
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
|
||||
m_rx_clock(0),
|
||||
m_tx_clock(0),
|
||||
m_read_si_cb(*this),
|
||||
m_write_so_cb(*this),
|
||||
m_status_changed_cb(*this)
|
||||
{
|
||||
}
|
||||
|
||||
ay31015_device::ay31015_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, AY31015, "AY-3-1015", tag, owner, clock, "ay31015", __FILE__)
|
||||
: device_t(mconfig, AY31015, "AY-3-1015", tag, owner, clock, "ay31015", __FILE__),
|
||||
m_read_si_cb(*this),
|
||||
m_write_so_cb(*this),
|
||||
m_status_changed_cb(*this)
|
||||
{
|
||||
}
|
||||
|
||||
@ -110,42 +118,15 @@ ay51013_device::ay51013_device(const machine_config &mconfig, const char *tag, d
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void ay31015_device::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const ay31015_config *intf = reinterpret_cast<const ay31015_config *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<ay31015_config *>(this) = *intf;
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
memset(&read_si_cb, 0, sizeof(read_si_cb));
|
||||
memset(&write_so_cb, 0, sizeof(write_so_cb));
|
||||
memset(&status_changed_cb, 0, sizeof(status_changed_cb));
|
||||
transmitter_clock = 0;
|
||||
receiver_clock = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void ay31015_device::device_start()
|
||||
{
|
||||
m_read_si.resolve(read_si_cb, *this);
|
||||
m_write_so.resolve(write_so_cb, *this);
|
||||
m_status_changed.resolve(status_changed_cb, *this);
|
||||
|
||||
m_tx_clock = transmitter_clock;
|
||||
m_rx_clock = receiver_clock;
|
||||
m_read_si_cb.resolve();
|
||||
m_write_so_cb.resolve();
|
||||
m_status_changed_cb.resolve();
|
||||
|
||||
m_rx_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ay31015_device::rx_process),this));
|
||||
m_tx_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ay31015_device::tx_process),this));
|
||||
@ -191,8 +172,8 @@ void ay31015_device::device_reset()
|
||||
|
||||
inline UINT8 ay31015_device::get_si()
|
||||
{
|
||||
if (!m_read_si.isnull())
|
||||
m_pins[AY31015_SI] = m_read_si(0) ? 1 : 0;
|
||||
if (!m_read_si_cb.isnull())
|
||||
m_pins[AY31015_SI] = m_read_si_cb(0) ? 1 : 0;
|
||||
|
||||
return m_pins[AY31015_SI];
|
||||
}
|
||||
@ -202,8 +183,8 @@ inline void ay31015_device::set_so( int data )
|
||||
{
|
||||
m_pins[AY31015_SO] = data ? 1 : 0;
|
||||
|
||||
if (!m_write_so.isnull())
|
||||
m_write_so(0, m_pins[AY31015_SO]);
|
||||
if (!m_write_so_cb.isnull())
|
||||
m_write_so_cb((offs_t)0, m_pins[AY31015_SO]);
|
||||
}
|
||||
|
||||
|
||||
@ -238,9 +219,9 @@ void ay31015_device::update_status_pins()
|
||||
}
|
||||
status_pins_changed += update_status_pin(STATUS_EOC, AY31015_EOC);
|
||||
|
||||
if (status_pins_changed && !m_status_changed.isnull())
|
||||
if (status_pins_changed && !m_status_changed_cb.isnull())
|
||||
{
|
||||
m_status_changed(0, status_pins_changed);
|
||||
m_status_changed_cb((offs_t)0, status_pins_changed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,16 +39,6 @@ enum ay31015_output_pin_t
|
||||
};
|
||||
|
||||
|
||||
struct ay31015_config
|
||||
{
|
||||
double transmitter_clock; /* TCP - pin 40 */
|
||||
double receiver_clock; /* RCP - pin 17 */
|
||||
devcb_read8 read_si_cb; /* SI - pin 20 - This will be called whenever the SI pin is sampled. Optional */
|
||||
devcb_write8 write_so_cb; /* SO - pin 25 - This will be called whenever data is put on the SO pin. Optional */
|
||||
devcb_write8 status_changed_cb; /* This will be called whenever one of the status pins may have changed. Optional */
|
||||
};
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
DEVICE INTERFACE
|
||||
***************************************************************************/
|
||||
@ -66,15 +56,19 @@ enum state_t
|
||||
|
||||
ALLOW_SAVE_TYPE(state_t);
|
||||
|
||||
class ay31015_device : public device_t,
|
||||
public ay31015_config
|
||||
class ay31015_device : public device_t
|
||||
{
|
||||
public:
|
||||
ay31015_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
ay31015_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source);
|
||||
~ay31015_device() {}
|
||||
|
||||
|
||||
static void set_tx_clock(device_t &device, double tx_clock) { downcast<ay31015_device &>(device).m_tx_clock = tx_clock; }
|
||||
static void set_rx_clock(device_t &device, double rx_clock) { downcast<ay31015_device &>(device).m_rx_clock = rx_clock; }
|
||||
template<class _Object> static devcb2_base &set_read_si_callback(device_t &device, _Object object) { return downcast<ay31015_device &>(device).m_read_si_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_write_so_callback(device_t &device, _Object object) { return downcast<ay31015_device &>(device).m_write_so_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_status_changed_callback(device_t &device, _Object object) { return downcast<ay31015_device &>(device).m_status_changed_cb.set_callback(object); }
|
||||
|
||||
/* Set an input pin */
|
||||
void set_input_pin( ay31015_input_pin_t pin, int data );
|
||||
|
||||
@ -102,7 +96,6 @@ public:
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
@ -133,7 +126,7 @@ protected:
|
||||
UINT8 m_rx_bit_count;
|
||||
UINT8 m_rx_parity;
|
||||
UINT16 m_rx_pulses; // total pulses left
|
||||
double m_rx_clock;
|
||||
double m_rx_clock; /* RCP - pin 17 */
|
||||
emu_timer *m_rx_timer;
|
||||
|
||||
state_t m_tx_state;
|
||||
@ -141,12 +134,12 @@ protected:
|
||||
UINT8 m_tx_buffer; // next byte to send
|
||||
UINT8 m_tx_parity;
|
||||
UINT16 m_tx_pulses; // total pulses left
|
||||
double m_tx_clock;
|
||||
double m_tx_clock; /* TCP - pin 40 */
|
||||
emu_timer *m_tx_timer;
|
||||
|
||||
devcb_resolved_read8 m_read_si; /* SI - pin 20 - This will be called whenever the SI pin is sampled. Optional */
|
||||
devcb_resolved_write8 m_write_so; /* SO - pin 25 - This will be called whenever data is put on the SO pin. Optional */
|
||||
devcb_resolved_write8 m_status_changed; /* This will be called whenever one of the status pins may have changed. Optional */
|
||||
devcb2_read8 m_read_si_cb; /* SI - pin 20 - This will be called whenever the SI pin is sampled. Optional */
|
||||
devcb2_write8 m_write_so_cb; /* SO - pin 25 - This will be called whenever data is put on the SO pin. Optional */
|
||||
devcb2_write8 m_status_changed_cb; /* This will be called whenever one of the status pins may have changed. Optional */
|
||||
};
|
||||
|
||||
class ay51013_device : public ay31015_device
|
||||
@ -168,10 +161,36 @@ extern const device_type AY51013; // For AY-3-1014, AY-5-1013 and AY-6-1013 va
|
||||
DEVICE CONFIGURATION MACROS
|
||||
***************************************************************************/
|
||||
|
||||
#define MCFG_AY31015_ADD(_tag, _config) \
|
||||
MCFG_DEVICE_ADD(_tag, AY31015, 0) \
|
||||
MCFG_DEVICE_CONFIG(_config)
|
||||
|
||||
#define MCFG_AY31015_TX_CLOCK(_txclk) \
|
||||
ay31015_device::set_tx_clock(*device, _txclk);
|
||||
|
||||
#define MCFG_AY31015_RX_CLOCK(_rxclk) \
|
||||
ay31015_device::set_rx_clock(*device, _rxclk);
|
||||
|
||||
#define MCFG_AY31015_READ_SI_CB(_devcb) \
|
||||
devcb = &ay31015_device::set_read_si_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_AY31015_WRITE_SO_CB(_devcb) \
|
||||
devcb = &ay31015_device::set_write_so_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_AY31015_STATUS_CHANGED_CB(_devcb) \
|
||||
devcb = &ay31015_device::set_status_changed_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
|
||||
#define MCFG_AY51013_TX_CLOCK(_txclk) \
|
||||
ay51013_device::set_tx_clock(*device, _txclk);
|
||||
|
||||
#define MCFG_AY51013_RX_CLOCK(_rxclk) \
|
||||
ay51013_device::set_rx_clock(*device, _rxclk);
|
||||
|
||||
#define MCFG_AY51013_READ_SI_CB(_devcb) \
|
||||
devcb = &ay51013_device::set_read_si_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_AY51013_WRITE_SO_CB(_devcb) \
|
||||
devcb = &ay51013_device::set_write_so_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_AY51013_STATUS_CHANGED_CB(_devcb) \
|
||||
devcb = &ay51013_device::set_status_changed_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#endif
|
||||
|
@ -258,16 +258,6 @@ INPUT_PORTS_END
|
||||
*
|
||||
*************************************/
|
||||
|
||||
static const ay31015_config nascom1_ay31015_config =
|
||||
{
|
||||
( XTAL_16MHz / 16 ) / 256,
|
||||
( XTAL_16MHz / 16 ) / 256,
|
||||
DEVCB_DRIVER_MEMBER(nascom1_state, nascom1_hd6402_si),
|
||||
DEVCB_DRIVER_MEMBER(nascom1_state, nascom1_hd6402_so),
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
|
||||
static Z80PIO_INTERFACE( nascom1_z80pio_intf )
|
||||
{
|
||||
DEVCB_NULL,
|
||||
@ -299,7 +289,12 @@ static MACHINE_CONFIG_START( nascom1, nascom1_state )
|
||||
MCFG_GFXDECODE_ADD("gfxdecode", "palette", nascom1)
|
||||
MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette")
|
||||
|
||||
MCFG_AY31015_ADD( "hd6402", nascom1_ay31015_config )
|
||||
MCFG_DEVICE_ADD( "hd6402", AY31015, 0 )
|
||||
MCFG_AY31015_TX_CLOCK(( XTAL_16MHz / 16 ) / 256)
|
||||
MCFG_AY31015_RX_CLOCK(( XTAL_16MHz / 16 ) / 256)
|
||||
MCFG_AY51013_READ_SI_CB(READ8(nascom1_state, nascom1_hd6402_si))
|
||||
MCFG_AY51013_WRITE_SO_CB(WRITE8(nascom1_state, nascom1_hd6402_so))
|
||||
|
||||
|
||||
MCFG_Z80PIO_ADD( "z80pio", XTAL_16MHz/8, nascom1_z80pio_intf )
|
||||
|
||||
|
@ -547,15 +547,6 @@ static INPUT_PORTS_START( sol20 )
|
||||
PORT_CONFSETTING( 0x02, "6575")
|
||||
INPUT_PORTS_END
|
||||
|
||||
static const ay31015_config sol20_ay31015_config =
|
||||
{
|
||||
4800.0,
|
||||
4800.0,
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
|
||||
static const cassette_interface sol20_cassette_interface =
|
||||
{
|
||||
@ -767,8 +758,12 @@ static MACHINE_CONFIG_START( sol20, sol20_state )
|
||||
// devices
|
||||
MCFG_CASSETTE_ADD( "cassette", sol20_cassette_interface )
|
||||
MCFG_CASSETTE_ADD( "cassette2", sol20_cassette_interface )
|
||||
MCFG_AY31015_ADD( "uart", sol20_ay31015_config )
|
||||
MCFG_AY31015_ADD( "uart_s", sol20_ay31015_config )
|
||||
MCFG_DEVICE_ADD( "uart", AY31015, 0 )
|
||||
MCFG_AY31015_TX_CLOCK(4800.0)
|
||||
MCFG_AY31015_RX_CLOCK(4800.0)
|
||||
MCFG_DEVICE_ADD( "uart_s", AY31015, 0 )
|
||||
MCFG_AY31015_TX_CLOCK(4800.0)
|
||||
MCFG_AY31015_RX_CLOCK(4800.0)
|
||||
MCFG_DEVICE_ADD(KEYBOARD_TAG, GENERIC_KEYBOARD, 0)
|
||||
MCFG_GENERIC_KEYBOARD_CB(WRITE8(sol20_state, kbd_put))
|
||||
MACHINE_CONFIG_END
|
||||
|
@ -386,16 +386,6 @@ UINT32 sorcerer_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap
|
||||
|
||||
/**********************************************************************************************************/
|
||||
|
||||
static const ay31015_config sorcerer_ay31015_config =
|
||||
{
|
||||
4800.0,
|
||||
4800.0,
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
|
||||
static const cassette_interface sorcerer_cassette_interface =
|
||||
{
|
||||
sorcerer_cassette_formats,
|
||||
@ -445,8 +435,10 @@ static MACHINE_CONFIG_START( sorcerer, sorcerer_state )
|
||||
MCFG_SOUND_WAVE_ADD(WAVE2_TAG, "cassette2")
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) // cass2 speaker
|
||||
|
||||
MCFG_AY31015_ADD( "uart", sorcerer_ay31015_config )
|
||||
|
||||
MCFG_DEVICE_ADD( "uart", AY31015, 0 )
|
||||
MCFG_AY31015_TX_CLOCK(4800.0)
|
||||
MCFG_AY31015_RX_CLOCK(4800.0)
|
||||
|
||||
/* printer */
|
||||
MCFG_CENTRONICS_ADD("centronics", centronics_printers, "covox")
|
||||
MCFG_SLOT_OPTION_ADD( "covox", CENTRONICS_COVOX )
|
||||
|
@ -554,15 +554,6 @@ static const cassette_interface trs80l2_cassette_interface =
|
||||
NULL
|
||||
};
|
||||
|
||||
static const ay31015_config trs80_ay31015_config =
|
||||
{
|
||||
0.0,
|
||||
0.0,
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
static const floppy_interface trs80_floppy_interface =
|
||||
{
|
||||
DEVCB_NULL,
|
||||
@ -629,7 +620,7 @@ static MACHINE_CONFIG_DERIVED( model1, trs80 ) // model I, level II
|
||||
|
||||
MCFG_CENTRONICS_OUTPUT_LATCH_ADD("cent_data_out", "centronics")
|
||||
|
||||
MCFG_AY31015_ADD( "tr1602", trs80_ay31015_config )
|
||||
MCFG_DEVICE_ADD( "tr1602", AY31015, 0 )
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
static MACHINE_CONFIG_DERIVED( model3, model1 )
|
||||
|
@ -400,15 +400,6 @@ static const UINT32 lx388palette[] =
|
||||
rgb_t(0xff, 0xc4, 0x18) /* ALPHANUMERIC BRIGHT ORANGE */
|
||||
};
|
||||
|
||||
static const ay31015_config z80ne_ay31015_config =
|
||||
{
|
||||
4800.0,
|
||||
4800.0,
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL,
|
||||
DEVCB_NULL
|
||||
};
|
||||
|
||||
static const cassette_interface z80ne_cassettea_config =
|
||||
{
|
||||
cassette_default_formats,
|
||||
@ -464,7 +455,9 @@ static MACHINE_CONFIG_START( z80ne, z80ne_state )
|
||||
MCFG_MACHINE_START_OVERRIDE(z80ne_state,z80ne)
|
||||
MCFG_MACHINE_RESET_OVERRIDE(z80ne_state,z80ne)
|
||||
|
||||
MCFG_AY31015_ADD( "ay_3_1015", z80ne_ay31015_config )
|
||||
MCFG_DEVICE_ADD( "ay_3_1015", AY31015, 0 )
|
||||
MCFG_AY31015_TX_CLOCK(4800.0)
|
||||
MCFG_AY31015_RX_CLOCK(4800.0)
|
||||
|
||||
MCFG_CASSETTE_ADD( "cassette", z80ne_cassettea_config )
|
||||
MCFG_CASSETTE_ADD( "cassette2", z80ne_cassetteb_config )
|
||||
@ -508,7 +501,9 @@ static MACHINE_CONFIG_START( z80netb, z80ne_state )
|
||||
MCFG_MACHINE_START_OVERRIDE(z80ne_state,z80netb)
|
||||
MCFG_MACHINE_RESET_OVERRIDE(z80ne_state,z80netb)
|
||||
|
||||
MCFG_AY31015_ADD( "ay_3_1015", z80ne_ay31015_config )
|
||||
MCFG_DEVICE_ADD( "ay_3_1015", AY31015, 0 )
|
||||
MCFG_AY31015_TX_CLOCK(4800.0)
|
||||
MCFG_AY31015_RX_CLOCK(4800.0)
|
||||
|
||||
MCFG_CASSETTE_ADD( "cassette", z80ne_cassettea_config )
|
||||
MCFG_CASSETTE_ADD( "cassette2", z80ne_cassetteb_config )
|
||||
@ -536,7 +531,9 @@ static MACHINE_CONFIG_START( z80netf, z80ne_state )
|
||||
MCFG_MACHINE_START_OVERRIDE(z80ne_state,z80netf)
|
||||
MCFG_MACHINE_RESET_OVERRIDE(z80ne_state,z80netf)
|
||||
|
||||
MCFG_AY31015_ADD( "ay_3_1015", z80ne_ay31015_config )
|
||||
MCFG_DEVICE_ADD( "ay_3_1015", AY31015, 0 )
|
||||
MCFG_AY31015_TX_CLOCK(4800.0)
|
||||
MCFG_AY31015_RX_CLOCK(4800.0)
|
||||
|
||||
MCFG_CASSETTE_ADD( "cassette", z80ne_cassettea_config )
|
||||
MCFG_CASSETTE_ADD( "cassette2", z80ne_cassetteb_config )
|
||||
|
Loading…
Reference in New Issue
Block a user