summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author 0kmg <9137159+0kmg@users.noreply.github.com>2021-12-25 06:50:08 -0900
committer GitHub <noreply@github.com>2021-12-26 02:50:08 +1100
commit9b853c77fd4d354a75126b12e7a5ec7a777308e1 (patch)
treef637012e8f67777bb48189ce3a85282685c02a0c
parentb4c4ced84f8f5d218237f2a9c1f9585db4cb1fea (diff)
-bus/nes_ctrl: Added support for Famicom Turbofile backup RAM. (#9034)
-nes.xml: Corrected Metroid release year.
-rw-r--r--hash/nes.xml14
-rw-r--r--scripts/src/bus.lua2
-rw-r--r--src/devices/bus/nes_ctrl/ctrl.cpp2
-rw-r--r--src/devices/bus/nes_ctrl/mjpanel.cpp2
-rw-r--r--src/devices/bus/nes_ctrl/partytap.cpp2
-rw-r--r--src/devices/bus/nes_ctrl/turbofile.cpp140
-rw-r--r--src/devices/bus/nes_ctrl/turbofile.h59
7 files changed, 217 insertions, 4 deletions
diff --git a/hash/nes.xml b/hash/nes.xml
index 6af0c4a7466..d68669585ca 100644
--- a/hash/nes.xml
+++ b/hash/nes.xml
@@ -3902,6 +3902,7 @@ license:CC0
<feature name="slot" value="sxrom" />
<feature name="pcb" value="HVC-SKROM" />
<feature name="mmc1_type" value="MMC1B2" />
+ <feature name="peripheral" value="turbofile" />
<dataarea name="prg" size="131072">
<rom name="hsp-46-1 prg" size="131072" crc="9c94a0ec" sha1="f5650471a1b3121e7bab77df2399cce157c1d91c" offset="00000" />
</dataarea>
@@ -3976,6 +3977,7 @@ license:CC0
<feature name="slot" value="sxrom" />
<feature name="pcb" value="HVC-SNROM" />
<feature name="mmc1_type" value="MMC1B2" />
+ <feature name="peripheral" value="turbofile" />
<dataarea name="prg" size="262144">
<rom name="hsp-36-0 prg" size="262144" crc="974e8840" sha1="8f228f38437423388a2e0860c05b1798e20cfe95" offset="00000" />
</dataarea>
@@ -4000,6 +4002,7 @@ license:CC0
<feature name="slot" value="sxrom" />
<feature name="pcb" value="HVC-SNROM" />
<feature name="mmc1_type" value="MMC1B2" />
+ <feature name="peripheral" value="turbofile" />
<dataarea name="prg" size="262144">
<rom name="hsp-33-0 prg" size="262144" crc="c2ef3422" sha1="ce103fe6971e2f97b82f13b8011c592039f46265" offset="00000" />
</dataarea>
@@ -4024,6 +4027,7 @@ license:CC0
<feature name="slot" value="sxrom" />
<feature name="pcb" value="HVC-SXROM" />
<feature name="mmc1_type" value="MMC1B2" />
+ <feature name="peripheral" value="turbofile" />
<dataarea name="prg" size="262144">
<rom name="hsp-bs-1 prg" size="262144" crc="c3de7c69" sha1="e847474c0576d394125245695d7e3a49d66f7956" offset="00000" />
</dataarea>
@@ -6000,6 +6004,7 @@ license:CC0
<feature name="slot" value="cnrom" />
<feature name="pcb" value="HVC-CNROM" />
<feature name="mirroring" value="vertical" />
+ <feature name="peripheral" value="turbofile" />
<dataarea name="prg" size="32768">
<rom name="hsp-05-0 prg" size="32768" crc="9fa1c11f" sha1="099b3b7e1b3f335abcd29cd3aa013894d745beb2" offset="00000" />
</dataarea>
@@ -9559,6 +9564,7 @@ license:CC0
<feature name="slot" value="txrom" />
<feature name="pcb" value="HVC-TLROM" />
<feature name="mmc3_type" value="MMC3A" />
+ <feature name="peripheral" value="turbofile" />
<dataarea name="prg" size="131072">
<rom name="tjc-dn-0 prg" size="131072" crc="728c3d98" sha1="dd6069c0827d60682bc97723750946ce89ab4630" offset="00000" />
</dataarea>
@@ -24577,10 +24583,10 @@ license:CC0
<software name="metroidu" cloneof="metroid">
<description>Metroid (USA)</description>
- <year>1986</year>
+ <year>1987</year>
<publisher>Nintendo</publisher>
<info name="serial" value="NES-MT-USA"/>
- <info name="release" value="198608xx"/>
+ <info name="release" value="198708xx"/>
<part name="cart" interface="nes_cart">
<feature name="slot" value="sxrom" />
<feature name="pcb" value="NES-SNROM" />
@@ -25708,6 +25714,7 @@ license:CC0
<feature name="slot" value="sxrom" />
<feature name="pcb" value="HVC-SLROM" />
<feature name="mmc1_type" value="MMC1B2" />
+ <feature name="peripheral" value="turbofile" />
<dataarea name="prg" size="131072">
<rom name="sfl-zm-0 prg" size="131072" crc="ea79cc19" sha1="682ce64b60645d5d76bd15deeb254ae8f7537015" offset="00000" />
</dataarea>
@@ -45116,6 +45123,7 @@ Also notice that VRAM, WRAM & mirror are probably incorrect for some of these se
<part name="cart" interface="nes_cart">
<feature name="slot" value="sxrom" />
<feature name="pcb" value="NES-SLROM" />
+ <feature name="peripheral" value="turbofile" />
<dataarea name="prg" size="131072">
<rom name="best keiba - derby stallion (japan).prg" size="131072" crc="41482da3" sha1="7545769a31a1623b6947ec412dda569aae9190f2" offset="00000" status="baddump" />
</dataarea>
@@ -45139,6 +45147,7 @@ Also notice that VRAM, WRAM & mirror are probably incorrect for some of these se
<part name="cart" interface="nes_cart">
<feature name="slot" value="sxrom" />
<feature name="pcb" value="NES-SLROM" />
+ <feature name="peripheral" value="turbofile" />
<dataarea name="prg" size="262144">
<rom name="best play pro yakyuu special (japan).prg" size="262144" crc="b8747abf" sha1="340f507cfc3f3827ee0b7269814e08d634b807f4" offset="00000" status="baddump" />
</dataarea>
@@ -46605,6 +46614,7 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx
<part name="cart" interface="nes_cart">
<feature name="slot" value="sxrom" />
<feature name="pcb" value="NES-SLROM" />
+ <feature name="peripheral" value="turbofile" />
<dataarea name="chr" size="131072">
<rom name="famicom shougi - ryuuousen (japan).chr" size="131072" crc="30989ad9" sha1="6d96e346713547af01adea39751327f8b924e41d" offset="00000" status="baddump" />
</dataarea>
diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua
index 2a6b0d4ffd2..8b432658573 100644
--- a/scripts/src/bus.lua
+++ b/scripts/src/bus.lua
@@ -3034,6 +3034,8 @@ if (BUSES["NES_CTRL"]~=null) then
MAME_DIR .. "src/devices/bus/nes_ctrl/snesadapter.h",
MAME_DIR .. "src/devices/bus/nes_ctrl/suborkey.cpp",
MAME_DIR .. "src/devices/bus/nes_ctrl/suborkey.h",
+ MAME_DIR .. "src/devices/bus/nes_ctrl/turbofile.cpp",
+ MAME_DIR .. "src/devices/bus/nes_ctrl/turbofile.h",
MAME_DIR .. "src/devices/bus/nes_ctrl/zapper.cpp",
MAME_DIR .. "src/devices/bus/nes_ctrl/zapper.h",
}
diff --git a/src/devices/bus/nes_ctrl/ctrl.cpp b/src/devices/bus/nes_ctrl/ctrl.cpp
index 345a0ba0e34..f13410fc98e 100644
--- a/src/devices/bus/nes_ctrl/ctrl.cpp
+++ b/src/devices/bus/nes_ctrl/ctrl.cpp
@@ -60,6 +60,7 @@
#include "powerpad.h"
#include "snesadapter.h"
#include "suborkey.h"
+#include "turbofile.h"
#include "zapper.h"
@@ -229,4 +230,5 @@ void fc_expansion_devices(device_slot_interface &device)
device.option_add("barcode_battler", NES_BARCODE_BATTLER);
device.option_add("subor_keyboard", NES_SUBORKEYBOARD);
device.option_add("taptapmat", NES_TAPTAPMAT);
+ device.option_add("turbofile", NES_TURBOFILE);
}
diff --git a/src/devices/bus/nes_ctrl/mjpanel.cpp b/src/devices/bus/nes_ctrl/mjpanel.cpp
index 08e7b6ce757..9624ff95226 100644
--- a/src/devices/bus/nes_ctrl/mjpanel.cpp
+++ b/src/devices/bus/nes_ctrl/mjpanel.cpp
@@ -106,7 +106,7 @@ void nes_mjpanel_device::device_start()
u8 nes_mjpanel_device::read_exp(offs_t offset)
{
u8 ret = 0;
- if (offset) // $4017
+ if (offset == 1) // $4017
{
if (m_strobe)
set_latch();
diff --git a/src/devices/bus/nes_ctrl/partytap.cpp b/src/devices/bus/nes_ctrl/partytap.cpp
index af5e890f2b8..b06be261e49 100644
--- a/src/devices/bus/nes_ctrl/partytap.cpp
+++ b/src/devices/bus/nes_ctrl/partytap.cpp
@@ -75,7 +75,7 @@ u8 nes_partytap_device::read_exp(offs_t offset)
{
if (m_strobe)
m_latch = m_inputs->read();
- ret |= m_latch & 0x1c;
+ ret = m_latch & 0x1c;
m_latch >>= 3;
m_latch |= 0xa0; // after first two reads, 0x14 will be returned
}
diff --git a/src/devices/bus/nes_ctrl/turbofile.cpp b/src/devices/bus/nes_ctrl/turbofile.cpp
new file mode 100644
index 00000000000..5f4db5c1641
--- /dev/null
+++ b/src/devices/bus/nes_ctrl/turbofile.cpp
@@ -0,0 +1,140 @@
+// license:BSD-3-Clause
+// copyright-holders:kmg
+/**********************************************************************
+
+ Nintendo Family Computer ASCII Turbofile SRAM external storage device
+
+ The original 8K Turbofile, emulated here, has been seen with serials
+ AS-TF02 through AS-TF04, differences unknown. We do not support the
+ Turbo File II (yet?), but it appears to simply be a 32K version with
+ a manual switch to select between four 8K banks. Both devices also
+ sport a write protect switch.
+
+**********************************************************************/
+
+#include "emu.h"
+#include "turbofile.h"
+
+//**************************************************************************
+// DEVICE DEFINITIONS
+//**************************************************************************
+
+DEFINE_DEVICE_TYPE(NES_TURBOFILE, nes_turbofile_device, "nes_turbofile", "ASCII Turbofile Backup RAM")
+
+
+INPUT_CHANGED_MEMBER( nes_turbofile_device::lock_changed )
+{
+ m_locked = newval;
+ popmessage("Turbofile Protect Switch %s\n", m_locked ? "ON" : "OFF");
+}
+
+
+static INPUT_PORTS_START( nes_turbofile )
+ PORT_START("LOCK")
+ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Protect Switch") PORT_TOGGLE PORT_CHANGED_MEMBER(DEVICE_SELF, nes_turbofile_device, lock_changed, 0)
+INPUT_PORTS_END
+
+//-------------------------------------------------
+// input_ports - device-specific input ports
+//-------------------------------------------------
+
+ioport_constructor nes_turbofile_device::device_input_ports() const
+{
+ return INPUT_PORTS_NAME( nes_turbofile );
+}
+
+
+//-------------------------------------------------
+// device_add_mconfig - add device configuration
+//-------------------------------------------------
+
+void nes_turbofile_device::device_add_mconfig(machine_config &config)
+{
+ NVRAM(config, "nvram", nvram_device::DEFAULT_NONE);
+}
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// nes_turbofile_device - constructor
+//-------------------------------------------------
+
+nes_turbofile_device::nes_turbofile_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : device_t(mconfig, NES_TURBOFILE, tag, owner, clock)
+ , device_nes_control_port_interface(mconfig, *this)
+ , m_nvram(*this, "nvram")
+ , m_lock(*this, "LOCK")
+ , m_addr(0)
+ , m_bit(0)
+ , m_latch(0)
+ , m_locked(0)
+{
+}
+
+
+//-------------------------------------------------
+// device_start
+//-------------------------------------------------
+
+void nes_turbofile_device::device_start()
+{
+ // 8K RAM
+ m_ram = std::make_unique<u8[]>(0x2000);
+ m_nvram->set_base(m_ram.get(), 0x2000);
+
+ save_pointer(NAME(m_ram), 0x2000);
+ save_item(NAME(m_addr));
+ save_item(NAME(m_bit));
+ save_item(NAME(m_latch));
+ save_item(NAME(m_locked));
+}
+
+
+//-------------------------------------------------
+// device_reset
+//-------------------------------------------------
+
+void nes_turbofile_device::device_reset()
+{
+ m_locked = m_lock->read();
+}
+
+
+//-------------------------------------------------
+// read
+//-------------------------------------------------
+
+u8 nes_turbofile_device::read_exp(offs_t offset)
+{
+ return (offset == 1) ? BIT(m_ram[m_addr], m_bit) << 2 : 0;
+}
+
+//-------------------------------------------------
+// write
+//-------------------------------------------------
+
+void nes_turbofile_device::write(u8 data)
+{
+ if (!BIT(data, 1)) // reset position to start of RAM
+ {
+ m_addr = 0;
+ m_bit = 0;
+ }
+
+ if (!BIT(data, 2) && BIT(m_latch, 2))
+ {
+ if (!m_locked)
+ {
+ m_ram[m_addr] &= ~(1 << m_bit);
+ m_ram[m_addr] |= (data & 1) << m_bit;
+ }
+ m_bit = (m_bit + 1) & 0x07;
+ if (!m_bit)
+ m_addr = (m_addr + 1) & 0x1fff;
+ }
+
+ m_latch = data;
+}
diff --git a/src/devices/bus/nes_ctrl/turbofile.h b/src/devices/bus/nes_ctrl/turbofile.h
new file mode 100644
index 00000000000..7137ad9892c
--- /dev/null
+++ b/src/devices/bus/nes_ctrl/turbofile.h
@@ -0,0 +1,59 @@
+// license:BSD-3-Clause
+// copyright-holders:kmg
+/**********************************************************************
+
+ Nintendo Family Computer ASCII Turbofile SRAM external storage device
+
+**********************************************************************/
+
+#ifndef MAME_BUS_NES_CTRL_TURBOFILE_H
+#define MAME_BUS_NES_CTRL_TURBOFILE_H
+
+#pragma once
+
+#include "ctrl.h"
+#include "machine/nvram.h"
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> nes_turbofile_device
+
+class nes_turbofile_device : public device_t,
+ public device_nes_control_port_interface
+{
+public:
+ // construction/destruction
+ nes_turbofile_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+
+ DECLARE_INPUT_CHANGED_MEMBER(lock_changed);
+
+protected:
+ // device-level overrides
+ virtual void device_start() override;
+ virtual void device_reset() override;
+
+ virtual ioport_constructor device_input_ports() const override;
+ virtual void device_add_mconfig(machine_config &config) override;
+
+ virtual u8 read_exp(offs_t offset) override;
+ virtual void write(u8 data) override;
+
+private:
+ required_device<nvram_device> m_nvram;
+ required_ioport m_lock;
+
+ std::unique_ptr<u8[]> m_ram;
+ u16 m_addr;
+ u8 m_bit;
+ u8 m_latch;
+ u8 m_locked;
+};
+
+
+// device type definition
+DECLARE_DEVICE_TYPE(NES_TURBOFILE, nes_turbofile_device)
+
+#endif // MAME_BUS_NES_CTRL_TURBOFILE_H