예제 #1
0
파일: mm74c922.cpp 프로젝트: Tauwasser/mame
void mm74c922_device::detect_keypress()
{
	uint8_t data = 0xff;

	switch (m_x)
	{
	case 0: data = m_read_x1(0); break;
	case 1: data = m_read_x2(0); break;
	case 2: data = m_read_x3(0); break;
	case 3: data = m_read_x4(0); break;
	case 4: data = m_read_x5(0); break;
	}

	if (m_inhibit)
	{
		if (BIT(data, m_y))
		{
			// key released
			m_inhibit = 0;
			m_next_da = 0;
			m_data = 0xff; // high-Z

			LOG("MM74C922 Key Released\n");
		}
	}
	else
	{
		for (int y = 0; y < m_max_y; y++)
		{
			if (!BIT(data, y))
			{
				// key depressed
				m_inhibit = 1;
				m_next_da = 1;
				m_y = y;

				m_data = (y << 2) | m_x;

				LOG("MM74C922 Key Depressed: X %u Y %u = %02x\n", m_x, y, m_data);
				return;
			}
		}
	}
}
예제 #2
0
void ay3600_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	int ako = 0;

	for (int x = 0; x < 9; x++)
	{
		UINT16 data = 0;

		switch(x)
		{
			case 0: data = m_read_x0(); break;
			case 1: data = m_read_x1(); break;
			case 2: data = m_read_x2(); break;
			case 3: data = m_read_x3(); break;
			case 4: data = m_read_x4(); break;
			case 5: data = m_read_x5(); break;
			case 6: data = m_read_x6(); break;
			case 7: data = m_read_x7(); break;
			case 8: data = m_read_x8(); break;
		}

		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 (!(m_x_mask[x] & (1 << y)))
				{
					ako = 1;

					m_x_mask[x] |= (1 << y);

					if (m_b != b)
					{
						m_b = b;

						m_write_data_ready(1);
						return;
					}
				}
			}
			else    // key released, unmark it from the "down" info
			{
				m_x_mask[x] &= ~(1 << y);
			}
		}
	}

	if (!ako)
	{
		m_b = -1;
	}

	if (ako != m_ako)
	{
		m_write_ako(ako);
		m_ako = ako;
	}
}
예제 #3
0
void ay3600_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	int ako = 0;

	for (int x = 0; x < 9; x++)
	{
		UINT16 data = 0;

		switch(x)
		{
			case 0: data = m_read_x0(); break;
			case 1: data = m_read_x1(); break;
			case 2: data = m_read_x2(); break;
			case 3: data = m_read_x3(); break;
			case 4: data = m_read_x4(); break;
			case 5: data = m_read_x5(); break;
			case 6: data = m_read_x6(); break;
			case 7: data = m_read_x7(); break;
			case 8: data = m_read_x8(); break;
		}

		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))
			{
				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;

						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;
					}
				}
			}
		}
	}

	if (!ako)
	{
		m_b = -1;
	}

	if (ako != m_ako)
	{
		m_write_ako(ako);
		m_ako = ako;
	}
}