diff options
Diffstat (limited to 'src/devices/machine/i8214.cpp')
-rw-r--r-- | src/devices/machine/i8214.cpp | 92 |
1 files changed, 75 insertions, 17 deletions
diff --git a/src/devices/machine/i8214.cpp b/src/devices/machine/i8214.cpp index f496c758453..fa511e32963 100644 --- a/src/devices/machine/i8214.cpp +++ b/src/devices/machine/i8214.cpp @@ -40,7 +40,8 @@ void i8214_device::trigger_interrupt(int level) // set interrupt line m_write_int(ASSERT_LINE); - m_write_int(CLEAR_LINE); + if (!m_int_dis_hack) + m_write_int(CLEAR_LINE); // TODO: wait one clock cycle to clear } @@ -50,25 +51,56 @@ void i8214_device::trigger_interrupt(int level) void i8214_device::check_interrupt() { - if (m_int_dis || !m_etlg || !m_inte) return; + if (m_int_dis) + { + LOG("not checking interrupts because m_int_dis (%02x)\n", m_r); + if (m_int_dis_hack && m_r == 0xff) + { + m_int_dis = 0; + m_write_int(CLEAR_LINE); + } + return; + } + if (!m_etlg) + { + LOG("not checking interrupts because !m_etlg\n"); + return; + } + if (!m_inte) + { + LOG("not checking interrupts because !m_inte\n"); + return; + } + + LOG("checking interrupts: R:%02x, sgs:%d, current:%d\n", m_r, m_sgs, m_current_status); for (int level = 7; level >= 0; level--) { - if (!BIT(m_r, 7 - level)) + if (!BIT(m_r, level)) { if (m_sgs) { if (level > m_current_status) { + LOG("bit %d unset, level %d > current %d, triggering interrupt\n", 7 - level, level, m_current_status); trigger_interrupt(level); + return; } } else { + LOG("bit %d unset, level %d, triggering interrupt\n", 7 - level, level); trigger_interrupt(level); + return; } } } + + if (m_int_dis_hack) + { + m_int_dis = 0; + m_write_int(CLEAR_LINE); + } } @@ -85,6 +117,7 @@ i8214_device::i8214_device(const machine_config &mconfig, const char *tag, devic : device_t(mconfig, I8214, tag, owner, clock) , m_write_int(*this) , m_write_enlg(*this) + , m_int_dis_hack(false) , m_inte(0) , m_int_dis(0) , m_a(0) @@ -102,10 +135,6 @@ i8214_device::i8214_device(const machine_config &mconfig, const char *tag, devic void i8214_device::device_start() { - // resolve callbacks - m_write_int.resolve_safe(); - m_write_enlg.resolve_safe(); - m_int_dis = 0; m_etlg = 1; @@ -128,7 +157,7 @@ uint8_t i8214_device::a_r() { uint8_t a = m_a & 0x07; - LOG("I8214 A: %01x\n", a); + LOG("%s: a_r: %01x\n", machine().describe_context(), a); return a; } @@ -139,13 +168,33 @@ uint8_t i8214_device::a_r() // 8080-compatible interrupt vector //------------------------------------------------- -READ8_MEMBER(i8214_device::vector_r) +uint8_t i8214_device::vector_r() { return 0xc7 | (m_a << 3); } //------------------------------------------------- +// b_sgs_w - +//------------------------------------------------- + +void i8214_device::b_sgs_w(uint8_t data) +{ + m_current_status = data & 0x07; + m_sgs = BIT(data, 3); + + LOG("%s: b_sgs_w: b:%d, sgs:%d\n", machine().describe_context(), m_current_status, m_sgs); + + // enable interrupts + m_int_dis = 0; + + // enable next level group + m_write_enlg(1); + + check_interrupt(); +} + +//------------------------------------------------- // b_w - //------------------------------------------------- @@ -153,7 +202,7 @@ void i8214_device::b_w(uint8_t data) { m_current_status = data & 0x07; - LOG("I8214 B: %01x\n", m_current_status); + LOG("%s: b_w: %d\n", machine().describe_context(), m_current_status); // enable interrupts m_int_dis = 0; @@ -172,7 +221,7 @@ void i8214_device::b_w(uint8_t data) void i8214_device::r_w(int line, int state) { - LOG("I8214 R%d: %d\n", line, state); + LOG("%s: r_w: line %d, state %d\n", machine().describe_context(), line, state); m_r &= ~(1 << line); m_r |= (state << line); @@ -181,13 +230,22 @@ void i8214_device::r_w(int line, int state) } +void i8214_device::r_all_w(uint8_t state) +{ + LOG("%s: r_all_w: state %02x\n", machine().describe_context(), state); + + m_r = state; + + check_interrupt(); +} + //------------------------------------------------- // sgs_w - //------------------------------------------------- -WRITE_LINE_MEMBER( i8214_device::sgs_w ) +void i8214_device::sgs_w(int state) { - LOG("I8214 SGS: %u\n", state); + LOG("%s: sgs_w: %d\n", machine().describe_context(), state); m_sgs = state; @@ -199,9 +257,9 @@ WRITE_LINE_MEMBER( i8214_device::sgs_w ) // etlg_w - //------------------------------------------------- -WRITE_LINE_MEMBER( i8214_device::etlg_w ) +void i8214_device::etlg_w(int state) { - LOG("I8214 ETLG: %u\n", state); + LOG("%s: etlg_w: %d\n", machine().describe_context(), state); m_etlg = state; @@ -213,9 +271,9 @@ WRITE_LINE_MEMBER( i8214_device::etlg_w ) // inte_w - //------------------------------------------------- -WRITE_LINE_MEMBER( i8214_device::inte_w ) +void i8214_device::inte_w(int state) { - LOG("I8214 INTE: %u\n", state); + LOG("%s: inte_w: %d\n", machine().describe_context(), state); m_inte = state; |