mirror of
https://github.com/holub/mame
synced 2025-04-25 01:40:16 +03:00
f4431: Emulate keyboard, add layout for keyboard LEDs, honor cliprect for screen update
This commit is contained in:
parent
bec888712b
commit
b0ad4fcc4c
@ -29,14 +29,17 @@
|
||||
#include "emu.h"
|
||||
#include "cpu/z80/z80.h"
|
||||
#include "machine/ay31015.h"
|
||||
#include "machine/clock.h"
|
||||
#include "machine/er1400.h"
|
||||
#include "machine/ripple_counter.h"
|
||||
#include "machine/z80ctc.h"
|
||||
#include "machine/z80sio.h"
|
||||
#include "video/tms9927.h"
|
||||
#include "f4431_kbd.h"
|
||||
#include "emupal.h"
|
||||
#include "screen.h"
|
||||
|
||||
#include "f4431.lh"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
@ -158,27 +161,23 @@ uint32_t f4431_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap,
|
||||
{
|
||||
if (m_display_enabled)
|
||||
{
|
||||
for (int y = 0; y < 25; y++)
|
||||
for (int i = cliprect.min_y; i <= cliprect.max_y; i++)
|
||||
{
|
||||
for (int x = 0; x < 80; x++)
|
||||
{
|
||||
uint8_t code = m_ascii[y * 80 + x];
|
||||
uint8_t code = m_ascii[(i / 10) * 80 + x];
|
||||
uint8_t data = m_chargen[((i % 10) << 7) | code];
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
uint8_t data = m_chargen[(i << 7) | code];
|
||||
|
||||
bitmap.pix(y * 10 + i, x * 10 + 0) = BIT(data, 7) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(y * 10 + i, x * 10 + 1) = (BIT(data, 7) || BIT(data, 6)) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(y * 10 + i, x * 10 + 2) = (BIT(data, 6) || BIT(data, 5)) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(y * 10 + i, x * 10 + 3) = (BIT(data, 5) || BIT(data, 4)) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(y * 10 + i, x * 10 + 4) = (BIT(data, 4) || BIT(data, 3)) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(y * 10 + i, x * 10 + 5) = (BIT(data, 3) || BIT(data, 2)) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(y * 10 + i, x * 10 + 6) = (BIT(data, 2) || BIT(data, 1)) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(y * 10 + i, x * 10 + 7) = (BIT(data, 1) || BIT(data, 0)) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(y * 10 + i, x * 10 + 8) = BIT(data, 0) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(y * 10 + i, x * 10 + 9) = rgb_t::black();
|
||||
}
|
||||
bitmap.pix(i, x * 10 + 0) = BIT(data, 7) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(i, x * 10 + 1) = (BIT(data, 7) || BIT(data, 6)) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(i, x * 10 + 2) = (BIT(data, 6) || BIT(data, 5)) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(i, x * 10 + 3) = (BIT(data, 5) || BIT(data, 4)) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(i, x * 10 + 4) = (BIT(data, 4) || BIT(data, 3)) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(i, x * 10 + 5) = (BIT(data, 3) || BIT(data, 2)) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(i, x * 10 + 6) = (BIT(data, 2) || BIT(data, 1)) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(i, x * 10 + 7) = (BIT(data, 1) || BIT(data, 0)) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(i, x * 10 + 8) = BIT(data, 0) ? rgb_t::white() : rgb_t::black();
|
||||
bitmap.pix(i, x * 10 + 9) = rgb_t::black();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -192,7 +191,8 @@ uint32_t f4431_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap,
|
||||
|
||||
void f4431_state::brightness_w(uint8_t data)
|
||||
{
|
||||
logerror("brightness_w: %02x\n", data);
|
||||
if (0)
|
||||
logerror("brightness_w: %02x\n", data);
|
||||
}
|
||||
|
||||
|
||||
@ -250,6 +250,15 @@ void f4431_state::latch_w(uint8_t data)
|
||||
|
||||
void f4431_state::machine_start()
|
||||
{
|
||||
// set uart control lines
|
||||
m_uart->write_cs(1);
|
||||
m_uart->write_np(1);
|
||||
m_uart->write_tsb(1);
|
||||
m_uart->write_nb2(1);
|
||||
m_uart->write_nb1(1);
|
||||
m_uart->write_eps(1);
|
||||
m_uart->write_swe(0);
|
||||
|
||||
// register for save states
|
||||
save_item(NAME(m_display_enabled));
|
||||
save_item(NAME(m_nmi_disabled));
|
||||
@ -310,6 +319,18 @@ void f4431_state::f4431(machine_config &config)
|
||||
m_vtc->hsyn_callback().set(m_ctc, FUNC(z80ctc_device::trg3));
|
||||
|
||||
AY31015(config, m_uart);
|
||||
m_uart->set_auto_rdav(true);
|
||||
m_uart->write_so_callback().set("kbd", FUNC(f4431_kbd_device::rx_w));
|
||||
|
||||
ripple_counter_device &uart_clk(RIPPLE_COUNTER(config, "uart_clk", 4_MHz_XTAL / 13));
|
||||
uart_clk.set_stages(12);
|
||||
uart_clk.count_out_cb().set(m_uart, FUNC(ay31015_device::write_rcp)).bit(4); // Q4
|
||||
uart_clk.count_out_cb().append(m_uart, FUNC(ay31015_device::write_tcp)).bit(4); // Q4
|
||||
|
||||
f4431_kbd_device &kbd(F4431_KBD(config, "kbd"));
|
||||
kbd.tx_handler().set(m_uart, FUNC(ay31015_device::write_si));
|
||||
|
||||
config.set_default_layout(layout_f4431);
|
||||
}
|
||||
|
||||
|
||||
@ -342,9 +363,6 @@ ROM_START( f4431 )
|
||||
|
||||
ROM_REGION(0x20, "prom", 0)
|
||||
ROM_LOAD("11419960-00_4431.d19", 0x00, 0x20, CRC(daae0c28) SHA1(58c55b8b9d4161a9d38259a4375cf19799ea0b7a))
|
||||
|
||||
ROM_REGION(0x800, "keyb", 0)
|
||||
ROM_LOAD("11419660-00_kb31.u3", 0x000, 0x800, CRC(45b90749) SHA1(91d0ef181fe05e9474871e26dc75c313cb67c337))
|
||||
ROM_END
|
||||
|
||||
|
||||
|
334
src/mame/facit/f4431_kbd.cpp
Normal file
334
src/mame/facit/f4431_kbd.cpp
Normal file
@ -0,0 +1,334 @@
|
||||
// license: BSD-3-Clause
|
||||
// copyright-holders: Dirk Best
|
||||
/***************************************************************************
|
||||
|
||||
Facit F4431 keyboard
|
||||
|
||||
TOOD:
|
||||
- Speaker sounds weird
|
||||
- Verify country codes
|
||||
|
||||
Notes:
|
||||
- Also supports F4420 and F4430?
|
||||
- MCU P2 is never read?
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "f4431_kbd.h"
|
||||
#include "speaker.h"
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
DEFINE_DEVICE_TYPE(F4431_KBD, f4431_kbd_device, "f4431_kbd", "Facit F4431 keyboard")
|
||||
|
||||
//-------------------------------------------------
|
||||
// address maps
|
||||
//-------------------------------------------------
|
||||
|
||||
void f4431_kbd_device::mem_map(address_map &map)
|
||||
{
|
||||
map(0x000, 0x7ff).rom().region("mcu", 0);
|
||||
}
|
||||
|
||||
void f4431_kbd_device::io_map(address_map &map)
|
||||
{
|
||||
map(0x00, 0xff).rw(FUNC(f4431_kbd_device::data_r), FUNC(f4431_kbd_device::data_w));
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// rom_region - device-specific ROM region
|
||||
//-------------------------------------------------
|
||||
|
||||
ROM_START( firmware )
|
||||
ROM_REGION(0x800, "mcu", 0)
|
||||
ROM_LOAD("11419660-00_kb31.u3", 0x000, 0x800, CRC(45b90749) SHA1(91d0ef181fe05e9474871e26dc75c313cb67c337))
|
||||
ROM_END
|
||||
|
||||
const tiny_rom_entry *f4431_kbd_device::device_rom_region() const
|
||||
{
|
||||
return ROM_NAME(firmware);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_add_mconfig - add device configuration
|
||||
//-------------------------------------------------
|
||||
|
||||
void f4431_kbd_device::device_add_mconfig(machine_config &config)
|
||||
{
|
||||
I8035(config, m_mcu, 6_MHz_XTAL);
|
||||
m_mcu->set_addrmap(AS_PROGRAM, &f4431_kbd_device::mem_map);
|
||||
m_mcu->set_addrmap(AS_IO, &f4431_kbd_device::io_map);
|
||||
m_mcu->p1_out_cb().set(FUNC(f4431_kbd_device::p1_w));
|
||||
m_mcu->p2_in_cb().set(FUNC(f4431_kbd_device::p2_r));
|
||||
m_mcu->p2_out_cb().set(FUNC(f4431_kbd_device::p2_w));
|
||||
m_mcu->t0_in_cb().set(FUNC(f4431_kbd_device::t0_r));
|
||||
|
||||
SPEAKER(config, "mono").front_center();
|
||||
|
||||
SPEAKER_SOUND(config, m_speaker);
|
||||
m_speaker->add_route(ALL_OUTPUTS, "mono", 1.00);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// input_ports - device-specific input ports
|
||||
//-------------------------------------------------
|
||||
|
||||
static INPUT_PORTS_START( keyboard )
|
||||
PORT_START("switches")
|
||||
PORT_DIPNAME(0x03, 0x02, "Mode")
|
||||
PORT_DIPLOCATION("W:1,2")
|
||||
PORT_DIPSETTING( 0x03, "Invalid?")
|
||||
PORT_DIPSETTING( 0x02, "Facit 4431?")
|
||||
PORT_DIPSETTING( 0x01, "Facit 4430?")
|
||||
PORT_DIPSETTING( 0x00, "Facit 4420?")
|
||||
|
||||
PORT_START("A0")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SCRLOCK) PORT_CHAR(UCHAR_MAMEKEY(SCRLOCK)) PORT_NAME("No Scroll")
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) PORT_TOGGLE
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_SHIFT_2)
|
||||
PORT_DIPUNUSED_DIPLOC(0x10, 0x10, "W:3")
|
||||
PORT_DIPNAME(0xe0, 0xe0, "Country Code")
|
||||
PORT_DIPLOCATION("W:4,5,6")
|
||||
PORT_DIPSETTING( 0xe0, "U.S. (ASCII)")
|
||||
PORT_DIPSETTING( 0xc0, "Sweden/Finland")
|
||||
PORT_DIPSETTING( 0xa0, "Germany")
|
||||
PORT_DIPSETTING( 0x80, "Denmark")
|
||||
PORT_DIPSETTING( 0x60, "Britain")
|
||||
PORT_DIPSETTING( 0x40, "Spain")
|
||||
PORT_DIPSETTING( 0x20, "France")
|
||||
PORT_DIPSETTING( 0x00, "Norway")
|
||||
|
||||
PORT_START("A1")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"')
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) PORT_NAME("PF3")
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED) // alternate for 'Set Up' key (double width keycap)
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
|
||||
|
||||
PORT_START("A2")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS_PAD) PORT_CHAR(UCHAR_MAMEKEY(MINUS_PAD))
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR(')')
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) PORT_NAME("\xe2\x86\x90")
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
|
||||
|
||||
PORT_START("A3")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P')
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) PORT_NAME("PF1")
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_')
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) PORT_NAME("\xe2\x86\x92")
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
|
||||
|
||||
PORT_START("A4")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL))
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) PORT_NAME("PF2")
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|') // actually ¦
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
|
||||
PORT_START("A5")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(UCHAR_MAMEKEY(ENTER))
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD))
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD))
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD))
|
||||
|
||||
PORT_START("A6")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD))
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
|
||||
PORT_START("A7")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD))
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*')
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) PORT_NAME("\xe2\x86\x91")
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&')
|
||||
|
||||
PORT_START("A8")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_RCONTROL) PORT_NAME("Line Feed")
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) PORT_NAME("PF4")
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR(9)
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
|
||||
|
||||
PORT_START("A9")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}')
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD))
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('~') PORT_CHAR('`')
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CANCEL) PORT_CHAR(UCHAR_MAMEKEY(CANCEL)) PORT_NAME("Break")
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@')
|
||||
|
||||
PORT_START("A10")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD))
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD))
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(')
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_NAME("\xe2\x86\x93")
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^')
|
||||
|
||||
PORT_START("A11")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('[') PORT_CHAR('{')
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD))
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+')
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E')
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) PORT_NAME("Back Space")
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F')
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V')
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') // or £
|
||||
|
||||
PORT_START("A12")
|
||||
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD))
|
||||
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA_PAD) PORT_CHAR(UCHAR_MAMEKEY(COMMA_PAD))
|
||||
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL_PAD) PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD))
|
||||
PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD))
|
||||
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F5) PORT_NAME("Set Up")
|
||||
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED)
|
||||
INPUT_PORTS_END
|
||||
|
||||
ioport_constructor f4431_kbd_device::device_input_ports() const
|
||||
{
|
||||
return INPUT_PORTS_NAME(keyboard);
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// f4431_kbd_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
f4431_kbd_device::f4431_kbd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||
device_t(mconfig, F4431_KBD, tag, owner, clock),
|
||||
m_mcu(*this, "mcu"),
|
||||
m_speaker(*this, "speaker"),
|
||||
m_keys(*this, "A%u", 0U),
|
||||
m_switches(*this, "switches"),
|
||||
m_leds(*this, "key_led%u", 0U),
|
||||
m_tx_handler(*this)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void f4431_kbd_device::device_start()
|
||||
{
|
||||
// resolve callbacks
|
||||
m_tx_handler.resolve_safe();
|
||||
|
||||
// resolve artwork callback
|
||||
m_leds.resolve();
|
||||
|
||||
// register for save states
|
||||
save_item(NAME(m_rx));
|
||||
save_item(NAME(m_kbd_p2));
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_reset - device-specific reset
|
||||
//-------------------------------------------------
|
||||
|
||||
void f4431_kbd_device::device_reset()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// IMPLEMENTATION
|
||||
//**************************************************************************
|
||||
|
||||
void f4431_kbd_device::rx_w(int state)
|
||||
{
|
||||
m_rx = state;
|
||||
}
|
||||
|
||||
uint8_t f4431_kbd_device::data_r(offs_t offset)
|
||||
{
|
||||
uint16_t addr = ((m_kbd_p2 & 0x1f) << 8) | offset;
|
||||
uint8_t data = 0xff;
|
||||
|
||||
for (int i = 0; i < 13; i++)
|
||||
if (BIT(addr, i))
|
||||
data &= m_keys[i]->read();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void f4431_kbd_device::data_w(offs_t offset, uint8_t data)
|
||||
{
|
||||
m_speaker->level_w(BIT(data, 0));
|
||||
}
|
||||
|
||||
void f4431_kbd_device::p1_w(uint8_t data)
|
||||
{
|
||||
// 7------- serial data
|
||||
// -6543210 leds
|
||||
|
||||
for (int i = 0; i < 7; i++)
|
||||
m_leds[i] = BIT(data, i);
|
||||
|
||||
m_tx_handler(!BIT(data, 7));
|
||||
}
|
||||
|
||||
uint8_t f4431_kbd_device::p2_r()
|
||||
{
|
||||
// 7------- w2 switch
|
||||
// -6------ w1 switch
|
||||
// --5----- not used
|
||||
// ---43210 column driver high bits (write)
|
||||
|
||||
// never read?
|
||||
return (m_switches->read() << 6) | (m_kbd_p2 & 0x3f);
|
||||
}
|
||||
|
||||
void f4431_kbd_device::p2_w(uint8_t data)
|
||||
{
|
||||
m_kbd_p2 = data;
|
||||
}
|
||||
|
||||
int f4431_kbd_device::t0_r()
|
||||
{
|
||||
return !m_rx;
|
||||
}
|
70
src/mame/facit/f4431_kbd.h
Normal file
70
src/mame/facit/f4431_kbd.h
Normal file
@ -0,0 +1,70 @@
|
||||
// license: BSD-3-Clause
|
||||
// copyright-holders: Dirk Best
|
||||
/***************************************************************************
|
||||
|
||||
Facit F4431 keyboard
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef MAME_FACIT_F4431_KBD_H
|
||||
#define MAME_FACIT_F4431_KBD_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cpu/mcs48/mcs48.h"
|
||||
#include "sound/spkrdev.h"
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
// ======================> f4431_kbd_device
|
||||
|
||||
class f4431_kbd_device : public device_t
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
f4431_kbd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
|
||||
|
||||
// callbacks
|
||||
auto tx_handler() { return m_tx_handler.bind(); }
|
||||
|
||||
void rx_w(int state);
|
||||
|
||||
protected:
|
||||
// device_t overrides
|
||||
virtual const tiny_rom_entry *device_rom_region() const override;
|
||||
virtual void device_add_mconfig(machine_config &config) override;
|
||||
virtual ioport_constructor device_input_ports() const override;
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
|
||||
private:
|
||||
void mem_map(address_map &map);
|
||||
void io_map(address_map &map);
|
||||
|
||||
uint8_t data_r(offs_t offset);
|
||||
void data_w(offs_t offset, uint8_t data);
|
||||
void p1_w(uint8_t data);
|
||||
uint8_t p2_r();
|
||||
void p2_w(uint8_t data);
|
||||
int t0_r();
|
||||
|
||||
required_device<i8035_device> m_mcu;
|
||||
required_device<speaker_sound_device> m_speaker;
|
||||
required_ioport_array<13> m_keys;
|
||||
required_ioport m_switches;
|
||||
|
||||
output_finder<7> m_leds;
|
||||
|
||||
devcb_write_line m_tx_handler;
|
||||
|
||||
int m_rx;
|
||||
uint8_t m_kbd_p2;
|
||||
};
|
||||
|
||||
// device type definition
|
||||
DECLARE_DEVICE_TYPE(F4431_KBD, f4431_kbd_device)
|
||||
|
||||
#endif // MAME_FACIT_F4431_KBD_H
|
85
src/mame/layout/f4431.lay
Normal file
85
src/mame/layout/f4431.lay
Normal file
@ -0,0 +1,85 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
license:CC0
|
||||
copyright-holders: Dirk Best
|
||||
|
||||
Facit 4431 layout
|
||||
-->
|
||||
|
||||
<mamelayout version="2">
|
||||
|
||||
<element name="led" defstate="0">
|
||||
<disk state="0">
|
||||
<color red="0" green="0.2" blue="0" />
|
||||
</disk>
|
||||
<disk state="1">
|
||||
<color red="0" green="0.8" blue="0" />
|
||||
</disk>
|
||||
</element>
|
||||
|
||||
<element name="text_KEYBOARD"><text string="KEYBOARD"><color red="0.80" green="0.80" blue="0.80" /></text></element>
|
||||
|
||||
<element name="text_ONLINE"><text string="ON LINE"><color red="0.80" green="0.80" blue="0.80" /></text></element>
|
||||
<element name="text_LOCAL"><text string="LOCAL"><color red="0.80" green="0.80" blue="0.80" /></text></element>
|
||||
<element name="text_KBDLOCKED"><text string="KBD LOCKED"><color red="0.80" green="0.80" blue="0.80" /></text></element>
|
||||
<element name="text_L1"><text string="L1"><color red="0.80" green="0.80" blue="0.80" /></text></element>
|
||||
<element name="text_L2"><text string="L2"><color red="0.80" green="0.80" blue="0.80" /></text></element>
|
||||
<element name="text_L3"><text string="L3"><color red="0.80" green="0.80" blue="0.80" /></text></element>
|
||||
<element name="text_L4"><text string="L4"><color red="0.80" green="0.80" blue="0.80" /></text></element>
|
||||
|
||||
<view name="Keyboard LEDs">
|
||||
<bounds x="0" y="0" width="800" height="640" />
|
||||
|
||||
<screen index="0">
|
||||
<bounds left="0" top="0" right="800" bottom="600" />
|
||||
</screen>
|
||||
|
||||
<element ref="text_KEYBOARD">
|
||||
<bounds left="10" top="610" right="100" bottom="630" />
|
||||
</element>
|
||||
|
||||
<element name="key_led6" ref="led">
|
||||
<bounds x="140" y="605" width="10" height="10" />
|
||||
</element>
|
||||
<element ref="text_ONLINE">
|
||||
<bounds x="120" y="620" width="50" height="15" />
|
||||
</element>
|
||||
<element name="key_led5" ref="led">
|
||||
<bounds x="200" y="605" width="10" height="10" />
|
||||
</element>
|
||||
<element ref="text_LOCAL">
|
||||
<bounds x="180" y="620" width="50" height="15" />
|
||||
</element>
|
||||
<element name="key_led4" ref="led">
|
||||
<bounds x="260" y="605" width="10" height="10" />
|
||||
</element>
|
||||
<element ref="text_KBDLOCKED">
|
||||
<bounds x="235" y="620" width="60" height="15" />
|
||||
</element>
|
||||
<element name="key_led3" ref="led">
|
||||
<bounds x="320" y="605" width="10" height="10" />
|
||||
</element>
|
||||
<element ref="text_L1">
|
||||
<bounds x="300" y="620" width="50" height="15" />
|
||||
</element>
|
||||
<element name="key_led2" ref="led">
|
||||
<bounds x="380" y="605" width="10" height="10" />
|
||||
</element>
|
||||
<element ref="text_L2">
|
||||
<bounds x="360" y="620" width="50" height="15" />
|
||||
</element>
|
||||
<element name="key_led1" ref="led">
|
||||
<bounds x="440" y="605" width="10" height="10" />
|
||||
</element>
|
||||
<element ref="text_L3">
|
||||
<bounds x="420" y="620" width="50" height="15" />
|
||||
</element>
|
||||
<element name="key_led0" ref="led">
|
||||
<bounds x="500" y="605" width="10" height="10" />
|
||||
</element>
|
||||
<element ref="text_L4">
|
||||
<bounds x="480" y="620" width="50" height="15" />
|
||||
</element>
|
||||
</view>
|
||||
|
||||
</mamelayout>
|
Loading…
Reference in New Issue
Block a user