From 0045b0304538ad146e8554b3381d8dfdd820d6bc Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 14 Oct 2018 17:53:51 -0400 Subject: itt1700: Very preliminary keyboard stuff (nw) --- scripts/target/mame/mess.lua | 2 + src/mame/drivers/itt1700.cpp | 10 +- src/mame/machine/itt1700_kbd.cpp | 282 +++++++++++++++++++++++++++++++++++++++ src/mame/machine/itt1700_kbd.h | 47 +++++++ 4 files changed, 339 insertions(+), 2 deletions(-) create mode 100644 src/mame/machine/itt1700_kbd.cpp create mode 100644 src/mame/machine/itt1700_kbd.h diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua index 08e16def7ea..9ccb660642e 100644 --- a/scripts/target/mame/mess.lua +++ b/scripts/target/mame/mess.lua @@ -3733,6 +3733,8 @@ files { MAME_DIR .. "src/mame/drivers/indiana.cpp", MAME_DIR .. "src/mame/drivers/is48x.cpp", MAME_DIR .. "src/mame/drivers/itt1700.cpp", + MAME_DIR .. "src/mame/machine/itt1700_kbd.cpp", + MAME_DIR .. "src/mame/machine/itt1700_kbd.h", MAME_DIR .. "src/mame/drivers/itt3030.cpp", MAME_DIR .. "src/mame/drivers/jade.cpp", MAME_DIR .. "src/mame/drivers/jonos.cpp", diff --git a/src/mame/drivers/itt1700.cpp b/src/mame/drivers/itt1700.cpp index fa1aa01f701..f59d1236daf 100644 --- a/src/mame/drivers/itt1700.cpp +++ b/src/mame/drivers/itt1700.cpp @@ -18,7 +18,7 @@ This device may be related to the Intel 8251, but it is definitely not a SCN2651 #include "emu.h" #include "cpu/z80/z80.h" #include "cpu/mcs48/mcs48.h" -//#include "machine/nvram.h" +#include "machine/itt1700_kbd.h" #include "video/mc6845.h" #include "screen.h" @@ -74,7 +74,13 @@ void itt1700_state::itt1700(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &itt1700_state::mem_map); m_maincpu->set_addrmap(AS_IO, &itt1700_state::io_map); - I8741(config, "upi", 16.6698_MHz_XTAL / 3); // clock guessed + upi41_cpu_device &upi(I8741(config, "upi", 16.6698_MHz_XTAL / 3)); // clock guessed + upi.p1_out_cb().set("keyboard", FUNC(itt1700_keyboard_device::clock_w)).bit(0); + upi.p1_out_cb().append("keyboard", FUNC(itt1700_keyboard_device::line1_w)).bit(1); + upi.p1_out_cb().append("keyboard", FUNC(itt1700_keyboard_device::line2_w)).bit(2); + upi.t0_in_cb().set("keyboard", FUNC(itt1700_keyboard_device::sense_r)); + + ITT1700_KEYBOARD(config, "keyboard"); screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); screen.set_raw(16.6698_MHz_XTAL, 882, 0, 720, 315, 0, 300); 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); +} diff --git a/src/mame/machine/itt1700_kbd.h b/src/mame/machine/itt1700_kbd.h new file mode 100644 index 00000000000..b8ee3cfd3ee --- /dev/null +++ b/src/mame/machine/itt1700_kbd.h @@ -0,0 +1,47 @@ +// license:BSD-3-Clause +// copyright-holders:AJR + +#ifndef MAME_MACHINE_ITT1700_KBD +#define MAME_MACHINE_ITT1700_KBD + +#pragma once + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> itt1700_keyboard_device + +class itt1700_keyboard_device : public device_t +{ +public: + // device constructor + itt1700_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); + + // host interface + DECLARE_WRITE_LINE_MEMBER(line1_w); + DECLARE_WRITE_LINE_MEMBER(line2_w); + DECLARE_WRITE_LINE_MEMBER(clock_w); + DECLARE_READ_LINE_MEMBER(sense_r); + +protected: + // device-specific overrides + virtual void device_start() override; + virtual ioport_constructor device_input_ports() const override; + +private: + // internal state + bool m_clock_state; + bool m_line1_state; + bool m_line2_state; + u8 m_scan_counter; + + // key input matrix + required_ioport_array<16> m_keys; +}; + +// device type definition +DECLARE_DEVICE_TYPE(ITT1700_KEYBOARD, itt1700_keyboard_device) + +#endif // MAME_MACHINE_ITT1700_KBD_H -- cgit v1.2.3