mirror of
https://github.com/holub/mame
synced 2025-10-05 08:41:31 +03:00
mbc55x: Rewrite keyboard as HLE serial device
This commit is contained in:
parent
025a252aa7
commit
43aff157dc
@ -2985,10 +2985,11 @@ files {
|
||||
MAME_DIR .. "src/mame/drivers/mbc200.cpp",
|
||||
MAME_DIR .. "src/mame/drivers/mbc55x.cpp",
|
||||
MAME_DIR .. "src/mame/includes/mbc55x.h",
|
||||
MAME_DIR .. "src/mame/machine/mbc55x.cpp",
|
||||
MAME_DIR .. "src/mame/video/mbc55x.cpp",
|
||||
MAME_DIR .. "src/mame/drivers/phc25.cpp",
|
||||
MAME_DIR .. "src/mame/includes/phc25.h",
|
||||
MAME_DIR .. "src/mame/machine/mbc55x_kbd.cpp",
|
||||
MAME_DIR .. "src/mame/machine/mbc55x_kbd.h",
|
||||
}
|
||||
|
||||
-- Don't call this project "sega" or it collides with the arcade one
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "machine/clock.h"
|
||||
#include "machine/i8087.h"
|
||||
#include "machine/input_merger.h"
|
||||
//#include "machine/mbc55x_kbd.h"
|
||||
#include "machine/mbc55x_kbd.h"
|
||||
#include "screen.h"
|
||||
#include "softlist.h"
|
||||
#include "speaker.h"
|
||||
@ -64,7 +64,7 @@ void mbc55x_state::mbc55x_iodecode(address_map &map)
|
||||
map(0x14, 0x15).mirror(0x02).rw("sio", FUNC(i8251_device::read), FUNC(i8251_device::write));
|
||||
map(0x18, 0x18).mirror(0x02).rw(m_crtc, FUNC(mc6845_device::status_r), FUNC(mc6845_device::address_w));
|
||||
map(0x19, 0x19).mirror(0x02).rw(m_crtc, FUNC(mc6845_device::register_r), FUNC(mc6845_device::register_w));
|
||||
map(0x1c, 0x1d).mirror(0x02).r(FUNC(mbc55x_state::mbc55x_kb_usart_r)).w(m_kb_uart, FUNC(i8251_device::write));
|
||||
map(0x1c, 0x1d).mirror(0x02).rw(m_kb_uart, FUNC(i8251_device::read), FUNC(i8251_device::write));
|
||||
}
|
||||
|
||||
READ8_MEMBER(mbc55x_state::iodecode_r)
|
||||
@ -144,26 +144,6 @@ WRITE_LINE_MEMBER(mbc55x_state::printer_select_w)
|
||||
}
|
||||
|
||||
|
||||
READ8_MEMBER(mbc55x_state::mbc55x_kb_usart_r)
|
||||
{
|
||||
uint8_t result = 0;
|
||||
|
||||
switch (offset)
|
||||
{
|
||||
case 0: //logerror("%s read kb_uart\n",machine().describe_context());
|
||||
result = m_kb_uart->data_r();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
result = m_kb_uart->status_r();
|
||||
if (m_keyboard.key_special & KEY_BIT_CTRL) // Parity error used to flag control down
|
||||
result |= i8251_device::I8251_STATUS_PARITY_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void mbc55x_state::set_ram_size()
|
||||
{
|
||||
address_space &space = m_maincpu->space( AS_PROGRAM );
|
||||
@ -210,22 +190,18 @@ void mbc55x_state::set_ram_size()
|
||||
void mbc55x_state::machine_reset()
|
||||
{
|
||||
set_ram_size();
|
||||
keyboard_reset();
|
||||
}
|
||||
|
||||
void mbc55x_state::machine_start()
|
||||
{
|
||||
m_printer_status = 0xff;
|
||||
|
||||
// Allocate keyscan timer
|
||||
m_keyboard.keyscan_timer=machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mbc55x_state::keyscan_callback),this));
|
||||
|
||||
m_kb_uart->write_cts(0);
|
||||
}
|
||||
|
||||
|
||||
//static INPUT_PORTS_START( mbc55x )
|
||||
//INPUT_PORTS_END
|
||||
static INPUT_PORTS_START( mbc55x )
|
||||
INPUT_PORTS_END
|
||||
|
||||
|
||||
FLOPPY_FORMATS_MEMBER( mbc55x_state::floppy_formats )
|
||||
@ -267,7 +243,8 @@ MACHINE_CONFIG_START(mbc55x_state::mbc55x)
|
||||
m_iodecode->addr_width(5);
|
||||
m_iodecode->set_addrmap(0, &mbc55x_state::mbc55x_iodecode);
|
||||
|
||||
//MBC55X_KEYBOARD(config, "keyboard");
|
||||
mbc55x_keyboard_device &keyboard(MBC55X_KEYBOARD(config, "keyboard"));
|
||||
keyboard.txd_callback().set(m_kb_uart, FUNC(i8251_device::write_rxd));
|
||||
|
||||
/* video hardware */
|
||||
screen_device &screen(SCREEN(config, SCREEN_TAG, SCREEN_TYPE_RASTER));
|
||||
|
@ -57,20 +57,6 @@
|
||||
#define RED_PLANE_TAG "red"
|
||||
#define BLUE_PLANE_TAG "blue"
|
||||
|
||||
// Keyboard
|
||||
|
||||
#define MBC55X_KEYROWS 7
|
||||
#define KEYBOARD_QUEUE_SIZE 32
|
||||
|
||||
#define KB_BITMASK 0x1000
|
||||
#define KB_SHIFTS 12
|
||||
|
||||
#define KEY_SPECIAL_TAG "KEY_SPECIAL"
|
||||
#define KEY_BIT_LSHIFT 0x01
|
||||
#define KEY_BIT_RSHIFT 0x02
|
||||
#define KEY_BIT_CTRL 0x04
|
||||
#define KEY_BIT_GRAPH 0x08
|
||||
|
||||
#define PPI8255_TAG "ppi8255"
|
||||
#define PIC8259_TAG "pic8259"
|
||||
#define PIT8253_TAG "pit8253"
|
||||
@ -80,14 +66,6 @@
|
||||
#define FDC_TAG "wd1793"
|
||||
|
||||
|
||||
struct keyboard_t
|
||||
{
|
||||
uint8_t keyrows[MBC55X_KEYROWS];
|
||||
emu_timer *keyscan_timer;
|
||||
|
||||
uint8_t key_special;
|
||||
};
|
||||
|
||||
|
||||
class mbc55x_state : public driver_device
|
||||
{
|
||||
@ -127,7 +105,6 @@ private:
|
||||
DECLARE_READ8_MEMBER(iodecode_r);
|
||||
DECLARE_WRITE8_MEMBER(iodecode_w);
|
||||
|
||||
DECLARE_READ8_MEMBER(mbc55x_kb_usart_r);
|
||||
DECLARE_READ8_MEMBER(vram_page_r);
|
||||
DECLARE_WRITE8_MEMBER(vram_page_w);
|
||||
DECLARE_READ8_MEMBER(game_io_r);
|
||||
@ -144,14 +121,11 @@ private:
|
||||
|
||||
MC6845_UPDATE_ROW(crtc_update_row);
|
||||
void mbc55x_palette(palette_device &palette) const;
|
||||
TIMER_CALLBACK_MEMBER(keyscan_callback);
|
||||
|
||||
void mbc55x_io(address_map &map);
|
||||
void mbc55x_mem(address_map &map);
|
||||
void mbc55x_iodecode(address_map &map);
|
||||
|
||||
void keyboard_reset();
|
||||
void scan_keyboard();
|
||||
void set_ram_size();
|
||||
|
||||
required_device<mc6845_device> m_crtc;
|
||||
@ -171,13 +145,9 @@ private:
|
||||
uint8_t m_vram_page;
|
||||
uint8_t m_printer_status;
|
||||
|
||||
keyboard_t m_keyboard;
|
||||
|
||||
void video_debug(int ref, const std::vector<std::string> ¶ms);
|
||||
};
|
||||
|
||||
INPUT_PORTS_EXTERN(mbc55x);
|
||||
|
||||
/*----------- defined in machine/mbc55x.c -----------*/
|
||||
|
||||
/* Memory controller */
|
||||
|
@ -1,247 +0,0 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Phill Harvey-Smith
|
||||
/*
|
||||
machine/mbc55x.c
|
||||
|
||||
Machine driver for the Sanyo MBC-550 and MBC-555.
|
||||
|
||||
Phill Harvey-Smith
|
||||
2011-01-29.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
|
||||
#include "includes/mbc55x.h"
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
/* Defines, constants, and global variables */
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* Debugging */
|
||||
|
||||
#define LOG_KEYBOARD 1
|
||||
|
||||
|
||||
/*
|
||||
Keyboard emulation
|
||||
|
||||
*/
|
||||
|
||||
INPUT_PORTS_START( mbc55x )
|
||||
PORT_START("KEY0") /* Key row 0 scancodes 00..07 */
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1')
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) PORT_CHAR('2')
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) PORT_CHAR('3')
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) PORT_CHAR('4')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) PORT_CHAR('5')
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) PORT_CHAR('6')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7) PORT_CHAR('7')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) PORT_CHAR('8')
|
||||
|
||||
PORT_START("KEY1") /* Key row 1 scancodes 08..0F */
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9) PORT_CHAR('9')
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) PORT_CHAR('0')
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-')
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("=") PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("BSLASH") PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\')
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) PORT_CHAR('Q')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W) PORT_CHAR('W')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) PORT_CHAR('E')
|
||||
|
||||
PORT_START("KEY2") /* Key row 2 scancodes 10..17 */
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R) PORT_CHAR('R')
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) PORT_CHAR('T')
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) PORT_CHAR('Y')
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U) PORT_CHAR('U')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I) PORT_CHAR('I')
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O) PORT_CHAR('O')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) PORT_CHAR('P')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("[") PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[')
|
||||
|
||||
|
||||
PORT_START("KEY3") /* Key row 3 scancodes 18..1F */
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("]") PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']')
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) PORT_CHAR('A')
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) PORT_CHAR('S')
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) PORT_CHAR('D')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) PORT_CHAR('F')
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) PORT_CHAR('G')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H) PORT_CHAR('H')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J) PORT_CHAR('J')
|
||||
|
||||
PORT_START("KEY4") /* Key row 4 scancodes 20..27 */
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K) PORT_CHAR('K')
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) PORT_CHAR('L')
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(";") PORT_CODE(KEYCODE_COLON) PORT_CHAR(';')
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("TILDE") PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("#") PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('#')
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(0x0D)
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) PORT_CHAR('Z')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X) PORT_CHAR('X')
|
||||
|
||||
|
||||
PORT_START("KEY5") /* Key row 5 scancodes 28..2F */
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('C')
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V) PORT_CHAR('V')
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) PORT_CHAR('B')
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N) PORT_CHAR('N')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) PORT_CHAR('M')
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(".") PORT_CODE(KEYCODE_STOP) PORT_CHAR('.')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("/") PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/')
|
||||
|
||||
PORT_START("KEY6") /* Key row 6 scancodes 30..37 */
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SPACE") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(0x08)
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
|
||||
#if 0
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("BACKSLASH") PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\')
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LSHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
|
||||
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) // Ether control
|
||||
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RSHIFT") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_2)
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("PRSCR") PORT_CODE(KEYCODE_ASTERISK) PORT_CHAR('*')
|
||||
|
||||
PORT_START("KEY7") /* Key row 7 scancodes 38..3F */
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ALT") PORT_CODE(KEYCODE_LALT) PORT_CODE(KEYCODE_RALT)
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CAPS") PORT_CODE(KEYCODE_CAPSLOCK)
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1)
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2)
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3)
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4)
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5)
|
||||
|
||||
PORT_START("KEY8") /* Key row 8 scancodes 40..47 */
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F6)
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F7") PORT_CODE(KEYCODE_F7)
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F8") PORT_CODE(KEYCODE_F8)
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F9") PORT_CODE(KEYCODE_F9)
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F10") PORT_CODE(KEYCODE_F10)
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NUMLK") PORT_CODE(KEYCODE_NUMLOCK)
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SCRLK") PORT_CODE(KEYCODE_SCRLOCK)
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP7") PORT_CODE(KEYCODE_7_PAD) PORT_CHAR('7')
|
||||
|
||||
PORT_START("KEY9") /* Key row 9 scancodes 48..4F */
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP8") PORT_CODE(KEYCODE_8_PAD) //PORT_CHAR('8')
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP9") PORT_CODE(KEYCODE_9_PAD) //PORT_CHAR('9')
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP-") PORT_CODE(KEYCODE_MINUS_PAD) //PORT_CHAR('-')
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP4") PORT_CODE(KEYCODE_4_PAD) //PORT_CHAR('4')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP5") PORT_CODE(KEYCODE_5_PAD) //PORT_CHAR('5')
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP6") PORT_CODE(KEYCODE_6_PAD) //PORT_CHAR('6')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP+") PORT_CODE(KEYCODE_PLUS_PAD) //PORT_CHAR('+')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP1") PORT_CODE(KEYCODE_1_PAD) //PORT_CHAR('1')
|
||||
|
||||
PORT_START("KEY10") /* Key row 10 scancodes 50..57 */
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP2") PORT_CODE(KEYCODE_2_PAD) //PORT_CHAR('2')
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP3") PORT_CODE(KEYCODE_3_PAD) //PORT_CHAR('3')
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP0") PORT_CODE(KEYCODE_0_PAD) //PORT_CHAR('0')
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP.") PORT_CODE(KEYCODE_DEL_PAD) //PORT_CHAR('.')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
//PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP5") PORT_CODE(KEYCODE_5_PAD) PORT_CHAR('5')
|
||||
//PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP6") PORT_CODE(KEYCODE_6_PAD) PORT_CHAR('6')
|
||||
//PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP+") PORT_CODE(KEYCODE_PLUS_PAD) PORT_CHAR('+')
|
||||
//PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("KP1") PORT_CODE(KEYCODE_1_PAD) PORT_CHAR('1')
|
||||
#endif
|
||||
|
||||
PORT_START(KEY_SPECIAL_TAG)
|
||||
PORT_BIT(KEY_BIT_LSHIFT, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("LSHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
|
||||
PORT_BIT(KEY_BIT_RSHIFT, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("RSHIFT") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_2)
|
||||
PORT_BIT(KEY_BIT_CTRL, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) // Ether control
|
||||
PORT_BIT(KEY_BIT_GRAPH, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("GRAPH") PORT_CODE(KEYCODE_LALT) PORT_CODE(KEYCODE_RALT)
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
|
||||
INPUT_PORTS_END
|
||||
|
||||
void mbc55x_state::keyboard_reset()
|
||||
{
|
||||
logerror("keyboard_reset()\n");
|
||||
|
||||
memset(m_keyboard.keyrows,0xFF,MBC55X_KEYROWS);
|
||||
m_keyboard.key_special=0;
|
||||
|
||||
// Setup timer to scan keyboard.
|
||||
m_keyboard.keyscan_timer->adjust(attotime::zero, 0, attotime::from_hz(50));
|
||||
}
|
||||
|
||||
void mbc55x_state::scan_keyboard()
|
||||
{
|
||||
uint8_t keyrow;
|
||||
uint8_t row;
|
||||
uint8_t bitno;
|
||||
uint8_t mask;
|
||||
|
||||
char key;
|
||||
static const char *const keynames[] =
|
||||
{
|
||||
"KEY0", "KEY1", "KEY2", "KEY3", "KEY4",
|
||||
"KEY5", "KEY6", "KEY7", "KEY8", "KEY9",
|
||||
"KEY10"
|
||||
};
|
||||
|
||||
static const char keyvalues_normal[MBC55X_KEYROWS][8] =
|
||||
{
|
||||
{ '1', '2', '3', '4' , '5', '6', '7', '8' },
|
||||
{ '9', '0', '-', '=', '\\', 'q', 'w', 'e' },
|
||||
{ 'r', 't', 'y', 'u', 'i', 'o', 'p', '[' },
|
||||
{ ']', 'a', 's', 'd', 'f', 'g', 'h', 'j' },
|
||||
{ 'k', 'l', ';', '\'', '`', 0x0d, 'z', 'x' },
|
||||
{ 'c', 'v', 'b', 'n', 'm', ',', '.', '/', },
|
||||
{ ' ', 0x08, ' ', ' ', ' ', ' ', ' ', ' ', }
|
||||
|
||||
};
|
||||
|
||||
static const char keyvalues_shift[MBC55X_KEYROWS][8] =
|
||||
{
|
||||
{ '!', '@', '#', '$' , '%', '^', '&', '*' },
|
||||
{ '(', ')', '_', '+', '|', 'Q', 'W', 'E' },
|
||||
{ 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{' },
|
||||
{ '}', 'A', 'S', 'D', 'F', 'G', 'H', 'J' },
|
||||
{ 'K', 'L', ':', '"', '~', 0x0d, 'Z', 'X' },
|
||||
{ 'C', 'V', 'B', 'N', 'M', ',', '?', '/' },
|
||||
{ ' ', 0x08, ' ', ' ', ' ', ' ', ' ', ' ' }
|
||||
};
|
||||
|
||||
// First read shift, control and graph
|
||||
|
||||
m_keyboard.key_special = ioport(KEY_SPECIAL_TAG)->read();
|
||||
|
||||
for(row=0; row<MBC55X_KEYROWS; row++)
|
||||
{
|
||||
keyrow = ioport(keynames[row])->read();
|
||||
|
||||
for(mask=0x80, bitno=7;mask>0;mask=mask>>1, bitno-=1)
|
||||
{
|
||||
if(!(keyrow & mask) && (m_keyboard.keyrows[row] & mask))
|
||||
{
|
||||
if(m_keyboard.key_special & (KEY_BIT_LSHIFT | KEY_BIT_RSHIFT))
|
||||
key=keyvalues_shift[row][bitno];
|
||||
else
|
||||
key=keyvalues_normal[row][bitno];
|
||||
|
||||
if (LOG_KEYBOARD) logerror("keypress %c\n",key);
|
||||
m_kb_uart->receive_character(key);
|
||||
}
|
||||
}
|
||||
|
||||
m_keyboard.keyrows[row]=keyrow;
|
||||
}
|
||||
}
|
||||
|
||||
TIMER_CALLBACK_MEMBER(mbc55x_state::keyscan_callback)
|
||||
{
|
||||
scan_keyboard();
|
||||
}
|
292
src/mame/machine/mbc55x_kbd.cpp
Normal file
292
src/mame/machine/mbc55x_kbd.cpp
Normal file
@ -0,0 +1,292 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:AJR
|
||||
/*******************************************************************************
|
||||
|
||||
Serial keyboard emulation for Sanyo MBC-55x.
|
||||
|
||||
The key matrix is based on schematics, though the MCU is not yet dumped.
|
||||
Many keys are not yet implemented, as are the Lock and Graph key LEDs. The
|
||||
unknown jumper may select an international key layout.
|
||||
|
||||
The interface has only one unidirectional communication line. The reset
|
||||
switch appears to be part of the main unit rather than the keyboard.
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "machine/mbc55x_kbd.h"
|
||||
|
||||
#include "cpu/mcs48/mcs48.h"
|
||||
#include "machine/keyboard.ipp"
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE TYPE DEFINITION
|
||||
//**************************************************************************
|
||||
|
||||
DEFINE_DEVICE_TYPE(MBC55X_KEYBOARD, mbc55x_keyboard_device, "mbc55x_kbd", "MBC-55x Keyboard")
|
||||
|
||||
mbc55x_keyboard_device::mbc55x_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
|
||||
: device_t(mconfig, MBC55X_KEYBOARD, tag, owner, clock)
|
||||
, device_matrix_keyboard_interface(mconfig, *this, "Y0", "Y1", "Y2", "Y3", "Y4", "Y5", "Y6", "Y7", "Y8", "Y9", "Y10", "Y11")
|
||||
, device_serial_interface(mconfig, *this)
|
||||
, m_modifiers(*this, "BUS")
|
||||
, m_txd_callback(*this)
|
||||
{
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
// INPUT MATRIX
|
||||
//**************************************************************************
|
||||
|
||||
static INPUT_PORTS_START(mbc55x_kbd)
|
||||
PORT_START("Y0")
|
||||
PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('\\') PORT_CHAR('|') PORT_CODE(KEYCODE_BACKSLASH)
|
||||
PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR(0x1b) PORT_CODE(KEYCODE_ESC)
|
||||
PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR(UCHAR_MAMEKEY(NUMLOCK)) PORT_CODE(KEYCODE_NUMLOCK)
|
||||
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('1') PORT_CHAR('!') PORT_CODE(KEYCODE_1)
|
||||
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('q') PORT_CHAR('Q') PORT_CODE(KEYCODE_Q)
|
||||
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('a') PORT_CHAR('A') PORT_CODE(KEYCODE_A)
|
||||
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('<') PORT_CHAR('>') PORT_CODE(KEYCODE_BACKSLASH2)
|
||||
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("PF1 PF6") PORT_CHAR(UCHAR_MAMEKEY(F1)) PORT_CHAR(UCHAR_MAMEKEY(F6)) PORT_CODE(KEYCODE_F1)
|
||||
|
||||
PORT_START("Y1")
|
||||
PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("\xe2\x87\x90") PORT_CHAR(0x08) PORT_CODE(KEYCODE_BACKSPACE)
|
||||
PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("\xe2\x86\xb9") PORT_CHAR(0x09) PORT_CODE(KEYCODE_TAB)
|
||||
PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Space") PORT_CHAR(' ') PORT_CODE(KEYCODE_SPACE)
|
||||
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('2') PORT_CHAR('@') PORT_CODE(KEYCODE_2)
|
||||
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('w') PORT_CHAR('W') PORT_CODE(KEYCODE_W)
|
||||
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('s') PORT_CHAR('S') PORT_CODE(KEYCODE_S)
|
||||
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('z') PORT_CHAR('Z') PORT_CODE(KEYCODE_Z)
|
||||
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("PF2 PF7") PORT_CHAR(UCHAR_MAMEKEY(F2)) PORT_CHAR(UCHAR_MAMEKEY(F7)) PORT_CODE(KEYCODE_F2)
|
||||
|
||||
PORT_START("Y2")
|
||||
PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Del Ins") PORT_CHAR(UCHAR_MAMEKEY(DEL)) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) PORT_CODE(KEYCODE_DEL)
|
||||
PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("\xe2\x8f\x8e") PORT_CHAR(0x0d) PORT_CODE(KEYCODE_ENTER)
|
||||
PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Lock") PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) PORT_CODE(KEYCODE_LALT)
|
||||
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('3') PORT_CHAR('#') PORT_CODE(KEYCODE_3)
|
||||
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('e') PORT_CHAR('E') PORT_CODE(KEYCODE_E)
|
||||
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('d') PORT_CHAR('D') PORT_CODE(KEYCODE_D)
|
||||
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('x') PORT_CHAR('X') PORT_CODE(KEYCODE_X)
|
||||
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("PF3 PF8") PORT_CHAR(UCHAR_MAMEKEY(F3)) PORT_CHAR(UCHAR_MAMEKEY(F8)) PORT_CODE(KEYCODE_F3)
|
||||
|
||||
PORT_START("Y3")
|
||||
PORT_BIT(0xc0, IP_ACTIVE_HIGH, IPT_UNUSED)
|
||||
PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Graph") PORT_CODE(KEYCODE_RALT)
|
||||
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('4') PORT_CHAR('$') PORT_CODE(KEYCODE_4)
|
||||
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('r') PORT_CHAR('R') PORT_CODE(KEYCODE_R)
|
||||
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('f') PORT_CHAR('F') PORT_CODE(KEYCODE_F)
|
||||
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('c') PORT_CHAR('C') PORT_CODE(KEYCODE_C)
|
||||
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("PF4 PF9") PORT_CHAR(UCHAR_MAMEKEY(F4)) PORT_CHAR(UCHAR_MAMEKEY(F9)) PORT_CODE(KEYCODE_F4)
|
||||
|
||||
PORT_START("Y4")
|
||||
PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED)
|
||||
PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Keypad 4 " UTF8_LEFT) PORT_CHAR(UCHAR_MAMEKEY(4_PAD)) PORT_CODE(KEYCODE_4_PAD)
|
||||
PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD)) PORT_CODE(KEYCODE_0_PAD)
|
||||
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('5') PORT_CHAR('%') PORT_CODE(KEYCODE_5)
|
||||
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('t') PORT_CHAR('T') PORT_CODE(KEYCODE_T)
|
||||
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('g') PORT_CHAR('G') PORT_CODE(KEYCODE_G)
|
||||
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('v') PORT_CHAR('V') PORT_CODE(KEYCODE_V)
|
||||
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("PF5 PF10") PORT_CHAR(UCHAR_MAMEKEY(F5)) PORT_CHAR(UCHAR_MAMEKEY(F10)) PORT_CODE(KEYCODE_F5)
|
||||
|
||||
PORT_START("Y5")
|
||||
PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED)
|
||||
PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Keypad 5 " UTF8_DOWN) PORT_CHAR(UCHAR_MAMEKEY(5_PAD)) PORT_CODE(KEYCODE_5_PAD)
|
||||
PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR(UCHAR_MAMEKEY(00_PAD)) PORT_CODE(KEYCODE_00_PAD)
|
||||
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('6') PORT_CHAR('^') PORT_CODE(KEYCODE_6)
|
||||
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('y') PORT_CHAR('Y') PORT_CODE(KEYCODE_Y)
|
||||
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('h') PORT_CHAR('H') PORT_CODE(KEYCODE_H)
|
||||
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('b') PORT_CHAR('B') PORT_CODE(KEYCODE_B)
|
||||
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR(UCHAR_MAMEKEY(EQUALS_PAD)) PORT_CODE(KEYCODE_EQUALS_PAD)
|
||||
|
||||
PORT_START("Y6")
|
||||
PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED)
|
||||
PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Keypad 6 " UTF8_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(6_PAD)) PORT_CODE(KEYCODE_6_PAD)
|
||||
PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD)) PORT_CODE(KEYCODE_DEL_PAD)
|
||||
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('7') PORT_CHAR('$') PORT_CODE(KEYCODE_7)
|
||||
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('u') PORT_CHAR('U') PORT_CODE(KEYCODE_U)
|
||||
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('j') PORT_CHAR('J') PORT_CODE(KEYCODE_J)
|
||||
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('n') PORT_CHAR('N') PORT_CODE(KEYCODE_N)
|
||||
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR(UCHAR_MAMEKEY(SLASH_PAD)) PORT_CODE(KEYCODE_SLASH_PAD)
|
||||
|
||||
PORT_START("Y7")
|
||||
PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED)
|
||||
PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Keypad 7 \xe2\x86\x96") PORT_CHAR(UCHAR_MAMEKEY(7_PAD)) PORT_CODE(KEYCODE_7_PAD)
|
||||
PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Keypad 1 LF") PORT_CHAR(UCHAR_MAMEKEY(1_PAD)) PORT_CODE(KEYCODE_1_PAD)
|
||||
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('8') PORT_CHAR('*') PORT_CODE(KEYCODE_8)
|
||||
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('i') PORT_CHAR('I') PORT_CODE(KEYCODE_I)
|
||||
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('k') PORT_CHAR('K') PORT_CODE(KEYCODE_K)
|
||||
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('m') PORT_CHAR('M') PORT_CODE(KEYCODE_M)
|
||||
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR(UCHAR_MAMEKEY(ASTERISK)) PORT_CODE(KEYCODE_ASTERISK)
|
||||
|
||||
PORT_START("Y8")
|
||||
PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED)
|
||||
PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Keypad 8 " UTF8_UP) PORT_CHAR(UCHAR_MAMEKEY(8_PAD)) PORT_CODE(KEYCODE_8_PAD)
|
||||
PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD)) PORT_CODE(KEYCODE_2_PAD)
|
||||
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('9') PORT_CHAR('(') PORT_CODE(KEYCODE_9)
|
||||
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('o') PORT_CHAR('O') PORT_CODE(KEYCODE_O)
|
||||
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('l') PORT_CHAR('L') PORT_CODE(KEYCODE_L)
|
||||
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(", ,") PORT_CHAR(',') PORT_CODE(KEYCODE_COMMA)
|
||||
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Break") PORT_CODE(KEYCODE_F15)
|
||||
|
||||
PORT_START("Y9")
|
||||
PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_UNUSED)
|
||||
PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Keypad 9 Pg Up") PORT_CHAR(UCHAR_MAMEKEY(9_PAD)) PORT_CODE(KEYCODE_9_PAD)
|
||||
PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Keypad 3 Pg Dn") PORT_CHAR(UCHAR_MAMEKEY(3_PAD)) PORT_CODE(KEYCODE_3_PAD)
|
||||
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('0') PORT_CHAR(')') PORT_CODE(KEYCODE_0)
|
||||
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('p') PORT_CHAR('P') PORT_CODE(KEYCODE_P)
|
||||
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR(';') PORT_CHAR(':') PORT_CODE(KEYCODE_COLON)
|
||||
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(". .") PORT_CHAR('.') PORT_CODE(KEYCODE_STOP)
|
||||
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD)) PORT_CODE(KEYCODE_F15)
|
||||
|
||||
PORT_START("Y10")
|
||||
PORT_BIT(0xe0, IP_ACTIVE_HIGH, IPT_UNUSED)
|
||||
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('-') PORT_CHAR('_') PORT_CODE(KEYCODE_MINUS)
|
||||
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('[') PORT_CHAR('{') PORT_CODE(KEYCODE_OPENBRACE)
|
||||
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('\'') PORT_CHAR('"') PORT_CODE(KEYCODE_QUOTE)
|
||||
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('/') PORT_CHAR('?') PORT_CODE(KEYCODE_SLASH)
|
||||
|
||||
PORT_START("Y11")
|
||||
PORT_BIT(0xe0, IP_ACTIVE_HIGH, IPT_UNUSED)
|
||||
PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('=') PORT_CHAR('+') PORT_CODE(KEYCODE_EQUALS)
|
||||
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR(']') PORT_CHAR('}') PORT_CODE(KEYCODE_CLOSEBRACE)
|
||||
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('`') PORT_CHAR('~') PORT_CODE(KEYCODE_TILDE) // to right of quote
|
||||
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHAR('*') PORT_CODE(KEYCODE_RCONTROL) // between slash and right shift
|
||||
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Keypad \xe2\x8f\x8e") PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD)) PORT_CODE(KEYCODE_ENTER_PAD)
|
||||
|
||||
PORT_START("BUS")
|
||||
PORT_BIT(0x8f, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CHAR(UCHAR_SHIFT_1) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT)
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Ctrl") PORT_CHAR(UCHAR_SHIFT_2) PORT_CODE(KEYCODE_LCONTROL)
|
||||
PORT_DIPNAME(0x40, 0x00, DEF_STR(Unknown)) PORT_DIPLOCATION("JP1:1")
|
||||
PORT_DIPSETTING(0x40, DEF_STR(Off))
|
||||
PORT_DIPSETTING(0x00, DEF_STR(On))
|
||||
INPUT_PORTS_END
|
||||
|
||||
ioport_constructor mbc55x_keyboard_device::device_input_ports() const
|
||||
{
|
||||
return INPUT_PORTS_NAME(mbc55x_kbd);
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
// INITIALIZATION AND HLE SERIAL INTERFACE
|
||||
//**************************************************************************
|
||||
|
||||
void mbc55x_keyboard_device::device_resolve_objects()
|
||||
{
|
||||
m_txd_callback.resolve_safe();
|
||||
}
|
||||
|
||||
void mbc55x_keyboard_device::device_start()
|
||||
{
|
||||
set_tra_rate(1230); // more or less
|
||||
}
|
||||
|
||||
void mbc55x_keyboard_device::device_reset()
|
||||
{
|
||||
start_processing(attotime::from_hz(6_MHz_XTAL / 75)); // guess
|
||||
m_txd_callback(1);
|
||||
}
|
||||
|
||||
void mbc55x_keyboard_device::tra_callback()
|
||||
{
|
||||
m_txd_callback(transmit_register_get_data_bit());
|
||||
}
|
||||
|
||||
void mbc55x_keyboard_device::tra_complete()
|
||||
{
|
||||
start_processing(attotime::from_hz(6_MHz_XTAL / 75));
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
// KEYBOARD SCAN AND DECODING
|
||||
//**************************************************************************
|
||||
|
||||
const u8 mbc55x_keyboard_device::s_code_table[2][12][8] =
|
||||
{
|
||||
{
|
||||
{ 0x00, '>', 'A', 'Q', '!', 0x00, 0x1b, '|' },
|
||||
{ 0x00, 'Z', 'S', 'W', '@', ' ', 0x00, 0x08 },
|
||||
{ 0x00, 'X', 'D', 'E', '#', 0x00, 0x0d, 0x00 },
|
||||
{ 0x00, 'C', 'F', 'R', '$', '0', '4', 0x00 },
|
||||
{ 0x00, 'V', 'G', 'T', '%', 0x00, '5', 0x00 },
|
||||
{ 0x00, 'B', 'H', 'Y', '^', '.', '6', 0x00 },
|
||||
{ 0x00, 'N', 'J', 'U', '&', '1', '7', 0x00 },
|
||||
{ 0x00, 'M', 'K', 'I', '*', '2', '8', 0x00 },
|
||||
{ 0x00, ',', 'L', 'O', '(', '3', '9', 0x00 },
|
||||
{ '-', '.', ':', 'P', ')', 0x00, 0x00, 0x00 },
|
||||
{ '+', '?', '"', '{', '_', 0x00, 0x00, 0x00 },
|
||||
{ 0x0d, '*', '~', '}', '+', 0x00, 0x00, 0x00 }
|
||||
},
|
||||
{
|
||||
{ 0x00, '<', 'a', 'q', '1', 0x00, 0x1b, '\\' },
|
||||
{ 0x00, 'z', 's', 'w', '2', ' ', 0x09, 0x08 },
|
||||
{ 0x00, 'x', 'd', 'e', '3', 0x00, 0x0d, 0x00 },
|
||||
{ 0x00, 'c', 'f', 'r', '4', '0', '4', 0x00 },
|
||||
{ 0x00, 'v', 'g', 't', '5', 0x00, '5', 0x00 },
|
||||
{ 0x00, 'b', 'h', 'y', '6', '.', '6', 0x00 },
|
||||
{ 0x00, 'n', 'j', 'u', '7', '1', '7', 0x00 },
|
||||
{ 0x00, 'm', 'k', 'i', '8', '2', '8', 0x00 },
|
||||
{ 0x00, ',', 'l', 'o', '9', '3', '9', 0x00 },
|
||||
{ '-', '.', ';', 'p', '0', 0x00, 0x00, 0x00 },
|
||||
{ '+', '?', '\'', '[', '-', 0x00, 0x00, 0x00 },
|
||||
{ 0x0d, '*', '`', ']', '=', 0x00, 0x00, 0x00 }
|
||||
}
|
||||
};
|
||||
|
||||
void mbc55x_keyboard_device::key_make(u8 row, u8 column)
|
||||
{
|
||||
send_translated(row, column);
|
||||
}
|
||||
|
||||
void mbc55x_keyboard_device::key_repeat(u8 row, u8 column)
|
||||
{
|
||||
send_translated(row, column);
|
||||
}
|
||||
|
||||
void mbc55x_keyboard_device::scan_complete()
|
||||
{
|
||||
if (!is_transmit_register_empty())
|
||||
stop_processing();
|
||||
}
|
||||
|
||||
void mbc55x_keyboard_device::send_key(u8 code, bool ctrl_active)
|
||||
{
|
||||
if (!is_transmit_register_empty())
|
||||
return;
|
||||
|
||||
// Control characters are transmitted with inverted parity
|
||||
set_data_frame(1, 8, ctrl_active ? PARITY_ODD : PARITY_EVEN, STOP_BITS_2);
|
||||
|
||||
transmit_register_setup(code);
|
||||
}
|
||||
|
||||
void mbc55x_keyboard_device::send_translated(u8 row, u8 column)
|
||||
{
|
||||
const ioport_value modifiers = m_modifiers->read();
|
||||
|
||||
u8 code = s_code_table[BIT(modifiers, 4)][row][column];
|
||||
if (code != 0)
|
||||
send_key(code, !BIT(modifiers, 5));
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
// KEYBOARD CONTROLLER CONFIGURATION
|
||||
//**************************************************************************
|
||||
|
||||
void mbc55x_keyboard_device::device_add_mconfig(machine_config &config)
|
||||
{
|
||||
I8049(config, "kbdc", 6_MHz_XTAL).set_disable();
|
||||
//kbdc.bus_in_cb().set_ioport("BUS");
|
||||
//kbdc.p1_in_cb().set(FUNC(mbc55x_keyboard_device::key_matrix_r));
|
||||
//kbdc.p2_out_cb().set(FUNC(mbc55x_keyboard_device::scan_output_w));
|
||||
}
|
||||
|
||||
ROM_START(mbc55x_kbd)
|
||||
ROM_REGION(0x0800, "kbdc", 0)
|
||||
ROM_LOAD("d8049hc.m1", 0x0000, 0x0800, NO_DUMP)
|
||||
ROM_END
|
||||
|
||||
const tiny_rom_entry *mbc55x_keyboard_device::device_rom_region() const
|
||||
{
|
||||
return ROM_NAME(mbc55x_kbd);
|
||||
}
|
64
src/mame/machine/mbc55x_kbd.h
Normal file
64
src/mame/machine/mbc55x_kbd.h
Normal file
@ -0,0 +1,64 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:AJR
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
Serial keyboard emulation for Sanyo MBC-55x.
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef MAME_MACHINE_MBC55X_KBD
|
||||
#define MAME_MACHINE_MBC55X_KBD 1
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "diserial.h"
|
||||
#include "machine/keyboard.h"
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
class mbc55x_keyboard_device : public device_t, public device_matrix_keyboard_interface<12U>, public device_serial_interface
|
||||
{
|
||||
static const u8 s_code_table[2][12][8];
|
||||
|
||||
public:
|
||||
// construction/destruction
|
||||
mbc55x_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0);
|
||||
|
||||
// configuration
|
||||
auto txd_callback() { return m_txd_callback.bind(); }
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual ioport_constructor device_input_ports() const override;
|
||||
virtual void device_resolve_objects() override;
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
virtual void device_add_mconfig(machine_config &config) override;
|
||||
virtual const tiny_rom_entry *device_rom_region() const override;
|
||||
|
||||
// device_matrix_keyboard_interface overrides
|
||||
virtual void key_make(u8 row, u8 column) override;
|
||||
virtual void key_repeat(u8 row, u8 column) override;
|
||||
virtual void scan_complete() override;
|
||||
|
||||
// device_serial_interface overrides;
|
||||
virtual void tra_callback() override;
|
||||
virtual void tra_complete() override;
|
||||
|
||||
private:
|
||||
void send_key(u8 code, bool ctrl_active);
|
||||
void send_translated(u8 row, u8 column);
|
||||
|
||||
// input ports
|
||||
required_ioport m_modifiers;
|
||||
|
||||
// output callback
|
||||
devcb_write_line m_txd_callback;
|
||||
};
|
||||
|
||||
DECLARE_DEVICE_TYPE(MBC55X_KEYBOARD, mbc55x_keyboard_device)
|
||||
|
||||
#endif // MAME_MACHINE_MBC55X_KBD
|
Loading…
Reference in New Issue
Block a user