From 24091af194fcaaf5d2bb64c874323a5de4af235f Mon Sep 17 00:00:00 2001 From: DavidHaywood <28625134+DavidHaywood@users.noreply.github.com> Date: Mon, 25 Mar 2019 19:35:25 +0000 Subject: irq callbacks (nw) --- src/devices/machine/spg2xx.cpp | 41 +++++++++++++++++++++++++++++++-------- src/devices/machine/spg2xx.h | 6 ++++++ src/devices/machine/spg2xx_io.cpp | 23 ++++++++++++++++------ src/devices/machine/spg2xx_io.h | 14 ++++++++++++- 4 files changed, 69 insertions(+), 15 deletions(-) diff --git a/src/devices/machine/spg2xx.cpp b/src/devices/machine/spg2xx.cpp index 1faad3858ef..e6a881ee67c 100644 --- a/src/devices/machine/spg2xx.cpp +++ b/src/devices/machine/spg2xx.cpp @@ -150,16 +150,36 @@ void spg2xx_device::device_reset() WRITE_LINE_MEMBER(spg2xx_device::audioirq_w) { - if (state == ASSERT_LINE) - { - m_cpu->set_state_unsynced(UNSP_IRQ4_LINE, ASSERT_LINE); - } - else - { - m_cpu->set_state_unsynced(UNSP_IRQ4_LINE, CLEAR_LINE); - } + m_cpu->set_state_unsynced(UNSP_IRQ4_LINE, state); +} + +WRITE_LINE_MEMBER(spg2xx_device::timerirq_w) +{ + m_cpu->set_state_unsynced(UNSP_IRQ2_LINE, state); +} + +WRITE_LINE_MEMBER(spg2xx_device::uartirq_w) +{ + m_cpu->set_state_unsynced(UNSP_IRQ3_LINE, state); } +WRITE_LINE_MEMBER(spg2xx_device::extirq_w) +{ + m_cpu->set_state_unsynced(UNSP_IRQ5_LINE, state); +} + +WRITE_LINE_MEMBER(spg2xx_device::ffreq1_w) +{ + m_cpu->set_state_unsynced(UNSP_IRQ6_LINE, state); +} + +WRITE_LINE_MEMBER(spg2xx_device::ffreq2_w) +{ + m_cpu->set_state_unsynced(UNSP_IRQ7_LINE, state); +} + + + READ16_MEMBER(spg2xx_device::space_r) { address_space &cpuspace = m_cpu->space(AS_PROGRAM); @@ -999,6 +1019,11 @@ void spg2xx_device::configure_spg_io(spg2xx_io_device* io) io->uart_tx().set(FUNC(spg2xx_device::tx_w)); io->chip_select().set(FUNC(spg2xx_device::cs_w)); io->pal_read_callback().set(FUNC(spg2xx_device::get_pal_r)); + io->write_timer_irq_callback().set(FUNC(spg2xx_device::timerirq_w)); + io->write_uart_adc_irq_callback().set(FUNC(spg2xx_device::uartirq_w)); + io->write_external_irq_callback().set(FUNC(spg2xx_device::extirq_w)); + io->write_ffrq_tmr1_irq_callback().set(FUNC(spg2xx_device::ffreq1_w)); + io->write_ffrq_tmr2_irq_callback().set(FUNC(spg2xx_device::ffreq2_w)); } void spg24x_device::device_add_mconfig(machine_config &config) diff --git a/src/devices/machine/spg2xx.h b/src/devices/machine/spg2xx.h index c7b9fb279f2..859620d9f66 100644 --- a/src/devices/machine/spg2xx.h +++ b/src/devices/machine/spg2xx.h @@ -106,6 +106,12 @@ protected: DECLARE_WRITE16_MEMBER(dma_w); DECLARE_WRITE_LINE_MEMBER(audioirq_w); + DECLARE_WRITE_LINE_MEMBER(timerirq_w); + DECLARE_WRITE_LINE_MEMBER(uartirq_w); + DECLARE_WRITE_LINE_MEMBER(extirq_w); + DECLARE_WRITE_LINE_MEMBER(ffreq1_w); + DECLARE_WRITE_LINE_MEMBER(ffreq2_w); + DECLARE_READ16_MEMBER(space_r); inline void check_video_irq(); diff --git a/src/devices/machine/spg2xx_io.cpp b/src/devices/machine/spg2xx_io.cpp index d6a2e360ea9..68e52ce47d7 100644 --- a/src/devices/machine/spg2xx_io.cpp +++ b/src/devices/machine/spg2xx_io.cpp @@ -48,6 +48,11 @@ spg2xx_io_device::spg2xx_io_device(const machine_config &mconfig, device_type ty , m_cpu(*this, finder_base::DUMMY_TAG) , m_screen(*this, finder_base::DUMMY_TAG) , m_pal_read_cb(*this) + , m_timer_irq_cb(*this) + , m_uart_adc_irq_cb(*this) + , m_external_irq_cb(*this) + , m_ffreq_tmr1_irq_cb(*this) + , m_ffreq_tmr2_irq_cb(*this) { } @@ -78,6 +83,12 @@ void spg2xx_io_device::device_start() m_chip_sel.resolve_safe(); m_pal_read_cb.resolve_safe(0); + m_timer_irq_cb.resolve(); + m_uart_adc_irq_cb.resolve(); + m_external_irq_cb.resolve(); + m_ffreq_tmr1_irq_cb.resolve(); + m_ffreq_tmr2_irq_cb.resolve(); + m_tmb1 = timer_alloc(TIMER_TMB1); m_tmb2 = timer_alloc(TIMER_TMB2); m_tmb1->adjust(attotime::never); @@ -1150,31 +1161,31 @@ void spg2xx_io_device::check_irqs(const uint16_t changed) if (changed & 0x0c00) // Timer A, Timer B IRQ { LOGMASKED(LOG_TIMERS, "%ssserting IRQ2 (%04x, %04x)\n", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0c00) ? "A" : "Dea", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0c00), changed); - m_cpu->set_state_unsynced(UNSP_IRQ2_LINE, (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0c00) ? ASSERT_LINE : CLEAR_LINE); + m_timer_irq_cb((IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0c00) ? ASSERT_LINE : CLEAR_LINE); } if (changed & 0x2100) // UART, ADC IRQ { LOGMASKED(LOG_UART, "%ssserting IRQ3 (%04x, %04x)\n", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x2100) ? "A" : "Dea", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x2100), changed); - m_cpu->set_state_unsynced(UNSP_IRQ3_LINE, (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x2100) ? ASSERT_LINE : CLEAR_LINE); + m_uart_adc_irq_cb((IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x2100) ? ASSERT_LINE : CLEAR_LINE); } if (changed & 0x1200) // External IRQ { LOGMASKED(LOG_UART, "%ssserting IRQ5 (%04x, %04x)\n", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x1200) ? "A" : "Dea", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x1200), changed); - m_cpu->set_state_unsynced(UNSP_IRQ5_LINE, (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x1200) ? ASSERT_LINE : CLEAR_LINE); + m_external_irq_cb((IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x1200) ? ASSERT_LINE : CLEAR_LINE); } if (changed & 0x0070) // 1024Hz, 2048Hz, 4096Hz IRQ { - LOGMASKED(LOG_TIMERS, "%ssserting IRQ6 (%04x, %04x)\n", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0070) ? "A" : "Dea", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0070), changed); - m_cpu->set_state_unsynced(UNSP_IRQ6_LINE, (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0070) ? ASSERT_LINE : CLEAR_LINE); + LOGMASKED(LOG_TIMERS, "%ssserting IRQ6 (%04x, %04x)\n", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0070) ? "A" : "Dea", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0070), changed); //m_cpu->set_state_unsynced(UNSP_IRQ6_LINE, (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0070) ? ASSERT_LINE : CLEAR_LINE); + m_ffreq_tmr1_irq_cb((IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x0070) ? ASSERT_LINE : CLEAR_LINE); } if (changed & 0x008b) // TMB1, TMB2, 4Hz, key change IRQ { LOGMASKED(LOG_IRQS, "%ssserting IRQ7 (%04x, %04x)\n", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x008b) ? "A" : "Dea", (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x008b), changed); - m_cpu->set_state_unsynced(UNSP_IRQ7_LINE, (IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x008b) ? ASSERT_LINE : CLEAR_LINE); + m_ffreq_tmr2_irq_cb((IO_IRQ_ENABLE & IO_IRQ_STATUS & 0x008b) ? ASSERT_LINE : CLEAR_LINE); } } diff --git a/src/devices/machine/spg2xx_io.h b/src/devices/machine/spg2xx_io.h index ef2e2c3a4cf..71b165553fc 100644 --- a/src/devices/machine/spg2xx_io.h +++ b/src/devices/machine/spg2xx_io.h @@ -37,7 +37,13 @@ public: virtual DECLARE_READ16_MEMBER(io_r); virtual DECLARE_WRITE16_MEMBER(io_w); - auto pal_read_callback() { return m_pal_read_cb.bind(); } + auto pal_read_callback() { return m_pal_read_cb.bind(); }; + + auto write_timer_irq_callback() { return m_timer_irq_cb.bind(); }; + auto write_uart_adc_irq_callback() { return m_uart_adc_irq_cb.bind(); }; + auto write_external_irq_callback() { return m_external_irq_cb.bind(); }; + auto write_ffrq_tmr1_irq_callback() { return m_ffreq_tmr1_irq_cb.bind(); }; + auto write_ffrq_tmr2_irq_callback() { return m_ffreq_tmr2_irq_cb.bind(); }; protected: spg2xx_io_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, const uint32_t sprite_limit) @@ -129,6 +135,12 @@ protected: required_device m_screen; devcb_read16 m_pal_read_cb; + + devcb_write_line m_timer_irq_cb; + devcb_write_line m_uart_adc_irq_cb; + devcb_write_line m_external_irq_cb; + devcb_write_line m_ffreq_tmr1_irq_cb; + devcb_write_line m_ffreq_tmr2_irq_cb; }; class spg24x_io_device : public spg2xx_io_device -- cgit v1.2.3