From 53f28f0934dbe41df294e4015d9c59fa90818407 Mon Sep 17 00:00:00 2001 From: 0kmg <9137159+0kmg@users.noreply.github.com> Date: Tue, 14 Dec 2021 06:30:56 -0900 Subject: bus/nes_ctrl: Updated Partytap controller. (#8943) * bus/nes_ctrl: Updated Partytap controller. Project Q now detects the controller and inputs work. --- hash/nes.xml | 6 ++++- src/devices/bus/nes_ctrl/partytap.cpp | 49 ++++++++++++----------------------- src/devices/bus/nes_ctrl/partytap.h | 13 +++++----- 3 files changed, 27 insertions(+), 41 deletions(-) diff --git a/hash/nes.xml b/hash/nes.xml index ab6592e424c..e79bf5656d2 100644 --- a/hash/nes.xml +++ b/hash/nes.xml @@ -5903,6 +5903,7 @@ license:CC0 + @@ -14721,6 +14722,7 @@ license:CC0 + @@ -47086,6 +47088,7 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx + @@ -49387,7 +49390,8 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + + diff --git a/src/devices/bus/nes_ctrl/partytap.cpp b/src/devices/bus/nes_ctrl/partytap.cpp index b9029ab2f3a..af5e890f2b8 100644 --- a/src/devices/bus/nes_ctrl/partytap.cpp +++ b/src/devices/bus/nes_ctrl/partytap.cpp @@ -2,7 +2,7 @@ // copyright-holders:Fabio Priuli /********************************************************************** - Nintendo Family Computer Yonezawa / PartyRoom 21 Party Tap Controller + Nintendo Family Computer Yonezawa / Party Room 21 Partytap Controller **********************************************************************/ @@ -13,7 +13,7 @@ // DEVICE DEFINITIONS //************************************************************************** -DEFINE_DEVICE_TYPE(NES_PARTYTAP, nes_partytap_device, "nes_partytap", "Yonezawa Party Tap Controller") +DEFINE_DEVICE_TYPE(NES_PARTYTAP, nes_partytap_device, "nes_partytap", "Yonezawa Partytap Controller") static INPUT_PORTS_START( nes_partytap ) @@ -44,12 +44,11 @@ ioport_constructor nes_partytap_device::device_input_ports() const // 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) +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) { } @@ -61,18 +60,7 @@ nes_partytap_device::nes_partytap_device(const machine_config &mconfig, const ch 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; + save_item(NAME(m_strobe)); } @@ -80,15 +68,16 @@ void nes_partytap_device::device_reset() // read //------------------------------------------------- -uint8_t nes_partytap_device::read_exp(offs_t offset) +u8 nes_partytap_device::read_exp(offs_t offset) { - uint8_t ret = 0; + u8 ret = 0; if (offset == 1) //$4017 { + if (m_strobe) + m_latch = m_inputs->read(); ret |= m_latch & 0x1c; m_latch >>= 3; - // append mode bits - m_latch |= m_mode; + m_latch |= 0xa0; // after first two reads, 0x14 will be returned } return ret; } @@ -97,14 +86,8 @@ uint8_t nes_partytap_device::read_exp(offs_t offset) // write //------------------------------------------------- -void nes_partytap_device::write(uint8_t data) +void nes_partytap_device::write(u8 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(); + if (write_strobe(data)) + m_latch = m_inputs->read(); } diff --git a/src/devices/bus/nes_ctrl/partytap.h b/src/devices/bus/nes_ctrl/partytap.h index c3da2278aed..587f4fd164d 100644 --- a/src/devices/bus/nes_ctrl/partytap.h +++ b/src/devices/bus/nes_ctrl/partytap.h @@ -2,7 +2,7 @@ // copyright-holders:Fabio Priuli /********************************************************************** - Nintendo Family Computer Yonezawa / PartyRoom 21 Party Tap Controller + Nintendo Family Computer Yonezawa / Party Room 21 Partytap Controller **********************************************************************/ @@ -25,23 +25,22 @@ class nes_partytap_device : public device_t, { public: // construction/destruction - nes_partytap_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + nes_partytap_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); virtual ioport_constructor device_input_ports() const override; protected: // device-level overrides virtual void device_start() override; - virtual void device_reset() override; - virtual uint8_t read_exp(offs_t offset) override; - virtual void write(uint8_t data) override; + virtual u8 read_exp(offs_t offset) override; + virtual void write(u8 data) override; required_ioport m_inputs; - uint8_t m_mode; - uint32_t m_latch; + u8 m_latch; }; + // device type definition DECLARE_DEVICE_TYPE(NES_PARTYTAP, nes_partytap_device) -- cgit v1.2.3