1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
// license: BSD-3-Clause
// copyright-holders: Vas Crabb
/***************************************************************************
Mac 128k/512k/Plus keyboard interface (pre-ADB)
4p4c RJ11 connector (cables wired straight through):
1: power/signal ground (black)
2: clock (red, peripheral to host)
3: data (green, bidirectional)
4: +5V power (yellow, maximum 200mA for all peripherals)
***************************************************************************/
#ifndef MAME_BUS_MACKBD_MACKBD_H
#define MAME_BUS_MACKBD_MACKBD_H
#pragma once
class device_mac_keyboard_interface;
DECLARE_DEVICE_TYPE(MAC_KEYBOARD_PORT, mac_keyboard_port_device)
void mac_keyboard_devices(device_slot_interface &device);
//**************************************************************************
// HOST PORT
//**************************************************************************
class mac_keyboard_port_device : public device_t, public device_single_card_slot_interface<device_mac_keyboard_interface>
{
public:
template <typename T>
mac_keyboard_port_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&opts, char const *dflt)
: mac_keyboard_port_device(mconfig, tag, owner, 0U)
{
option_reset();
opts(*this);
set_default_option(dflt);
set_fixed(false);
}
mac_keyboard_port_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock = 0U);
virtual ~mac_keyboard_port_device() override;
auto clock_cb() { return m_clock_cb.bind(); }
auto data_cb() { return m_data_cb.bind(); }
DECLARE_WRITE_LINE_MEMBER(data_w);
protected:
virtual void device_resolve_objects() override;
virtual void device_start() override;
private:
devcb_write_line m_clock_cb;
devcb_write_line m_data_cb;
device_mac_keyboard_interface *m_peripheral;
friend class device_mac_keyboard_interface;
};
//**************************************************************************
// PERIPHERAL INTERFACE
//**************************************************************************
class device_mac_keyboard_interface : public device_interface
{
public:
virtual ~device_mac_keyboard_interface() override;
protected:
device_mac_keyboard_interface(machine_config const &mconfig, device_t &device);
virtual void interface_validity_check(validity_checker &valid) const override;
DECLARE_WRITE_LINE_MEMBER(write_clock) { if (m_host) m_host->m_clock_cb(state); }
DECLARE_WRITE_LINE_MEMBER(write_data) { if (m_host) m_host->m_data_cb(state); }
virtual DECLARE_WRITE_LINE_MEMBER(data_w) = 0;
private:
mac_keyboard_port_device *const m_host;
friend class mac_keyboard_port_device;
};
#endif // MAME_BUS_MACKBD_MACKBD_H
|