basf7100: Hook up interrupt controller, keyboard

- Hooked up PIC and connected keyboard and vblank interrupts
- Implemented HLE keyboard (all keys mapped, using the translation ROM for keycodes)
- Increased shared memory to 40k
- Fixed interrupt flags register
- Implemented cursor and roll offset
This commit is contained in:
Dirk Best 2021-04-19 19:27:01 +02:00
parent 3cee2739a2
commit 02516af978
4 changed files with 495 additions and 36 deletions

View File

@ -4437,6 +4437,8 @@ files {
MAME_DIR .. "src/mame/video/aussiebyte.cpp",
MAME_DIR .. "src/mame/drivers/ax20.cpp",
MAME_DIR .. "src/mame/drivers/basf7100.cpp",
MAME_DIR .. "src/mame/machine/basf7100_kbd.cpp",
MAME_DIR .. "src/mame/machine/basf7100_kbd.h",
MAME_DIR .. "src/mame/drivers/binbug.cpp",
MAME_DIR .. "src/mame/drivers/bert.cpp",
MAME_DIR .. "src/mame/drivers/besta.cpp",

View File

@ -35,11 +35,12 @@
- COM8116
- 5.0688 MHz XTAL
Keyboard:
- 30293E-054 20-04592-054 (?)
TODO:
- The floppy is partially hooked up, everything else needs to be done
- Dump real character ROM
- Improve video emulation
- Hook up switches
- Hook up serial ports
- Hook up parallel port
Notes:
- Runs the BOS operating system, possibly also CP/M?
@ -49,8 +50,10 @@
#include "emu.h"
#include "cpu/z80/z80.h"
#include "machine/i8255.h"
#include "machine/pic8259.h"
#include "machine/wd_fdc.h"
#include "imagedev/floppy.h"
#include "machine/basf7100_kbd.h"
#include "emupal.h"
#include "screen.h"
@ -68,16 +71,23 @@ public:
basf7100_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_ppi(*this, "ppi%u", 0U),
m_fdccpu(*this, "fdccpu"),
m_pic(*this, "pic"),
m_ppi(*this, "ppi%u", 0U),
m_fdc(*this, "fdc"),
m_floppy(*this, "fdc:%u", 0),
m_screen(*this, "screen"),
m_palette(*this, "palette"),
m_shared_ram(*this, "shared_ram"),
m_chargen(*this, "chargen"),
m_bootview(*this, "bootview"),
m_cursor_col(0x00), m_cursor_row(0x00),
m_highlight(0x00),
m_roll_offset(0x00),
m_sod(0x0000),
m_fdc_intrq_vector(0),
m_fdc_drq(false)
m_fdc_drq(false),
m_int_flags(0x00)
{ }
void basf7100(machine_config &config);
@ -88,15 +98,23 @@ protected:
private:
required_device<z80_device> m_maincpu;
required_device_array<i8255_device, 5> m_ppi;
required_device<z80_device> m_fdccpu;
required_device<pic8259_device> m_pic;
required_device_array<i8255_device, 5> m_ppi;
required_device<fd1791_device> m_fdc;
required_device_array<floppy_connector, 3> m_floppy;
required_device<screen_device> m_screen;
required_device<palette_device> m_palette;
required_shared_ptr<uint8_t> m_shared_ram;
required_region_ptr<uint8_t> m_chargen;
memory_view m_bootview;
enum : uint8_t
{
INT_KEYBOARD = 0x08,
INT_VBLANK = 0x10
};
void mem_map(address_map &map);
void io_map(address_map &map);
@ -106,8 +124,15 @@ private:
uint8_t mmio_r(offs_t offset);
void mmio_w(offs_t offset, uint8_t data);
void keyboard_w(uint8_t data);
void cursor_col_w(uint8_t data);
void cursor_row_w(uint8_t data);
void highlight_w(uint8_t data);
void roll_offset_w(uint8_t data);
void sod_high_w(uint8_t data);
void sod_low_w(uint8_t data);
void vblank_w(int state);
uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
void fdc_drq_w(int state);
@ -116,12 +141,17 @@ private:
void fdc_intrq_vector_w(uint8_t data);
void unk_cc_w(uint8_t data);
IRQ_CALLBACK_MEMBER(maincpu_irq_callback);
IRQ_CALLBACK_MEMBER(fdccpu_irq_callback);
uint8_t int_flags_r();
uint8_t m_cursor_col;
uint8_t m_cursor_row;
uint8_t m_highlight;
uint8_t m_roll_offset;
uint16_t m_sod;
uint8_t m_fdc_intrq_vector;
bool m_fdc_drq;
uint8_t m_int_flags;
};
@ -131,8 +161,8 @@ private:
void basf7100_state::mem_map(address_map &map)
{
map(0x0000, 0x7fff).ram().share("shared_ram");
map(0x8000, 0xffff).ram();
map(0x0000, 0x9fff).ram().share("shared_ram");
map(0xa000, 0xffff).ram();
map(0xff00, 0xffff).rw(FUNC(basf7100_state::mmio_r), FUNC(basf7100_state::mmio_w));
map(0x0000, 0xffff).view(m_bootview);
m_bootview[0](0x0000, 0x001f).mirror(0xffe0).rom().region("maincpu", 0);
@ -143,14 +173,14 @@ void basf7100_state::io_map(address_map &map)
map.global_mask(0xff);
map(0x00, 0x03).rw(m_ppi[0], FUNC(i8255_device::read), FUNC(i8255_device::write));
map(0x04, 0x07).rw(m_ppi[1], FUNC(i8255_device::read), FUNC(i8255_device::write));
// map(0x08, 0x09).mirror(0x02) 8259
map(0x08, 0x09).mirror(0x02).rw(m_pic, FUNC(pic8259_device::read), FUNC(pic8259_device::write));
map(0x0c, 0x0f).rw(m_ppi[2], FUNC(i8255_device::read), FUNC(i8255_device::write));
// map(0x10, 0x11) 8251 (primary)
// map(0x12, 0x12) baud rate
// map(0x14, 0x15) 8251 (secondary)
// map(0x16, 0x16) baud rate
// map(0x17, 0x17) rs232 flags/control
map(0x18, 0x18).r(FUNC(basf7100_state::int_flags_r));
map(0x18, 0x18).lr8(NAME([this] () -> uint8_t { return m_int_flags; }));
// map(0x1c, 0x1f) switches
// map(0xb0, 0xb3) display hardware clear
map(0xb8, 0xbb).rw(m_ppi[3], FUNC(i8255_device::read), FUNC(i8255_device::write));
@ -164,9 +194,8 @@ void basf7100_state::io_map(address_map &map)
void basf7100_state::fdc_mem_map(address_map &map)
{
map(0x0000, 0x7fff).ram().share("shared_ram");
map(0x8000, 0xefff).ram();
map(0xf000, 0xfbff).ram();
map(0x0000, 0x9fff).ram().share("shared_ram");
map(0xa000, 0xfbff).ram();
map(0xfc00, 0xffff).rom().region("fdccpu", 0);
map(0xff00, 0xffff).rw(FUNC(basf7100_state::mmio_r), FUNC(basf7100_state::mmio_w));
}
@ -185,6 +214,17 @@ void basf7100_state::fdc_io_map(address_map &map)
static INPUT_PORTS_START( basf7100 )
INPUT_PORTS_END
void basf7100_state::keyboard_w(uint8_t data)
{
// PPI OBF
m_int_flags &= ~INT_KEYBOARD;
m_int_flags |= BIT(data, 1) ? INT_KEYBOARD : 0x00;
m_pic->ir3_w(BIT(data, 1));
// TODO: keyboard bell
}
//**************************************************************************
// VIDEO EMULATION
@ -205,6 +245,32 @@ static GFXDECODE_START( gfx_crt8002 )
GFXDECODE_ENTRY( "chargen", 0, crt8002_charlayout, 0, 1 )
GFXDECODE_END
void basf7100_state::cursor_col_w(uint8_t data)
{
m_cursor_col = data;
}
void basf7100_state::cursor_row_w(uint8_t data)
{
// 7------- graphics enable?
// -65----- unknown
// ---43210 cursor row
m_cursor_row = data & 0x1f;
}
void basf7100_state::highlight_w(uint8_t data)
{
logerror("highlight = %02x\n", data);
m_highlight = data;
}
void basf7100_state::roll_offset_w(uint8_t data)
{
logerror("roll offset = %02x\n", data);
m_roll_offset = data;
}
void basf7100_state::sod_high_w(uint8_t data)
{
m_sod = (data << 8) | (m_sod & 0x00ff);
@ -218,23 +284,39 @@ void basf7100_state::sod_low_w(uint8_t data)
m_sod = (m_sod & 0xff00) | ((data & 0xf0) << 0);
}
void basf7100_state::vblank_w(int state)
{
m_int_flags &= ~INT_VBLANK;
m_int_flags |= state ? INT_VBLANK : 0x00;
m_pic->ir4_w(state);
}
uint32_t basf7100_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
uint16_t addr = m_sod + (m_roll_offset * 16);
for (int y = 0; y < 24; y++)
{
for (int x = 0; x < 80; x++)
{
uint16_t addr = m_sod + y * 80 + x;
uint8_t code = m_maincpu->space(AS_PROGRAM).read_byte(addr);
if (addr >= (m_sod + 0x780))
addr = m_sod;
uint8_t code = m_shared_ram[addr];
// draw 12 lines
for (int i = 0; i < 12; i++)
{
uint8_t data = m_chargen[(((code & 0x7f) << 4) + i)];
// wrong
if (BIT(code, 7))
data ^= 0xff;
if (y == m_cursor_row && x == m_cursor_col)
data ^= 0xff;
// 8 pixels of the character
bitmap.pix(y * 12 + i, x * 8 + 0) = BIT(data, 7) ? rgb_t::white() : rgb_t::black();
bitmap.pix(y * 12 + i, x * 8 + 1) = BIT(data, 6) ? rgb_t::white() : rgb_t::black();
@ -245,6 +327,9 @@ uint32_t basf7100_state::screen_update(screen_device &screen, bitmap_rgb32 &bitm
bitmap.pix(y * 12 + i, x * 8 + 6) = BIT(data, 1) ? rgb_t::white() : rgb_t::black();
bitmap.pix(y * 12 + i, x * 8 + 7) = BIT(data, 0) ? rgb_t::white() : rgb_t::black();
}
// next char
addr++;
}
}
@ -334,24 +419,29 @@ void basf7100_state::mmio_w(offs_t offset, uint8_t data)
m_maincpu->space(AS_IO).write_byte(offset, data);
}
IRQ_CALLBACK_MEMBER( basf7100_state::maincpu_irq_callback )
{
uint32_t vector = 0;
vector |= m_pic->acknowledge() << 16;
vector |= m_pic->acknowledge();
vector |= m_pic->acknowledge() << 8;
return vector;
}
IRQ_CALLBACK_MEMBER( basf7100_state::fdccpu_irq_callback )
{
return m_fdc_intrq_vector;
}
uint8_t basf7100_state::int_flags_r()
{
// 765----- unknown
// ---4---- unknown (used, needs to be set at least 2 times to continue booting)
// ----3--- unknown (used)
// -----210 unknown
return m_screen->vblank() ? 0x10 : 0x00;
}
void basf7100_state::machine_start()
{
// register for save states
save_item(NAME(m_cursor_col));
save_item(NAME(m_cursor_row));
save_item(NAME(m_highlight));
save_item(NAME(m_roll_offset));
save_item(NAME(m_sod));
save_item(NAME(m_fdc_intrq_vector));
save_item(NAME(m_fdc_drq));
@ -373,16 +463,20 @@ void basf7100_state::basf7100(machine_config &config)
Z80(config, m_maincpu, 4000000);
m_maincpu->set_addrmap(AS_PROGRAM, &basf7100_state::mem_map);
m_maincpu->set_addrmap(AS_IO, &basf7100_state::io_map);
m_maincpu->set_irq_acknowledge_callback(FUNC(basf7100_state::maincpu_irq_callback));
Z80(config, m_fdccpu, 4000000);
m_fdccpu->set_addrmap(AS_PROGRAM, &basf7100_state::fdc_mem_map);
m_fdccpu->set_addrmap(AS_IO, &basf7100_state::fdc_io_map);
m_fdccpu->set_irq_acknowledge_callback(FUNC(basf7100_state::fdccpu_irq_callback));
PIC8259(config, m_pic, 0);
m_pic->out_int_callback().set_inputline(m_maincpu, INPUT_LINE_IRQ0);
I8255(config, m_ppi[0]);
// port a: input (switches?)
// port b: input (keyboard data)
// port c: input (keyboard strobe), output (bell)
m_ppi[0]->in_pb_callback().set("keyboard", FUNC(basf7100_kbd_device::read));
m_ppi[0]->out_pc_callback().set(FUNC(basf7100_state::keyboard_w));
I8255(config, m_ppi[1]);
// port a: output (printer data)
@ -395,12 +489,12 @@ void basf7100_state::basf7100(machine_config &config)
// port c: input (auto dialer status), output (rs232 and auto dialer control)
I8255(config, m_ppi[3]);
// port a: output (cursor column)
// port b: output (cursor row, graphics enable)
// port c: output (highlight mode)
m_ppi[3]->out_pa_callback().set(FUNC(basf7100_state::cursor_col_w));
m_ppi[3]->out_pb_callback().set(FUNC(basf7100_state::cursor_row_w));
m_ppi[3]->out_pc_callback().set(FUNC(basf7100_state::highlight_w));
I8255(config, m_ppi[4]);
// port a: output (roll offset)
m_ppi[4]->out_pa_callback().set(FUNC(basf7100_state::roll_offset_w));
m_ppi[4]->out_pb_callback().set(FUNC(basf7100_state::sod_high_w));
m_ppi[4]->out_pc_callback().set(FUNC(basf7100_state::sod_low_w));
@ -412,6 +506,7 @@ void basf7100_state::basf7100(machine_config &config)
m_screen->set_refresh_hz(60);
m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(2500)); // not accurate
m_screen->set_screen_update(FUNC(basf7100_state::screen_update));
m_screen->screen_vblank().set(FUNC(basf7100_state::vblank_w));
GFXDECODE(config, "gfxdecode", "palette", gfx_crt8002);
@ -424,6 +519,10 @@ void basf7100_state::basf7100(machine_config &config)
FLOPPY_CONNECTOR(config, "fdc:0", basf7100_floppies, "basf6106", floppy_image_device::default_mfm_floppy_formats);
FLOPPY_CONNECTOR(config, "fdc:1", basf7100_floppies, "basf6106", floppy_image_device::default_mfm_floppy_formats);
FLOPPY_CONNECTOR(config, "fdc:2", basf7100_floppies, "basf6106", floppy_image_device::default_mfm_floppy_formats);
// keyboard
basf7100_kbd_device &keyboard(BASF7100_KBD(config, "keyboard"));
keyboard.int_handler().set(m_ppi[0], FUNC(i8255_device::pc2_w));
}
@ -437,9 +536,6 @@ ROM_START( basf7120 )
ROM_REGION(0x400, "fdccpu", 0)
ROM_LOAD("19-2130-2h.u45", 0x000, 0x400, CRC(cb077c69) SHA1(dfa16082b88275442c48082aeb5f62fe1238ae3e)) // 2708
ROM_REGION(0x400, "keyboard", 0)
ROM_LOAD("19-2114-01e.bin", 0x000, 0x400, CRC(d694b5dd) SHA1(6262379ba565c1de072b2b21dc3141db1ec5129c))
ROM_REGION(0x50, "floppy_pal", 0)
ROM_LOAD("19-2131-1.u23", 0x00, 0x28, CRC(f37ed4bc) SHA1(824b4405f396c262cf8116f85eb0b548eabb4c04)) // PAL10L8MJ

View File

@ -0,0 +1,300 @@
// license: BSD-3-Clause
// copyright-holders: Dirk Best
/***************************************************************************
BASF 7100 Keyboard (HLE)
Keytronics keyboard hardware: A65-01966-003 PCB-201 F
BASF part number 19-4203-01
Hardware:
- 30293E-054 20-04592-054 (possibly PIC1650)
- 1 KB ROM (contains translation tables)
- Speaker
TODO:
- Extract internal ROM from MCU and convert to LLE
- Speaker
***************************************************************************/
#include "emu.h"
#include "basf7100_kbd.h"
#include "machine/keyboard.ipp"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(BASF7100_KBD, basf7100_kbd_device, "basf7100_kbd", "BASF 7100 Keyboard (HLE)")
//-------------------------------------------------
// rom_region - device-specific ROM region
//-------------------------------------------------
ROM_START( keyboard )
ROM_REGION(0x400, "translation", 0)
ROM_LOAD("19-2114-01e.bin", 0x000, 0x400, CRC(d694b5dd) SHA1(6262379ba565c1de072b2b21dc3141db1ec5129c))
ROM_END
const tiny_rom_entry *basf7100_kbd_device::device_rom_region() const
{
return ROM_NAME(keyboard);
}
//-------------------------------------------------
// input_ports - device-specific input ports
//-------------------------------------------------
static INPUT_PORTS_START( keyboard )
PORT_START("mod")
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(LCONTROL))
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CAPS") PORT_CODE(KEYCODE_CAPSLOCK) PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) PORT_TOGGLE
PORT_START("row_0")
PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q')
PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A')
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_0) PORT_CHAR('0') PORT_CHAR(')')
PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P')
PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR(':')
PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_BIT(0xf800, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_START("row_1")
PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('@')
PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W')
PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S')
PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X')
PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('_')
PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('{') PORT_CHAR('[')
PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD))
PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR('\'') PORT_CHAR('"')
PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t') // 0x89 with shift
PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD))
PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD))
PORT_BIT(0xf800, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_START("row_2")
PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E')
PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D')
PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C')
PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('+')
PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\\') PORT_CHAR('|') // actually ¦
PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('}') PORT_CHAR(']')
PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD))
PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD))
PORT_BIT(0xf800, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_START("row_3")
PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R')
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_V) PORT_CHAR('v') PORT_CHAR('V')
PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('`') PORT_CHAR('~')
PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(UCHAR_MAMEKEY(ENTER)) PORT_NAME("RETURN")
PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA_PAD) PORT_CHAR(UCHAR_MAMEKEY(COMMA_PAD)) PORT_CHAR(UCHAR_MAMEKEY(COMMA_PAD)) PORT_NAME("Keypad .")
PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("LF")
PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_UNUSED) // sends keycode for "-", but not on keyboard
PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD))
PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD))
PORT_BIT(0xf800, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_START("row_4")
PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T')
PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G')
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_NAME("DEL")
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_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9_PAD) PORT_CHAR(UCHAR_MAMEKEY(9_PAD))
PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Keypad Space")
PORT_BIT(0xf800, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_START("row_5")
PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('^')
PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y')
PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H')
PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N')
PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_CANCEL) PORT_CHAR(UCHAR_MAMEKEY(CANCEL)) PORT_NAME("BREAK")
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_KEYBOARD) PORT_CODE(KEYCODE_LALT) PORT_CHAR(UCHAR_MAMEKEY(LALT)) PORT_NAME("FUNCT")
PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8_PAD) PORT_CHAR(UCHAR_MAMEKEY(8_PAD))
PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_BIT(0xf800, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_START("row_6")
PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('&')
PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U')
PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J')
PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M')
PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CLEAR")
PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) PORT_NAME("INS CHAR")
PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("INS LINE")
PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) PORT_NAME("\xe2\x86\x90") // ←
PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER_PAD) PORT_CHAR(UCHAR_MAMEKEY(ENTER_PAD)) PORT_NAME("ENTER")
PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD))
PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_BIT(0xf800, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_START("row_7")
PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('*')
PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I')
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_COMMA) PORT_CHAR(',') PORT_CHAR('<')
PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_END) PORT_CHAR(UCHAR_MAMEKEY(END)) PORT_NAME("CLR EOL")
PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP)) PORT_NAME("\xe2\x86\x91") // ↑
PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_NAME("\xe2\x86\x93") // ↓
PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(HOME)) PORT_NAME("HOME")
PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_UNUSED) // sends keycode for TAB, but physical space taken by ENTER key
PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_BIT(0xf800, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_START("row_8")
PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR('(')
PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O')
PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L')
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_NAME("CLR EOS")
PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL)) PORT_NAME("DEL CHAR")
PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("DEL LINE")
PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) PORT_NAME("\xe2\x86\x92") // →
PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("SOM EOM")
PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_BIT(0x0400, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_BIT(0xf800, IP_ACTIVE_HIGH, IPT_UNUSED)
INPUT_PORTS_END
ioport_constructor basf7100_kbd_device::device_input_ports() const
{
return INPUT_PORTS_NAME( keyboard );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// basf7100_kbd_device - constructor
//-------------------------------------------------
basf7100_kbd_device::basf7100_kbd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, BASF7100_KBD, tag, owner, clock),
device_matrix_keyboard_interface(mconfig, *this, "row_0", "row_1", "row_2", "row_3", "row_4", "row_5", "row_6", "row_7", "row_8"),
m_translation(*this, "translation"),
m_modifiers(*this, "mod"),
m_int_handler(*this)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void basf7100_kbd_device::device_start()
{
// resolve callbacks
m_int_handler.resolve_safe();
// register for state saving
save_item(NAME(m_data));
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void basf7100_kbd_device::device_reset()
{
reset_key_state();
start_processing(attotime::from_hz(1200));
typematic_stop();
}
//-------------------------------------------------
// key_make - handle a key being pressed
//-------------------------------------------------
void basf7100_kbd_device::key_make(uint8_t row, uint8_t column)
{
uint8_t code = translate(row, column);
if (code != 0xff)
{
send_key(code);
typematic_start(row, column, attotime::from_msec(750), attotime::from_msec(50));
}
}
//-------------------------------------------------
// key_break - handle a key being released
//-------------------------------------------------
void basf7100_kbd_device::key_break(uint8_t row, uint8_t column)
{
if (typematic_is(row, column))
typematic_stop();
}
//-------------------------------------------------
// key_repeat - handle a key being repeated
//-------------------------------------------------
void basf7100_kbd_device::key_repeat(u8 row, u8 column)
{
uint8_t code = translate(row, column);
send_key(code);
}
//-------------------------------------------------
// translate - row and column to key code
//-------------------------------------------------
uint8_t basf7100_kbd_device::translate(uint8_t row, uint8_t column)
{
uint8_t const modifiers(m_modifiers->read());
bool const ctrl(modifiers & 0x01);
bool const shift(bool(modifiers & 0x02) || (bool(modifiers & 0x04)));
bool const ctrl_shift(ctrl && shift);
unsigned const map(ctrl_shift? 3 : ctrl ? 2 : shift ? 1 : 0);
return m_translation[(map * 0x100) + 0x10 + (row * 0x10) + column];
}
//-------------------------------------------------
// send_key - send key code to host
//-------------------------------------------------
void basf7100_kbd_device::send_key(uint8_t code)
{
m_data = code;
m_int_handler(1);
m_int_handler(0);
}
//-------------------------------------------------
// read - return current keycode
//-------------------------------------------------
uint8_t basf7100_kbd_device::read()
{
return m_data;
}

View File

@ -0,0 +1,61 @@
// license: BSD-3-Clause
// copyright-holders: Dirk Best
/***************************************************************************
BASF 7100 Keyboard (HLE)
***************************************************************************/
#ifndef MAME_MACHINE_BASF7100_KBD_H
#define MAME_MACHINE_BASF7100_KBD_H
#pragma once
#include "machine/keyboard.h"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> basf7100_kbd_device
class basf7100_kbd_device : public device_t, protected device_matrix_keyboard_interface<9>
{
public:
// construction/destruction
basf7100_kbd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
// callbacks
auto int_handler() { return m_int_handler.bind(); }
uint8_t read();
protected:
// device-level overrides
virtual const tiny_rom_entry *device_rom_region() const override;
virtual ioport_constructor device_input_ports() const override;
virtual void device_start() override;
virtual void device_reset() 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;
virtual void key_repeat(uint8_t row, uint8_t column) override;
private:
required_region_ptr<uint8_t> m_translation;
required_ioport m_modifiers;
devcb_write_line m_int_handler;
uint8_t translate(uint8_t row, uint8_t column);
void send_key(uint8_t code);
uint8_t m_data;
};
// device type definition
DECLARE_DEVICE_TYPE(BASF7100_KBD, basf7100_kbd_device)
#endif // MAME_MACHINE_BASF7100_KBD_H