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
|
// license:BSD-3-Clause
// copyright-holders:Fabio Priuli
/**********************************************************************
Nintendo Family Computer Yonezawa / Party Room 21 Partytap Controller
**********************************************************************/
#include "emu.h"
#include "partytap.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(NES_PARTYTAP, nes_partytap_device, "nes_partytap", "Yonezawa Partytap Controller")
static INPUT_PORTS_START( nes_partytap )
PORT_START("INPUTS")
PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("P1 Button") PORT_CODE(KEYCODE_Z)
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("P2 Button") PORT_CODE(KEYCODE_X)
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("P3 Button") PORT_CODE(KEYCODE_C)
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("P4 Button") PORT_CODE(KEYCODE_V)
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("P5 Button") PORT_CODE(KEYCODE_B)
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("P6 Button") PORT_CODE(KEYCODE_N)
INPUT_PORTS_END
//-------------------------------------------------
// input_ports - device-specific input ports
//-------------------------------------------------
ioport_constructor nes_partytap_device::device_input_ports() const
{
return INPUT_PORTS_NAME( nes_partytap );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// nes_partytap_device - constructor
//-------------------------------------------------
nes_partytap_device::nes_partytap_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, NES_PARTYTAP, tag, owner, clock)
, device_nes_control_port_interface(mconfig, *this)
, m_inputs(*this, "INPUTS")
, m_latch(0)
{
}
//-------------------------------------------------
// device_start
//-------------------------------------------------
void nes_partytap_device::device_start()
{
save_item(NAME(m_latch));
save_item(NAME(m_strobe));
}
//-------------------------------------------------
// read
//-------------------------------------------------
u8 nes_partytap_device::read_exp(offs_t offset)
{
u8 ret = 0;
if (offset == 1) //$4017
{
if (m_strobe)
m_latch = m_inputs->read();
ret = m_latch & 0x1c;
m_latch >>= 3;
m_latch |= 0xa0; // after first two reads, 0x14 will be returned
}
return ret;
}
//-------------------------------------------------
// write
//-------------------------------------------------
void nes_partytap_device::write(u8 data)
{
if (write_strobe(data))
m_latch = m_inputs->read();
}
|