summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/nes_ctrl/ctrl.cpp
diff options
context:
space:
mode:
author 0kmg <9137159+0kmg@users.noreply.github.com>2021-12-08 16:15:34 -0900
committer GitHub <noreply@github.com>2021-12-08 20:15:34 -0500
commit98bcd68b0b1e0479e04248704759271e2e50b55f (patch)
tree437bbaa5db4e4b255db994e58d93ed3b3e62127c /src/devices/bus/nes_ctrl/ctrl.cpp
parenta95da6eb6d675d63169536d572cc85c427ccf02a (diff)
bus/nes_ctrl: Disentangled Famicom joypad 2 from expansion port code. (#8949)
- Removed read_exp call from fcpad2. The FC expansion port is not tied to the relevant line at all. - Replaced with read_bit2 in the control port interface for the same purpose. - Separated JOYPAD inputs from MIC. The microphone shouldn't be mixed with button inputs' shift register. machine/nes.cpp: Also removed read_exp calls on FC control ports. Other than the microphone on fcpad2 nothing used these (nor should they as the only line in common is $4017 bit 0, which in general is never used by the expansion port).
Diffstat (limited to 'src/devices/bus/nes_ctrl/ctrl.cpp')
-rw-r--r--src/devices/bus/nes_ctrl/ctrl.cpp40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/devices/bus/nes_ctrl/ctrl.cpp b/src/devices/bus/nes_ctrl/ctrl.cpp
index 1f4f0274687..33bd74e77cf 100644
--- a/src/devices/bus/nes_ctrl/ctrl.cpp
+++ b/src/devices/bus/nes_ctrl/ctrl.cpp
@@ -6,18 +6,18 @@
and Family Computer expansion port emulation
Here we emulate in fact 3 different kind of ports, which are
- connected to different bis of memory locations $4016 and $4017:
+ connected to different bits of memory locations $4016 and $4017:
- NES controller ports: these are hooked to bit 0,3,4 of the
corresponding address ($4016 for port1, $4017 for port2)
- FC controller ports: these are only hooked to bit 0 of the
corresponding address (so that e.g. a NES Zapper could not
be connected to a later FC AV model, because its inputs
would not be detected)
- - FC expansion port: this is hooked to bits 0-4 of both addresses
- To make things a little bit more complex, old FC models have the
- controller hardwired to the unit, and the P2 controllers are
- directly hooked also to one of the expansion port lines (namely,
- microphone inputs from P2 go to $4016 bit 2)
+ - FC expansion port: this is hooked to bit 1 of memory location
+ $4016 and bits 0-4 of $4017
+ To make things a little bit more complex, old FC models have
+ controllers hardwired to the unit, and the P2 controllers are
+ directly hooked to bit 2 of $4016 (for microphone inputs).
Even if the controller port and the expansion port are
physically different (the FC expansion is a 15pin port, while
@@ -35,8 +35,8 @@
handlers they have hooks for: Basic usage is that the expansion
port calls read_exp, FC ctrl ports call read_bit0, and NES ctrl
ports call both read_bit0 and read_bit34. However, to cope with
- the original FC microphone, we will have the second controller
- port calling read_exp too.
+ the original FC microphone, we have a one-off read_bit2 handler
+ called by the second controller.
**********************************************************************/
@@ -103,7 +103,7 @@ device_nes_control_port_interface::~device_nes_control_port_interface()
// nes_control_port_device - constructor
//-------------------------------------------------
-nes_control_port_device::nes_control_port_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+nes_control_port_device::nes_control_port_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
device_t(mconfig, NES_CONTROL_PORT, tag, owner, clock),
device_single_card_slot_interface<device_nes_control_port_interface>(mconfig, *this),
m_screen(*this, finder_base::DUMMY_TAG),
@@ -131,31 +131,39 @@ void nes_control_port_device::device_start()
}
-uint8_t nes_control_port_device::read_bit0()
+u8 nes_control_port_device::read_bit0()
{
- uint8_t data = 0;
+ u8 data = 0;
if (m_device)
data = m_device->read_bit0();
return data;
}
-uint8_t nes_control_port_device::read_bit34()
+u8 nes_control_port_device::read_bit2()
{
- uint8_t data = 0;
+ u8 data = 0;
+ if (m_device)
+ data = m_device->read_bit2();
+ return data;
+}
+
+u8 nes_control_port_device::read_bit34()
+{
+ u8 data = 0;
if (m_device)
data = m_device->read_bit34();
return data;
}
-uint8_t nes_control_port_device::read_exp(offs_t offset)
+u8 nes_control_port_device::read_exp(offs_t offset)
{
- uint8_t data = 0;
+ u8 data = 0;
if (m_device)
data = m_device->read_exp(offset);
return data;
}
-void nes_control_port_device::write(uint8_t data)
+void nes_control_port_device::write(u8 data)
{
if (m_device)
m_device->write(data);