From d173cae03ca47654976b005e2fbeb3097309ebf7 Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Thu, 24 Apr 2014 18:28:20 +0000 Subject: [PATCH] tmsprom_device: converted to devcb2 (nw) --- src/emu/sound/tms5110.c | 52 +++++++++++------------- src/emu/sound/tms5110.h | 83 ++++++++++++++++++++++++++++----------- src/mame/audio/scramble.c | 30 ++++++-------- src/mame/drivers/bagman.c | 31 ++++++--------- 4 files changed, 108 insertions(+), 88 deletions(-) diff --git a/src/emu/sound/tms5110.c b/src/emu/sound/tms5110.c index 564b81c9a96..986336a8071 100644 --- a/src/emu/sound/tms5110.c +++ b/src/emu/sound/tms5110.c @@ -1160,7 +1160,7 @@ void tmsprom_device::register_for_save_states() void tmsprom_device::update_prom_cnt() { UINT8 prev_val = m_prom[m_prom_cnt] | 0x0200; - if (m_enable && (prev_val & (1<stop_bit))) + if (m_enable && (prev_val & (1<reset_bit)) + if (ctrl & (1 << m_reset_bit)) m_address = 0; - m_ctl_func(0, BITSWAP8(ctrl,0,0,0,0,m_intf->ctl8_bit, - m_intf->ctl4_bit,m_intf->ctl2_bit,m_intf->ctl1_bit)); + m_ctl_cb((offs_t)0, BITSWAP8(ctrl,0,0,0,0,m_ctl8_bit, + m_ctl4_bit,m_ctl2_bit,m_ctl1_bit)); - m_pdc_func((ctrl >> m_intf->pdc_bit) & 0x01); + m_pdc_cb((ctrl >> m_pdc_bit) & 0x01); } //------------------------------------------------- @@ -1199,22 +1199,17 @@ void tmsprom_device::device_timer(emu_timer &timer, device_timer_id id, int para void tmsprom_device::device_start() { - m_intf = (const tmsprom_interface *) static_config(); - assert_always(m_intf != NULL, "Error creating TMSPROM chip: No configuration"); - /* resolve lines */ - m_pdc_func.resolve(m_intf->pdc_func, *this); - m_ctl_func.resolve(m_intf->ctl_func, *this); + m_pdc_cb.resolve_safe(); + m_ctl_cb.resolve_safe(); m_rom = *region(); assert_always(m_rom != NULL, "Error creating TMSPROM chip: No rom region found"); - m_prom = machine().root_device().memregion(m_intf->prom_region)->base(); - assert_always(m_rom != NULL, "Error creating TMSPROM chip: No prom region found"); - - m_clock = clock(); + m_prom = machine().root_device().memregion(m_prom_region)->base(); + assert_always(m_prom != NULL, "Error creating TMSPROM chip: No prom region found"); m_romclk_timer = timer_alloc(0); - m_romclk_timer->adjust(attotime::zero, 0, attotime::from_hz(m_clock)); + m_romclk_timer->adjust(attotime::zero, 0, attotime::from_hz(clock())); m_bit = 0; m_base_address = 0; @@ -1232,7 +1227,7 @@ WRITE_LINE_MEMBER( tmsprom_device::m0_w ) if (m_m0 && !state) { m_address += 1; - m_address &= (m_intf->rom_size-1); + m_address &= (m_rom_size-1); } m_m0 = state; } @@ -1246,7 +1241,7 @@ READ_LINE_MEMBER( tmsprom_device::data_r ) WRITE8_MEMBER( tmsprom_device::rom_csq_w ) { if (!data) - m_base_address = offset * m_intf->rom_size; + m_base_address = offset * m_rom_size; } WRITE8_MEMBER( tmsprom_device::bit_w ) @@ -1357,16 +1352,17 @@ m58817_device::m58817_device(const machine_config &mconfig, const char *tag, dev const device_type TMSPROM = &device_creator; tmsprom_device::tmsprom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, TMSPROM, "TMSPROM", tag, owner, clock, "tmsprom", __FILE__) -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void tmsprom_device::device_config_complete() + : device_t(mconfig, TMSPROM, "TMSPROM", tag, owner, clock, "tmsprom", __FILE__), + m_prom_region(""), + m_rom_size(0), + m_pdc_bit(0), + m_ctl1_bit(0), + m_ctl2_bit(0), + m_ctl4_bit(0), + m_ctl8_bit(0), + m_reset_bit(0), + m_stop_bit(0), + m_pdc_cb(*this), + m_ctl_cb(*this) { } diff --git a/src/emu/sound/tms5110.h b/src/emu/sound/tms5110.h index 86739f48ff1..3acaf27754f 100644 --- a/src/emu/sound/tms5110.h +++ b/src/emu/sound/tms5110.h @@ -243,38 +243,33 @@ extern const device_type M58817; /* PROM controlled TMS5110 interface */ -struct tmsprom_interface -{ - const char *prom_region; /* prom memory region - sound region is automatically assigned */ - UINT32 rom_size; /* individual rom_size */ - UINT8 pdc_bit; /* bit # of pdc line */ - /* virtual bit 8: constant 0, virtual bit 9:constant 1 */ - UINT8 ctl1_bit; /* bit # of ctl1 line */ - UINT8 ctl2_bit; /* bit # of ctl2 line */ - UINT8 ctl4_bit; /* bit # of ctl4 line */ - UINT8 ctl8_bit; /* bit # of ctl8 line */ - UINT8 reset_bit; /* bit # of rom reset */ - UINT8 stop_bit; /* bit # of stop */ - devcb_write_line pdc_func; /* tms pdc func */ - devcb_write8 ctl_func; /* tms ctl func */ -}; - class tmsprom_device : public device_t { public: tmsprom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - WRITE_LINE_MEMBER( m0_w ); - READ_LINE_MEMBER( data_r ); + static void set_region(device_t &device, const char *region) { downcast(device).m_prom_region = region; } + static void set_rom_size(device_t &device, UINT32 rom_size) { downcast(device).m_rom_size = rom_size; } + static void set_pdc_bit(device_t &device, UINT8 pdc_bit) { downcast(device).m_pdc_bit = pdc_bit; } + static void set_ctl1_bit(device_t &device, UINT8 ctl1_bit) { downcast(device).m_ctl1_bit = ctl1_bit; } + static void set_ctl2_bit(device_t &device, UINT8 ctl2_bit) { downcast(device).m_ctl2_bit = ctl2_bit; } + static void set_ctl4_bit(device_t &device, UINT8 ctl4_bit) { downcast(device).m_ctl4_bit = ctl4_bit; } + static void set_ctl8_bit(device_t &device, UINT8 ctl8_bit) { downcast(device).m_ctl8_bit = ctl8_bit; } + static void set_reset_bit(device_t &device, UINT8 reset_bit) { downcast(device).m_reset_bit = reset_bit; } + static void set_stop_bit(device_t &device, UINT8 stop_bit) { downcast(device).m_stop_bit = stop_bit; } + template static devcb2_base &set_pdc_callback(device_t &device, _Object object) { return downcast(device).m_pdc_cb.set_callback(object); } + template static devcb2_base &set_ctl_callback(device_t &device, _Object object) { return downcast(device).m_ctl_cb.set_callback(object); } + + DECLARE_WRITE_LINE_MEMBER( m0_w ); + DECLARE_READ_LINE_MEMBER( data_r ); /* offset is rom # */ DECLARE_WRITE8_MEMBER( rom_csq_w ); DECLARE_WRITE8_MEMBER( bit_w ); - WRITE_LINE_MEMBER( enable_w ); + DECLARE_WRITE_LINE_MEMBER( enable_w ); protected: // device-level overrides - virtual void device_config_complete(); virtual void device_start(); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); @@ -294,17 +289,57 @@ private: int m_prom_cnt; - devcb_resolved_write_line m_pdc_func; /* tms pdc func */ - devcb_resolved_write8 m_ctl_func; /* tms ctl func */ + const char *m_prom_region; /* prom memory region - sound region is automatically assigned */ + UINT32 m_rom_size; /* individual rom_size */ + UINT8 m_pdc_bit; /* bit # of pdc line */ + /* virtual bit 8: constant 0, virtual bit 9:constant 1 */ + UINT8 m_ctl1_bit; /* bit # of ctl1 line */ + UINT8 m_ctl2_bit; /* bit # of ctl2 line */ + UINT8 m_ctl4_bit; /* bit # of ctl4 line */ + UINT8 m_ctl8_bit; /* bit # of ctl8 line */ + UINT8 m_reset_bit; /* bit # of rom reset */ + UINT8 m_stop_bit; /* bit # of stop */ + devcb2_write_line m_pdc_cb; /* tms pdc func */ + devcb2_write8 m_ctl_cb; /* tms ctl func */ - int m_clock; emu_timer *m_romclk_timer; - const tmsprom_interface *m_intf; const UINT8 *m_rom; const UINT8 *m_prom; }; extern const device_type TMSPROM; +#define MCFG_TMSPROM_REGION(_region) \ + tmsprom_device::set_region(*device, _region); + +#define MCFG_TMSPROM_ROM_SIZE(_size) \ + tmsprom_device::set_rom_size(*device, _size); + +#define MCFG_TMSPROM_PDC_BIT(_bit) \ + tmsprom_device::set_pdc_bit(*device, _bit); + +#define MCFG_TMSPROM_CTL1_BIT(_bit) \ + tmsprom_device::set_ctl1_bit(*device, _bit); + +#define MCFG_TMSPROM_CTL2_BIT(_bit) \ + tmsprom_device::set_ctl2_bit(*device, _bit); + +#define MCFG_TMSPROM_CTL4_BIT(_bit) \ + tmsprom_device::set_ctl4_bit(*device, _bit); + +#define MCFG_TMSPROM_CTL8_BIT(_bit) \ + tmsprom_device::set_ctl8_bit(*device, _bit); + +#define MCFG_TMSPROM_RESET_BIT(_bit) \ + tmsprom_device::set_reset_bit(*device, _bit); + +#define MCFG_TMSPROM_STOP_BIT(_bit) \ + tmsprom_device::set_stop_bit(*device, _bit); + +#define MCFG_TMSPROM_PDC_CB(_devcb) \ + devcb = &tmsprom_device::set_pdc_callback(*device, DEVCB2_##_devcb); + +#define MCFG_TMSPROM_CTL_CB(_devcb) \ + devcb = &tmsprom_device::set_ctl_callback(*device, DEVCB2_##_devcb); #endif /* __TMS5110_H__ */ diff --git a/src/mame/audio/scramble.c b/src/mame/audio/scramble.c index 73624268cc2..cadf9892bd4 100644 --- a/src/mame/audio/scramble.c +++ b/src/mame/audio/scramble.c @@ -307,23 +307,6 @@ static ADDRESS_MAP_START( ad2083_sound_io_map, AS_IO, 8, scramble_state ) AM_RANGE(0x80, 0x80) AM_DEVWRITE("ay2", ay8910_device, address_w) ADDRESS_MAP_END -static const tmsprom_interface prom_intf = -{ - "5110ctrl", /* prom memory region - sound region is automatically assigned */ - 0x1000, /* individual rom_size */ - 1, /* bit # of pdc line */ - /* virtual bit 8: constant 0, virtual bit 9:constant 1 */ - 8, /* bit # of ctl1 line */ - 2, /* bit # of ctl2 line */ - 8, /* bit # of ctl4 line */ - 2, /* bit # of ctl8 line */ - 6, /* bit # of rom reset */ - 7, /* bit # of stop */ - DEVCB_DEVICE_LINE_MEMBER("tms", tms5110_device, pdc_w), /* tms pdc func */ - DEVCB_DEVICE_MEMBER("tms", tms5110_device, ctl_w) /* tms ctl func */ -}; - - MACHINE_CONFIG_FRAGMENT( ad2083_audio ) MCFG_CPU_ADD("audiocpu", Z80, 14318000/8) /* 1.78975 MHz */ @@ -332,7 +315,18 @@ MACHINE_CONFIG_FRAGMENT( ad2083_audio ) MCFG_CPU_IRQ_ACKNOWLEDGE_DRIVER(scramble_state,scramble_sh_irq_callback) MCFG_DEVICE_ADD("tmsprom", TMSPROM, AD2083_TMS5110_CLOCK / 2) /* rom clock */ - MCFG_DEVICE_CONFIG(prom_intf) + MCFG_TMSPROM_REGION("5110ctrl") /* prom memory region - sound region is automatically assigned */ + MCFG_TMSPROM_ROM_SIZE(0x1000) /* individual rom_size */ + MCFG_TMSPROM_PDC_BIT(1) /* bit # of pdc line */ + /* virtual bit 8: constant 0, virtual bit 9:constant 1 */ + MCFG_TMSPROM_CTL1_BIT(8) /* bit # of ctl1 line */ + MCFG_TMSPROM_CTL2_BIT(2) /* bit # of ctl2 line */ + MCFG_TMSPROM_CTL4_BIT(8) /* bit # of ctl4 line */ + MCFG_TMSPROM_CTL8_BIT(2) /* bit # of ctl8 line */ + MCFG_TMSPROM_RESET_BIT(6) /* bit # of rom reset */ + MCFG_TMSPROM_STOP_BIT(7) /* bit # of stop */ + MCFG_TMSPROM_PDC_CB(DEVWRITELINE("tms", tms5110_device, pdc_w)) /* tms pdc func */ + MCFG_TMSPROM_CTL_CB(DEVWRITE8("tms", tms5110_device, ctl_w)) /* tms ctl func */ MCFG_SPEAKER_STANDARD_MONO("mono") MCFG_SOUND_ADD("ay1", AY8910, 14318000/8) diff --git a/src/mame/drivers/bagman.c b/src/mame/drivers/bagman.c index 1b1f80937bc..c829877036e 100644 --- a/src/mame/drivers/bagman.c +++ b/src/mame/drivers/bagman.c @@ -432,22 +432,6 @@ static const ay8910_interface ay8910_interface_2 = DEVCB_NULL }; -static const tmsprom_interface prom_intf = -{ - "5110ctrl", /* prom memory region - sound region is automatically assigned */ - 0x1000, /* individual rom_size */ - 1, /* bit # of pdc line */ - /* virtual bit 8: constant 0, virtual bit 9:constant 1 */ - 8, /* bit # of ctl1 line */ - 2, /* bit # of ctl2 line */ - 8, /* bit # of ctl4 line */ - 2, /* bit # of ctl8 line */ - 6, /* bit # of rom reset */ - 7, /* bit # of stop */ - DEVCB_DEVICE_LINE_MEMBER("tms", tms5110_device, pdc_w), /* tms pdc func */ - DEVCB_DEVICE_MEMBER("tms", tms5110_device, ctl_w) /* tms ctl func */ -}; - INTERRUPT_GEN_MEMBER(bagman_state::vblank_irq) { if(m_irq_mask) @@ -478,8 +462,19 @@ static MACHINE_CONFIG_START( bagman, bagman_state ) MCFG_VIDEO_START_OVERRIDE(bagman_state,bagman) MCFG_DEVICE_ADD("tmsprom", TMSPROM, 640000 / 2) /* rom clock */ - MCFG_DEVICE_CONFIG(prom_intf) - + MCFG_TMSPROM_REGION("5110ctrl") /* prom memory region - sound region is automatically assigned */ + MCFG_TMSPROM_ROM_SIZE(0x1000) /* individual rom_size */ + MCFG_TMSPROM_PDC_BIT(1) /* bit # of pdc line */ + /* virtual bit 8: constant 0, virtual bit 9:constant 1 */ + MCFG_TMSPROM_CTL1_BIT(8) /* bit # of ctl1 line */ + MCFG_TMSPROM_CTL2_BIT(2) /* bit # of ctl2 line */ + MCFG_TMSPROM_CTL4_BIT(8) /* bit # of ctl4 line */ + MCFG_TMSPROM_CTL8_BIT(2) /* bit # of ctl8 line */ + MCFG_TMSPROM_RESET_BIT(6) /* bit # of rom reset */ + MCFG_TMSPROM_STOP_BIT(7) /* bit # of stop */ + MCFG_TMSPROM_PDC_CB(DEVWRITELINE("tms", tms5110_device, pdc_w)) /* tms pdc func */ + MCFG_TMSPROM_CTL_CB(DEVWRITE8("tms", tms5110_device, ctl_w)) /* tms ctl func */ + /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono")