From 534b7d15957d518990809c8b381b2ca4c8a22e0b Mon Sep 17 00:00:00 2001 From: Patrick Mackinlay Date: Tue, 9 May 2023 11:07:59 +0700 Subject: sgi: add 4D keyboard low-level emulation [Bitsavers] --- scripts/src/bus.lua | 14 -- src/devices/bus/sgikbd/hlekbd.cpp | 406 -------------------------------------- src/devices/bus/sgikbd/hlekbd.h | 113 ----------- src/devices/bus/sgikbd/sgikbd.cpp | 69 ------- src/devices/bus/sgikbd/sgikbd.h | 81 -------- src/mame/sgi/4dpi.cpp | 12 +- src/mame/sgi/hpc1.cpp | 8 +- src/mame/sgi/kbd.cpp | 403 +++++++++++++++++++++++++++++++++++++ src/mame/sgi/kbd.h | 97 +++++++++ 9 files changed, 510 insertions(+), 693 deletions(-) delete mode 100644 src/devices/bus/sgikbd/hlekbd.cpp delete mode 100644 src/devices/bus/sgikbd/hlekbd.h delete mode 100644 src/devices/bus/sgikbd/sgikbd.cpp delete mode 100644 src/devices/bus/sgikbd/sgikbd.h create mode 100644 src/mame/sgi/kbd.cpp create mode 100644 src/mame/sgi/kbd.h diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 4f254b218ee..889b669b959 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -4334,20 +4334,6 @@ if (BUSES["ZORRO"]~=null) then } end ---------------------------------------------------- --- ---@src/devices/bus/sgikbd/sgikbd.h,BUSES["SGIKBD"] = true ---------------------------------------------------- - -if (BUSES["SGIKBD"]~=null) then - files { - MAME_DIR .. "src/devices/bus/sgikbd/hlekbd.cpp", - MAME_DIR .. "src/devices/bus/sgikbd/hlekbd.h", - MAME_DIR .. "src/devices/bus/sgikbd/sgikbd.cpp", - MAME_DIR .. "src/devices/bus/sgikbd/sgikbd.h", - } -end - --------------------------------------------------- -- --@src/devices/bus/sunkbd/sunkbd.h,BUSES["SUNKBD"] = true diff --git a/src/devices/bus/sgikbd/hlekbd.cpp b/src/devices/bus/sgikbd/hlekbd.cpp deleted file mode 100644 index 42ffb0eb76c..00000000000 --- a/src/devices/bus/sgikbd/hlekbd.cpp +++ /dev/null @@ -1,406 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ryan Holtz -#include "emu.h" -#include "hlekbd.h" - -#include "machine/keyboard.ipp" -#include "speaker.h" - -DEFINE_DEVICE_TYPE(SGI_HLE_KEYBOARD, bus::sgikbd::hle_device, "hlekbd", "SGI Indigo Keyboard (HLE)") - -namespace bus::sgikbd { - -namespace { - -INPUT_PORTS_START( hle_device ) - PORT_START("ROW0") - PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("L Control") PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL)) - PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Caps Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) - PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("R Shift") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_MAMEKEY(RSHIFT)) - PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("L Shift") PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) - PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Esc") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) - PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') - PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tab") PORT_CODE(KEYCODE_TAB) PORT_CHAR(9) - PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') - PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') - PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') - PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@') - PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') - PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') - - PORT_START("ROW1") - PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') - PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') - PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') - PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') - PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') - PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') - PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') - PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') - PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') - PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') - PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') - PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') - PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') - PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^') - PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&') - PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') - - PORT_START("ROW2") - PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') - PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') - PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') - PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') - PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') - PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*') - PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(') - PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') - PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') - PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') - PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':') - PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') - PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') - PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(')') - PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_') - PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') - - PORT_START("ROW3") - PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{') - PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"') - PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Return") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) - PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') - PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') - PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+') - PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~') - PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}') - PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|') - PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP 1") PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD)) - PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP 0") PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD)) - PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Backspace") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) - PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP 4") PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD)) - PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP 2") PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD)) - - PORT_START("ROW4") - PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP 3") PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD)) - PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP .") PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD)) - PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP 7") PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD)) - PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP 8") PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD)) - PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP 5") PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD)) - PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP 6") PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD)) - PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Left") PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) - PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Down") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) - PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP 9") PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD)) - PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP -") PORT_CODE(KEYCODE_MINUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD)) - PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Right") PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) - - PORT_START("ROW5") - PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Up") PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) - PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Enter") PORT_CODE(KEYCODE_ENTER_PAD) - PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') - PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("L Alt") PORT_CODE(KEYCODE_LALT) PORT_CHAR(UCHAR_MAMEKEY(LALT)) - PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("R Alt") PORT_CODE(KEYCODE_RALT) PORT_CHAR(UCHAR_MAMEKEY(RALT)) - PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("R Control") PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(RCONTROL)) - PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) - PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) - PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) - PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) - PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5)) - PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6)) - PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7)) - PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8)) - PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F9") PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9)) - PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F10") PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10)) - - PORT_START("ROW6") - PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F11") PORT_CODE(KEYCODE_F11) PORT_CHAR(UCHAR_MAMEKEY(F11)) - PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F12") PORT_CODE(KEYCODE_F12) PORT_CHAR(UCHAR_MAMEKEY(F12)) - PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Print Screen") PORT_CODE(KEYCODE_PRTSCR) PORT_CHAR(UCHAR_MAMEKEY(PRTSCR)) - PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Scroll Lock") PORT_CODE(KEYCODE_SCRLOCK) PORT_CHAR(UCHAR_MAMEKEY(SCRLOCK)) - PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Pause") PORT_CODE(KEYCODE_PAUSE) - PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Insert") PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) - PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Home") PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME)) - PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Page Up") PORT_CODE(KEYCODE_PGUP) PORT_CHAR(UCHAR_MAMEKEY(PGUP)) - PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("End") PORT_CODE(KEYCODE_END) PORT_CHAR(UCHAR_MAMEKEY(END)) - PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Page Down") PORT_CODE(KEYCODE_PGDN) PORT_CHAR(UCHAR_MAMEKEY(PGDN)) - PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Num Lock") PORT_CODE(KEYCODE_NUMLOCK) PORT_CHAR(UCHAR_MAMEKEY(NUMLOCK)) - PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP /") PORT_CODE(KEYCODE_SLASH_PAD) - PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP *") PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR(UCHAR_MAMEKEY(ASTERISK)) - PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("KP +") PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD)) - PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_UNUSED ) - - PORT_START("ROW7") - PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_UNUSED ) - PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_UNUSED ) -INPUT_PORTS_END - -} // anonymous namespace - -hle_device::hle_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, SGI_HLE_KEYBOARD, tag, owner, clock) - , device_buffered_serial_interface(mconfig, *this) - , device_sgi_keyboard_port_interface(mconfig, *this) - , device_matrix_keyboard_interface(mconfig, *this, "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7") - , m_click_timer(nullptr) - , m_beep_timer(nullptr) - , m_beeper(*this, "beeper") - , m_leds(*this, "led%u", 0U) - , m_make_count(0) - , m_keyclick(true) - , m_auto_repeat(false) - , m_beeper_state(0) - , m_led_state(0) -{ -} - -hle_device::~hle_device() -{ -} - -ioport_constructor hle_device::device_input_ports() const -{ - return INPUT_PORTS_NAME(hle_device); -} - -WRITE_LINE_MEMBER(hle_device::input_txd) -{ - device_buffered_serial_interface::rx_w(state); -} - -void hle_device::device_add_mconfig(machine_config &config) -{ - SPEAKER(config, "bell").front_center(); - BEEP(config, m_beeper, ATTOSECONDS_TO_HZ(480 * ATTOSECONDS_PER_MICROSECOND)); - m_beeper->add_route(ALL_OUTPUTS, "bell", 1.0); -} - -void hle_device::device_start() -{ - m_leds.resolve(); - m_click_timer = timer_alloc(FUNC(hle_device::click_off), this); - m_beep_timer = timer_alloc(FUNC(hle_device::beep_off), this); - - save_item(NAME(m_make_count)); - save_item(NAME(m_keyclick)); - save_item(NAME(m_auto_repeat)); - save_item(NAME(m_beeper_state)); - save_item(NAME(m_led_state)); -} - -void hle_device::device_reset() -{ - // initialise state - clear_fifo(); - m_make_count = 0; - m_keyclick = true; - m_auto_repeat = false; - m_beeper_state = 0; - m_led_state = 0; - - // configure device_buffered_serial_interface - set_data_frame(START_BIT_COUNT, DATA_BIT_COUNT, PARITY, STOP_BITS); - set_rate(BAUD); - receive_register_reset(); - transmit_register_reset(); - - // set device_sgi_keyboard_port_interface lines - output_rxd(1); - - // start with keyboard LEDs off - m_leds[LED_NUM] = 0; - m_leds[LED_CAPS] = 0; - m_leds[LED_SCROLL] = 0; - m_leds[LED_USER1] = 0; - m_leds[LED_USER2] = 0; - m_leds[LED_USER3] = 0; - m_leds[LED_USER4] = 0; - - m_click_timer->adjust(attotime::never); - m_beep_timer->adjust(attotime::never); - - // kick the base - reset_key_state(); - start_processing(attotime::from_hz(600)); -} - -TIMER_CALLBACK_MEMBER(hle_device::click_off) -{ - m_beeper_state &= ~BEEPER_CLICK; - m_beeper->set_state(m_beeper_state ? 1 : 0); -} - -TIMER_CALLBACK_MEMBER(hle_device::beep_off) -{ - m_beeper_state &= ~BEEPER_BELL; - m_beeper->set_state(m_beeper_state ? 1 : 0); -} - -void hle_device::tra_callback() -{ - output_rxd(transmit_register_get_data_bit()); -} - -void hle_device::tra_complete() -{ - if (fifo_full()) - start_processing(attotime::from_hz(600)); - - device_buffered_serial_interface::tra_complete(); -} - -void hle_device::key_make(uint8_t row, uint8_t column) -{ - // we should have stopped processing if we filled the FIFO - assert(!fifo_full()); - - // send the make code, click if desired - transmit_byte((row << 4) | column); - if (m_keyclick) - { - m_beeper_state |= uint8_t(BEEPER_CLICK); - m_beeper->set_state(m_beeper_state ? 1 : 0); - m_click_timer->reset(attotime::from_msec(5)); - } - - // count keys - ++m_make_count; - assert(m_make_count); -} - -void hle_device::key_break(uint8_t row, uint8_t column) -{ - // we should have stopped processing if we filled the FIFO - assert(!fifo_full()); - assert(m_make_count); - - // send the break code, and the idle code if no other keys are down - transmit_byte(0x80 | (row << 4) | column); - if (!--m_make_count) - transmit_byte(0xf0); -} - -void hle_device::transmit_byte(uint8_t byte) -{ - device_buffered_serial_interface::transmit_byte(byte); - if (fifo_full()) - stop_processing(); -} - -void hle_device::received_byte(uint8_t byte) -{ - if (BIT(byte, CTRL_B)) - { - if (BIT(byte, CTRL_B_CMPL_DS1_2)) - { - logerror("Not Yet Implemented: Complement DS1/2\n"); - } - - if (BIT(byte, CTRL_B_SCRLK)) - { - logerror("Toggle Scroll Lock LED\n"); - m_led_state ^= (1 << LED_SCROLL); - m_leds[LED_SCROLL] = BIT(m_led_state, LED_SCROLL); - } - if (BIT(byte, CTRL_B_L1)) - { - logerror("Toggle User LED 1\n"); - m_led_state ^= (1 << LED_USER1); - m_leds[LED_USER1] = BIT(m_led_state, LED_USER1); - } - if (BIT(byte, CTRL_B_L2)) - { - logerror("Toggle User LED 2\n"); - m_led_state ^= (1 << LED_USER2); - m_leds[LED_USER2] = BIT(m_led_state, LED_USER2); - } - if (BIT(byte, CTRL_B_L3)) - { - logerror("Toggle User LED 3\n"); - m_led_state ^= (1 << LED_USER3); - m_leds[LED_USER3] = BIT(m_led_state, LED_USER3); - } - if (BIT(byte, CTRL_B_L4)) - { - logerror("Toggle User LED 4\n"); - m_led_state ^= (1 << LED_USER4); - m_leds[LED_USER3] = BIT(m_led_state, LED_USER4); - } - } - else - { - if (BIT(byte, CTRL_A_SBEEP)) - { - logerror("Short Beep\n"); - m_beeper_state |= uint8_t(BEEPER_BELL); - m_beeper->set_state(m_beeper_state ? 1 : 0); - m_click_timer->adjust(attotime::from_msec(200)); - } - - if (BIT(byte, CTRL_A_LBEEP)) - { - logerror("Long Beep\n"); - m_beeper_state |= uint8_t(BEEPER_BELL); - m_beeper->set_state(m_beeper_state ? 1 : 0); - m_click_timer->adjust(attotime::from_msec(1000)); - } - - if (BIT(byte, CTRL_A_NOCLICK)) - { - logerror("Keyclick Off\n"); - m_keyclick = false; - } - - if (BIT(byte, CTRL_A_RCB)) - { - logerror("Receive Config Byte\n"); - transmit_byte(0x6e); - transmit_byte(0x00); // US layout - } - - if (BIT(byte, CTRL_A_NUMLK)) - { - logerror("Toggle Num Lock LED\n"); - m_led_state ^= (1 << LED_NUM); - m_leds[LED_NUM] = BIT(m_led_state, LED_NUM); - } - - if (BIT(byte, CTRL_A_CAPSLK)) - { - logerror("Toggle Caps Lock LED\n"); - m_led_state ^= (1 << LED_CAPS); - m_leds[LED_CAPS] = BIT(m_led_state, LED_CAPS); - } - - if (BIT(byte, CTRL_A_AUTOREP)) - { - logerror("Toggle Auto Repeat\n"); - m_auto_repeat = !m_auto_repeat; - } - } -} - -} // namespace bus::sgikbd diff --git a/src/devices/bus/sgikbd/hlekbd.h b/src/devices/bus/sgikbd/hlekbd.h deleted file mode 100644 index ce066e90c55..00000000000 --- a/src/devices/bus/sgikbd/hlekbd.h +++ /dev/null @@ -1,113 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ryan Holtz -#ifndef DEVICES_BUS_SGIKBD_HLEKBD_H -#define DEVICES_BUS_SGIKBD_HLEKBD_H - -#pragma once - -#include "sgikbd.h" -#include "machine/keyboard.h" -#include "sound/beep.h" -#include "diserial.h" - - -namespace bus::sgikbd { - -class hle_device : public device_t - , public device_buffered_serial_interface<16U> - , public device_sgi_keyboard_port_interface - , protected device_matrix_keyboard_interface<8U> -{ -public: - // constructor/destructor - hle_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock); - - virtual ~hle_device() override; - - virtual DECLARE_WRITE_LINE_MEMBER(input_txd) override; - -protected: - // device overrides - virtual void device_add_mconfig(machine_config &config) override; - virtual void device_start() override; - virtual void device_reset() override; - virtual ioport_constructor device_input_ports() const override; - - // device_buffered_serial_interface overrides - virtual void tra_callback() override; - virtual void tra_complete() override; - - // device_matrix_keyboard_interface overrides - virtual void key_make(uint8_t row, uint8_t column) override; - virtual void key_break(uint8_t row, uint8_t column) override; - - // customised transmit_byte method - void transmit_byte(uint8_t byte); - - TIMER_CALLBACK_MEMBER(click_off); - TIMER_CALLBACK_MEMBER(beep_off); - -private: - enum - { - LED_NUM, - LED_CAPS, - LED_SCROLL, - LED_USER1, - LED_USER2, - LED_USER3, - LED_USER4 - }; - - enum - { - BEEPER_BELL = 0x01, - BEEPER_CLICK = 0x02 - }; - - enum - { - RX_IDLE, - }; - - enum - { - CTRL_A_SBEEP = 1, - CTRL_A_LBEEP = 2, - CTRL_A_NOCLICK = 3, - CTRL_A_RCB = 4, - CTRL_A_NUMLK = 5, - CTRL_A_CAPSLK = 6, - CTRL_A_AUTOREP = 7, - - CTRL_B = 0, - CTRL_B_CMPL_DS1_2 = 1, - CTRL_B_SCRLK = 2, - CTRL_B_L1 = 3, - CTRL_B_L2 = 4, - CTRL_B_L3 = 5, - CTRL_B_L4 = 6 - }; - - // device_buffered_serial_interface overrides - virtual void received_byte(uint8_t byte) override; - - emu_timer *m_click_timer; - emu_timer *m_beep_timer; - required_device m_beeper; - output_finder<7> m_leds; - - uint8_t m_make_count; - - bool m_keyclick; - bool m_auto_repeat; - uint8_t m_beeper_state; - uint8_t m_led_state; -}; - -} // namespace bus::sgikbd - - -DECLARE_DEVICE_TYPE_NS(SGI_HLE_KEYBOARD, bus::sgikbd, hle_device) - -#endif // DEVICES_BUS_SGIKBD_HLEKBD_H diff --git a/src/devices/bus/sgikbd/sgikbd.cpp b/src/devices/bus/sgikbd/sgikbd.cpp deleted file mode 100644 index 80138f1d7a3..00000000000 --- a/src/devices/bus/sgikbd/sgikbd.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ryan Holtz - -#include "emu.h" -#include "sgikbd.h" - - -DEFINE_DEVICE_TYPE(SGIKBD_PORT, sgi_keyboard_port_device, "sgikbd", "SGI Keyboard Port") - - -sgi_keyboard_port_device::sgi_keyboard_port_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) - : sgi_keyboard_port_device(mconfig, SGIKBD_PORT, tag, owner, clock) -{ -} - -sgi_keyboard_port_device::sgi_keyboard_port_device(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock) - , device_single_card_slot_interface(mconfig, *this) - , m_rxd(0) - , m_rxd_handler(*this) - , m_dev(nullptr) -{ -} - -sgi_keyboard_port_device::~sgi_keyboard_port_device() -{ -} - -void sgi_keyboard_port_device::device_config_complete() -{ - m_dev = get_card_device(); -} - -void sgi_keyboard_port_device::device_resolve_objects() -{ - m_rxd_handler.resolve_safe(); -} - -void sgi_keyboard_port_device::device_start() -{ - save_item(NAME(m_rxd)); - - m_rxd = 1; - m_rxd_handler(m_rxd); -} - -WRITE_LINE_MEMBER(sgi_keyboard_port_device::write_txd) -{ - if (m_dev) - m_dev->input_txd(state); -} - -device_sgi_keyboard_port_interface::device_sgi_keyboard_port_interface(machine_config const &mconfig, device_t &device) - : device_interface(device, "sgikbd") - , m_port(dynamic_cast(device.owner())) -{ -} - -device_sgi_keyboard_port_interface::~device_sgi_keyboard_port_interface() -{ -} - - -#include "hlekbd.h" - -void default_sgi_keyboard_devices(device_slot_interface &device) -{ - device.option_add("hlekbd", SGI_HLE_KEYBOARD); -} diff --git a/src/devices/bus/sgikbd/sgikbd.h b/src/devices/bus/sgikbd/sgikbd.h deleted file mode 100644 index bf64fd34b6a..00000000000 --- a/src/devices/bus/sgikbd/sgikbd.h +++ /dev/null @@ -1,81 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ryan Holtz -#ifndef DEVICES_BUS_SGIKBD_SGIKBD_H -#define DEVICES_BUS_SGIKBD_SGIKBD_H - -#pragma once - -#include "diserial.h" - -class device_sgi_keyboard_port_interface; - -class sgi_keyboard_port_device : public device_t, public device_single_card_slot_interface -{ - friend class device_sgi_keyboard_port_interface; - -public: - template - sgi_keyboard_port_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&opts, char const *dflt) - : sgi_keyboard_port_device(mconfig, tag, owner, 0) - { - option_reset(); - opts(*this); - set_default_option(dflt); - set_fixed(false); - } - sgi_keyboard_port_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock = 0); - virtual ~sgi_keyboard_port_device(); - - // configuration helpers - auto rxd_handler() { return m_rxd_handler.bind(); } - - DECLARE_WRITE_LINE_MEMBER( write_txd ); - - DECLARE_READ_LINE_MEMBER( rxd_r ) { return m_rxd; } - -protected: - sgi_keyboard_port_device(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, uint32_t clock); - - virtual void device_config_complete() override; - virtual void device_resolve_objects() override; - virtual void device_start() override; - - int m_rxd; - - devcb_write_line m_rxd_handler; - -private: - device_sgi_keyboard_port_interface *m_dev; -}; - - -class device_sgi_keyboard_port_interface : public device_interface -{ - friend class sgi_keyboard_port_device; - -public: - virtual ~device_sgi_keyboard_port_interface() override; - -protected: - device_sgi_keyboard_port_interface(machine_config const &mconfig, device_t &device); - - virtual DECLARE_WRITE_LINE_MEMBER(input_txd) { } - - DECLARE_WRITE_LINE_MEMBER(output_rxd) { m_port->m_rxd = state; m_port->m_rxd_handler(state); } - - sgi_keyboard_port_device *m_port; - - static constexpr int START_BIT_COUNT = 1; - static constexpr int DATA_BIT_COUNT = 8; - static constexpr device_serial_interface::parity_t PARITY = device_serial_interface::PARITY_ODD; - static constexpr device_serial_interface::stop_bits_t STOP_BITS = device_serial_interface::STOP_BITS_1; - static constexpr int BAUD = 600; -}; - - -DECLARE_DEVICE_TYPE(SGIKBD_PORT, sgi_keyboard_port_device) - - -void default_sgi_keyboard_devices(device_slot_interface &device); - -#endif // DEVICES_BUS_SGIKBD_SGIKBD_H diff --git a/src/mame/sgi/4dpi.cpp b/src/mame/sgi/4dpi.cpp index b49cd7016e0..be8d327445d 100644 --- a/src/mame/sgi/4dpi.cpp +++ b/src/mame/sgi/4dpi.cpp @@ -55,8 +55,8 @@ #include "bus/nscsi/hd.h" #include "bus/nscsi/cd.h" #include "bus/rs232/rs232.h" -#include "bus/sgikbd/sgikbd.h" #include "bus/rs232/hlemouse.h" +#include "kbd.h" // video and audio #include "sgi_gr1.h" @@ -664,7 +664,7 @@ void pi4d2x_state::common(machine_config &config) EEPROM_93C56_16BIT(config, m_eeprom); - DP8573(config, m_rtc).set_use_utc(true); // DP8572AN + DP8573(config, m_rtc); // DP8572AN PIT8254(config, m_pit); m_pit->set_clk<2>(3.6864_MHz_XTAL); @@ -712,7 +712,7 @@ void pi4d2x_state::common(machine_config &config) // duart 0 (keyboard/mouse) SCN2681(config, m_duart[0], 3.6864_MHz_XTAL); // SCN2681AC1N24 - sgi_keyboard_port_device &keyboard_port(SGIKBD_PORT(config, "keyboard_port", default_sgi_keyboard_devices, "hlekbd")); + sgi_kbd_port_device &keyboard_port(SGI_KBD_PORT(config, "keyboard_port", default_sgi_kbd_devices, "keyboard")); rs232_port_device &mouse_port(RS232_PORT(config, "mouse_port", [](device_slot_interface &device) { @@ -722,7 +722,7 @@ void pi4d2x_state::common(machine_config &config) // duart 0 outputs m_duart[0]->irq_cb().set(FUNC(pi4d2x_state::lio_interrupt)).invert(); - m_duart[0]->a_tx_cb().set(keyboard_port, FUNC(sgi_keyboard_port_device::write_txd)); + m_duart[0]->a_tx_cb().set(keyboard_port, FUNC(sgi_kbd_port_device::write_txd)); m_duart[0]->b_tx_cb().set(mouse_port, FUNC(rs232_port_device::write_txd)); // duart 0 inputs @@ -843,8 +843,8 @@ void pi4d3x_state::common(machine_config &config) m_duart[0]->out_int_callback().set(duart_int, FUNC(input_merger_device::in_w<0>)); // keyboard - sgi_keyboard_port_device &keyboard_port(SGIKBD_PORT(config, "keyboard_port", default_sgi_keyboard_devices, "hlekbd")); - m_duart[0]->out_txdb_callback().set(keyboard_port, FUNC(sgi_keyboard_port_device::write_txd)); + sgi_kbd_port_device &keyboard_port(SGI_KBD_PORT(config, "keyboard_port", default_sgi_kbd_devices, "keyboard")); + m_duart[0]->out_txdb_callback().set(keyboard_port, FUNC(sgi_kbd_port_device::write_txd)); keyboard_port.rxd_handler().set(m_duart[0], FUNC(z80scc_device::rxb_w)); // mouse diff --git a/src/mame/sgi/hpc1.cpp b/src/mame/sgi/hpc1.cpp index 84af54e244b..8e139e3d953 100644 --- a/src/mame/sgi/hpc1.cpp +++ b/src/mame/sgi/hpc1.cpp @@ -13,7 +13,7 @@ #include "machine/nscsi_bus.h" #include "bus/nscsi/cd.h" #include "bus/nscsi/hd.h" -#include "bus/sgikbd/sgikbd.h" +#include "kbd.h" #include "hpc1.h" #include "speaker.h" @@ -139,7 +139,7 @@ void hpc1_device::device_add_mconfig(machine_config &config) SCC85C30(config, m_scc[0], SCC_PCLK); m_scc[0]->configure_channels(SCC_RXA_CLK.value(), SCC_TXA_CLK.value(), SCC_RXB_CLK.value(), SCC_TXB_CLK.value()); m_scc[0]->out_int_callback().set(FUNC(hpc1_device::duart0_int_w)); - m_scc[0]->out_txda_callback().set("keyboard", FUNC(sgi_keyboard_port_device::write_txd)); + m_scc[0]->out_txda_callback().set("keyboard_port", FUNC(sgi_kbd_port_device::write_txd)); SCC85C30(config, m_scc[1], SCC_PCLK); m_scc[1]->configure_channels(SCC_RXA_CLK.value(), SCC_TXA_CLK.value(), SCC_RXB_CLK.value(), SCC_TXB_CLK.value()); @@ -155,9 +155,9 @@ void hpc1_device::device_add_mconfig(machine_config &config) m_scc[2]->configure_channels(SCC_RXA_CLK.value(), SCC_TXA_CLK.value(), SCC_RXB_CLK.value(), SCC_TXB_CLK.value()); m_scc[2]->out_int_callback().set(FUNC(hpc1_device::duart2_int_w)); - SGIKBD_PORT(config, "keyboard", default_sgi_keyboard_devices, "hlekbd").rxd_handler().set(m_scc[0], FUNC(z80scc_device::rxa_w)); + SGI_KBD_PORT(config, "keyboard_port", default_sgi_kbd_devices, "keyboard").rxd_handler().set(m_scc[0], FUNC(z80scc_device::rxa_w)); - rs232_port_device &mouseport(RS232_PORT(config, "mouseport", indigo_mice, "sgimouse")); + rs232_port_device &mouseport(RS232_PORT(config, "mouse_port", indigo_mice, "sgimouse")); mouseport.set_fixed(true); mouseport.rxd_handler().set(m_scc[0], FUNC(scc85c30_device::rxb_w)); mouseport.cts_handler().set(m_scc[0], FUNC(scc85c30_device::ctsb_w)); diff --git a/src/mame/sgi/kbd.cpp b/src/mame/sgi/kbd.cpp new file mode 100644 index 00000000000..fdf150c9908 --- /dev/null +++ b/src/mame/sgi/kbd.cpp @@ -0,0 +1,403 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz, Patrick Mackinlay + +#include "emu.h" +#include "kbd.h" + +#include "sound/beep.h" +#include "speaker.h" + +DEFINE_DEVICE_TYPE(SGI_KBD_PORT, sgi_kbd_port_device, "sgi_kbd_port", "SGI Keyboard Port") +DEFINE_DEVICE_TYPE(SGI_KBD, sgi_kbd_device, "sgi_kbd", "SGI Keyboard") + +/* + * An emulation of a keyboard compatible with the Silicon Graphics 4D series + * (Professional IRIS, Personal IRIS, PowerSeries, Crimson), Indigo, and Onyx + * systems. The physical interface may be DB-15, DB-9 or DIN-6 depending on the + * system, however these are all logically and electrically compatible. A mouse + * port is also present on the keyboard, but its signals are routed directly + * to/from the host. Later SGI machines use a PS/2 compatible keyboard. + * + * The emulated keyboard is a Key Tronic design with an Intel 8031 MCU and an + * Exar 22-00958-000 capacitive sensing chip. The 8-position DIP switch is not + * used by the keyboard itself, but is read and returned as configuration data + * to the host, which uses it to identify the keyboard layout. The keyboard + * protocol is RS-423 asynchronous serial at 600 baud, with 1 start, 8 data, + * odd parity and 1 stop bit. Modifier keys and LEDs are managed by the host. + * + * Part Function + * ---- -------- + * P8031AH MCS-51 series microcontroller + * D2764A 8KiB eprom + * SN74LS373N octal d-type transparent latch + * SN74LS374N octal d-type edge triggered flip-flops + * 22-00958-000C5145B capacitive sensing chip + * DS26LS32ACN quad differential line receivers + * DS3692N differential line drivers + * NE555N beep timer? + * 11059 KSSOH 11.0592 MHz crystal + * 8-pos DIP keyboard layout configuration + * + * Sources: + * - IRIX keyboard(7) manual page + * + * TODO: + * - port 1 outputs and beeper/keyclick + * + */ + +sgi_kbd_port_device::sgi_kbd_port_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, SGI_KBD_PORT, tag, owner, clock) + , device_single_card_slot_interface(mconfig, *this) + , m_rxd_handler(*this) + , m_kbd(nullptr) +{ +} + +sgi_kbd_port_device::~sgi_kbd_port_device() +{ +} + +void sgi_kbd_port_device::device_config_complete() +{ + m_kbd = get_card_device(); +} + +void sgi_kbd_port_device::device_resolve_objects() +{ + m_rxd_handler.resolve_safe(); +} + +void sgi_kbd_port_device::device_start() +{ + m_rxd_handler(1); +} + +WRITE_LINE_MEMBER(sgi_kbd_port_device::write_txd) +{ + if (m_kbd) + m_kbd->write_txd(state); +} + +device_sgi_kbd_port_interface::device_sgi_kbd_port_interface(machine_config const &mconfig, device_t &device) + : device_interface(device, "sgi_kbd") + , m_port(dynamic_cast(device.owner())) +{ +} + +device_sgi_kbd_port_interface::~device_sgi_kbd_port_interface() +{ +} + +sgi_kbd_device::sgi_kbd_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, SGI_KBD, tag, owner, clock) + , device_sgi_kbd_port_interface(mconfig, *this) + , m_mcu(*this, "mcu") + , m_matrix(*this, "col.%x", 0U) + , m_led(*this, "led.%u", 0U) + , m_col(0) + , m_row(0) + , m_p3(0) +{ +} + +/* + * MCU port 1 WIP + * -------------- + * p1.0 o scan matrix + * p1.1 o ? + * p1.2 + * p1.3 o beeper? + * p1.4 + * p1.5 + * p1.6 + * p1.7 +*/ + +enum p3_mask : u8 +{ + P3_RXD = 0x01, + P3_TXD = 0x02, + P3_INT0 = 0x04, + P3_INT1 = 0x08, + P3_T0 = 0x10, + P3_T1 = 0x20, + P3_WR = 0x40, + P3_RD = 0x80, +}; + +void sgi_kbd_device::device_add_mconfig(machine_config &config) +{ + speaker_device &speaker(SPEAKER(config, "speaker").front_center()); + + beep_device &beeper(BEEP(config, "beeper", 480)); + beeper.add_route(ALL_OUTPUTS, speaker, 0.25); + + I8031(config, m_mcu, 11.0592_MHz_XTAL); + m_mcu->set_addrmap(AS_PROGRAM, &sgi_kbd_device::map_mem); + m_mcu->set_addrmap(AS_IO, &sgi_kbd_device::map_pio); + m_mcu->port_out_cb<1>().append(FUNC(sgi_kbd_device::scan_matrix)).bit(0); + m_mcu->port_out_cb<1>().append(beeper, FUNC(beep_device::set_state)).bit(3); + m_mcu->port_out_cb<3>().append(FUNC(sgi_kbd_device::write_rxd)).bit(1); + m_mcu->port_in_cb<3>().set([this]() { return m_p3; }); +} + +void sgi_kbd_device::map_mem(address_map &map) +{ + map(0x0000, 0x1fff).rom().region("mcu", 0); +} + +void sgi_kbd_device::map_pio(address_map &map) +{ + map(0x2000, 0x2000).select(0x0f00).mirror(0x00ff).lr8( + [this](offs_t offset) + { + m_col = offset >> 8; + m_row = 0; + return 0; + }, "set_column"); + + map(0xff40, 0xff40).w(FUNC(sgi_kbd_device::led_w)); +} + +void sgi_kbd_device::device_start() +{ + save_item(NAME(m_col)); + save_item(NAME(m_row)); + save_item(NAME(m_p3)); + + m_led.resolve(); +} + +void sgi_kbd_device::scan_matrix(int state) +{ + if (!state) + { + if (BIT(m_matrix[m_col]->read(), m_row & 7)) + m_p3 &= ~P3_T0; + else + m_p3 |= P3_T0; + + m_row++; + } +} + +void sgi_kbd_device::write_txd(int state) +{ + if (state) + m_p3 |= P3_RXD; + else + m_p3 &= ~P3_RXD; +} + +void sgi_kbd_device::led_w(u8 data) +{ + /* + * bit output + * 0 L1 + * 1 Num Lock + * 2 L2 + * 3 Caps Lock + * 4 L3 + * 5 Scroll Lock + * 6 L4 + * 7 not used + */ + for (unsigned i = 0; i < 7; i++) + m_led[i] = BIT(data, i); +} + +namespace { + +INPUT_PORTS_START(sgi_kbd) + PORT_START("col.0") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') + + PORT_START("col.1") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5)) + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F7") PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7)) + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F9") PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9)) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F11") PORT_CODE(KEYCODE_F11) PORT_CHAR(UCHAR_MAMEKEY(F11)) + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Print Screen") PORT_CODE(KEYCODE_PRTSCR) PORT_CHAR(UCHAR_MAMEKEY(PRTSCR)) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Pause") PORT_CODE(KEYCODE_PAUSE) + + PORT_START("col.2") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@') + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') + + PORT_START("col.3") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~') + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Tab") PORT_CODE(KEYCODE_TAB) PORT_CHAR(9) + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Caps Lock") PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L Shift") PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) + + PORT_START("col.4") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Esc") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6)) + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F8") PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8)) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F10") PORT_CODE(KEYCODE_F10) PORT_CHAR(UCHAR_MAMEKEY(F10)) + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F12") PORT_CODE(KEYCODE_F12) PORT_CHAR(UCHAR_MAMEKEY(F12)) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Scroll Lock") PORT_CODE(KEYCODE_SCRLOCK) PORT_CHAR(UCHAR_MAMEKEY(SCRLOCK)) + + PORT_START("col.5") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^') + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&') + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') + + PORT_START("col.6") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*') + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(') + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') + + PORT_START("col.7") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(')') + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_') + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{') + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"') + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':') + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("R Shift") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_MAMEKEY(RSHIFT)) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') + + PORT_START("col.8") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+') + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Backspace") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|') + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}') + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Enter") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED) + + PORT_START("col.9") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Home") PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME)) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Insert") PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Delete") PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL)) + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("End") PORT_CODE(KEYCODE_END) PORT_CHAR(UCHAR_MAMEKEY(END)) + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Page Up") PORT_CODE(KEYCODE_PGUP) PORT_CHAR(UCHAR_MAMEKEY(PGUP)) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Page Down") PORT_CODE(KEYCODE_PGDN) PORT_CHAR(UCHAR_MAMEKEY(PGDN)) + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 0") PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD)) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Up") PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) + + PORT_START("col.a") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L Control") PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL)) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L Alt") PORT_CODE(KEYCODE_LALT) PORT_CHAR(UCHAR_MAMEKEY(LALT)) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("R Alt") PORT_CODE(KEYCODE_RALT) PORT_CHAR(UCHAR_MAMEKEY(RALT)) + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Right") PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("R Control") PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(RCONTROL)) + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Left") PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Down") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) + + PORT_START("col.b") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Num Lock") PORT_CODE(KEYCODE_NUMLOCK) PORT_CHAR(UCHAR_MAMEKEY(NUMLOCK)) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP /") PORT_CODE(KEYCODE_SLASH_PAD) PORT_CHAR(UCHAR_MAMEKEY(SLASH_PAD)) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 8") PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD)) + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 7") PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD)) + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 5") PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD)) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 4") PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD)) + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 2") PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD)) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 1") PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD)) + + PORT_START("col.c") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP *") PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR(UCHAR_MAMEKEY(ASTERISK)) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP -") PORT_CODE(KEYCODE_MINUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD)) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP +") PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(PLUS_PAD)) + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 9") PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD)) + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Enter") PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD)) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 6") PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD)) + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP .") PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD)) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("KP 3") PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD)) + + PORT_START("col.d") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED) + + PORT_START("col.e") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_UNUSED) + PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED) + + PORT_START("col.f") + PORT_DIPNAME(0xff, 0x00, "Layout") + PORT_DIPSETTING(0x00, "us") // United States + PORT_DIPSETTING(0x01, "de") // Germany + PORT_DIPSETTING(0x02, "fr") // France + PORT_DIPSETTING(0x03, "it") // Italy + PORT_DIPSETTING(0x04, "dk") // Denmark + PORT_DIPSETTING(0x05, "sp") // Spain + PORT_DIPSETTING(0x06, "nw") // Norway + PORT_DIPSETTING(0x07, "sw") // Sweden + PORT_DIPSETTING(0x08, "sf") // Swiss French + PORT_DIPSETTING(0x09, "uk") // United Kingdom + PORT_DIPSETTING(0x0a, "be") // Belgium + PORT_DIPSETTING(0x0b, "sg") // Swiss German + PORT_DIPSETTING(0x0c, "nl") // Netherlands + PORT_DIPSETTING(0x0d, "fn") // Finland + PORT_DIPSETTING(0x0e, "po") // Portugal + PORT_DIPSETTING(0x0f, "gr") // Greece +INPUT_PORTS_END + +ROM_START(sgi_kbd) + ROM_REGION(0x2000, "mcu", 0) + ROM_LOAD("17159__1987__key_tronic.z6", 0x0, 0x2000, CRC(5502cb77) SHA1(a000a2b29e8629c686b29a5af22beedcc94710dc)) +ROM_END + +} // anonymous namespace + +ioport_constructor sgi_kbd_device::device_input_ports() const +{ + return INPUT_PORTS_NAME(sgi_kbd); +} + +tiny_rom_entry const *sgi_kbd_device::device_rom_region() const +{ + return ROM_NAME(sgi_kbd); +} + +void default_sgi_kbd_devices(device_slot_interface &device) +{ + device.option_add("keyboard", SGI_KBD); +} diff --git a/src/mame/sgi/kbd.h b/src/mame/sgi/kbd.h new file mode 100644 index 00000000000..a94bde185dd --- /dev/null +++ b/src/mame/sgi/kbd.h @@ -0,0 +1,97 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz, Patrick Mackinlay + +#ifndef MAME_SGI_KBD_H +#define MAME_SGI_KBD_H + +#pragma once + +#include "cpu/mcs51/mcs51.h" + +class device_sgi_kbd_port_interface; + +class sgi_kbd_port_device + : public device_t + , public device_single_card_slot_interface +{ + friend class device_sgi_kbd_port_interface; + +public: + template + sgi_kbd_port_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&opts, char const *dflt) + : sgi_kbd_port_device(mconfig, tag, owner, 0) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } + sgi_kbd_port_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock = 0); + virtual ~sgi_kbd_port_device(); + + auto rxd_handler() { return m_rxd_handler.bind(); } + DECLARE_WRITE_LINE_MEMBER(write_txd); + +protected: + virtual void device_config_complete() override; + virtual void device_resolve_objects() override; + virtual void device_start() override; + +private: + devcb_write_line m_rxd_handler; + device_sgi_kbd_port_interface *m_kbd; +}; + +class device_sgi_kbd_port_interface + : public device_interface +{ +public: + virtual DECLARE_WRITE_LINE_MEMBER(write_txd) = 0; + +protected: + device_sgi_kbd_port_interface(machine_config const &mconfig, device_t &device); + virtual ~device_sgi_kbd_port_interface() override; + + DECLARE_WRITE_LINE_MEMBER(write_rxd) { m_port->m_rxd_handler(state); } + +private: + sgi_kbd_port_device *m_port; +}; + +class sgi_kbd_device + : public device_t + , public device_sgi_kbd_port_interface +{ +public: + sgi_kbd_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock); + + virtual DECLARE_WRITE_LINE_MEMBER(write_txd) override; + +protected: + virtual void device_add_mconfig(machine_config &config) override; + virtual void device_start() override; + virtual tiny_rom_entry const *device_rom_region() const override; + virtual ioport_constructor device_input_ports() const override; + +private: + virtual void map_mem(address_map &map); + virtual void map_pio(address_map &map); + + void scan_matrix(int state); + void led_w(u8 data); + + required_device m_mcu; + required_ioport_array<16> m_matrix; + output_finder<7> m_led; + + u8 m_col; // selected matrix column + u8 m_row; // selected matrix row + u8 m_p3; // mcu port 3 input data +}; + +DECLARE_DEVICE_TYPE(SGI_KBD_PORT, sgi_kbd_port_device) +DECLARE_DEVICE_TYPE(SGI_KBD, sgi_kbd_device) + +void default_sgi_kbd_devices(device_slot_interface &device); + +#endif // MAME_SGI_KBD_H -- cgit v1.2.3