示例#1
0
void mm1_keyboard_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	// handle scan timer
	UINT8 data = 0xff;

	switch (m_drive)
	{
	case 0: data = m_y0->read(); break;
	case 1: data = m_y1->read(); break;
	case 2: data = m_y2->read(); break;
	case 3: data = m_y3->read(); break;
	case 4: data = m_y4->read(); break;
	case 5: data = m_y5->read(); break;
	case 6: data = m_y6->read(); break;
	case 7: data = m_y7->read(); break;
	case 8: data = m_y8->read(); break;
	case 9: data = m_y9->read(); break;
	}

	UINT8 special = m_special->read();
	int ctrl = BIT(special, 0);
	int shift = BIT(special, 2) & BIT(special, 1);
	UINT8 keydata = 0xff;

	if (!BIT(data, m_sense))
	{
		// get key data from PROM
		keydata = m_rom->base()[(ctrl << 8) | (shift << 7) | (m_drive << 3) | (m_sense)];
	}

	if (m_data != keydata)
	{
		// latch key data
		m_data = keydata;

		if (keydata != 0xff)
		{
			// strobe in key data
			m_write_kbst(1);
			m_write_kbst(0);
		}
	}

	if (keydata == 0xff)
	{
		// increase scan counters
		m_sense++;

		if (m_sense == 8)
		{
			m_sense = 0;
			m_drive++;

			if (m_drive == 10)
			{
				m_drive = 0;
			}
		}
	}
}
示例#2
0
文件: mm1kb.cpp 项目: mbarnes/mame
void mm1_keyboard_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	// handle scan timer
	uint8_t data = 0xff;

	if (m_drive < 10)
	{
		data = m_y[m_drive]->read();
	}

	uint8_t special = m_special->read();
	int ctrl = BIT(special, 0);
	int shift = BIT(special, 2) & BIT(special, 1);
	uint8_t keydata = 0xff;

	if (!BIT(data, m_sense))
	{
		// get key data from PROM
		keydata = m_rom->base()[(ctrl << 8) | (shift << 7) | (m_drive << 3) | (m_sense)];
	}

	if (m_data != keydata)
	{
		// latch key data
		m_data = keydata;

		if (keydata != 0xff)
		{
			// strobe in key data
			m_write_kbst(1);
			m_write_kbst(0);
		}
	}

	if (keydata == 0xff)
	{
		// increase scan counters
		m_sense++;

		if (m_sense == 8)
		{
			m_sense = 0;
			m_drive++;

			if (m_drive == 10)
			{
				m_drive = 0;
			}
		}
	}
}