From 0270ca721b9b28dfcb597a52ca6f34c813f719de Mon Sep 17 00:00:00 2001 From: 0kmg <9137159+0kmg@users.noreply.github.com> Date: Sat, 9 Apr 2022 16:51:16 -0800 Subject: [PATCH] =?UTF-8?q?bus/nes:=20Added=20support=20for=20Sachen's=20Z?= =?UTF-8?q?h=C5=8Dnggu=C3=B3=20D=C3=A0h=C4=93ng=20cartridge.=20(#9540)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hash/nes.xml | 19 +++++--- src/devices/bus/nes/mmc3_clones.cpp | 75 +++++++++++++++++++++++++++++ src/devices/bus/nes/mmc3_clones.h | 25 ++++++++++ src/devices/bus/nes/nes_carts.cpp | 3 +- src/devices/bus/nes/nes_ines.hxx | 2 +- src/devices/bus/nes/nes_pcb.hxx | 3 +- src/devices/bus/nes/nes_slot.h | 2 +- 7 files changed, 117 insertions(+), 12 deletions(-) diff --git a/hash/nes.xml b/hash/nes.xml index 18dd35393f2..34de8949d20 100644 --- a/hash/nes.xml +++ b/hash/nes.xml @@ -54310,7 +54310,7 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + @@ -54399,23 +54399,26 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - - Chuugoku Taitei (Tw) - 19?? + + Zhōngguó Dàhēng (Taiwan) + 199? Sachen - - + - - + + + + + + diff --git a/src/devices/bus/nes/mmc3_clones.cpp b/src/devices/bus/nes/mmc3_clones.cpp index d38bb934354..23e2969b149 100644 --- a/src/devices/bus/nes/mmc3_clones.cpp +++ b/src/devices/bus/nes/mmc3_clones.cpp @@ -52,6 +52,7 @@ DEFINE_DEVICE_TYPE(NES_COCOMA, nes_cocoma_device, "nes_cocoma", DEFINE_DEVICE_TYPE(NES_GOUDER, nes_gouder_device, "nes_gouder", "NES Cart Gouder PCB") DEFINE_DEVICE_TYPE(NES_SA9602B, nes_sa9602b_device, "nes_sa9602b", "NES Cart SA-9602B PCB") DEFINE_DEVICE_TYPE(NES_SACHEN_SHERO, nes_sachen_shero_device, "nes_shero", "NES Cart Street Hero PCB") +DEFINE_DEVICE_TYPE(NES_SACHEN_ZGDH, nes_sachen_zgdh_device, "nes_zgdh", "NES Cart Zhongguo Daheng PCB") DEFINE_DEVICE_TYPE(NES_A9746, nes_a9746_device, "nes_bmc_a9746", "NES Cart A-9746 PCB") DEFINE_DEVICE_TYPE(NES_A88S1, nes_a88s1_device, "nes_a88s1", "NES Cart BMC A88S-1 PCB") @@ -294,6 +295,11 @@ nes_sachen_shero_device::nes_sachen_shero_device(const machine_config &mconfig, { } +nes_sachen_zgdh_device::nes_sachen_zgdh_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_txrom_device(mconfig, NES_SACHEN_ZGDH, tag, owner, clock), m_reg(0) +{ +} + nes_a9746_device::nes_a9746_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : nes_txrom_device(mconfig, NES_A9746, tag, owner, clock) { @@ -689,6 +695,20 @@ void nes_sachen_shero_device::pcb_reset() mmc3_common_initialize(0xff, 0xff, 0); } +void nes_sachen_zgdh_device::device_start() +{ + mmc3_start(); + save_item(NAME(m_reg)); +} + +void nes_sachen_zgdh_device::pcb_reset() +{ + assert(m_vram.size() >= 0x2000); + + m_reg = 0; + mmc3_common_initialize(0x1f, 0x7f, 0); +} + void nes_a9746_device::device_start() { mmc3_start(); @@ -2116,6 +2136,61 @@ u8 nes_sachen_shero_device::read_l(offs_t offset) return get_open_bus(); } +/*------------------------------------------------- + + SACHEN-ZGDH + + Sachen board used for Zhongguo Daheng + + NES 2.0: mapper 512 + + In MAME: Supported. + + -------------------------------------------------*/ + +u8 nes_sachen_zgdh_device::nt_r(offs_t offset) +{ + if (m_reg == 1) + return m_vram[0x1000 + (offset & 0x0fff)]; + else + return device_nes_cart_interface::nt_r(offset); +} + +void nes_sachen_zgdh_device::nt_w(offs_t offset, u8 data) +{ + if (m_reg == 1) + m_vram[0x1000 + (offset & 0x0fff)] = data; + else + device_nes_cart_interface::nt_w(offset, data); +} + +void nes_sachen_zgdh_device::set_chr(u8 chr, int chr_base, int chr_mask) +{ + if (m_reg <= 1) + { + chr = CHRROM; + m_chr_mask = 0x7f; + } + else + { + chr = CHRRAM; + m_chr_mask = 0x03; + } + nes_txrom_device::set_chr(chr, chr_base, m_chr_mask); +} + +void nes_sachen_zgdh_device::write_l(offs_t offset, u8 data) +{ + LOG_MMC(("zgdh write_l, offset: %04x, data: %02x\n", offset, data)); + + offset += 0x100; + if ((offset & 0x1100) == 0x0100) + { + m_reg = data & 0x03; + set_chr(m_chr_source, m_chr_base, m_chr_mask); + } +} + /*------------------------------------------------- UNL-A9746 diff --git a/src/devices/bus/nes/mmc3_clones.h b/src/devices/bus/nes/mmc3_clones.h index d6da92864d6..c9cd8b0e57a 100644 --- a/src/devices/bus/nes/mmc3_clones.h +++ b/src/devices/bus/nes/mmc3_clones.h @@ -476,6 +476,30 @@ private: u8 m_reg; }; +// ======================> nes_sachen_zgdh_device + +class nes_sachen_zgdh_device : public nes_txrom_device +{ +public: + // construction/destruction + nes_sachen_zgdh_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + + virtual void write_l(offs_t offset, u8 data) override; + virtual u8 nt_r(offs_t offset) override; + virtual void nt_w(offs_t offset, u8 data) override; + + virtual void pcb_reset() override; + +protected: + // device-level overrides + virtual void device_start() override; + + virtual void set_chr(u8 chr, int chr_base, int chr_mask) override; + +private: + u8 m_reg; +}; + // ======================> nes_a9746_device class nes_a9746_device : public nes_txrom_device @@ -1229,6 +1253,7 @@ DECLARE_DEVICE_TYPE(NES_COCOMA, nes_cocoma_device) DECLARE_DEVICE_TYPE(NES_GOUDER, nes_gouder_device) DECLARE_DEVICE_TYPE(NES_SA9602B, nes_sa9602b_device) DECLARE_DEVICE_TYPE(NES_SACHEN_SHERO, nes_sachen_shero_device) +DECLARE_DEVICE_TYPE(NES_SACHEN_ZGDH, nes_sachen_zgdh_device) DECLARE_DEVICE_TYPE(NES_A9746, nes_a9746_device) DECLARE_DEVICE_TYPE(NES_A88S1, nes_a88s1_device) diff --git a/src/devices/bus/nes/nes_carts.cpp b/src/devices/bus/nes/nes_carts.cpp index 93cca5a75f6..33178c9fd3c 100644 --- a/src/devices/bus/nes/nes_carts.cpp +++ b/src/devices/bus/nes/nes_carts.cpp @@ -364,7 +364,8 @@ void nes_cart(device_slot_interface &device) device.option_add_internal("sfight3", NES_SF3); device.option_add_internal("gouder", NES_GOUDER); device.option_add_internal("sa9602b", NES_SA9602B); - device.option_add_internal("unl_shero", NES_SACHEN_SHERO); + device.option_add_internal("sachen_shero", NES_SACHEN_SHERO); + device.option_add_internal("sachen_zgdh", NES_SACHEN_ZGDH); device.option_add_internal("a9746", NES_A9746); // mapper 219 // misc multigame cart boards device.option_add_internal("benshieng", NES_BENSHIENG); diff --git a/src/devices/bus/nes/nes_ines.hxx b/src/devices/bus/nes/nes_ines.hxx index b7cdca3fa35..21a5388deea 100644 --- a/src/devices/bus/nes/nes_ines.hxx +++ b/src/devices/bus/nes/nes_ines.hxx @@ -490,7 +490,7 @@ static const nes_mmc mmc_list[] = { 452, BMC_DS927 }, // 453 Realtec 8042 // 454...511 Unused - // 512 probably the correct MMC3 clone for chuugokt in nes.xml + { 512, SACHEN_ZGDH }, { 513, SACHEN_SA9602B }, // 514 seems to be for skaraok, currently set to UNKNOWN in nes.xml // 515 Korean Family Noraebang karaoke cart with expansion cart, mic, and YM2413! diff --git a/src/devices/bus/nes/nes_pcb.hxx b/src/devices/bus/nes/nes_pcb.hxx index d409d81969c..a41bb0f5629 100644 --- a/src/devices/bus/nes/nes_pcb.hxx +++ b/src/devices/bus/nes/nes_pcb.hxx @@ -369,7 +369,8 @@ static const nes_pcb pcb_list[] = { "jyc_c", JYCOMPANY_C }, { "tek90", JYCOMPANY_A }, { "sa9602b", SACHEN_SA9602B }, - { "unl_shero", SACHEN_SHERO }, + { "sachen_shero", SACHEN_SHERO }, + { "sachen_zgdh", SACHEN_ZGDH }, { "a9746", UNL_A9746 }, { "mmalee2", UNL_MMALEE }, { "unl_2708", UNL_2708 }, diff --git a/src/devices/bus/nes/nes_slot.h b/src/devices/bus/nes/nes_slot.h index 95ae301ce1f..5ff2747254f 100644 --- a/src/devices/bus/nes/nes_slot.h +++ b/src/devices/bus/nes/nes_slot.h @@ -72,7 +72,7 @@ enum SACHEN_SA009, SACHEN_SA0036, SACHEN_SA0037, SACHEN_SA72007, SACHEN_SA72008, SACHEN_SA9602B, SACHEN_TCA01, SACHEN_TCU01, SACHEN_TCU02, SACHEN_3013, SACHEN_3014, - SACHEN_74LS374, SACHEN_74LS374_ALT, SACHEN_SHERO, + SACHEN_74LS374, SACHEN_74LS374_ALT, SACHEN_SHERO, SACHEN_ZGDH, // Sunsoft SUNSOFT_1, SUNSOFT_2, SUNSOFT_3, SUNSOFT_4, SUNSOFT_DCS, SUNSOFT_5, SUNSOFT_FME7,