diff options
Diffstat (limited to 'src/devices/machine/msm6200.cpp')
-rw-r--r-- | src/devices/machine/msm6200.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/devices/machine/msm6200.cpp b/src/devices/machine/msm6200.cpp index 70e05aa1ddf..ef21d538c1f 100644 --- a/src/devices/machine/msm6200.cpp +++ b/src/devices/machine/msm6200.cpp @@ -21,6 +21,8 @@ msm6200_device::msm6200_device(const machine_config &mconfig, const char *tag, d /**************************************************************************/ void msm6200_device::device_start() { + m_timer = timer_alloc(FUNC(msm6200_device::scan_timer), this); + m_cmd = 0xf; save_item(NAME(m_cmd)); @@ -40,6 +42,18 @@ void msm6200_device::device_reset() } /**************************************************************************/ +TIMER_CALLBACK_MEMBER(msm6200_device::scan_timer) +{ + (++m_row) %= m_keys.size(); + m_key_state = m_keys[m_row].read_safe(0); + if (m_key_state != m_last_state[m_row]) + { + m_irq_cb(1); + m_timer->adjust(attotime::never); + } +} + +/**************************************************************************/ void msm6200_device::write(offs_t offset, u8 data) { // 8-bit multiplexed address/data bus, upper 4 bits are output only @@ -60,30 +74,32 @@ void msm6200_device::write(offs_t offset, u8 data) } } if (m_key_state == m_last_state[m_row]) + { m_irq_cb(0); + m_timer->adjust(attotime::zero, 0, attotime::from_ticks(TIMER_RATE, clock())); + } break; case 1: // read velocity m_key_data = m_velocity.read_safe(0x3f); break; - case 2: // next row? - (++m_row) %= m_keys.size(); + case 2: // TODO: what should this one actually be? // the cz1/ht6000 key MCU code outputs the result to port 1 for debugging m_key_data = m_row; break; - case 7: // capture current row? - m_key_state = m_keys[m_row].read_safe(0); - if (m_key_state != m_last_state[m_row]) - m_irq_cb(1); + case 7: // ? + // cz1/ht6000 writes this constantly, cps2000 much less frequently break; - case 8: // init all rows + case 8: // init all rows, start scanning for (int i = 0; i < m_keys.size(); i++) m_last_state[i] = m_keys[i].read_safe(0); + m_irq_cb(0); + m_timer->adjust(attotime::zero, 0, attotime::from_ticks(TIMER_RATE, clock())); break; default: |