summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/kay_kbd.h
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2017-10-28 03:50:22 +1100
committer Vas Crabb <vas@vastheman.com>2017-10-28 03:50:22 +1100
commit30361572bd7841087519417cbaae1957bf385d80 (patch)
tree3f773355ac1ee5afc537706bbfc4bee764e65f20 /src/mame/machine/kay_kbd.h
parentf1dfb9d54481abdd5edade910525e060ce0fe391 (diff)
Replaced hacky Kaypro keyboard that bypassed the SIO with emulated
Kaypro 10 keyboard. [Vas Crabb, rfka01, TeamEurope] (nw) This exposes other issues in MAME. Some incredibly poorly-written code in the keyboard MCU depends on the fact that the T register is updated during S4 then copied to A during S4 when mov a,t is executed. If it doesn't see zero in this register when mov a,t is executed immediately before the timer interrupt is taken, it hangs. Really, the MCS-48 core needs to be re-written so it works at S-cycle level (if not clock cycle leve), but for now I've worked around this case in the least intrusive way possible. This also exposes issues in the Z80DART code. The keyboard communicates 0.8% slower than the nominal 300 Baud. This works perfectly in real life, but it causes occasional corrupted characters with MAME's implementation, particularly if you hold a key down and let it repeat. The Z80DART device needs to be fixed so it samples closer to the middle of the bit intervals and re-aquires on each start bit. Finally, I haven't hooked up the Kaypro's serial port Baud rate genrators, or exposed the serial ports as slots. I'll leave that for someone else to worry about.
Diffstat (limited to 'src/mame/machine/kay_kbd.h')
-rw-r--r--src/mame/machine/kay_kbd.h54
1 files changed, 52 insertions, 2 deletions
diff --git a/src/mame/machine/kay_kbd.h b/src/mame/machine/kay_kbd.h
index 6dc347d78b0..22edbaf207b 100644
--- a/src/mame/machine/kay_kbd.h
+++ b/src/mame/machine/kay_kbd.h
@@ -1,4 +1,54 @@
// license:BSD-3-Clause
-// copyright-holders:Robbbert
+// copyright-holders:Vas Crabb
+#ifndef MAME_MACHINE_KAY_KBD_H
+#define MAME_MACHINE_KAY_KBD_H
-INPUT_PORTS_EXTERN( kay_kbd );
+#pragma once
+
+#include "sound/spkrdev.h"
+
+
+#define MCFG_KAYPRO10KBD_RXD_CB(cb) \
+ devcb = &kaypro_10_keyboard_device::set_rxd_cb(*device, DEVCB_##cb);
+
+
+class kaypro_10_keyboard_device : public device_t
+{
+public:
+ kaypro_10_keyboard_device(
+ machine_config const &mconfig,
+ char const *tag,
+ device_t *owner,
+ uint32_t clock);
+
+ template <class Object> static devcb_base &set_rxd_cb(device_t &device, Object &&cb)
+ { return downcast<kaypro_10_keyboard_device &>(device).m_rxd_cb.set_callback(std::forward<Object>(cb)); }
+
+ DECLARE_WRITE_LINE_MEMBER(txd_w) { m_txd = state ? 1U : 0U; }
+
+protected:
+ 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;
+
+ DECLARE_READ8_MEMBER(p1_r);
+ DECLARE_READ8_MEMBER(p2_r);
+ DECLARE_WRITE8_MEMBER(p2_w);
+ DECLARE_READ_LINE_MEMBER(t1_r);
+ DECLARE_READ8_MEMBER(bus_r);
+ DECLARE_WRITE8_MEMBER(bus_w);
+
+private:
+ required_device<speaker_sound_device> m_bell;
+ required_ioport_array<16> m_matrix;
+ required_ioport m_modifiers;
+ devcb_write_line m_rxd_cb;
+
+ std::uint8_t m_txd;
+ std::uint8_t m_bus;
+};
+
+DECLARE_DEVICE_TYPE(KAYPRO_10_KEYBOARD, kaypro_10_keyboard_device)
+
+#endif // MAME_MACHINE_KAY_KBD_H