From 972d324eb2463a8628a6a20234c66af520dd0b88 Mon Sep 17 00:00:00 2001 From: 0kmg <9137159+0kmg@users.noreply.github.com> Date: Tue, 7 Sep 2021 16:20:08 -0800 Subject: bus/nes: Added support for a 4 in 1 multicart. (#8549) New working software list additions (nes.xml) ----------------------------------- 4 in 1 HQ [famiac] --- hash/nes.xml | 16 ++++++++ src/devices/bus/nes/bootleg.cpp | 79 +++++++++++++++++++++++++++++++++++++-- src/devices/bus/nes/bootleg.h | 24 +++++++++++- src/devices/bus/nes/nes_carts.cpp | 1 + src/devices/bus/nes/nes_ines.hxx | 2 +- src/devices/bus/nes/nes_pcb.hxx | 1 + src/devices/bus/nes/nes_slot.h | 3 +- src/mame/machine/nes.cpp | 1 + 8 files changed, 120 insertions(+), 7 deletions(-) diff --git a/hash/nes.xml b/hash/nes.xml index b1fe1b9bee5..c01360d0bd6 100644 --- a/hash/nes.xml +++ b/hash/nes.xml @@ -79684,6 +79684,22 @@ be better to redump them properly. --> + + + 4 in 1 HQ + 19?? + <pirate> + + + + + + + + + + + 4 in 1 (KS-106C) 19?? diff --git a/src/devices/bus/nes/bootleg.cpp b/src/devices/bus/nes/bootleg.cpp index 52fbf4b11f1..52990004f14 100644 --- a/src/devices/bus/nes/bootleg.cpp +++ b/src/devices/bus/nes/bootleg.cpp @@ -50,6 +50,7 @@ DEFINE_DEVICE_TYPE(NES_BTL_DNINJA, nes_btl_dn_device, "nes_btl_dn", "N DEFINE_DEVICE_TYPE(NES_SMB2J, nes_smb2j_device, "nes_smb2j", "NES Cart Super Mario Bros. 2 Jpn PCB") DEFINE_DEVICE_TYPE(NES_SMB2JA, nes_smb2ja_device, "nes_smb2ja", "NES Cart Super Mario Bros. 2 Jpn (Alt) PCB") DEFINE_DEVICE_TYPE(NES_SMB2JB, nes_smb2jb_device, "nes_smb2jb", "NES Cart Super Mario Bros. 2 Jpn (Alt 2) PCB") +DEFINE_DEVICE_TYPE(NES_N32_4IN1, nes_n32_4in1_device, "nes_n32_4in1", "NES Cart N-32 4 in 1 PCB") DEFINE_DEVICE_TYPE(NES_0353, nes_0353_device, "nes_0353", "NES Cart 0353 PCB") DEFINE_DEVICE_TYPE(NES_09034A, nes_09034a_device, "nes_09034a", "NES Cart 09-034A PCB") DEFINE_DEVICE_TYPE(NES_BATMANFS, nes_batmanfs_device, "nes_batmanfs", "NES Cart Batman Pirate PCB") @@ -118,8 +119,18 @@ nes_smb2ja_device::nes_smb2ja_device(const machine_config &mconfig, const char * { } +nes_smb2jb_device::nes_smb2jb_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) + : nes_nrom_device(mconfig, type, tag, owner, clock), m_irq_count(0), m_irq_enable(0), m_reg(0), m_bank67(type == NES_SMB2JB ? 0x0f : 0x07), irq_timer(nullptr) +{ +} + nes_smb2jb_device::nes_smb2jb_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : nes_nrom_device(mconfig, NES_SMB2JB, tag, owner, clock), m_irq_count(0), m_irq_enable(0), irq_timer(nullptr) + : nes_smb2jb_device(mconfig, NES_SMB2JB, tag, owner, clock) +{ +} + +nes_n32_4in1_device::nes_n32_4in1_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_smb2jb_device(mconfig, NES_N32_4IN1, tag, owner, clock) { } @@ -427,6 +438,7 @@ void nes_smb2jb_device::device_start() save_item(NAME(m_irq_enable)); save_item(NAME(m_irq_count)); + save_item(NAME(m_reg)); } void nes_smb2jb_device::pcb_reset() @@ -439,6 +451,16 @@ void nes_smb2jb_device::pcb_reset() m_irq_enable = 0; m_irq_count = 0; + m_reg = 0; +} + +void nes_n32_4in1_device::pcb_reset() +{ + // Powers up in menu, but soft reset does not touch banks (so each game returns to its own title). Is this correct? + + m_irq_enable = 0; + m_irq_count = 0; + m_reg = 0; } void nes_0353_device::device_start() @@ -1341,7 +1363,8 @@ void nes_smb2jb_device::write_45(offs_t offset, u8 data) switch (offset & 0x4120) { case 0x4020: - prg8_cd(bitswap<4>(data, 3, 0, 2, 1)); + m_reg = bitswap<4>(data, 3, 0, 2, 1); + prg8_cd(m_reg); break; case 0x4120: m_irq_enable = BIT(data, 0); @@ -1369,7 +1392,57 @@ void nes_smb2jb_device::write_l(offs_t offset, u8 data) u8 nes_smb2jb_device::read_m(offs_t offset) { LOG_MMC(("smb2jb read_m, offset: %04x\n", offset)); - return m_prg[0x0f * 0x2000 + offset]; + return m_prg[m_bank67 * 0x2000 + offset]; +} + +/*------------------------------------------------- + + BMC-N32-4IN1 + + Unknown Bootleg Multigame Board + Games: 4 in 1 + + This multicart contains the mapper 50 version of SMB2. + There are changes to bank locations compared to that + game, but otherwise we rely on the existing SMB2JB + emulation (unless other differences are discovered?) + + NES 2.0: mapper 416 + + In MAME: Supported. + + -------------------------------------------------*/ + +void nes_n32_4in1_device::write_h(offs_t offset, u8 data) +{ + LOG_MMC(("n32_4in1 write_h, offset: %04x, data: %02x\n", offset, data)); + + if (offset < 0x2000) + { + if (BIT(data, 3)) // NROM games + { + u8 bank = bitswap<3>(data, 3, 7, 5); + u8 mode = BIT(data, 7); + if (data & 0xc0) + { + prg16_89ab(bank & ~mode); + prg16_cdef(bank | mode); + } + else + for (int i = 0; i < 4; i++) + prg8_x(i, bank << 1); + } + else // SMB2 only + { + prg8_89(0); + prg8_ab(1); + prg8_cd(m_reg); + prg8_ef(3); + } + + chr8((data >> 1) & 0x03, CHRROM); + set_nt_mirroring(BIT(data, 2) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); + } } /*------------------------------------------------- diff --git a/src/devices/bus/nes/bootleg.h b/src/devices/bus/nes/bootleg.h index 88ec925d2ba..7eeaaaf2ff9 100644 --- a/src/devices/bus/nes/bootleg.h +++ b/src/devices/bus/nes/bootleg.h @@ -236,20 +236,39 @@ public: virtual void pcb_reset() override; protected: + nes_smb2jb_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_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; -private: - void write_45(offs_t offset, u8 data); u16 m_irq_count; int m_irq_enable; + u8 m_reg; + +private: + void write_45(offs_t offset, u8 data); + u8 m_bank67; static const device_timer_id TIMER_IRQ = 0; emu_timer *irq_timer; }; +// ======================> nes_n32_4in1_device + +class nes_n32_4in1_device : public nes_smb2jb_device +{ +public: + // construction/destruction + nes_n32_4in1_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; +}; + + // ======================> nes_0353_device class nes_0353_device : public nes_nrom_device @@ -729,6 +748,7 @@ DECLARE_DEVICE_TYPE(NES_BTL_DNINJA, nes_btl_dn_device) DECLARE_DEVICE_TYPE(NES_SMB2J, nes_smb2j_device) DECLARE_DEVICE_TYPE(NES_SMB2JA, nes_smb2ja_device) DECLARE_DEVICE_TYPE(NES_SMB2JB, nes_smb2jb_device) +DECLARE_DEVICE_TYPE(NES_N32_4IN1, nes_n32_4in1_device) DECLARE_DEVICE_TYPE(NES_0353, nes_0353_device) DECLARE_DEVICE_TYPE(NES_09034A, nes_09034a_device) DECLARE_DEVICE_TYPE(NES_BATMANFS, nes_batmanfs_device) diff --git a/src/devices/bus/nes/nes_carts.cpp b/src/devices/bus/nes/nes_carts.cpp index 5df2c7fa9c9..bd64a114fa3 100644 --- a/src/devices/bus/nes/nes_carts.cpp +++ b/src/devices/bus/nes/nes_carts.cpp @@ -372,6 +372,7 @@ void nes_cart(device_slot_interface &device) device.option_add_internal("bmc_810544c", NES_BMC_810544C); device.option_add_internal("bmc_830425c", NES_BMC_830425C); device.option_add_internal("bmc_850437c", NES_BMC_850437C); + device.option_add_internal("n32_4in1", NES_N32_4IN1); device.option_add_internal("ntd03", NES_NTD03); device.option_add_internal("bmc_ctc09", NES_BMC_CTC09); device.option_add_internal("bmc_gb63", NES_BMC_GB63); diff --git a/src/devices/bus/nes/nes_ines.hxx b/src/devices/bus/nes/nes_ines.hxx index 315804c8bc3..42553811ae6 100644 --- a/src/devices/bus/nes/nes_ines.hxx +++ b/src/devices/bus/nes/nes_ines.hxx @@ -451,7 +451,7 @@ static const nes_mmc mmc_list[] = // 413 homebrew game Super Russian Roulette // 414 9999999-in-1 multicart { 415, BTL_0353 }, // Lucky (Roger) Rabbit FDS conversion - // 416 4-in-1 that includes mapper 50 SMB2j pirate + { 416, BMC_N32_4IN1 }, { 417, BTL_BATMANFS }, // "Fine Studio" Batman bootleg { 418, UNL_LH42 }, // Highway Star Whirlwind Manu bootleg // 419 VT03 PnPs diff --git a/src/devices/bus/nes/nes_pcb.hxx b/src/devices/bus/nes/nes_pcb.hxx index 861f641f3dc..2ec5f5153fd 100644 --- a/src/devices/bus/nes/nes_pcb.hxx +++ b/src/devices/bus/nes/nes_pcb.hxx @@ -258,6 +258,7 @@ static const nes_pcb pcb_list[] = { "bmc_810544c", BMC_810544C }, { "bmc_830425c", BMC_830425C }, { "bmc_850437c", BMC_850437C }, + { "n32_4in1", BMC_N32_4IN1 }, { "ntd03", BMC_NTD_03 }, { "bmc_ctc09", BMC_CTC09 }, { "bmc_gb63", BMC_G63IN1 }, diff --git a/src/devices/bus/nes/nes_slot.h b/src/devices/bus/nes/nes_slot.h index 49159c57aa6..52d9c7cc6cd 100644 --- a/src/devices/bus/nes/nes_slot.h +++ b/src/devices/bus/nes/nes_slot.h @@ -97,7 +97,8 @@ enum BMC_70IN1, BMC_500IN1, BMC_800IN1, BMC_1200IN1, BMC_GKA, BMC_GKB, BMC_GKCXIN1, BMC_VT5201, BMC_BENSHIENG, BMC_60311C, BMC_80013B, BMC_810544C, BMC_830425C, BMC_850437C, - BMC_NT639, BMC_NTD_03, BMC_G63IN1, BMC_FCGENJIN_8IN1, BMC_FK23C, BMC_FK23CA, + BMC_N32_4IN1, BMC_NT639, BMC_NTD_03, BMC_G63IN1, + BMC_FCGENJIN_8IN1, BMC_FK23C, BMC_FK23CA, BMC_PJOY84, BMC_TH22913, BMC_11160, BMC_G146, BMC_2751, BMC_8157, BMC_830118C, BMC_830832C, BMC_841101C, BMC_411120C, BMC_GOLD150, BMC_GOLD260, BMC_SUPER22, diff --git a/src/mame/machine/nes.cpp b/src/mame/machine/nes.cpp index 2393557500b..62282c255be 100644 --- a/src/mame/machine/nes.cpp +++ b/src/mame/machine/nes.cpp @@ -106,6 +106,7 @@ void nes_state::machine_start() static const int w_ex_pcbs[] = { + BMC_N32_4IN1, BTL_SMB2JB, BTL_YUNG08, UNL_AC08, -- cgit v1.2.3