EPC: Keyboard working, added leds and removed imperfect feature (#5832)

* i8251.cpp: required initial state to enable receiver of a 8251a and also to avoid sending start bit to diserial on reset and get framing error

* eispc_kb.cpp: removed need for scheduler abuse as problem is fixed by correcting the init of the i8251 USART on host side instead

* eispc.cpp: removed an obsolete TODO

* eispc_kb.h: removed imperfect_features marking

* epc: Added keyboard LEDs, Caps and Num lock works with current keyboard rom, scroll lock led needs a dump from a newer keyboard
This commit is contained in:
Joakim Larsson Edström 2019-10-30 22:49:24 +01:00 committed by ajrhacker
parent fe1612aa81
commit 9582866bbf
4 changed files with 66 additions and 4 deletions

View File

@ -43,6 +43,7 @@
#include "emu.h"
#include "machine/eispc_kb.h"
#include "epc.lh"
// Devices
#include "cpu/i86/i86.h"
@ -113,6 +114,7 @@ public:
, m_lpt(*this, "lpt")
, m_kbd8251(*this, "kbd8251")
, m_keyboard(*this, "keyboard")
, m_leds(*this, "kbled%u")
, m_pic8259(*this, "pic8259")
, m_pit8253(*this, "pit8253")
, m_speaker(*this, "speaker")
@ -170,6 +172,7 @@ private:
emu_timer *m_kbdclk_timer;
TIMER_CALLBACK_MEMBER(rxtxclk_w);
int m_rxtx_clk_state;
output_finder<3> m_leds;
// Interrupt Controller
required_device<pic8259_device> m_pic8259;
@ -475,6 +478,8 @@ void epc_state::machine_start()
save_item(NAME(m_drq));
save_item(NAME(m_fdc_irq));
save_item(NAME(m_fdc_drq));
m_leds.resolve();
}
void epc_state::machine_reset()
@ -738,6 +743,8 @@ static void epc_sd_floppies(device_slot_interface &device)
void epc_state::epc(machine_config &config)
{
config.set_default_layout(layout_epc);
I8088(config, m_maincpu, XTAL(14'318'181) / 3.0); // TWE crystal marked X1 verified divided through a 82874
m_maincpu->set_addrmap(AS_PROGRAM, &epc_state::epc_map);
m_maincpu->set_addrmap(AS_IO, &epc_state::epc_io);
@ -762,11 +769,15 @@ void epc_state::epc(machine_config &config)
m_dma8237a->out_dack_callback<3>().set(FUNC(epc_state::epc_dack_w<3>));
// TTL-level serial keyboard callback
EISPC_KB(config, "keyboard").txd_cb().set([this](bool state)
EISPC_KB(config, m_keyboard);
m_keyboard->txd_cb().set([this](bool state)
{
LOGBITS("KBD->EPC: %d\n", state);
m_kbd8251->write_rxd(state);
});
m_keyboard->caps_cb().set( [this](bool state){ m_leds[0] = state; });
m_keyboard->num_cb().set( [this](bool state){ m_leds[1] = state; });
m_keyboard->scroll_cb().set([this](bool state){ m_leds[2] = state; });
// Keyboard USART
I8251( config, m_kbd8251, XTAL(14'318'181) / 6.0 ); // TWE crystal marked X1 verified divided through a 82874

34
src/mame/layout/epc.lay Normal file
View File

@ -0,0 +1,34 @@
<?xml version="1.0"?>
<!--
license:CC0
copyright-holders:Joakim Larsson Edstrom
LEDs for the Ericsson PC keyboard
-->
<mamelayout version="2">
<element name="text_caps"><text string="Caps Lock"><color red="0.7" green="0.7" blue="0.7" /></text></element>
<element name="text_num"><text string="Num Lock"><color red="0.7" green="0.7" blue="0.7" /></text></element>
<element name="text_scroll"><text string="Scroll Lock"><color red="0.7" green="0.7" blue="0.7" /></text></element>
<element name="led" defstate="0"><disk><color red="0.85" green="0.18" blue="0.16" /></disk></element>
<group name="caps">
<bezel element="led" name="kbled0"><bounds x="0" y="0" width="100" height="100" /></bezel>
<bezel element="text_caps"><bounds x="120" y="0" width="900" height="100" /></bezel>
</group>
<group name="num">
<bezel element="led" name="kbled1"><bounds x="0" y="0" width="100" height="100" /></bezel>
<bezel element="text_num"><bounds x="120" y="0" width="800" height="100" /></bezel>
</group>
<group name="scroll">
<bezel element="led" name="kbled2"><bounds x="0" y="0" width="100" height="100" /></bezel>
<bezel element="text_scroll"><bounds x="120" y="0" width="1000" height="100" /></bezel>
</group>
<view name="Default Layout">
<screen index="0"><bounds left="0" top="150" right="1000" bottom="900" /></screen>
<group ref="caps"> <bounds x="0" y="0" width="90" height="10" /></group>
<group ref="num"> <bounds x="110" y="0" width="80" height="10" /></group>
<group ref="scroll"><bounds x="210" y="0" width="100" height="10" /></group>
</view>
</mamelayout>

View File

@ -85,8 +85,9 @@
#define LOG_RESET (1U << 2)
#define LOG_BITS (1U << 3)
#define LOG_UI (1U << 4)
#define LOG_LEDS (1U << 5)
//#define VERBOSE (LOG_UI)
//#define VERBOSE (LOG_LEDS)
//#define LOG_OUTPUT_STREAM std::cout
#include "logmacro.h"
@ -95,6 +96,7 @@
#define LOGRST(...) LOGMASKED(LOG_RESET, __VA_ARGS__)
#define LOGBITS(...) LOGMASKED(LOG_BITS, __VA_ARGS__)
#define LOGUI(...) LOGMASKED(LOG_UI, __VA_ARGS__)
#define LOGLEDS(...) LOGMASKED(LOG_LEDS, __VA_ARGS__)
//**************************************************************************
// MACROS / CONSTANTS
@ -249,6 +251,9 @@ eispc_keyboard_device::eispc_keyboard_device(
, m_mcu(*this, M6801_TAG)
, m_rows(*this, "P1%u", 0)
, m_txd_cb(*this)
, m_led_caps_cb(*this)
, m_led_num_cb(*this)
, m_led_scroll_cb(*this)
, m_rxd_high(true)
, m_txd_high(true)
, m_hold(true)
@ -288,6 +293,9 @@ WRITE_LINE_MEMBER(eispc_keyboard_device::rst_line_w)
void eispc_keyboard_device::device_start()
{
m_txd_cb.resolve_safe();
m_led_caps_cb.resolve_safe();
m_led_num_cb.resolve_safe();
m_led_scroll_cb.resolve_safe();
save_item(NAME(m_rxd_high));
save_item(NAME(m_txd_high));
@ -330,6 +338,8 @@ void eispc_keyboard_device::device_add_mconfig(machine_config &config)
m_mcu->out_p1_cb().set([this](uint8_t data)
{
LOGPORTS("Writing %02x PORT 1\n", data);
LOGLEDS("Num: %d\n", BIT(data, 7));
m_led_num_cb(BIT(data, 7) ? 1 : 0);
});
m_mcu->in_p2_cb().set([this]
@ -343,6 +353,9 @@ void eispc_keyboard_device::device_add_mconfig(machine_config &config)
m_mcu->out_p2_cb().set([this](uint8_t data)
{
LOGPORTS("Writing port 2: %02x\n", data);
LOGLEDS("Caps: %d Scroll: %d\n", BIT(data, 0), BIT(data, 2));
m_led_caps_cb(BIT(data, 0) ? 1 : 0);
m_led_scroll_cb(BIT(data, 2) ? 1 : 0); // Only working with "Roger Moore" roms
LOGBITS("KBD: writing bit: %02x\n", BIT(data, 4));
});

View File

@ -13,11 +13,12 @@ class eispc_keyboard_device : public device_t
{
public:
auto txd_cb() { return m_txd_cb.bind(); }
auto caps_cb() { return m_led_caps_cb.bind(); }
auto num_cb() { return m_led_num_cb.bind(); }
auto scroll_cb() { return m_led_scroll_cb.bind(); }
eispc_keyboard_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock = 0);
static constexpr feature_type imperfect_features() { return feature::KEYBOARD; }
DECLARE_INPUT_CHANGED_MEMBER(key);
DECLARE_WRITE_LINE_MEMBER(rxd_w);
DECLARE_WRITE_LINE_MEMBER(hold_w);
@ -32,6 +33,9 @@ protected:
required_device<m6801_cpu_device> m_mcu;
required_ioport_array<6> m_rows;
devcb_write_line m_txd_cb; // Callback for KBD-> EPC
devcb_write_line m_led_caps_cb; // Callback for Caps led -> layout
devcb_write_line m_led_num_cb; // Callback for Num led -> layout
devcb_write_line m_led_scroll_cb; // Callback for Scroll led -> layout
bool m_rxd_high; // state of Rx input line
bool m_txd_high; // state of Tx output line