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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
/**********************************************************************
Furrtek's homemade multitap emulation
Copyright MESS Team.
Visit http://mamedev.org for licensing and usage restrictions.
**********************************************************************/
#include "multitap.h"
// Scheme: http://www.smspower.org/uploads/Homebrew/BOoM-SMS-sms4p_2.png
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
const device_type SMS_MULTITAP = &device_creator<sms_multitap_device>;
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// sms_multitap_device - constructor
//-------------------------------------------------
sms_multitap_device::sms_multitap_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, SMS_MULTITAP, "Furrtek's Multitap", tag, owner, clock, "sms_multitap", __FILE__),
device_sms_control_port_interface(mconfig, *this),
m_subctrl1_port(*this, "ctrl1"),
m_subctrl2_port(*this, "ctrl2"),
m_subctrl3_port(*this, "ctrl3"),
m_subctrl4_port(*this, "ctrl4"),
m_read_state(0),
m_last_data(0)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void sms_multitap_device::device_start()
{
save_item(NAME(m_read_state));
save_item(NAME(m_last_data));
m_subctrl1_port->device_start();
m_subctrl2_port->device_start();
m_subctrl3_port->device_start();
m_subctrl4_port->device_start();
}
//-------------------------------------------------
// sms_peripheral_r - multitap read
//-------------------------------------------------
UINT8 sms_multitap_device::peripheral_r()
{
UINT8 data = 0xff;
switch(m_read_state)
{
case 0:
data = m_subctrl1_port->port_r();
break;
case 1:
data = m_subctrl2_port->port_r();
break;
case 2:
data = m_subctrl3_port->port_r();
break;
case 3:
data = m_subctrl4_port->port_r();
break;
}
// force TH level high (1), as the line is not connected to subports.
data |= 0x40;
return data;
}
//-------------------------------------------------
// sms_peripheral_w - multitap write
//-------------------------------------------------
void sms_multitap_device::peripheral_w(UINT8 data)
{
UINT8 output_data;
// check if TH level is low (0) and was high (1)
if (!(data & 0x40) && (m_last_data & 0x40))
{
m_read_state = (m_read_state + 1) & 3;
}
m_last_data = data;
// output default TH level (1), as the line is not connected to subports.
output_data = data | 0x40;
switch(m_read_state)
{
case 0:
m_subctrl1_port->port_w(output_data);
break;
case 1:
m_subctrl2_port->port_w(output_data);
break;
case 2:
m_subctrl3_port->port_w(output_data);
break;
case 3:
m_subctrl4_port->port_w(output_data);
break;
}
}
//-------------------------------------------------
// machine_config_additions - device-specific
// machine configurations
//-------------------------------------------------
READ32_MEMBER( sms_multitap_device::pixel_r )
{
return m_port->pixel_r();
}
static MACHINE_CONFIG_FRAGMENT( multitap_slot )
// Controller subports setup, without the TH callback declaration,
// because the circuit scheme shows TH of subports without connection.
MCFG_SMS_CONTROL_PORT_ADD("ctrl1", sms_control_port_devices, "joypad")
MCFG_SMS_CONTROL_PORT_PIXEL_HANDLER(READ32(sms_multitap_device, pixel_r))
MCFG_SMS_CONTROL_PORT_ADD("ctrl2", sms_control_port_devices, "joypad")
MCFG_SMS_CONTROL_PORT_PIXEL_HANDLER(READ32(sms_multitap_device, pixel_r))
MCFG_SMS_CONTROL_PORT_ADD("ctrl3", sms_control_port_devices, "joypad")
MCFG_SMS_CONTROL_PORT_PIXEL_HANDLER(READ32(sms_multitap_device, pixel_r))
MCFG_SMS_CONTROL_PORT_ADD("ctrl4", sms_control_port_devices, "joypad")
MCFG_SMS_CONTROL_PORT_PIXEL_HANDLER(READ32(sms_multitap_device, pixel_r))
MACHINE_CONFIG_END
machine_config_constructor sms_multitap_device::device_mconfig_additions() const
{
return MACHINE_CONFIG_NAME( multitap_slot );
}
|