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
|
// license:BSD-3-Clause
// copyright-holders:Fabio Priuli
/**********************************************************************
Nintendo Family Computer Yonezawa / PartyRoom 21 Party Tap Controller
**********************************************************************/
#include "emu.h"
#include "partytap.h"
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(NES_PARTYTAP, nes_partytap_device, "nes_partytap", "Yonezawa Party Tap 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, uint32_t clock) :
device_t(mconfig, NES_PARTYTAP, tag, owner, clock),
device_nes_control_port_interface(mconfig, *this),
m_inputs(*this, "INPUTS"),
m_mode(0),
m_latch(0)
{
}
//-------------------------------------------------
// device_start
//-------------------------------------------------
void nes_partytap_device::device_start()
{
save_item(NAME(m_latch));
save_item(NAME(m_mode));
}
//-------------------------------------------------
// device_reset
//-------------------------------------------------
void nes_partytap_device::device_reset()
{
m_mode = 0xe0;
m_latch = 0;
}
//-------------------------------------------------
// read
//-------------------------------------------------
uint8_t nes_partytap_device::read_exp(offs_t offset)
{
uint8_t ret = 0;
if (offset == 1) //$4017
{
ret |= m_latch & 0x1c;
m_latch >>= 3;
// append mode bits
m_latch |= m_mode;
}
return ret;
}
//-------------------------------------------------
// write
//-------------------------------------------------
void nes_partytap_device::write(uint8_t data)
{
// inputs are read in two chunks of 3 bits, before the second one is read bit2 is written here
// probably a mechanism for the game to detect which group of inputs is being read
m_mode = BIT(data, 2) ? 0xa0 : 0xe0;
if (data & 0x01)
return;
m_latch = m_inputs->read();
}
|