From dce1fd7dfa91b41b82af90069e133d2a83e86976 Mon Sep 17 00:00:00 2001 From: 0kmg <9137159+0kmg@users.noreply.github.com> Date: Tue, 2 Nov 2021 11:46:43 -0800 Subject: bus/nes_ctrl: Added emulation for IGS Tap-tap Mat controller. (#8772) * Refactored Family Trainer and Tap-tap Mat into common base class. Software list items promoted to working (nes.xml) --------------------------------------- Super Mogura Tataki!! Pokkun Moguraa (Japan) --- hash/nes.xml | 12 +-- scripts/src/bus.lua | 4 +- src/devices/bus/nes_ctrl/ctrl.cpp | 3 +- src/devices/bus/nes_ctrl/fcmat.cpp | 187 ++++++++++++++++++++++++++++++++++ src/devices/bus/nes_ctrl/fcmat.h | 76 ++++++++++++++ src/devices/bus/nes_ctrl/ftrainer.cpp | 144 -------------------------- src/devices/bus/nes_ctrl/ftrainer.h | 50 --------- 7 files changed, 273 insertions(+), 203 deletions(-) create mode 100644 src/devices/bus/nes_ctrl/fcmat.cpp create mode 100644 src/devices/bus/nes_ctrl/fcmat.h delete mode 100644 src/devices/bus/nes_ctrl/ftrainer.cpp delete mode 100644 src/devices/bus/nes_ctrl/ftrainer.h diff --git a/hash/nes.xml b/hash/nes.xml index d0622236a56..9fd420d9bdd 100644 --- a/hash/nes.xml +++ b/hash/nes.xml @@ -12167,7 +12167,7 @@ license:CC0 - + Family Trainer 1 - Athletic World (Jpn, v1.1) 1986 Bandai @@ -12188,7 +12188,7 @@ license:CC0 - + Family Trainer 1 - Athletic World (Jpn) 1986 Bandai @@ -12255,7 +12255,7 @@ license:CC0 - + Family Trainer 4 - Jogging Race (Jpn) 1987 Bandai @@ -37030,18 +37030,18 @@ license:CC0 - - + Super Mogura Tataki!! Pokkun Moguraa (Japan) 1989 IGS - + + diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index cb898a2a4c9..561ff9e496f 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -2910,8 +2910,8 @@ if (BUSES["NES_CTRL"]~=null) then MAME_DIR .. "src/devices/bus/nes_ctrl/arkpaddle.h", MAME_DIR .. "src/devices/bus/nes_ctrl/bcbattle.cpp", MAME_DIR .. "src/devices/bus/nes_ctrl/bcbattle.h", - MAME_DIR .. "src/devices/bus/nes_ctrl/ftrainer.cpp", - MAME_DIR .. "src/devices/bus/nes_ctrl/ftrainer.h", + MAME_DIR .. "src/devices/bus/nes_ctrl/fcmat.cpp", + MAME_DIR .. "src/devices/bus/nes_ctrl/fcmat.h", MAME_DIR .. "src/devices/bus/nes_ctrl/fckeybrd.cpp", MAME_DIR .. "src/devices/bus/nes_ctrl/fckeybrd.h", MAME_DIR .. "src/devices/bus/nes_ctrl/hori.cpp", diff --git a/src/devices/bus/nes_ctrl/ctrl.cpp b/src/devices/bus/nes_ctrl/ctrl.cpp index 991191a1f0c..77f72d6b687 100644 --- a/src/devices/bus/nes_ctrl/ctrl.cpp +++ b/src/devices/bus/nes_ctrl/ctrl.cpp @@ -46,8 +46,8 @@ #include "4score.h" #include "arkpaddle.h" #include "bcbattle.h" -#include "ftrainer.h" #include "fckeybrd.h" +#include "fcmat.h" #include "hori.h" #include "joypad.h" #include "konamihs.h" @@ -211,4 +211,5 @@ void fc_expansion_devices(device_slot_interface &device) device.option_add("hori_4p", NES_HORI4P); device.option_add("barcode_battler", NES_BARCODE_BATTLER); device.option_add("subor_keyboard", NES_SUBORKEYBOARD); + device.option_add("taptapmat", NES_TAPTAPMAT); } diff --git a/src/devices/bus/nes_ctrl/fcmat.cpp b/src/devices/bus/nes_ctrl/fcmat.cpp new file mode 100644 index 00000000000..5a01fcd209a --- /dev/null +++ b/src/devices/bus/nes_ctrl/fcmat.cpp @@ -0,0 +1,187 @@ +// license:BSD-3-Clause +// copyright-holders:kmg, Fabio Priuli +/********************************************************************** + + Here we emulate two distinct mat controllers which share a common + read/write interface with the hardware: + + Nintendo Family Computer - Bandai Family Trainer Mat + Nintendo Family Computer - IGS Tap-tap Mat + +**********************************************************************/ + +#include "emu.h" +#include "fcmat.h" + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +DEFINE_DEVICE_TYPE(NES_FTRAINER, nes_ftrainer_device, "nes_famtrain", "Bandai Family Trainer") +DEFINE_DEVICE_TYPE(NES_TAPTAPMAT, nes_taptapmat_device, "nes_taptapmat", "IGS Tap-tap Mat") + + +static INPUT_PORTS_START( nes_ftrainer ) + PORT_START("LAYOUT") + PORT_CONFNAME( 0x01, 0x00, "Family Trainer Button Layout") + PORT_CONFSETTING( 0x00, "Side A" ) + PORT_CONFSETTING( 0x01, "Side B" ) + + // difference between the two sides is that we mirror the key mapping to match the real pad layout! + PORT_START("MAT_COL.0") + // side A layout + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_NAME("Family Trainer Mid1") PORT_CODE(KEYCODE_F) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) + // side B layout + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON12 ) PORT_NAME("Family Trainer 12") PORT_CODE(KEYCODE_M) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_NAME("Family Trainer 8") PORT_CODE(KEYCODE_J) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Family Trainer 4") PORT_CODE(KEYCODE_U) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) + + PORT_START("MAT_COL.1") + // side A layout + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON11 ) PORT_NAME("Family Trainer Low1") PORT_CODE(KEYCODE_B) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_NAME("Family Trainer Mid2") PORT_CODE(KEYCODE_G) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Family Trainer Top1") PORT_CODE(KEYCODE_T) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) + // side B layout + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON11 ) PORT_NAME("Family Trainer 11") PORT_CODE(KEYCODE_N) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_NAME("Family Trainer 7") PORT_CODE(KEYCODE_H) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Family Trainer 3") PORT_CODE(KEYCODE_Y) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) + + PORT_START("MAT_COL.2") + // side A layout + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON10 ) PORT_NAME("Family Trainer Low2") PORT_CODE(KEYCODE_N) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("Family Trainer Mid3") PORT_CODE(KEYCODE_H) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Family Trainer Top2") PORT_CODE(KEYCODE_Y) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) + // side B layout + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON10 ) PORT_NAME("Family Trainer 10") PORT_CODE(KEYCODE_B) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("Family Trainer 6") PORT_CODE(KEYCODE_G) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Family Trainer 2") PORT_CODE(KEYCODE_T) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) + + PORT_START("MAT_COL.3") + // side A layout + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("Family Trainer Mid4") PORT_CODE(KEYCODE_J) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) + // side B layout + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON9 ) PORT_NAME("Family Trainer 9") PORT_CODE(KEYCODE_V) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("Family Trainer 5") PORT_CODE(KEYCODE_F) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Family Trainer 1") PORT_CODE(KEYCODE_R) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) +INPUT_PORTS_END + + +static INPUT_PORTS_START( nes_taptapmat ) + PORT_START("MAT_COL.0") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON12 ) PORT_NAME("Bottom Left (Frankenstein)") PORT_CODE(KEYCODE_V) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_NAME("Middle Left (Bang!)") PORT_CODE(KEYCODE_F) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Top Left (Antlion)") PORT_CODE(KEYCODE_R) + + PORT_START("MAT_COL.1") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON11 ) PORT_NAME("Bottom Mid-Left (Bang!)") PORT_CODE(KEYCODE_B) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_NAME("Middle Mid-Left (Caveman)") PORT_CODE(KEYCODE_G) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Top Mid-Left (Bang!)") PORT_CODE(KEYCODE_T) + + PORT_START("MAT_COL.2") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON10 ) PORT_NAME("Bottom Mid-Right (Shark)") PORT_CODE(KEYCODE_N) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("Middle Mid-Right (Bang!)") PORT_CODE(KEYCODE_H) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Top Mid-Right (Dinosaur)") PORT_CODE(KEYCODE_Y) + + PORT_START("MAT_COL.3") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON9 ) PORT_NAME("Bottom Right (Bang!)") PORT_CODE(KEYCODE_M) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("Middle Right (Mole)") PORT_CODE(KEYCODE_J) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Top Right (Bang!)") PORT_CODE(KEYCODE_U) +INPUT_PORTS_END + + +//------------------------------------------------- +// input_ports - device-specific input ports +//------------------------------------------------- + +ioport_constructor nes_ftrainer_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( nes_ftrainer ); +} + +ioport_constructor nes_taptapmat_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( nes_taptapmat ); +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// constructor +//------------------------------------------------- + +nes_fcmat_device::nes_fcmat_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) + : device_t(mconfig, type, tag, owner, clock) + , device_nes_control_port_interface(mconfig, *this) + , m_mat(*this, "MAT_COL.%u", 0) + , m_row_scan(0) +{ +} + +nes_ftrainer_device::nes_ftrainer_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_fcmat_device(mconfig, NES_FTRAINER, tag, owner, clock) +{ +} + +nes_taptapmat_device::nes_taptapmat_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_fcmat_device(mconfig, NES_TAPTAPMAT, tag, owner, clock) +{ +} + + +//------------------------------------------------- +// device_start +//------------------------------------------------- + +void nes_fcmat_device::device_start() +{ + save_item(NAME(m_row_scan)); +} + + +//------------------------------------------------- +// device_reset +//------------------------------------------------- + +void nes_fcmat_device::device_reset() +{ + m_row_scan = 0; +} + + +//------------------------------------------------- +// read +//------------------------------------------------- + +u8 nes_fcmat_device::read_exp(offs_t offset) +{ + u8 ret = 0; + + if (offset == 1) // $4017 + { + for (int row = 0; row < 3; row++) // bottom row first (buttons 9,10,11,12 on Family Trainer) + if (!BIT(m_row_scan, row)) + for (int col = 0; col < 4; col++) // left column first (Family Trainer side A and Tap-tap Mat) + ret |= BIT(m_mat[col]->read(), row) << (col + 1); + ret = ~ret & 0x1e; // 0: pressed, 1: not pressed + } + + return ret; +} + +//------------------------------------------------- +// write +//------------------------------------------------- + +void nes_fcmat_device::write(u8 data) +{ + // select row to scan + m_row_scan = data & 0x07; +} diff --git a/src/devices/bus/nes_ctrl/fcmat.h b/src/devices/bus/nes_ctrl/fcmat.h new file mode 100644 index 00000000000..7c6a595e532 --- /dev/null +++ b/src/devices/bus/nes_ctrl/fcmat.h @@ -0,0 +1,76 @@ +// license:BSD-3-Clause +// copyright-holders:kmg, Fabio Priuli +/********************************************************************** + + Nintendo Family Computer - Bandai Family Trainer Mat + Nintendo Family Computer - IGS Tap-tap Mat + +**********************************************************************/ + +#ifndef MAME_BUS_NES_CTRL_FCMAT_H +#define MAME_BUS_NES_CTRL_FCMAT_H + +#pragma once + +#include "ctrl.h" + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> nes_fcmat_device + +class nes_fcmat_device : + public device_t, + public device_nes_control_port_interface +{ +protected: + // construction/destruction + nes_fcmat_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock); + + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + + virtual u8 read_exp(offs_t offset) override; + virtual void write(u8 data) override; + +private: + required_ioport_array<4> m_mat; + u8 m_row_scan; +}; + + +// ======================> nes_ftrainer_device + +class nes_ftrainer_device : public nes_fcmat_device +{ +public: + // construction/destruction + nes_ftrainer_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + +protected: + virtual ioport_constructor device_input_ports() const override; +}; + + +// ======================> nes_taptapmat_device + +class nes_taptapmat_device : public nes_fcmat_device +{ +public: + // construction/destruction + nes_taptapmat_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + +protected: + virtual ioport_constructor device_input_ports() const override; +}; + + +// device type definition +DECLARE_DEVICE_TYPE(NES_FTRAINER, nes_ftrainer_device) +DECLARE_DEVICE_TYPE(NES_TAPTAPMAT, nes_taptapmat_device) + + +#endif // MAME_BUS_NES_CTRL_FCMAT_H diff --git a/src/devices/bus/nes_ctrl/ftrainer.cpp b/src/devices/bus/nes_ctrl/ftrainer.cpp deleted file mode 100644 index fe89436ce90..00000000000 --- a/src/devices/bus/nes_ctrl/ftrainer.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Fabio Priuli -/********************************************************************** - - Nintendo Family Computer - Bandai Family Trainer Mat - -**********************************************************************/ - -#include "emu.h" -#include "ftrainer.h" - -//************************************************************************** -// DEVICE DEFINITIONS -//************************************************************************** - -DEFINE_DEVICE_TYPE(NES_FTRAINER, nes_ftrainer_device, "nes_famtrain", "Bandai Family Trainer") - - -static INPUT_PORTS_START( nes_ftrainer ) - PORT_START("LAYOUT") - PORT_CONFNAME( 0x01, 0x00, "Family Trainer Button Layout") - PORT_CONFSETTING( 0x00, "Side A" ) - PORT_CONFSETTING( 0x01, "Side B" ) - - // difference between the two sides is that we mirror the key mapping to match the real pad layout! - PORT_START("FT_COL.0") - // side A layout - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid1") PORT_CODE(KEYCODE_F) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) - // side B layout - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 12") PORT_CODE(KEYCODE_M) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 8") PORT_CODE(KEYCODE_J) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 4") PORT_CODE(KEYCODE_U) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) - - PORT_START("FT_COL.1") - // side A layout - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Low1") PORT_CODE(KEYCODE_B) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid2") PORT_CODE(KEYCODE_G) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Top1") PORT_CODE(KEYCODE_T) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) - // side B layout - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 11") PORT_CODE(KEYCODE_N) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 7") PORT_CODE(KEYCODE_H) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 3") PORT_CODE(KEYCODE_Y) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) - - PORT_START("FT_COL.2") - // side A layout - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Low2") PORT_CODE(KEYCODE_N) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid3") PORT_CODE(KEYCODE_H) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Top2") PORT_CODE(KEYCODE_Y) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) - // side B layout - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 10") PORT_CODE(KEYCODE_B) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 6") PORT_CODE(KEYCODE_G) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 2") PORT_CODE(KEYCODE_T) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) - - PORT_START("FT_COL.3") - // side A layout - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer Mid4") PORT_CODE(KEYCODE_J) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x00) - // side B layout - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 9") PORT_CODE(KEYCODE_V) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 5") PORT_CODE(KEYCODE_F) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Family Trainer 1") PORT_CODE(KEYCODE_R) PORT_CONDITION("LAYOUT", 0x01, EQUALS, 0x01) -INPUT_PORTS_END - - -//------------------------------------------------- -// input_ports - device-specific input ports -//------------------------------------------------- - -ioport_constructor nes_ftrainer_device::device_input_ports() const -{ - return INPUT_PORTS_NAME( nes_ftrainer ); -} - - - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// nes_ftrainer_device - constructor -//------------------------------------------------- - -nes_ftrainer_device::nes_ftrainer_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, NES_FTRAINER, tag, owner, clock) - , device_nes_control_port_interface(mconfig, *this) - , m_trainer(*this, "FT_COL.%u", 0) - , m_row_scan(0) -{ -} - - -//------------------------------------------------- -// device_start -//------------------------------------------------- - -void nes_ftrainer_device::device_start() -{ - save_item(NAME(m_row_scan)); -} - - -//------------------------------------------------- -// device_reset -//------------------------------------------------- - -void nes_ftrainer_device::device_reset() -{ - m_row_scan = 0; -} - - -//------------------------------------------------- -// read -//------------------------------------------------- - -uint8_t nes_ftrainer_device::read_exp(offs_t offset) -{ - uint8_t ret = 0; - - if (offset == 1) // $4017 - { - for (int row = 0; row < 3; row++) // bottom row first (buttons 9,10,11,12) - if (!BIT(m_row_scan, row)) - for (int col = 0; col < 4; col++) // side B right column first (buttons 4,8,12) - ret |= BIT(m_trainer[col]->read(), row) << (col + 1); - return ~ret & 0x1e; // 0: pressed, 1: not pressed - } - - return ret; -} - -//------------------------------------------------- -// write -//------------------------------------------------- - -void nes_ftrainer_device::write(uint8_t data) -{ - // select row to scan - m_row_scan = data & 0x07; -} diff --git a/src/devices/bus/nes_ctrl/ftrainer.h b/src/devices/bus/nes_ctrl/ftrainer.h deleted file mode 100644 index d72077c93a2..00000000000 --- a/src/devices/bus/nes_ctrl/ftrainer.h +++ /dev/null @@ -1,50 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Fabio Priuli -/********************************************************************** - - Nintendo Family Computer - Bandai Family Trainer Mat - -**********************************************************************/ - -#ifndef MAME_BUS_NES_CTRL_FTRAINER_H -#define MAME_BUS_NES_CTRL_FTRAINER_H - -#pragma once - -#include "ctrl.h" - - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> nes_ftrainer_device - -class nes_ftrainer_device : public device_t, - public device_nes_control_port_interface -{ -public: - // construction/destruction - nes_ftrainer_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t 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; - -private: - required_ioport_array<4> m_trainer; - uint8_t m_row_scan; -}; - - -// device type definition -DECLARE_DEVICE_TYPE(NES_FTRAINER, nes_ftrainer_device) - - -#endif // MAME_BUS_NES_CTRL_FTRAINER_H -- cgit v1.2.3