mac128: fix multiple keyboard regressions since 0.180 (MT#6481) [R. Belmont]

This commit is contained in:
arbee 2017-04-22 21:35:42 -04:00
parent b80d130133
commit f5da128a94

View File

@ -202,6 +202,8 @@ public:
/* keycode buffer (used for keypad/arrow key transition) */ /* keycode buffer (used for keypad/arrow key transition) */
int m_keycode_buf[2]; int m_keycode_buf[2];
int m_keycode_buf_index; int m_keycode_buf_index;
int m_cb2_in;
#endif #endif
/* keyboard matrix to detect transition - macadb needs to stop relying on this */ /* keyboard matrix to detect transition - macadb needs to stop relying on this */
@ -380,6 +382,24 @@ void mac128_state::set_via_interrupt(int value)
void mac128_state::vblank_irq() void mac128_state::vblank_irq()
{ {
#ifndef MAC_USE_EMULATED_KBD
/* handle keyboard */
if (m_kbd_comm == true && m_kbd_receive == false)
{
int keycode = scan_keyboard();
if (keycode != 0x7B)
{
/* if key pressed, send the code */
logerror("keyboard enquiry successful, keycode %X\n", keycode);
m_inquiry_timeout->reset();
kbd_shift_out(keycode);
}
}
#endif
m_ca1_data ^= 1; m_ca1_data ^= 1;
m_via->write_ca1(m_ca1_data); m_via->write_ca1(m_ca1_data);
@ -940,14 +960,29 @@ TIMER_CALLBACK_MEMBER(mac128_state::kbd_clock)
if (m_kbd_comm == TRUE) if (m_kbd_comm == TRUE)
{ {
for (i=0; i<8; i++) for (i=0; i<9; i++)
{ {
/* Put data on CB2 if we are sending*/ /* Put data on CB2 if we are sending*/
if (m_kbd_receive == FALSE) if (m_kbd_receive == FALSE)
{
m_via->write_cb2(m_kbd_shift_reg&0x80?1:0); m_via->write_cb2(m_kbd_shift_reg&0x80?1:0);
m_kbd_shift_reg <<= 1; if (i > 0)
{
m_kbd_shift_reg <<= 1;
}
}
m_via->write_cb1(0); m_via->write_cb1(0);
m_via->write_cb1(1); m_via->write_cb1(1);
if (m_kbd_receive == TRUE)
{
if (i < 8)
{
m_kbd_shift_reg <<= 1;
m_kbd_shift_reg |= (m_cb2_in & 1);
}
}
} }
if (m_kbd_receive == TRUE) if (m_kbd_receive == TRUE)
{ {
@ -967,6 +1002,7 @@ void mac128_state::kbd_shift_out(int data)
{ {
if (m_kbd_comm == TRUE) if (m_kbd_comm == TRUE)
{ {
//printf("%02x to Mac\n", data);
m_kbd_shift_reg = data; m_kbd_shift_reg = data;
machine().scheduler().timer_set(attotime::from_msec(1), timer_expired_delegate(FUNC(mac128_state::kbd_clock),this)); machine().scheduler().timer_set(attotime::from_msec(1), timer_expired_delegate(FUNC(mac128_state::kbd_clock),this));
} }
@ -984,7 +1020,7 @@ WRITE_LINE_MEMBER(mac128_state::mac_via_out_cb2)
if (m_kbd_comm == TRUE && m_kbd_receive == TRUE) if (m_kbd_comm == TRUE && m_kbd_receive == TRUE)
{ {
/* Shift in what mac is sending */ /* Shift in what mac is sending */
m_kbd_shift_reg = (m_kbd_shift_reg & ~1) | state; m_cb2_in = state;
} }
} }
@ -1003,6 +1039,7 @@ TIMER_CALLBACK_MEMBER(mac128_state::inquiry_timeout_func)
*/ */
void mac128_state::keyboard_receive(int val) void mac128_state::keyboard_receive(int val)
{ {
//printf("Mac sent %02x\n", val);
switch (val) switch (val)
{ {
case 0x10: case 0x10: