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
save_item(NAME(m_b));
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()
{
m_ako = 0;
for (int i = 0; i < MAX_KEYS_DOWN; i++)
{
m_keys_down[i] = -1;
}
}
//-------------------------------------------------
@ -127,13 +132,9 @@ void ay3600_device::device_timer(emu_timer &timer, device_timer_id id, int param
}
for (int y = 0; y < 10; y++)
{
if (BIT(data, y))
{
int b = (x * 10) + y;
ako = 1;
if (b > 63)
{
b -= 64;
@ -143,6 +144,24 @@ void ay3600_device::device_timer(emu_timer &timer, device_timer_id id, int param
b |= (m_read_shift() << 6);
b |= (m_read_control() << 7);
if (BIT(data, y))
{
bool found = false;
// is this key already down?
for (int k = 0; k < MAX_KEYS_DOWN; k++)
{
if (b == m_keys_down[k])
{
found = true;
break;
}
}
if (!found)
{
ako = 1;
if (m_b != b)
{
m_b = b;
@ -150,6 +169,27 @@ void ay3600_device::device_timer(emu_timer &timer, device_timer_id id, int param
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);
private:
static const int MAX_KEYS_DOWN = 4;
int m_b; // output buffer
int m_ako; // any key down
int m_keys_down[MAX_KEYS_DOWN];
// timers
emu_timer *m_scan_timer; // keyboard scan timer
};