From 489ee80f93144128e977fc371dfb07df809a480a Mon Sep 17 00:00:00 2001 From: smf- Date: Wed, 31 Oct 2012 21:28:07 +0000 Subject: [PATCH] use DEVCB2 for hooking up irq controller to cpu core (nw) --- src/emu/cpu/psx/irq.c | 11 +++++++---- src/emu/cpu/psx/irq.h | 8 ++++++++ src/emu/cpu/psx/psx.c | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/emu/cpu/psx/irq.c b/src/emu/cpu/psx/irq.c index 6bde04640ad..368ff3db86a 100644 --- a/src/emu/cpu/psx/irq.c +++ b/src/emu/cpu/psx/irq.c @@ -27,8 +27,9 @@ INLINE void ATTR_PRINTF(3,4) verboselog( running_machine& machine, int n_level, const device_type PSX_IRQ = &device_creator; -psxirq_device::psxirq_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, PSX_IRQ, "PSX IRQ", tag, owner, clock) +psxirq_device::psxirq_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, PSX_IRQ, "PSX IRQ", tag, owner, clock), + m_irq_handler(*this) { } @@ -47,6 +48,8 @@ void psxirq_device::device_post_load() void psxirq_device::device_start() { + m_irq_handler.resolve_safe(); + save_item( NAME( n_irqdata ) ); save_item( NAME( n_irqmask ) ); } @@ -63,12 +66,12 @@ void psxirq_device::psx_irq_update( void ) if( ( n_irqdata & n_irqmask ) != 0 ) { verboselog( machine(), 2, "psx irq assert\n" ); - machine().device("maincpu")->execute().set_input_line(PSXCPU_IRQ0, ASSERT_LINE ); + m_irq_handler( ASSERT_LINE ); } else { verboselog( machine(), 2, "psx irq clear\n" ); - machine().device("maincpu")->execute().set_input_line(PSXCPU_IRQ0, CLEAR_LINE ); + m_irq_handler( CLEAR_LINE ); } } diff --git a/src/emu/cpu/psx/irq.h b/src/emu/cpu/psx/irq.h index 3381ea55f3d..3f8c8b67c40 100644 --- a/src/emu/cpu/psx/irq.h +++ b/src/emu/cpu/psx/irq.h @@ -14,11 +14,17 @@ extern const device_type PSX_IRQ; +#define MCFG_PSX_IRQ_HANDLER(_devcb) \ + devcb = &psxirq_device::set_irq_handler(*device, DEVCB2_##_devcb); + class psxirq_device : public device_t { public: psxirq_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + // static configuration helpers + template static devcb2_base &set_irq_handler(device_t &device, _Object object) { return downcast(device).m_irq_handler.set_callback(object); } + DECLARE_READ32_MEMBER( read ); DECLARE_WRITE32_MEMBER( write ); @@ -45,6 +51,8 @@ private: UINT32 n_irqdata; UINT32 n_irqmask; + + devcb2_write_line m_irq_handler; }; #endif diff --git a/src/emu/cpu/psx/psx.c b/src/emu/cpu/psx/psx.c index d47802f7af5..5d0031b2e9a 100644 --- a/src/emu/cpu/psx/psx.c +++ b/src/emu/cpu/psx/psx.c @@ -3189,6 +3189,8 @@ WRITE32_HANDLER( psxcpu_device::gpu_w ) static MACHINE_CONFIG_FRAGMENT( psx ) MCFG_DEVICE_ADD("irq", PSX_IRQ, 0) + MCFG_PSX_IRQ_HANDLER(INPUTLINE(DEVICE_SELF, PSXCPU_IRQ0)) + MCFG_DEVICE_ADD("dma", PSX_DMA, 0) MCFG_PSX_DMA_IRQ_HANDLER(DEVWRITELINE("irq", psxirq_device, intin3))