kb3600: track "down" keys to avoid spurious retriggers during fast typing (nw)

This commit is contained in:
R. Belmont 2014-02-13 02:47:26 +00:00
parent a36d4c6609
commit 1e800b70eb
2 changed files with 57 additions and 13 deletions

View File

@ -89,6 +89,7 @@ void ay3600_device::device_start()
// state saving // state saving
save_item(NAME(m_b)); save_item(NAME(m_b));
save_item(NAME(m_ako)); save_item(NAME(m_ako));
save_item(NAME(m_keys_down));
} }
@ -99,6 +100,10 @@ void ay3600_device::device_start()
void ay3600_device::device_reset() void ay3600_device::device_reset()
{ {
m_ako = 0; m_ako = 0;
for (int i = 0; i < MAX_KEYS_DOWN; i++)
{
m_keys_down[i] = -1;
}
} }
//------------------------------------------------- //-------------------------------------------------
@ -128,27 +133,62 @@ void ay3600_device::device_timer(emu_timer &timer, device_timer_id id, int param
for (int y = 0; y < 10; y++) for (int y = 0; y < 10; y++)
{ {
int b = (x * 10) + y;
if (b > 63)
{
b -= 64;
b = 0x100 | b;
}
b |= (m_read_shift() << 6);
b |= (m_read_control() << 7);
if (BIT(data, y)) if (BIT(data, y))
{ {
int b = (x * 10) + y; bool found = false;
ako = 1; // is this key already down?
for (int k = 0; k < MAX_KEYS_DOWN; k++)
if (b > 63)
{ {
b -= 64; if (b == m_keys_down[k])
b = 0x100 | b; {
found = true;
break;
}
} }
b |= (m_read_shift() << 6); if (!found)
b |= (m_read_control() << 7);
if (m_b != b)
{ {
m_b = b; ako = 1;
m_write_data_ready(1); if (m_b != b)
return; {
m_b = b;
m_write_data_ready(1);
return;
}
// add to the keys down list
for (int k = 0; k < MAX_KEYS_DOWN; k++)
{
if (m_keys_down[k] == -1)
{
m_keys_down[k] = b;
break;
}
}
}
}
else // key released, unmark it from the keys_down table
{
for (int k = 0; k < MAX_KEYS_DOWN; k++)
{
if (b == m_keys_down[k])
{
m_keys_down[k] = -1;
}
} }
} }
} }

View File

@ -132,9 +132,13 @@ protected:
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
private: private:
static const int MAX_KEYS_DOWN = 4;
int m_b; // output buffer int m_b; // output buffer
int m_ako; // any key down int m_ako; // any key down
int m_keys_down[MAX_KEYS_DOWN];
// timers // timers
emu_timer *m_scan_timer; // keyboard scan timer emu_timer *m_scan_timer; // keyboard scan timer
}; };