From dfa5b141d632c7fc1d1ab4f15e73ce234f0c7f27 Mon Sep 17 00:00:00 2001
From: 0kmg <9137159+0kmg@users.noreply.github.com>
Date: Fri, 3 Sep 2021 12:35:05 -0800
Subject: bus/nes: Improved emulation of N625092-related multi-game cartridges.
(#8526)
* Fixes corrupt graphics in multiple games on all seven multi-game carts (including the new addition).
* Fixes flickering menu for several cartridges, making them usable.
New working software list additions (nes.xml)
-----------------------------------
5000000 in 1 (JPx72) [anonymous]
---
hash/nes.xml | 15 +++++
src/devices/bus/nes/multigame.cpp | 129 +++++++++++++++++---------------------
src/devices/bus/nes/multigame.h | 43 +++++++------
3 files changed, 92 insertions(+), 95 deletions(-)
diff --git a/hash/nes.xml b/hash/nes.xml
index e91d1c37bb4..723fe81e893 100644
--- a/hash/nes.xml
+++ b/hash/nes.xml
@@ -80126,6 +80126,21 @@ be better to redump them properly. -->
+
+ 5000000 in 1 (JPx72)
+ 19??
+ <pirate>
+
+
+
+
+
+
+
+
+
+
+
5 in 1 (SPC005)
19??
diff --git a/src/devices/bus/nes/multigame.cpp b/src/devices/bus/nes/multigame.cpp
index ac9452893e0..decded4f6c7 100644
--- a/src/devices/bus/nes/multigame.cpp
+++ b/src/devices/bus/nes/multigame.cpp
@@ -145,11 +145,6 @@ nes_kn42_device::nes_kn42_device(const machine_config &mconfig, const char *tag,
{
}
-nes_n625092_device::nes_n625092_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : nes_nrom_device(mconfig, NES_N625092, tag, owner, clock), m_latch1(0), m_latch2(0)
-{
-}
-
nes_a65as_device::nes_a65as_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: nes_nrom_device(mconfig, NES_A65AS, tag, owner, clock)
{
@@ -432,6 +427,11 @@ nes_bmc_k1029_device::nes_bmc_k1029_device(const machine_config &mconfig, const
{
}
+nes_n625092_device::nes_n625092_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : nes_vram_protect_device(mconfig, NES_N625092, tag, owner, clock)
+{
+}
+
nes_bmc_th22913_device::nes_bmc_th22913_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: nes_vram_protect_device(mconfig, NES_BMC_TH22913, tag, owner, clock)
{
@@ -530,24 +530,6 @@ void nes_kn42_device::pcb_reset()
chr8(0, CHRRAM);
}
-void nes_n625092_device::device_start()
-{
- common_start();
- save_item(NAME(m_latch1));
- save_item(NAME(m_latch2));
-}
-
-void nes_n625092_device::pcb_reset()
-{
- m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
- prg16_89ab(0);
- prg16_cdef(0);
- chr8(0, m_chr_source);
-
- m_latch1 = 0;
- m_latch2 = 0;
-}
-
void nes_a65as_device::device_start()
{
common_start();
@@ -1180,6 +1162,21 @@ void nes_bmc_60311c_device::pcb_reset()
update_banks();
}
+void nes_n625092_device::device_start()
+{
+ nes_vram_protect_device::device_start();
+ save_item(NAME(m_latch));
+}
+
+void nes_n625092_device::pcb_reset()
+{
+ nes_vram_protect_device::pcb_reset();
+ prg16_89ab(0);
+ prg16_cdef(0);
+
+ m_latch[0] = m_latch[1] = 0;
+}
+
void nes_bmc_th22913_device::pcb_reset()
{
nes_vram_protect_device::pcb_reset();
@@ -1416,56 +1413,6 @@ void nes_kn42_device::write_h(offs_t offset, u8 data)
prg16_89ab(m_latch | (data & 0x07) << 1 | BIT(data, 4));
}
-/*-------------------------------------------------
-
- Bootleg Board N625092
-
- Games: 400 in 1, 700 in 1, 1000 in 1
-
- iNES: mapper 221
-
- In MESS: Supported.
-
- -------------------------------------------------*/
-
-void nes_n625092_device::set_prg(uint8_t reg1, uint8_t reg2)
-{
- uint8_t helper1, helper2;
-
- helper1 = !(reg1 & 0x01) ? reg2 : (reg1 & 0x80) ? reg2 : (reg2 & 0x06) | 0x00;
- helper2 = !(reg1 & 0x01) ? reg2 : (reg1 & 0x80) ? 0x07 : (reg2 & 0x06) | 0x01;
-
- prg16_89ab(helper1 | ((reg1 & 0x70) >> 1));
- prg16_cdef(helper2 | ((reg1 & 0x70) >> 1));
-}
-
-void nes_n625092_device::write_h(offs_t offset, uint8_t data)
-{
- LOG_MMC(("n625092 write_h, offset: %04x, data: %02x\n", offset, data));
-
- if (offset < 0x4000)
- {
- set_nt_mirroring(BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
- offset = (offset >> 1) & 0xff;
-
- if (m_latch1 != offset)
- {
- m_latch1 = offset;
- set_prg(m_latch1, m_latch2);
- }
- }
- else
- {
- offset &= 0x07;
-
- if (m_latch2 != offset)
- {
- m_latch2 = offset;
- set_prg(m_latch1, m_latch2);
- }
- }
-}
-
/*-------------------------------------------------
Board BMC-A65AS
@@ -3157,6 +3104,42 @@ void nes_bmc_k1029_device::write_h(offs_t offset, u8 data)
m_vram_protect = BIT(offset, 0) == BIT(offset, 1);
}
+/*-------------------------------------------------
+
+ Bootleg Board N625092
+
+ Games: 320 in 1, 400 in 1, 700 in 1, 800 in 1,
+ 1000 in 1, 2000 in 1, 5000000 in 1
+
+ iNES: mapper 221
+
+ In MAME: Supported.
+
+ -------------------------------------------------*/
+
+void nes_n625092_device::write_h(offs_t offset, u8 data)
+{
+ LOG_MMC(("n625092 write_h, offset: %04x, data: %02x\n", offset, data));
+
+ m_latch[BIT(offset, 14)] = offset;
+
+ u8 bank = (m_latch[0] & 0x200) >> 3 | (m_latch[0] & 0xe0) >> 2 | (m_latch[1] & 0x07); // NesDev shows the high bit here, but is it correct? So far no cart is large enough to use this.
+ u8 mode = BIT(m_latch[0], 1);
+ if (mode && BIT(m_latch[0], 8)) // UNROM mode
+ {
+ prg16_89ab(bank);
+ prg16_cdef(bank | 7);
+ }
+ else // NROM mode
+ {
+ prg16_89ab(bank & ~mode);
+ prg16_cdef(bank | mode);
+ }
+
+ set_nt_mirroring(BIT(m_latch[0], 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
+ m_vram_protect = BIT(m_latch[1], 3);
+}
+
/*-------------------------------------------------
BMC-TH2291-3, BMC-CH-011
diff --git a/src/devices/bus/nes/multigame.h b/src/devices/bus/nes/multigame.h
index 74342513ff6..83ff5fbf5ef 100644
--- a/src/devices/bus/nes/multigame.h
+++ b/src/devices/bus/nes/multigame.h
@@ -137,28 +137,6 @@ private:
};
-// ======================> nes_n625092_device
-
-class nes_n625092_device : public nes_nrom_device
-{
-public:
- // construction/destruction
- nes_n625092_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- virtual void write_h(offs_t offset, uint8_t data) override;
-
- virtual void pcb_reset() override;
-
-protected:
- // device-level overrides
- virtual void device_start() override;
-
-private:
- void set_prg(uint8_t reg1, uint8_t reg2);
- uint8_t m_latch1, m_latch2;
-};
-
-
// ======================> nes_a65as_device
class nes_a65as_device : public nes_nrom_device
@@ -1166,6 +1144,27 @@ public:
};
+// ======================> nes_n625092_device
+
+class nes_n625092_device : public nes_vram_protect_device
+{
+public:
+ // construction/destruction
+ nes_n625092_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+
+ virtual void write_h(offs_t offset, u8 data) override;
+
+ virtual void pcb_reset() override;
+
+protected:
+ // device-level overrides
+ virtual void device_start() override;
+
+private:
+ u16 m_latch[2];
+};
+
+
// ======================> nes_bmc_th22913_device
class nes_bmc_th22913_device : public nes_vram_protect_device
--
cgit v1.2.3