mirror of
https://github.com/holub/mame
synced 2025-04-26 10:13:37 +03:00
Updated upd1771.c to use devcb2 (nw)
This commit is contained in:
parent
c8ea1c0d04
commit
7f6756ef15
@ -223,31 +223,11 @@ const device_type UPD1771C = &device_creator<upd1771c_device>;
|
||||
|
||||
upd1771c_device::upd1771c_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, UPD1771C, "NEC uPD1771C 017", tag, owner, clock, "upd1771c", __FILE__),
|
||||
device_sound_interface(mconfig, *this)
|
||||
device_sound_interface(mconfig, *this),
|
||||
m_ack_handler(*this)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void upd1771c_device::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const upd1771_interface *intf = reinterpret_cast<const upd1771_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<upd1771_interface *>(this) = *intf;
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
memset(&m_ack_callback, 0, sizeof(m_ack_callback));
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
@ -255,7 +235,7 @@ void upd1771c_device::device_config_complete()
|
||||
void upd1771c_device::device_start()
|
||||
{
|
||||
/* resolve callbacks */
|
||||
m_ack_out_func.resolve(m_ack_callback, *this);
|
||||
m_ack_handler.resolve();
|
||||
|
||||
m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(upd1771c_device::ack_callback),this));
|
||||
|
||||
@ -374,7 +354,7 @@ WRITE8_MEMBER( upd1771c_device::write )
|
||||
//if (LOG)
|
||||
// logerror( "upd1771_w: received byte 0x%02x\n", data );
|
||||
|
||||
m_ack_out_func(0);
|
||||
m_ack_handler(0);
|
||||
|
||||
if (m_index < MAX_PACKET_SIZE)
|
||||
m_packet[m_index++] = data;
|
||||
@ -476,7 +456,7 @@ WRITE_LINE_MEMBER( upd1771c_device::pcm_write )
|
||||
|
||||
TIMER_CALLBACK_MEMBER( upd1771c_device::ack_callback )
|
||||
{
|
||||
m_ack_out_func(1);
|
||||
m_ack_handler(1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,18 +7,12 @@
|
||||
#ifndef __UPD1771_H__
|
||||
#define __UPD1771_H__
|
||||
|
||||
#include "devcb.h"
|
||||
#include "emu.h"
|
||||
|
||||
#define MAX_PACKET_SIZE 0x8000
|
||||
|
||||
/***************************************************************************
|
||||
TYPE DEFINITIONS
|
||||
***************************************************************************/
|
||||
|
||||
struct upd1771_interface
|
||||
{
|
||||
devcb_write_line m_ack_callback;
|
||||
};
|
||||
#define MCFG_UPD1771_ACK_HANDLER(_devcb) \
|
||||
devcb = &upd1771c_device::set_ack_handler(*device, DEVCB2_##_devcb);
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
@ -26,20 +20,20 @@ struct upd1771_interface
|
||||
***************************************************************************/
|
||||
|
||||
class upd1771c_device : public device_t,
|
||||
public device_sound_interface,
|
||||
public upd1771_interface
|
||||
public device_sound_interface
|
||||
{
|
||||
public:
|
||||
upd1771c_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
~upd1771c_device() {}
|
||||
|
||||
template<class _Object> static devcb2_base &set_ack_handler(device_t &device, _Object object) { return downcast<upd1771c_device &>(device).m_ack_handler.set_callback(object); }
|
||||
|
||||
DECLARE_READ8_MEMBER( read );
|
||||
DECLARE_WRITE8_MEMBER( write );
|
||||
WRITE_LINE_MEMBER( pcm_write );
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
@ -49,7 +43,7 @@ protected:
|
||||
private:
|
||||
// internal state
|
||||
sound_stream *m_channel;
|
||||
devcb_resolved_write_line m_ack_out_func;
|
||||
devcb2_write_line m_ack_handler;
|
||||
emu_timer *m_timer;
|
||||
|
||||
TIMER_CALLBACK_MEMBER(ack_callback);
|
||||
|
@ -982,8 +982,6 @@ PALETTE_INIT_MEMBER(apc_state,apc)
|
||||
palette.set_pen_color(i, pal1bit(0), pal1bit(0), pal1bit(0));
|
||||
}
|
||||
|
||||
static const upd1771_interface upd1771c_config = { DEVCB_NULL };
|
||||
|
||||
static MACHINE_CONFIG_START( apc, apc_state )
|
||||
|
||||
/* basic machine hardware */
|
||||
@ -1028,7 +1026,6 @@ static MACHINE_CONFIG_START( apc, apc_state )
|
||||
/* sound hardware */
|
||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||
MCFG_SOUND_ADD( "upd1771c", UPD1771C, MAIN_CLOCK ) //uPD1771C-006
|
||||
MCFG_SOUND_CONFIG( upd1771c_config )
|
||||
MCFG_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 )
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
|
@ -815,9 +815,6 @@ static GFXDECODE_START( scv )
|
||||
GFXDECODE_END
|
||||
|
||||
|
||||
static const upd1771_interface scv_upd1771c_config = { DEVCB_DRIVER_LINE_MEMBER( scv_state, scv_upd1771_ack_w ) };
|
||||
|
||||
|
||||
static MACHINE_CONFIG_START( scv, scv_state )
|
||||
|
||||
MCFG_CPU_ADD( "maincpu", UPD7801, XTAL_4MHz )
|
||||
@ -837,7 +834,7 @@ static MACHINE_CONFIG_START( scv, scv_state )
|
||||
/* Sound is generated by UPD1771C clocked at XTAL_6MHz */
|
||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||
MCFG_SOUND_ADD( "upd1771c", UPD1771C, XTAL_6MHz )
|
||||
MCFG_SOUND_CONFIG( scv_upd1771c_config )
|
||||
MCFG_UPD1771_ACK_HANDLER(WRITELINE(scv_state, scv_upd1771_ack_w))
|
||||
MCFG_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 )
|
||||
|
||||
MCFG_CARTSLOT_ADD( "cart" )
|
||||
|
Loading…
Reference in New Issue
Block a user