z80daisy_generic: Add irq output callback

This commit is contained in:
Dirk Best 2017-11-20 01:23:40 +01:00
parent b4c60415ae
commit 4a211c8443
2 changed files with 26 additions and 0 deletions

View File

@ -28,6 +28,7 @@ DEFINE_DEVICE_TYPE(Z80DAISY_GENERIC, z80daisy_generic_device, "z80daisy_generic"
z80daisy_generic_device::z80daisy_generic_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, Z80DAISY_GENERIC, tag, owner, clock),
device_z80daisy_interface(mconfig, *this),
m_int_handler(*this),
m_int(0), m_mask(0), m_vector(0xff)
{
}
@ -48,6 +49,9 @@ void z80daisy_generic_device::static_set_vector(device_t &device, uint8_t vector
void z80daisy_generic_device::device_start()
{
// resolve callbacks
m_int_handler.resolve_safe();
// register for save states
save_item(NAME(m_int));
save_item(NAME(m_mask));
@ -86,6 +90,15 @@ void z80daisy_generic_device::z80daisy_irq_reti()
{
}
//-------------------------------------------------
// update_interrupt() - check interrupt status
//-------------------------------------------------
void z80daisy_generic_device::update_interrupt()
{
m_int_handler(m_int & ~m_mask ? ASSERT_LINE : CLEAR_LINE);
}
//**************************************************************************
// INTERFACE
@ -94,9 +107,11 @@ void z80daisy_generic_device::z80daisy_irq_reti()
WRITE_LINE_MEMBER( z80daisy_generic_device::int_w )
{
m_int = state;
update_interrupt();
}
WRITE_LINE_MEMBER( z80daisy_generic_device::mask_w )
{
m_mask = state;
update_interrupt();
}

View File

@ -22,6 +22,9 @@
MCFG_DEVICE_ADD(_tag, Z80DAISY_GENERIC, 0) \
z80daisy_generic_device::static_set_vector(*device, _vector); \
#define MCFG_Z80DAISY_GENERIC_INT_CB(_devcb) \
devcb = &z80daisy_generic_device::set_int_handler(*device, DEVCB_##_devcb);
//**************************************************************************
// TYPE DEFINITIONS
@ -33,6 +36,10 @@ public:
// construction/destruction
z80daisy_generic_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// callbacks
template <class Object> static devcb_base &set_int_handler(device_t &device, Object &&cb)
{ return downcast<z80daisy_generic_device &>(device).m_int_handler.set_callback(std::forward<Object>(cb)); }
// configuration
static void static_set_vector(device_t &device, uint8_t vector);
@ -49,6 +56,10 @@ protected:
virtual void z80daisy_irq_reti() override;
private:
void update_interrupt();
devcb_write_line m_int_handler;
int m_int;
int m_mask;
int m_vector;