From b7a5efe5b70db8eaebcf0aa46dc9a72a3bcc0f50 Mon Sep 17 00:00:00 2001 From: k2-git Date: Fri, 17 Apr 2015 09:34:52 +0900 Subject: [PATCH] fix kbm3rd keyboard error(nw) --- src/mame/machine/midikbd.c | 121 ++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 57 deletions(-) diff --git a/src/mame/machine/midikbd.c b/src/mame/machine/midikbd.c index 070511fc2a8..2ceb68ae23f 100644 --- a/src/mame/machine/midikbd.c +++ b/src/mame/machine/midikbd.c @@ -12,66 +12,73 @@ midi_keyboard_device::midi_keyboard_device(const machine_config &mconfig, const void midi_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { - const int keyboard_notes[24] = + if(id) { - 0x3c, // C1 - 0x3d, // C1# - 0x3e, // D1 - 0x3f, // D1# - 0x40, // E1 - 0x41, // F1 - 0x42, // F1# - 0x43, // G1 - 0x44, // G1# - 0x45, // A1 - 0x46, // A1# - 0x47, // B1 - 0x48, // C2 - 0x49, // C2# - 0x4a, // D2 - 0x4b, // D2# - 0x4c, // E2 - 0x4d, // F2 - 0x4e, // F2# - 0x4f, // G2 - 0x50, // G2# - 0x51, // A2 - 0x52, // A2# - 0x53, // B2 - }; - - int i; - - UINT32 kbstate = m_keyboard->read(); - if(kbstate != m_keyboard_state) - { - for (i=0; i < 24; i++) - { - int kbnote = keyboard_notes[i]; - - if ((m_keyboard_state & (1 << i)) != 0 && (kbstate & (1 << i)) == 0) - { - // key was on, now off -> send Note Off message - push_tx(0x80); - push_tx(kbnote); - push_tx(0x7f); - } - else if ((m_keyboard_state & (1 << i)) == 0 && (kbstate & (1 << i)) != 0) - { - // key was off, now on -> send Note On message - push_tx(0x90); - push_tx(kbnote); - push_tx(0x7f); - } - } + device_serial_interface::device_timer(timer, id, param, ptr); } else - // no messages, send Active Sense message instead - push_tx(0xfe); - - m_keyboard_state = kbstate; - if(is_transmit_register_empty()) - tra_complete(); + { + const int keyboard_notes[24] = + { + 0x3c, // C1 + 0x3d, // C1# + 0x3e, // D1 + 0x3f, // D1# + 0x40, // E1 + 0x41, // F1 + 0x42, // F1# + 0x43, // G1 + 0x44, // G1# + 0x45, // A1 + 0x46, // A1# + 0x47, // B1 + 0x48, // C2 + 0x49, // C2# + 0x4a, // D2 + 0x4b, // D2# + 0x4c, // E2 + 0x4d, // F2 + 0x4e, // F2# + 0x4f, // G2 + 0x50, // G2# + 0x51, // A2 + 0x52, // A2# + 0x53, // B2 + }; + + int i; + + UINT32 kbstate = m_keyboard->read(); + if(kbstate != m_keyboard_state) + { + for (i=0; i < 24; i++) + { + int kbnote = keyboard_notes[i]; + + if ((m_keyboard_state & (1 << i)) != 0 && (kbstate & (1 << i)) == 0) + { + // key was on, now off -> send Note Off message + push_tx(0x80); + push_tx(kbnote); + push_tx(0x7f); + } + else if ((m_keyboard_state & (1 << i)) == 0 && (kbstate & (1 << i)) != 0) + { + // key was off, now on -> send Note On message + push_tx(0x90); + push_tx(kbnote); + push_tx(0x7f); + } + } + } + else + // no messages, send Active Sense message instead + push_tx(0xfe); + + m_keyboard_state = kbstate; + if(is_transmit_register_empty()) + tra_complete(); + } } void midi_keyboard_device::device_start()