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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************
Watford Electronics User Port Splitter
**********************************************************************/
#include "emu.h"
#include "usersplit.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(BBC_USERSPLIT, bbc_usersplit_device, "bbc_usersplit", "BBC Micro User Port Splitter")
//-------------------------------------------------
// INPUT_PORTS( usersplit )
//-------------------------------------------------
static INPUT_PORTS_START( usersplit )
PORT_START("SELECT")
PORT_CONFNAME(0x01, 0x00, "User Port") PORT_CHANGED_MEMBER(DEVICE_SELF, bbc_usersplit_device, userport_changed, 0)
PORT_CONFSETTING(0x00, "A")
PORT_CONFSETTING(0x01, "B")
INPUT_PORTS_END
//-------------------------------------------------
// input_ports - device-specific input ports
//-------------------------------------------------
ioport_constructor bbc_usersplit_device::device_input_ports() const
{
return INPUT_PORTS_NAME( usersplit );
}
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
void bbc_usersplit_device::device_add_mconfig(machine_config &config)
{
/* user port A */
BBC_USERPORT_SLOT(config, m_userport[0], bbc_userport_devices, nullptr);
m_userport[0]->cb1_handler().set(FUNC(bbc_usersplit_device::cb1a_w));
m_userport[0]->cb2_handler().set(FUNC(bbc_usersplit_device::cb2a_w));
/* user port B */
BBC_USERPORT_SLOT(config, m_userport[1], bbc_userport_devices, nullptr);
m_userport[1]->cb1_handler().set(FUNC(bbc_usersplit_device::cb1b_w));
m_userport[1]->cb2_handler().set(FUNC(bbc_usersplit_device::cb2b_w));
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// bbc_usersplit_device - constructor
//-------------------------------------------------
bbc_usersplit_device::bbc_usersplit_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, BBC_USERSPLIT, tag, owner, clock)
, device_bbc_userport_interface(mconfig, *this)
, m_userport(*this, "userport%u", 1)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void bbc_usersplit_device::device_start()
{
m_selected = 0;
save_item(NAME(m_selected));
}
//**************************************************************************
// IMPLEMENTATION
//**************************************************************************
uint8_t bbc_usersplit_device::pb_r()
{
return m_userport[m_selected]->pb_r();
}
void bbc_usersplit_device::pb_w(uint8_t data)
{
m_userport[m_selected]->pb_w(data);
}
void bbc_usersplit_device::write_cb1(int state)
{
m_userport[m_selected]->write_cb1(state);
}
void bbc_usersplit_device::write_cb2(int state)
{
m_userport[m_selected]->write_cb2(state);
}
WRITE_LINE_MEMBER(bbc_usersplit_device::cb1a_w)
{
if (m_selected == 0x00)
m_slot->cb1_w(state);
}
WRITE_LINE_MEMBER(bbc_usersplit_device::cb2a_w)
{
if (m_selected == 0x00)
m_slot->cb2_w(state);
}
WRITE_LINE_MEMBER(bbc_usersplit_device::cb1b_w)
{
if (m_selected == 0x01)
m_slot->cb1_w(state);
}
WRITE_LINE_MEMBER(bbc_usersplit_device::cb2b_w)
{
if (m_selected == 0x01)
m_slot->cb2_w(state);
}
|