mb87078_device: converted to devcb2 (nw)

This commit is contained in:
Ivan Vangelista 2014-03-23 07:41:02 +00:00
parent fbc247ca40
commit 339936b0ae
6 changed files with 38 additions and 82 deletions

View File

@ -104,31 +104,12 @@ const device_type MB87078 = &device_creator<mb87078_device>;
mb87078_device::mb87078_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) mb87078_device::mb87078_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, MB87078, "Fujitsu MB87078", tag, owner, clock, "mb87078", __FILE__), : device_t(mconfig, MB87078, "Fujitsu MB87078", tag, owner, clock, "mb87078", __FILE__),
//m_gain[4],
m_channel_latch(0), m_channel_latch(0),
//m_latch[2][4], m_reset_comp(0),
m_reset_comp(0) m_gain_changed_cb(*this)
{ {
} m_gain[0] = m_gain[1] = m_gain[2] = m_gain[3] = 0;
memset(m_latch, 0, sizeof(m_latch));
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void mb87078_device::device_config_complete()
{
// inherit a copy of the static data
const mb87078_interface *intf = reinterpret_cast<const mb87078_interface *>(static_config());
if (intf != NULL)
*static_cast<mb87078_interface *>(this) = *intf;
// or initialize to defaults if none provided
else
{
m_gain_changed_cb = NULL;
}
} }
//------------------------------------------------- //-------------------------------------------------
@ -137,6 +118,8 @@ void mb87078_device::device_config_complete()
void mb87078_device::device_start() void mb87078_device::device_start()
{ {
m_gain_changed_cb.resolve_safe();
save_item(NAME(m_channel_latch)); save_item(NAME(m_channel_latch));
save_item(NAME(m_reset_comp)); save_item(NAME(m_reset_comp));
save_item(NAME(m_latch[0])); save_item(NAME(m_latch[0]));
@ -205,7 +188,7 @@ void mb87078_device::gain_recalc()
int old_index = m_gain[i]; int old_index = m_gain[i];
m_gain[i] = calc_gain_index(m_latch[0][i], m_latch[1][i]); m_gain[i] = calc_gain_index(m_latch[0][i], m_latch[1][i]);
if (old_index != m_gain[i]) if (old_index != m_gain[i])
m_gain_changed_cb(machine(), i, mb87078_gain_percent[m_gain[i]]); m_gain_changed_cb((offs_t)i, mb87078_gain_percent[m_gain[i]]);
} }
} }

View File

@ -9,25 +9,24 @@
#define __MB87078_H__ #define __MB87078_H__
/***************************************************************************
DEVICE CONFIGURATION MACROS
***************************************************************************/
#define MCFG_MB87078_GAIN_CHANGED_CB(_devcb) \
devcb = &mb87078_device::set_gain_changed_callback(*device, DEVCB2_##_devcb);
/*************************************************************************** /***************************************************************************
TYPE DEFINITIONS TYPE DEFINITIONS
***************************************************************************/ ***************************************************************************/
typedef void (*mb87078_gain_changed_cb)(running_machine &machine, int channel, int percent /*, float decibels*/); class mb87078_device : public device_t
struct mb87078_interface
{
mb87078_gain_changed_cb m_gain_changed_cb;
};
class mb87078_device : public device_t,
mb87078_interface
{ {
public: public:
mb87078_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); mb87078_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
~mb87078_device() {} ~mb87078_device() {}
template<class _Object> static devcb2_base &set_gain_changed_callback(device_t &device, _Object object) { return downcast<mb87078_device &>(device).m_gain_changed_cb.set_callback(object); }
void data_w(int data, int dsel); void data_w(int data, int dsel);
void reset_comp_w(int level); void reset_comp_w(int level);
@ -49,7 +48,6 @@ public:
protected: protected:
// device-level overrides // device-level overrides
virtual void device_config_complete();
virtual void device_start(); virtual void device_start();
virtual void device_reset(); virtual void device_reset();
@ -59,17 +57,10 @@ private:
int m_channel_latch; /* current channel */ int m_channel_latch; /* current channel */
UINT8 m_latch[2][4]; /* 6bit+3bit 4 data latches */ UINT8 m_latch[2][4]; /* 6bit+3bit 4 data latches */
UINT8 m_reset_comp; UINT8 m_reset_comp;
devcb2_write8 m_gain_changed_cb;
}; };
extern const device_type MB87078; extern const device_type MB87078;
/***************************************************************************
DEVICE CONFIGURATION MACROS
***************************************************************************/
#define MCFG_MB87078_ADD(_tag, _interface) \
MCFG_DEVICE_ADD(_tag, MB87078, 0) \
MCFG_DEVICE_CONFIG(_interface)
#endif /* __MB87078_H__ */ #endif /* __MB87078_H__ */

View File

@ -26,16 +26,6 @@ taito_en_device::taito_en_device(const machine_config &mconfig, const char *tag,
{ {
} }
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void taito_en_device::device_config_complete()
{
}
//------------------------------------------------- //-------------------------------------------------
// device_start - device-specific startup // device_start - device-specific startup
//------------------------------------------------- //-------------------------------------------------
@ -267,13 +257,11 @@ ADDRESS_MAP_END
* *
*************************************/ *************************************/
static void mb87078_gain_changed( running_machine &machine, int channel, int percent ) WRITE8_MEMBER(taito_en_device::mb87078_gain_changed)
{ {
if (channel > 1) if (offset > 1)
{ {
es5505_device *es5505 = machine.device<es5505_device>("ensoniq"); machine().device<es5505_device>("ensoniq")->set_output_gain(offset & 1, data / 100.0);
es5505->set_output_gain(channel & 1, percent / 100.0);
} }
} }
@ -317,11 +305,6 @@ WRITE_LINE_MEMBER(taito_en_device::duart_irq_handler)
IP5: 1MHz IP5: 1MHz
*/ */
static const mb87078_interface taito_en_mb87078_intf =
{
mb87078_gain_changed
};
static const es5505_interface es5505_taito_en_config = static const es5505_interface es5505_taito_en_config =
{ {
"ensoniq.0", /* Bank 0: Unused by F3 games? */ "ensoniq.0", /* Bank 0: Unused by F3 games? */
@ -346,7 +329,8 @@ MACHINE_CONFIG_FRAGMENT( taito_en_sound )
MCFG_MC68681_SET_EXTERNAL_CLOCKS(XTAL_16MHz/2/8, XTAL_16MHz/2/16, XTAL_16MHz/2/16, XTAL_16MHz/2/8) MCFG_MC68681_SET_EXTERNAL_CLOCKS(XTAL_16MHz/2/8, XTAL_16MHz/2/16, XTAL_16MHz/2/16, XTAL_16MHz/2/8)
MCFG_MC68681_IRQ_CALLBACK(DEVWRITELINE("taito_en", taito_en_device, duart_irq_handler)) MCFG_MC68681_IRQ_CALLBACK(DEVWRITELINE("taito_en", taito_en_device, duart_irq_handler))
MCFG_MB87078_ADD("mb87078", taito_en_mb87078_intf) MCFG_DEVICE_ADD("mb87078", MB87078, 0)
MCFG_MB87078_GAIN_CHANGED_CB(DEVWRITE8("taito_en", taito_en_device, mb87078_gain_changed))
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
MCFG_SOUND_ADD("ensoniq", ES5505, XTAL_30_4761MHz / 2) MCFG_SOUND_ADD("ensoniq", ES5505, XTAL_30_4761MHz / 2)

View File

@ -19,10 +19,11 @@ public:
DECLARE_WRITE16_MEMBER( es5510_dsp_w ); DECLARE_WRITE16_MEMBER( es5510_dsp_w );
DECLARE_WRITE_LINE_MEMBER(duart_irq_handler); DECLARE_WRITE_LINE_MEMBER(duart_irq_handler);
DECLARE_WRITE8_MEMBER(mb87078_gain_changed);
protected: protected:
// device-level overrides // device-level overrides
virtual void device_config_complete();
virtual void device_start(); virtual void device_start();
virtual void device_reset(); virtual void device_reset();

View File

@ -1893,26 +1893,19 @@ static const ay8910_interface ay8910_config =
Both ym2610 and ym2610b generate 3 (PSG like) + 2 (fm left,right) channels. Both ym2610 and ym2610b generate 3 (PSG like) + 2 (fm left,right) channels.
I use mixer_set_volume() to emulate the effect. I use mixer_set_volume() to emulate the effect.
*/ */
static void mb87078_gain_changed( running_machine &machine, int channel, int percent ) WRITE8_MEMBER(taitob_state::mb87078_gain_changed)
{ {
taitob_state *state = machine.driver_data<taitob_state>(); if (offset == 1)
if (channel == 1)
{ {
device_sound_interface *sound; device_sound_interface *sound;
state->m_ym->interface(sound); m_ym->interface(sound);
sound->set_output_gain(0, percent / 100.0); sound->set_output_gain(0, data / 100.0);
sound->set_output_gain(1, percent / 100.0); sound->set_output_gain(1, data / 100.0);
sound->set_output_gain(2, percent / 100.0); sound->set_output_gain(2, data / 100.0);
//popmessage("MB87078 gain ch#%i percent=%i", channel, percent); //popmessage("MB87078 gain ch#%i percent=%i", offset, data);
} }
} }
static const mb87078_interface taitob_mb87078_intf =
{
mb87078_gain_changed /*callback function for gain change*/
};
static const tc0220ioc_interface taitob_io_intf = static const tc0220ioc_interface taitob_io_intf =
{ {
DEVCB_INPUT_PORT("DSWA"), DEVCB_INPUT_PORT("DSWB"), DEVCB_INPUT_PORT("DSWA"), DEVCB_INPUT_PORT("DSWB"),
@ -2354,7 +2347,8 @@ static MACHINE_CONFIG_START( pbobble, taitob_state )
MCFG_TC0640FIO_ADD("tc0640fio", pbobble_io_intf) MCFG_TC0640FIO_ADD("tc0640fio", pbobble_io_intf)
MCFG_MB87078_ADD("mb87078", taitob_mb87078_intf) MCFG_DEVICE_ADD("mb87078", MB87078, 0)
MCFG_MB87078_GAIN_CHANGED_CB(WRITE8(taitob_state, mb87078_gain_changed))
/* video hardware */ /* video hardware */
MCFG_SCREEN_ADD("screen", RASTER) MCFG_SCREEN_ADD("screen", RASTER)
@ -2405,7 +2399,8 @@ static MACHINE_CONFIG_START( spacedx, taitob_state )
MCFG_TC0640FIO_ADD("tc0640fio", pbobble_io_intf) MCFG_TC0640FIO_ADD("tc0640fio", pbobble_io_intf)
MCFG_MB87078_ADD("mb87078", taitob_mb87078_intf) MCFG_DEVICE_ADD("mb87078", MB87078, 0)
MCFG_MB87078_GAIN_CHANGED_CB(WRITE8(taitob_state, mb87078_gain_changed))
/* video hardware */ /* video hardware */
MCFG_SCREEN_ADD("screen", RASTER) MCFG_SCREEN_ADD("screen", RASTER)
@ -2503,7 +2498,8 @@ static MACHINE_CONFIG_START( qzshowby, taitob_state )
MCFG_TC0640FIO_ADD("tc0640fio", pbobble_io_intf) MCFG_TC0640FIO_ADD("tc0640fio", pbobble_io_intf)
MCFG_MB87078_ADD("mb87078", taitob_mb87078_intf) MCFG_DEVICE_ADD("mb87078", MB87078, 0)
MCFG_MB87078_GAIN_CHANGED_CB(WRITE8(taitob_state, mb87078_gain_changed))
/* video hardware */ /* video hardware */
MCFG_SCREEN_ADD("screen", RASTER) MCFG_SCREEN_ADD("screen", RASTER)

View File

@ -95,6 +95,7 @@ public:
DECLARE_WRITE16_MEMBER(realpunc_video_ctrl_w); DECLARE_WRITE16_MEMBER(realpunc_video_ctrl_w);
DECLARE_READ16_MEMBER(tc0180vcu_framebuffer_word_r); DECLARE_READ16_MEMBER(tc0180vcu_framebuffer_word_r);
DECLARE_WRITE16_MEMBER(tc0180vcu_framebuffer_word_w); DECLARE_WRITE16_MEMBER(tc0180vcu_framebuffer_word_w);
DECLARE_WRITE8_MEMBER(mb87078_gain_changed);
DECLARE_INPUT_CHANGED_MEMBER(realpunc_sensor); DECLARE_INPUT_CHANGED_MEMBER(realpunc_sensor);
DECLARE_DRIVER_INIT(taito_b); DECLARE_DRIVER_INIT(taito_b);
virtual void machine_start(); virtual void machine_start();