From 68dbd42a24f56640642423f0e57fc9951ea819b9 Mon Sep 17 00:00:00 2001 From: Dirk Best Date: Wed, 4 Aug 2021 13:04:00 +0200 Subject: [PATCH] z8536: Better daisy chain support, fix port assignment when writing data --- src/devices/machine/z8536.cpp | 34 ++++++++++++++++++++++++++++++---- src/devices/machine/z8536.h | 1 - 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/devices/machine/z8536.cpp b/src/devices/machine/z8536.cpp index 5074d82ccf7..fe1a91ff631 100644 --- a/src/devices/machine/z8536.cpp +++ b/src/devices/machine/z8536.cpp @@ -919,6 +919,32 @@ void cio_base_device::device_timer(emu_timer &timer, device_timer_id id, int par int z8536_device::z80daisy_irq_state() { + static const int prio[] = + { + COUNTER_TIMER_3_COMMAND_AND_STATUS, + PORT_A_COMMAND_AND_STATUS, + COUNTER_TIMER_2_COMMAND_AND_STATUS, + PORT_B_COMMAND_AND_STATUS, + COUNTER_TIMER_1_COMMAND_AND_STATUS + }; + + if (m_register[MASTER_INTERRUPT_CONTROL] & MICR_MIE) + { + for (int i = 0; i < 5; i++) + { + if (m_register[prio[i]] & PCS_IUS) + { + // we are currently servicing an interrupt request + return Z80_DAISY_IEO; + } + else if ((m_register[prio[i]] & PCS_IE) && (m_register[prio[i]] & PCS_IP)) + { + // indicate that we have an interrupt request waiting + return Z80_DAISY_INT; + } + } + } + return 0; } @@ -1081,19 +1107,19 @@ void z8536_device::write(offs_t offset, u8 data) { switch (offset & 0x03) { - case PORT_C: + case 0: write_register(PORT_C_DATA, data); break; - case PORT_B: + case 1: write_register(PORT_B_DATA, data); break; - case PORT_A: + case 2: write_register(PORT_A_DATA, data); break; - case CONTROL: + case 3: if (m_state0) { // state 0: write pointer diff --git a/src/devices/machine/z8536.h b/src/devices/machine/z8536.h index 47c6545b670..487d9b771e0 100644 --- a/src/devices/machine/z8536.h +++ b/src/devices/machine/z8536.h @@ -381,7 +381,6 @@ protected: void match_pattern(int port); void external_port_w(int port, int bit, int state); -private: devcb_write_line m_write_irq; devcb_read8 m_read_pa;