summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/itt1700_kbd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/machine/itt1700_kbd.cpp')
-rw-r--r--src/mame/machine/itt1700_kbd.cpp282
1 files changed, 282 insertions, 0 deletions
diff --git a/src/mame/machine/itt1700_kbd.cpp b/src/mame/machine/itt1700_kbd.cpp
new file mode 100644
index 00000000000..23cbe0dd94b
--- /dev/null
+++ b/src/mame/machine/itt1700_kbd.cpp
@@ -0,0 +1,282 @@
+// license:BSD-3-Clause
+// copyright-holders:AJR
+/***********************************************************************************************************************************
+
+Preliminary ITT 1700 keyboard emulation.
+
+***********************************************************************************************************************************/
+
+#include "emu.h"
+#include "machine/itt1700_kbd.h"
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+DEFINE_DEVICE_TYPE(ITT1700_KEYBOARD, itt1700_keyboard_device, "itt1700_kbd", "ITT 1700 keyboard")
+
+//**************************************************************************
+// DEVICE DEFINITION
+//**************************************************************************
+
+//-------------------------------------------------
+// itt1700_keyboard_device - constructor
+//-------------------------------------------------
+
+itt1700_keyboard_device::itt1700_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : device_t(mconfig, ITT1700_KEYBOARD, tag, owner, clock)
+ , m_clock_state(true)
+ , m_line1_state(true)
+ , m_line2_state(true)
+ , m_scan_counter(0)
+ , m_keys(*this, "KEY%u", 0U)
+{
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void itt1700_keyboard_device::device_start()
+{
+ save_item(NAME(m_clock_state));
+ save_item(NAME(m_line1_state));
+ save_item(NAME(m_line2_state));
+ save_item(NAME(m_scan_counter));
+}
+
+//-------------------------------------------------
+// line1_w - write from host to control line 1
+//-------------------------------------------------
+
+WRITE_LINE_MEMBER(itt1700_keyboard_device::line1_w)
+{
+ m_line1_state = state;
+}
+
+//-------------------------------------------------
+// line2_w - write from host to control line 2
+//-------------------------------------------------
+
+WRITE_LINE_MEMBER(itt1700_keyboard_device::line2_w)
+{
+ m_line2_state = state;
+}
+
+//-------------------------------------------------
+// clock_w - write clock pulse from host
+//-------------------------------------------------
+
+WRITE_LINE_MEMBER(itt1700_keyboard_device::clock_w)
+{
+ if (state && !m_clock)
+ {
+ // TODO: what happens when both lines are on?
+ if (m_line1_state)
+ m_scan_counter = 0x7d;
+ else if (m_line2_state)
+ m_scan_counter = (m_scan_counter + 1) & 0x7f;
+ }
+
+ m_clock = state;
+}
+
+//-------------------------------------------------
+// sense_r - poll return line
+//-------------------------------------------------
+
+READ_LINE_MEMBER(itt1700_keyboard_device::sense_r)
+{
+ return !BIT(m_keys[m_scan_counter >> 3]->read(), m_scan_counter & 7);
+}
+
+//**************************************************************************
+// KEY INPUT MATRIX
+//**************************************************************************
+
+static INPUT_PORTS_START(itt1700_kbd)
+ PORT_START("KEY0")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY1")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY2")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY3")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY4")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY5")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY6")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY7")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY8")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY9")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY10")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY11")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY12")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY13")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY14")
+ PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
+ PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
+
+ PORT_START("KEY15")
+ PORT_DIPNAME(0x01, 0x01, DEF_STR(Unknown))
+ PORT_DIPSETTING(0x01, DEF_STR(Off))
+ PORT_DIPSETTING(0x00, DEF_STR(On))
+ PORT_DIPNAME(0x02, 0x02, DEF_STR(Unknown))
+ PORT_DIPSETTING(0x02, DEF_STR(Off))
+ PORT_DIPSETTING(0x00, DEF_STR(On))
+ PORT_DIPNAME(0x04, 0x04, DEF_STR(Unknown))
+ PORT_DIPSETTING(0x04, DEF_STR(Off))
+ PORT_DIPSETTING(0x00, DEF_STR(On))
+ PORT_DIPNAME(0x08, 0x08, DEF_STR(Unknown))
+ PORT_DIPSETTING(0x08, DEF_STR(Off))
+ PORT_DIPSETTING(0x00, DEF_STR(On))
+ PORT_DIPNAME(0x10, 0x10, DEF_STR(Unknown))
+ PORT_DIPSETTING(0x10, DEF_STR(Off))
+ PORT_DIPSETTING(0x00, DEF_STR(On))
+ PORT_DIPNAME(0x20, 0x20, DEF_STR(Unknown))
+ PORT_DIPSETTING(0x20, DEF_STR(Off))
+ PORT_DIPSETTING(0x00, DEF_STR(On))
+ PORT_DIPNAME(0x40, 0x40, DEF_STR(Unknown))
+ PORT_DIPSETTING(0x40, DEF_STR(Off))
+ PORT_DIPSETTING(0x00, DEF_STR(On))
+ PORT_DIPNAME(0x80, 0x80, DEF_STR(Unknown))
+ PORT_DIPSETTING(0x80, DEF_STR(Off))
+ PORT_DIPSETTING(0x00, DEF_STR(On))
+INPUT_PORTS_END
+
+//-------------------------------------------------
+// input_ports - device-specific input ports
+//-------------------------------------------------
+
+ioport_constructor itt1700_keyboard_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME(itt1700_kbd);
+}