z88cart_slot_device: converted to devcb2 (nw)

This commit is contained in:
Ivan Vangelista 2014-04-15 15:16:38 +00:00
parent 8f416aa020
commit e88c33c2c7
3 changed files with 21 additions and 41 deletions

View File

@ -59,7 +59,8 @@ device_z88cart_interface::~device_z88cart_interface()
z88cart_slot_device::z88cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, Z88CART_SLOT, "Z88 Cartridge Slot", tag, owner, clock, "z88cart_slot", __FILE__),
device_image_interface(mconfig, *this),
device_slot_interface(mconfig, *this)
device_slot_interface(mconfig, *this),
m_out_flp_cb(*this)
{
}
@ -80,7 +81,7 @@ void z88cart_slot_device::device_start()
m_cart = dynamic_cast<device_z88cart_interface *>(get_card_device());
// resolve callbacks
m_out_flp_func.resolve(m_out_flp_cb, *this);
m_out_flp_cb.resolve_safe();
m_flp_timer = timer_alloc(TIMER_FLP_CLEAR);
m_flp_timer->reset();
@ -94,19 +95,6 @@ void z88cart_slot_device::device_start()
void z88cart_slot_device::device_config_complete()
{
// inherit a copy of the static data
const z88cart_interface *intf = reinterpret_cast<const z88cart_interface *>(static_config());
if (intf != NULL)
{
*static_cast<z88cart_interface *>(this) = *intf;
}
// or initialize to defaults if none provided
else
{
memset(&m_out_flp_cb, 0, sizeof(m_out_flp_cb));
}
// set brief and instance name
update_names();
}
@ -121,7 +109,7 @@ void z88cart_slot_device::device_timer(emu_timer &timer, device_timer_id id, int
if (id == TIMER_FLP_CLEAR)
{
// close the flap
m_out_flp_func(CLEAR_LINE);
m_out_flp_cb(CLEAR_LINE);
}
}
@ -154,7 +142,7 @@ bool z88cart_slot_device::call_load()
}
// open the flap
m_out_flp_func(ASSERT_LINE);
m_out_flp_cb(ASSERT_LINE);
// setup the timer for close the flap
m_flp_timer->adjust(CLOSE_FLAP_TIME);
@ -173,7 +161,7 @@ void z88cart_slot_device::call_unload()
memset(m_cart->get_cart_base(), 0xff, m_cart->get_cart_size());
// open the flap
m_out_flp_func(ASSERT_LINE);
m_out_flp_cb(ASSERT_LINE);
// setup the timer for close the flap
m_flp_timer->adjust(CLOSE_FLAP_TIME);

View File

@ -58,14 +58,6 @@
TYPE DEFINITIONS
***************************************************************************/
// ======================> z88cart_interface
struct z88cart_interface
{
devcb_write_line m_out_flp_cb;
};
// ======================> device_z88cart_interface
class device_z88cart_interface : public device_slot_card_interface
@ -86,7 +78,6 @@ public:
// ======================> z88cart_slot_device
class z88cart_slot_device : public device_t,
public z88cart_interface,
public device_image_interface,
public device_slot_interface
{
@ -94,6 +85,8 @@ public:
// construction/destruction
z88cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
virtual ~z88cart_slot_device();
template<class _Object> static devcb2_base &set_out_flp_callback(device_t &device, _Object object) { return downcast<z88cart_slot_device &>(device).m_out_flp_cb.set_callback(object); }
// device-level overrides
virtual void device_start();
@ -125,7 +118,7 @@ public:
private:
static const device_timer_id TIMER_FLP_CLEAR = 0;
devcb_resolved_write_line m_out_flp_func;
devcb2_write_line m_out_flp_cb;
device_z88cart_interface* m_cart;
emu_timer * m_flp_timer;
};
@ -139,9 +132,7 @@ extern const device_type Z88CART_SLOT;
DEVICE CONFIGURATION MACROS
***************************************************************************/
#define MCFG_Z88_CARTRIDGE_ADD(_tag,_config,_slot_intf,_def_slot) \
MCFG_DEVICE_ADD(_tag, Z88CART_SLOT, 0) \
MCFG_DEVICE_CONFIG(_config) \
MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
#define MCFG_Z88CART_SLOT_OUT_FLP_CB(_devcb) \
devcb = &z88cart_slot_device::set_out_flp_callback(*device, DEVCB2_##_devcb);
#endif /* __Z88CART_H__ */

View File

@ -605,11 +605,6 @@ READ8_MEMBER(z88_state::kb_r)
return data;
}
static const z88cart_interface z88_cart_interface =
{
DEVCB_DEVICE_LINE_MEMBER("blink", upd65031_device, flp_w)
};
static SLOT_INTERFACE_START(z88_cart)
SLOT_INTERFACE("32krom", Z88_32K_ROM) // 32KB ROM cart
SLOT_INTERFACE("128krom", Z88_128K_ROM) // 128KB ROM cart
@ -660,9 +655,15 @@ static MACHINE_CONFIG_START( z88, z88_state )
MCFG_RAM_EXTRA_OPTIONS("32K,64K,256K,512k")
// cartridges
MCFG_Z88_CARTRIDGE_ADD("slot1", z88_cart_interface, z88_cart, NULL)
MCFG_Z88_CARTRIDGE_ADD("slot2", z88_cart_interface, z88_cart, NULL)
MCFG_Z88_CARTRIDGE_ADD("slot3", z88_cart_interface, z88_cart, NULL)
MCFG_DEVICE_ADD("slot1", Z88CART_SLOT, 0)
MCFG_DEVICE_SLOT_INTERFACE(z88_cart, NULL, false)
MCFG_Z88CART_SLOT_OUT_FLP_CB(DEVWRITELINE("blink", upd65031_device, flp_w))
MCFG_DEVICE_ADD("slot2", Z88CART_SLOT, 0)
MCFG_DEVICE_SLOT_INTERFACE(z88_cart, NULL, false)
MCFG_Z88CART_SLOT_OUT_FLP_CB(DEVWRITELINE("blink", upd65031_device, flp_w))
MCFG_DEVICE_ADD("slot3", Z88CART_SLOT, 0)
MCFG_DEVICE_SLOT_INTERFACE(z88_cart, NULL, false)
MCFG_Z88CART_SLOT_OUT_FLP_CB(DEVWRITELINE("blink", upd65031_device, flp_w))
MACHINE_CONFIG_END