msm5232_device: converted to devcb2 (nw)

This commit is contained in:
Ivan Vangelista 2014-03-31 16:29:34 +00:00
parent 7997e5441c
commit 9661f1d1ea
10 changed files with 44 additions and 105 deletions

View File

@ -13,30 +13,11 @@ const device_type MSM5232 = &device_creator<msm5232_device>;
msm5232_device::msm5232_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, MSM5232, "MSM5232", tag, owner, clock, "msm5232", __FILE__),
device_sound_interface(mconfig, *this)
device_sound_interface(mconfig, *this),
m_gate_handler_cb(*this)
{
}
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void msm5232_device::device_config_complete()
{
// inherit a copy of the static data
const msm5232_interface *intf = reinterpret_cast<const msm5232_interface *>(static_config());
if (intf != NULL)
*static_cast<msm5232_interface *>(this) = *intf;
// or initialize to defaults if none provided
else
{
memset(&m_gate_handler_cb, 0, sizeof(m_gate_handler_cb));
}
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
@ -45,6 +26,8 @@ void msm5232_device::device_start()
{
int rate = clock()/CLOCK_RATE_DIVIDER;
int voicenum;
m_gate_handler_cb.resolve();
init(clock(), rate);
@ -142,6 +125,18 @@ void msm5232_device::device_stop()
#endif
}
void msm5232_device::static_set_capacitors(device_t &device, double cap1, double cap2, double cap3, double cap4, double cap5, double cap6, double cap7, double cap8)
{
msm5232_device &msm = downcast<msm5232_device &>(device);
msm.m_external_capacity[0] = cap1;
msm.m_external_capacity[1] = cap2;
msm.m_external_capacity[2] = cap3;
msm.m_external_capacity[3] = cap4;
msm.m_external_capacity[4] = cap5;
msm.m_external_capacity[5] = cap6;
msm.m_external_capacity[6] = cap7;
msm.m_external_capacity[7] = cap8;
}
/* Default chip clock is 2119040 Hz */
/* At this clock chip generates exactly 440.0 Hz signal on 8' output when pitch data=0x21 */
@ -321,10 +316,10 @@ void msm5232_device::gate_update()
{
int new_state = (m_control2 & 0x20) ? m_voi[7].GF : 0;
if (m_gate != new_state && !m_gate_handler_func.isnull())
if (m_gate != new_state && !m_gate_handler_cb.isnull())
{
m_gate = new_state;
m_gate_handler_func(new_state);
m_gate_handler_cb(new_state);
}
}
@ -335,13 +330,6 @@ void msm5232_device::init(int clock, int rate)
m_chip_clock = clock;
m_rate = rate ? rate : 44100; /* avoid division by 0 */
for (j=0; j<8; j++)
{
m_external_capacity[j] = m_capacity[j];
}
m_gate_handler_func.resolve(m_gate_handler_cb, *this);
init_tables();
for (j=0; j<8; j++)

View File

@ -4,6 +4,12 @@
#define __MSM5232_H__
#define MCFG_MSM5232_SET_CAPACITORS(_a, _b, _c, _d, _e, _f, _g, _h) \
msm5232_device::static_set_capacitors(*device, _a, _b, _c, _d, _e, _f, _g, _h);
#define MCFG_MSM5232_GATE_HANDLER_CB(_devcb) \
devcb = &msm5232_device::set_gate_handler_callback(*device, DEVCB2_##_devcb);
struct VOICE {
UINT8 mode;
@ -33,27 +39,21 @@ struct VOICE {
};
struct msm5232_interface
{
double m_capacity[8]; /* in Farads, capacitors connected to pins: 24,25,26,27 and 37,38,39,40 */
devcb_write_line m_gate_handler_cb; /* callback called when the GATE output pin changes state */
};
class msm5232_device : public device_t,
public device_sound_interface,
public msm5232_interface
public device_sound_interface
{
public:
msm5232_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~msm5232_device() {}
static void static_set_capacitors(device_t &device, double cap1, double cap2, double cap3, double cap4, double cap5, double cap6, double cap7, double cap8);
template<class _Object> static devcb2_base &set_gate_handler_callback(device_t &device, _Object object) { return downcast<msm5232_device &>(device).m_gate_handler_cb.set_callback(object); }
DECLARE_WRITE8_MEMBER( write );
void set_clock(int clock);
protected:
// device-level overrides
virtual void device_config_complete();
virtual void device_start();
virtual void device_stop();
virtual void device_reset();
@ -92,7 +92,7 @@ protected:
int m_rate; /* sample rate in Hz */
double m_external_capacity[8]; /* in Farads, eg 0.39e-6 = 0.36 uF (microFarads) */
devcb_resolved_write_line m_gate_handler_func;/* callback called when the GATE output pin changes state */
devcb2_write_line m_gate_handler_cb;/* callback called when the GATE output pin changes state */
void init_tables();
void init_voice(int i);

View File

@ -963,12 +963,6 @@ static const ay8910_interface ay8910_config =
DEVCB_DRIVER_MEMBER(fortyl_state,sound_control_3_w)
};
static const msm5232_interface msm5232_config =
{
{ 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6 }, /* 1.0 uF capacitors (verified on real PCB) */
DEVCB_NULL
};
/*******************************************************************************/
MACHINE_START_MEMBER(fortyl_state,40love)
@ -1087,7 +1081,7 @@ static MACHINE_CONFIG_START( 40love, fortyl_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.10)
MCFG_SOUND_ADD("msm", MSM5232, 8000000/4)
MCFG_SOUND_CONFIG(msm5232_config)
MCFG_MSM5232_SET_CAPACITORS(1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6) /* 1.0 uF capacitors (verified on real PCB) */
MCFG_SOUND_ROUTE(0, "mono", 1.0) // pin 28 2'-1
MCFG_SOUND_ROUTE(1, "mono", 1.0) // pin 29 4'-1
MCFG_SOUND_ROUTE(2, "mono", 1.0) // pin 30 8'-1
@ -1143,7 +1137,7 @@ static MACHINE_CONFIG_START( undoukai, fortyl_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.10)
MCFG_SOUND_ADD("msm", MSM5232, 8000000/4)
MCFG_SOUND_CONFIG(msm5232_config)
MCFG_MSM5232_SET_CAPACITORS(1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6) /* 1.0 uF capacitors (verified on real PCB) */
MCFG_SOUND_ROUTE(0, "mono", 1.0) // pin 28 2'-1
MCFG_SOUND_ROUTE(1, "mono", 1.0) // pin 29 4'-1
MCFG_SOUND_ROUTE(2, "mono", 1.0) // pin 30 8'-1

View File

@ -405,11 +405,6 @@ static GFXDECODE_START( bigevglf )
GFXDECODE_ENTRY( "gfx1", 0, gfxlayout, 0x20*16, 16 )
GFXDECODE_END
static const msm5232_interface msm5232_config =
{
{ 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6 }, /* 0.65 (???) uF capacitors */
DEVCB_NULL
};
void bigevglf_state::machine_start()
{
@ -521,7 +516,7 @@ static MACHINE_CONFIG_START( bigevglf, bigevglf_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15) /* YM2149 really */
MCFG_SOUND_ADD("msm", MSM5232, 8000000/4)
MCFG_SOUND_CONFIG(msm5232_config)
MCFG_MSM5232_SET_CAPACITORS(0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6) /* 0.65 (???) uF capacitors */
MCFG_SOUND_ROUTE(0, "mono", 1.0) // pin 28 2'-1
MCFG_SOUND_ROUTE(1, "mono", 1.0) // pin 29 4'-1
MCFG_SOUND_ROUTE(2, "mono", 1.0) // pin 30 8'-1

View File

@ -346,12 +346,6 @@ static const ay8910_interface ay8910_interface_2 =
DEVCB_DRIVER_MEMBER(buggychl_state,port_b_1_w)
};
static const msm5232_interface msm5232_config =
{
{ 0.39e-6, 0.39e-6, 0.39e-6, 0.39e-6, 0.39e-6, 0.39e-6, 0.39e-6, 0.39e-6 }, /* default 0.39 uF capacitors (not verified) */
DEVCB_NULL
};
void buggychl_state::machine_start()
{
@ -427,7 +421,7 @@ static MACHINE_CONFIG_START( buggychl, buggychl_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_SOUND_ADD("msm", MSM5232, 2000000)
MCFG_SOUND_CONFIG(msm5232_config)
MCFG_MSM5232_SET_CAPACITORS(0.39e-6, 0.39e-6, 0.39e-6, 0.39e-6, 0.39e-6, 0.39e-6, 0.39e-6, 0.39e-6) /* default 0.39 uF capacitors (not verified) */
MCFG_SOUND_ROUTE(0, "mono", 1.0) // pin 28 2'-1
MCFG_SOUND_ROUTE(1, "mono", 1.0) // pin 29 4'-1
MCFG_SOUND_ROUTE(2, "mono", 1.0) // pin 30 8'-1

View File

@ -1089,13 +1089,6 @@ GFXDECODE_END
/******************************************************************************/
static const msm5232_interface equites_5232intf =
{
{ 0.47e-6, 0.47e-6, 0.47e-6, 0.47e-6, 0.47e-6, 0.47e-6, 0.47e-6, 0.47e-6 }, // verified
DEVCB_DRIVER_LINE_MEMBER(equites_state,equites_msm5232_gate)
};
static const ay8910_interface equites_8910intf =
{
AY8910_LEGACY_OUTPUT,
@ -1136,7 +1129,8 @@ static MACHINE_CONFIG_FRAGMENT( common_sound )
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("msm", MSM5232, MSM5232_MAX_CLOCK) // will be adjusted at runtime through PORT_ADJUSTER
MCFG_SOUND_CONFIG(equites_5232intf)
MCFG_MSM5232_SET_CAPACITORS(0.47e-6, 0.47e-6, 0.47e-6, 0.47e-6, 0.47e-6, 0.47e-6, 0.47e-6, 0.47e-6) // verified
MCFG_MSM5232_GATE_HANDLER_CB(WRITELINE(equites_state, equites_msm5232_gate))
MCFG_SOUND_ROUTE(0, "mono", MSM5232_BASE_VOLUME/2.2) // pin 28 2'-1 : 22k resistor
MCFG_SOUND_ROUTE(1, "mono", MSM5232_BASE_VOLUME/1.5) // pin 29 4'-1 : 15k resistor
MCFG_SOUND_ROUTE(2, "mono", MSM5232_BASE_VOLUME) // pin 30 8'-1 : 10k resistor

View File

@ -982,13 +982,6 @@ static const ay8910_interface ay8910_config =
DEVCB_DRIVER_MEMBER(flstory_state,sound_control_3_w)
};
static const msm5232_interface msm5232_config =
{
{ 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6 }, /* 1.0 uF capacitors (verified on real PCB) */
DEVCB_NULL
};
void flstory_state::machine_start()
{
/* video */
@ -1098,7 +1091,7 @@ static MACHINE_CONFIG_START( flstory, flstory_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.10)
MCFG_SOUND_ADD("msm", MSM5232, XTAL_8MHz/4) /* verified on pcb */
MCFG_SOUND_CONFIG(msm5232_config)
MCFG_MSM5232_SET_CAPACITORS(1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6) /* 1.0 uF capacitors (verified on real PCB) */
MCFG_SOUND_ROUTE(0, "mono", 1.0) // pin 28 2'-1
MCFG_SOUND_ROUTE(1, "mono", 1.0) // pin 29 4'-1
MCFG_SOUND_ROUTE(2, "mono", 1.0) // pin 30 8'-1
@ -1157,7 +1150,7 @@ static MACHINE_CONFIG_START( onna34ro, flstory_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.10)
MCFG_SOUND_ADD("msm", MSM5232, 8000000/4)
MCFG_SOUND_CONFIG(msm5232_config)
MCFG_MSM5232_SET_CAPACITORS(1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6) /* 1.0 uF capacitors (verified on real PCB) */
MCFG_SOUND_ROUTE(0, "mono", 1.0) // pin 28 2'-1
MCFG_SOUND_ROUTE(1, "mono", 1.0) // pin 29 4'-1
MCFG_SOUND_ROUTE(2, "mono", 1.0) // pin 30 8'-1
@ -1216,7 +1209,7 @@ static MACHINE_CONFIG_START( victnine, flstory_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_SOUND_ADD("msm", MSM5232, 8000000/4)
MCFG_SOUND_CONFIG(msm5232_config)
MCFG_MSM5232_SET_CAPACITORS(1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6) /* 1.0 uF capacitors (verified on real PCB) */
MCFG_SOUND_ROUTE(0, "mono", 1.0) // pin 28 2'-1
MCFG_SOUND_ROUTE(1, "mono", 1.0) // pin 29 4'-1
MCFG_SOUND_ROUTE(2, "mono", 1.0) // pin 30 8'-1
@ -1281,7 +1274,7 @@ static MACHINE_CONFIG_START( rumba, flstory_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_SOUND_ADD("msm", MSM5232, XTAL_8MHz/4) /* verified on pcb */
MCFG_SOUND_CONFIG(msm5232_config)
MCFG_MSM5232_SET_CAPACITORS(1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6, 1.0e-6) /* 1.0 uF capacitors (verified on real PCB) */
MCFG_SOUND_ROUTE(0, "mono", 1.0) // pin 28 2'-1
MCFG_SOUND_ROUTE(1, "mono", 1.0) // pin 29 4'-1
MCFG_SOUND_ROUTE(2, "mono", 1.0) // pin 30 8'-1

View File

@ -112,12 +112,6 @@ static const ay8910_interface ay8910_config =
DEVCB_DRIVER_MEMBER(ladyfrog_state,unk_w)
};
static const msm5232_interface msm5232_config =
{
{ 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6 },
DEVCB_NULL
};
READ8_MEMBER(ladyfrog_state::snd_flag_r)
{
return m_snd_flag | 0xfd;
@ -327,7 +321,7 @@ static MACHINE_CONFIG_START( ladyfrog, ladyfrog_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
MCFG_SOUND_ADD("msm", MSM5232, 2000000)
MCFG_SOUND_CONFIG(msm5232_config)
MCFG_MSM5232_SET_CAPACITORS(0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6)
MCFG_SOUND_ROUTE(0, "mono", 1.0) // pin 28 2'-1
MCFG_SOUND_ROUTE(1, "mono", 1.0) // pin 29 4'-1
MCFG_SOUND_ROUTE(2, "mono", 1.0) // pin 30 8'-1

View File

@ -416,12 +416,6 @@ static GFXDECODE_START( msisaac )
GFXDECODE_ENTRY( "gfx2", 0, tile_layout, 0, 64 )
GFXDECODE_END
static const msm5232_interface msm5232_config =
{
{ 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6 }, /* 0.65 (???) uF capacitors (match the sample, not verified) */
DEVCB_NULL
};
/*******************************************************************************/
@ -505,7 +499,7 @@ static MACHINE_CONFIG_START( msisaac, msisaac_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
MCFG_SOUND_ADD("msm", MSM5232, 2000000)
MCFG_SOUND_CONFIG(msm5232_config)
MCFG_MSM5232_SET_CAPACITORS(0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6) /* 0.65 (???) uF capacitors (match the sample, not verified) */
MCFG_SOUND_ROUTE(0, "mono", 1.0) // pin 28 2'-1
MCFG_SOUND_ROUTE(1, "mono", 1.0) // pin 29 4'-1
MCFG_SOUND_ROUTE(2, "mono", 1.0) // pin 30 8'-1

View File

@ -303,13 +303,6 @@ static const ay8910_interface ay8910_config =
DEVCB_DRIVER_MEMBER(nycaptor_state,unk_w)
};
static const msm5232_interface msm5232_config =
{
{ 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6 }, /* 0.65 (???) uF capacitors (match the sample, not verified) */
DEVCB_NULL
};
READ8_MEMBER(nycaptor_state::nycaptor_generic_control_r)
{
return m_generic_control_reg;
@ -858,7 +851,7 @@ static MACHINE_CONFIG_START( nycaptor, nycaptor_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
MCFG_SOUND_ADD("msm", MSM5232, 2000000)
MCFG_SOUND_CONFIG(msm5232_config)
MCFG_MSM5232_SET_CAPACITORS(0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6) /* 0.65 (???) uF capacitors (match the sample, not verified) */
MCFG_SOUND_ROUTE(0, "mono", 1.0) // pin 28 2'-1
MCFG_SOUND_ROUTE(1, "mono", 1.0) // pin 29 4'-1
MCFG_SOUND_ROUTE(2, "mono", 1.0) // pin 30 8'-1
@ -917,7 +910,7 @@ static MACHINE_CONFIG_START( cyclshtg, nycaptor_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
MCFG_SOUND_ADD("msm", MSM5232, 2000000)
MCFG_SOUND_CONFIG(msm5232_config)
MCFG_MSM5232_SET_CAPACITORS(0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6) /* 0.65 (???) uF capacitors (match the sample, not verified) */
MCFG_SOUND_ROUTE(0, "mono", 1.0) // pin 28 2'-1
MCFG_SOUND_ROUTE(1, "mono", 1.0) // pin 29 4'-1
MCFG_SOUND_ROUTE(2, "mono", 1.0) // pin 30 8'-1
@ -976,7 +969,7 @@ static MACHINE_CONFIG_START( bronx, nycaptor_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
MCFG_SOUND_ADD("msm", MSM5232, 2000000)
MCFG_SOUND_CONFIG(msm5232_config)
MCFG_MSM5232_SET_CAPACITORS(0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6, 0.65e-6) /* 0.65 (???) uF capacitors (match the sample, not verified) */
MCFG_SOUND_ROUTE(0, "mono", 1.0) // pin 28 2'-1
MCFG_SOUND_ROUTE(1, "mono", 1.0) // pin 29 4'-1
MCFG_SOUND_ROUTE(2, "mono", 1.0) // pin 30 8'-1