From ed4759152dc2282b0407e0245a0c7885fb8c9e25 Mon Sep 17 00:00:00 2001 From: Curt Coder Date: Sat, 22 Jun 2013 09:25:17 +0000 Subject: [PATCH] (MESS) ibm5150: Keyboard WIP. (nw) --- src/mess/machine/kb_pcxt83.c | 221 ++++++++++++++++++++++++++++++++++- src/mess/machine/kb_pcxt83.h | 25 +++- 2 files changed, 241 insertions(+), 5 deletions(-) diff --git a/src/mess/machine/kb_pcxt83.c b/src/mess/machine/kb_pcxt83.c index 3a05a3ca25e..10d1a324bea 100644 --- a/src/mess/machine/kb_pcxt83.c +++ b/src/mess/machine/kb_pcxt83.c @@ -96,6 +96,149 @@ machine_config_constructor ibm_pc_xt_83_keyboard_device::device_mconfig_addition //------------------------------------------------- INPUT_PORTS_START( ibm_pc_xt_83_keyboard ) + PORT_START("DR00") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR01") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR02") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR03") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR04") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR05") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR06") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR07") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR08") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR09") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR10") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR11") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR12") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR13") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR14") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR15") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR16") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR17") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR18") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR19") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR20") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR21") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR22") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) + + PORT_START("DR23") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) INPUT_PORTS_END @@ -121,7 +264,31 @@ ioport_constructor ibm_pc_xt_83_keyboard_device::device_input_ports() const ibm_pc_xt_83_keyboard_device::ibm_pc_xt_83_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, PC_KBD_IBM_PC_XT_83, "IBM PC/XT 5150/5160 Keyboard", tag, owner, clock, "kb_pcxt83", __FILE__), device_pc_kbd_interface(mconfig, *this), - m_maincpu(*this, I8048_TAG) + m_maincpu(*this, I8048_TAG), + m_dr00(*this, "DR00"), + m_dr01(*this, "DR01"), + m_dr02(*this, "DR02"), + m_dr03(*this, "DR03"), + m_dr04(*this, "DR04"), + m_dr05(*this, "DR05"), + m_dr06(*this, "DR06"), + m_dr07(*this, "DR07"), + m_dr08(*this, "DR08"), + m_dr09(*this, "DR09"), + m_dr10(*this, "DR10"), + m_dr11(*this, "DR11"), + m_dr12(*this, "DR12"), + m_dr13(*this, "DR13"), + m_dr14(*this, "DR14"), + m_dr15(*this, "DR15"), + m_dr16(*this, "DR16"), + m_dr17(*this, "DR17"), + m_dr18(*this, "DR18"), + m_dr19(*this, "DR19"), + m_dr20(*this, "DR20"), + m_dr21(*this, "DR21"), + m_dr22(*this, "DR22"), + m_dr23(*this, "DR23") { } @@ -134,7 +301,6 @@ void ibm_pc_xt_83_keyboard_device::device_start() { // state saving save_item(NAME(m_cnt)); - save_item(NAME(m_key_depressed)); } @@ -154,7 +320,22 @@ void ibm_pc_xt_83_keyboard_device::device_reset() WRITE8_MEMBER( ibm_pc_xt_83_keyboard_device::bus_w ) { - m_cnt = data; + /* + + bit description + + 0 CNT 1 + 1 CNT 2 + 2 CNT 4 + 3 CNT 8 + 4 CNT 16 + 5 CNT 32 + 6 CNT 64 + 7 + + */ + + m_cnt = data & 0x7f; } @@ -220,5 +401,37 @@ WRITE8_MEMBER( ibm_pc_xt_83_keyboard_device::p2_w ) READ8_MEMBER( ibm_pc_xt_83_keyboard_device::t1_r ) { - return m_key_depressed; + UINT8 data = 0xff; + + switch (m_cnt >> 2) + { + case 0: data = m_dr00->read(); break; + case 1: data = m_dr01->read(); break; + case 2: data = m_dr02->read(); break; + case 3: data = m_dr03->read(); break; + case 4: data = m_dr04->read(); break; + case 5: data = m_dr05->read(); break; + case 6: data = m_dr06->read(); break; + case 7: data = m_dr07->read(); break; + case 8: data = m_dr08->read(); break; + case 9: data = m_dr09->read(); break; + case 10: data = m_dr10->read(); break; + case 11: data = m_dr11->read(); break; + case 12: data = m_dr12->read(); break; + case 13: data = m_dr13->read(); break; + case 14: data = m_dr14->read(); break; + case 15: data = m_dr15->read(); break; + case 16: data = m_dr16->read(); break; + case 17: data = m_dr17->read(); break; + case 18: data = m_dr18->read(); break; + case 19: data = m_dr19->read(); break; + case 20: data = m_dr20->read(); break; + case 21: data = m_dr21->read(); break; + case 22: data = m_dr22->read(); break; + case 23: data = m_dr23->read(); break; + } + + int sense = m_cnt & 0x03; + + return BIT(data, sense); } diff --git a/src/mess/machine/kb_pcxt83.h b/src/mess/machine/kb_pcxt83.h index 7a9aa3bd579..e448427fd6c 100644 --- a/src/mess/machine/kb_pcxt83.h +++ b/src/mess/machine/kb_pcxt83.h @@ -53,9 +53,32 @@ protected: private: required_device m_maincpu; + required_ioport m_dr00; + required_ioport m_dr01; + required_ioport m_dr02; + required_ioport m_dr03; + required_ioport m_dr04; + required_ioport m_dr05; + required_ioport m_dr06; + required_ioport m_dr07; + required_ioport m_dr08; + required_ioport m_dr09; + required_ioport m_dr10; + required_ioport m_dr11; + required_ioport m_dr12; + required_ioport m_dr13; + required_ioport m_dr14; + required_ioport m_dr15; + required_ioport m_dr16; + required_ioport m_dr17; + required_ioport m_dr18; + required_ioport m_dr19; + required_ioport m_dr20; + required_ioport m_dr21; + required_ioport m_dr22; + required_ioport m_dr23; UINT8 m_cnt; - int m_key_depressed; };