diff options
author | arbee <rb6502@users.noreply.github.com> | 2015-01-05 23:08:20 -0500 |
---|---|---|
committer | arbee <rb6502@users.noreply.github.com> | 2015-01-05 23:08:20 -0500 |
commit | 13a0e248f1d28e4649967b37597b2c1b48e44254 (patch) | |
tree | f24f6922d89e7b3bfe36da7259584962ec00efa0 | |
parent | 4bf60e541d14c2dc54b3b66524d12172af8dc75a (diff) |
(MESS) mac: greatly improve keyboard reliability on Macs with first-generation ADB hardware (SE,II,IIx,IIcx,SE/30,IIci). [Rob Braun]
-rw-r--r-- | src/mess/includes/mac.h | 4 | ||||
-rw-r--r-- | src/mess/machine/macadb.c | 44 |
2 files changed, 44 insertions, 4 deletions
diff --git a/src/mess/includes/mac.h b/src/mess/includes/mac.h index ffe0a2ccea3..82e5df5959d 100644 --- a/src/mess/includes/mac.h +++ b/src/mess/includes/mac.h @@ -290,6 +290,10 @@ public: INT32 m_adb_streaming, m_adb_stream_ptr; INT32 m_adb_linestate; bool m_adb_srqflag; +#define kADBKeyBufSize 32 + UINT8 m_adb_keybuf[kADBKeyBufSize]; + UINT8 m_adb_keybuf_start; + UINT8 m_adb_keybuf_end; // Portable/PB100 Power Manager IC comms (chapter 4, "Guide to the Macintosh Family Hardware", second edition) UINT8 m_pm_data_send, m_pm_data_recv, m_pm_ack, m_pm_req, m_pm_cmd[32], m_pm_out[32], m_pm_dptr, m_pm_sptr, m_pm_slen, m_pm_state; diff --git a/src/mess/machine/macadb.c b/src/mess/machine/macadb.c index f9635719902..05d7b32db3a 100644 --- a/src/mess/machine/macadb.c +++ b/src/mess/machine/macadb.c @@ -194,6 +194,14 @@ int mac_state::adb_pollkbd(int update) // if we want to update the current read, do so if (update) { + if(m_adb_currentkeys[0] != codes[0]) { + m_adb_keybuf[m_adb_keybuf_end] = codes[0]; + m_adb_keybuf_end = (m_adb_keybuf_end+1) % kADBKeyBufSize; + } + if(m_adb_currentkeys[1] != codes[1]) { + m_adb_keybuf[m_adb_keybuf_end] = codes[1]; + m_adb_keybuf_end = (m_adb_keybuf_end+1) % kADBKeyBufSize; + } m_adb_currentkeys[0] = codes[0]; m_adb_currentkeys[1] = codes[1]; } @@ -388,6 +396,7 @@ void mac_state::adb_talk() } else if (addr == m_adb_keybaddr) { + int kbd_has_data = 1; #if LOG_ADB || LOG_ADB_TALK_LISTEN printf("Talking to keyboard, register %x\n", reg); #endif @@ -402,7 +411,7 @@ void mac_state::adb_talk() } else { - this->adb_pollkbd(1); + kbd_has_data = this->adb_pollkbd(1); } /* if (m_adb_currentkeys[0] != 0xff) @@ -414,9 +423,30 @@ void mac_state::adb_talk() printf("Keys[1] = %02x\n", m_adb_currentkeys[1]); }*/ - m_adb_buffer[0] = m_adb_currentkeys[1]; - m_adb_buffer[1] = m_adb_currentkeys[0]; - m_adb_datasize = 2; + if(kbd_has_data) + { + if(m_adb_keybuf_start == m_adb_keybuf_end) + { + // printf("%s: buffer empty\n", __func__); + m_adb_buffer[0] = 0xff; + m_adb_buffer[1] = 0xff; + } + else + { + m_adb_buffer[1] = m_adb_keybuf[m_adb_keybuf_start]; + m_adb_keybuf_start = (m_adb_keybuf_start+1) % kADBKeyBufSize; + if(m_adb_keybuf_start != m_adb_keybuf_end) + { + m_adb_buffer[0] = m_adb_keybuf[m_adb_keybuf_start]; + m_adb_keybuf_start = (m_adb_keybuf_start+1) % kADBKeyBufSize; + } + else + { + m_adb_buffer[0] = 0xff; + } + } + m_adb_datasize = 2; + } break; // read modifier keys @@ -633,6 +663,10 @@ TIMER_CALLBACK(mac_adb_tick) if ((mac->m_adb_direction) && (ADB_IS_BITBANG)) { mac->adb_talk(); + if((mac->m_adb_last_talk == 2) && mac->m_adb_datasize) { + mac->m_adb_timer_ticks = 8; + mac->m_adb_timer->adjust(attotime(0, ATTOSECONDS_IN_USEC(100))); + } } } else @@ -1191,6 +1225,8 @@ void mac_state::adb_reset() { m_key_matrix[i] = 0; } + m_adb_keybuf_start = 0; + m_adb_keybuf_end = 0; } WRITE_LINE_MEMBER(mac_state::adb_linechange_w) |