1 // license:BSD-3-Clause
2 // copyright-holders:Curt Coder
3 /**********************************************************************
4 
5     Amstrad PC1512 Keyboard emulation
6 
7 **********************************************************************/
8 
9 #ifndef MAME_MACHINE_PC1512KB_H
10 #define MAME_MACHINE_PC1512KB_H
11 
12 #pragma once
13 
14 
15 #include "bus/vcs_ctrl/ctrl.h"
16 #include "cpu/mcs48/mcs48.h"
17 
18 
19 
20 //**************************************************************************
21 //  MACROS / CONSTANTS
22 //**************************************************************************
23 
24 #define PC1512_KEYBOARD_TAG "kb"
25 
26 
27 //**************************************************************************
28 //  TYPE DEFINITIONS
29 //**************************************************************************
30 
31 // ======================> pc1512_keyboard_device
32 
33 class pc1512_keyboard_device :  public device_t
34 {
35 public:
36 	// construction/destruction
37 	pc1512_keyboard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
38 
clock_wr_callback()39 	auto clock_wr_callback() { return m_write_clock.bind(); }
data_wr_callback()40 	auto data_wr_callback() { return m_write_data.bind(); }
41 
42 	DECLARE_WRITE_LINE_MEMBER( data_w );
43 	DECLARE_WRITE_LINE_MEMBER( clock_w );
44 	DECLARE_WRITE_LINE_MEMBER( m1_w );
45 	DECLARE_WRITE_LINE_MEMBER( m2_w );
46 
47 protected:
48 	// device-level overrides
49 	virtual void device_start() override;
50 	virtual void device_reset() override;
51 	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
52 
53 	// optional information overrides
54 	virtual const tiny_rom_entry *device_rom_region() const override;
55 	virtual void device_add_mconfig(machine_config &config) override;
56 	virtual ioport_constructor device_input_ports() const override;
57 
58 private:
59 	enum
60 	{
61 		LED_CAPS = 0,
62 		LED_NUM
63 	};
64 
65 	required_device<i8048_device> m_maincpu;
66 	required_device<vcs_control_port_device> m_joy;
67 
68 	required_ioport_array<11> m_y;
69 	output_finder<2> m_leds;
70 
71 	devcb_write_line   m_write_clock;
72 	devcb_write_line   m_write_data;
73 
74 	int m_data_in;
75 	int m_clock_in;
76 	int m_kb_y;
77 	int m_joy_com;
78 	int m_m1;
79 	int m_m2;
80 
81 	emu_timer *m_reset_timer;
82 
83 	uint8_t kb_bus_r();
84 	void kb_p1_w(uint8_t data);
85 	uint8_t kb_p2_r();
86 	void kb_p2_w(uint8_t data);
87 	DECLARE_READ_LINE_MEMBER( kb_t0_r );
88 	DECLARE_READ_LINE_MEMBER( kb_t1_r );
89 };
90 
91 
92 // device type definition
93 DECLARE_DEVICE_TYPE(PC1512_KEYBOARD, pc1512_keyboard_device)
94 
95 
96 #endif // MAME_MACHINE_PC1512KB_H
97