ikt5a: Add keyboard

This commit is contained in:
AJR 2021-01-18 22:54:14 -05:00
parent 23af1066f2
commit ce8a98dd1e

View File

@ -7,8 +7,8 @@
*******************************************************************************/
#include "emu.h"
//#include "bus/pc_kbd/keyboards.h"
//#include "bus/pc_kbd/pc_kbdc.h"
#include "bus/pc_kbd/keyboards.h"
#include "bus/pc_kbd/pc_kbdc.h"
//#include "bus/rs232/rs232.h"
#include "cpu/mcs51/mcs51.h"
#include "machine/eepromser.h"
@ -21,16 +21,28 @@ public:
: driver_device(mconfig, type, tag)
, m_maincpu(*this, "maincpu")
, m_eeprom(*this, "eeprom")
, m_keyboard(*this, "keyboard")
, m_chargen(*this, "chargen")
, m_keyboard_clk(true)
, m_keyboard_data(true)
, m_keyboard_shifter(0)
{
}
void ikt5a(machine_config &config);
protected:
virtual void machine_start() override;
private:
u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
DECLARE_WRITE_LINE_MEMBER(keyboard_clk_w);
DECLARE_WRITE_LINE_MEMBER(keyboard_data_w);
void eeprom_w(u8 data);
void keyboard_ack_w(u8 data);
void keyboard_shift_w(u8 data);
u8 p1_r();
void p1_w(u8 data);
u8 p3_r();
@ -40,19 +52,62 @@ private:
required_device<mcs51_cpu_device> m_maincpu;
required_device<eeprom_serial_93cxx_device> m_eeprom;
required_device<pc_kbdc_device> m_keyboard;
required_region_ptr<u8> m_chargen;
bool m_keyboard_clk;
bool m_keyboard_data;
u8 m_keyboard_shifter;
};
void ikt5a_state::machine_start()
{
save_item(NAME(m_keyboard_clk));
save_item(NAME(m_keyboard_data));
save_item(NAME(m_keyboard_shifter));
}
u32 ikt5a_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
return 0;
}
WRITE_LINE_MEMBER(ikt5a_state::keyboard_clk_w)
{
if (m_keyboard_clk && !state)
{
m_maincpu->set_input_line(MCS51_INT1_LINE, BIT(m_keyboard_shifter, 0) ? ASSERT_LINE : CLEAR_LINE);
m_keyboard_shifter >>= 1;
if (m_keyboard_data)
m_keyboard_shifter |= 0x80;
}
m_keyboard_clk = state;
}
WRITE_LINE_MEMBER(ikt5a_state::keyboard_data_w)
{
m_keyboard_data = state;
}
void ikt5a_state::eeprom_w(u8 data)
{
m_eeprom->cs_write(BIT(data, 6));
m_eeprom->di_write(BIT(data, 3));
m_eeprom->clk_write(BIT(data, 1));
m_keyboard->clock_write_from_mb(!BIT(data, 0));
}
void ikt5a_state::keyboard_ack_w(u8 data)
{
m_maincpu->set_input_line(MCS51_INT1_LINE, CLEAR_LINE);
m_keyboard_shifter = 0;
}
void ikt5a_state::keyboard_shift_w(u8 data)
{
m_maincpu->set_input_line(MCS51_INT1_LINE, BIT(m_keyboard_shifter, 0) ? ASSERT_LINE : CLEAR_LINE);
m_keyboard_shifter >>= 1;
}
u8 ikt5a_state::p1_r()
@ -77,6 +132,8 @@ void ikt5a_state::prog_map(address_map &map)
void ikt5a_state::ext_map(address_map &map)
{
map(0x6400, 0x6400).mirror(0xff).w(FUNC(ikt5a_state::eeprom_w));
map(0x7000, 0x7000).mirror(0xff).w(FUNC(ikt5a_state::keyboard_ack_w));
map(0x7c00, 0x7c00).mirror(0xff).w(FUNC(ikt5a_state::keyboard_shift_w));
map(0x8000, 0x9fff).ram();
}
@ -91,6 +148,10 @@ void ikt5a_state::ikt5a(machine_config &config)
EEPROM_93C06_16BIT(config, m_eeprom); // ST M9306B6
PC_KBDC(config, m_keyboard, pc_xt_keyboards, STR_KBD_IBM_PC_XT_83);
m_keyboard->out_clock_cb().set(FUNC(ikt5a_state::keyboard_clk_w));
m_keyboard->out_data_cb().set(FUNC(ikt5a_state::keyboard_data_w));
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_raw(15_MHz_XTAL, 800, 0, 640, 375, 0, 350); // timings guessed
screen.set_screen_update(FUNC(ikt5a_state::screen_update));