From 2ad1f4d9aafb12c0e0b4058dd269f48651699d4a Mon Sep 17 00:00:00 2001 From: 0kmg <9137159+0kmg@users.noreply.github.com> Date: Wed, 28 Jul 2021 07:44:55 -0800 Subject: bus/nes: Added support for YUNG-08 SMB2 FDS conversions. (#8366) Software list items promoted to working (nes.xml) --------------------------------------- Super Mario Bros. 2 (YUNG-08) Super Mario Bros. 2 (YUNG-08, no protection) --- hash/nes.xml | 10 ++-- src/devices/bus/nes/bootleg.cpp | 103 +++++++++++++++++++++++++++++++++++++- src/devices/bus/nes/bootleg.h | 31 ++++++++++++ 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 | 2 +- src/mame/machine/nes.cpp | 2 +- 8 files changed, 143 insertions(+), 9 deletions(-) diff --git a/hash/nes.xml b/hash/nes.xml index 7569625f75d..87bdfc7a3e8 100644 --- a/hash/nes.xml +++ b/hash/nes.xml @@ -67263,14 +67263,15 @@ Also notice that VRAM & WRAM are probably incorrect for some of these sets, at t - + Super Mario Bros. 2 (YUNG-08) 19?? <pirate> - + + @@ -67285,14 +67286,15 @@ Also notice that VRAM & WRAM are probably incorrect for some of these sets, at t - + Super Mario Bros. 2 (YUNG-08, no protection) 19?? <pirate> - + + diff --git a/src/devices/bus/nes/bootleg.cpp b/src/devices/bus/nes/bootleg.cpp index 6ec1f747b03..a2da17d2210 100644 --- a/src/devices/bus/nes/bootleg.cpp +++ b/src/devices/bus/nes/bootleg.cpp @@ -13,6 +13,9 @@ TODO: - review all PCBs and fix the starting banks (which are often the main problem of not working games) + - SMB2 bootlegs all seem to have timing issues. This is apparent on worlds A-D as the bottom of the + world letter scrolls. Hardware footage of the mapper 50 version shows the letter bottoms flickering + (though it could be a video/compression artifact). ***********************************************************************************************************/ @@ -65,6 +68,7 @@ DEFINE_DEVICE_TYPE(NES_AC08, nes_ac08_device, "nes_ac08", "N DEFINE_DEVICE_TYPE(NES_MMALEE, nes_mmalee_device, "nes_mmalee", "NES Cart Super Mario Bros. Malee 2 Pirate PCB") DEFINE_DEVICE_TYPE(NES_SHUIGUAN, nes_shuiguan_device, "nes_shuiguan", "NES Cart Shui Guan Pipe Pirate PCB") DEFINE_DEVICE_TYPE(NES_RT01, nes_rt01_device, "nes_rt01", "NES Cart RT-01 PCB") +DEFINE_DEVICE_TYPE(NES_YUNG08, nes_yung08_device, "nes_yung08", "NES Cart Super Mario Bros. 2 YUNG-08 PCB") nes_ax5705_device::nes_ax5705_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) @@ -212,6 +216,11 @@ nes_rt01_device::nes_rt01_device(const machine_config &mconfig, const char *tag, { } +nes_yung08_device::nes_yung08_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_nrom_device(mconfig, NES_YUNG08, tag, owner, clock), m_irq_count(0), m_irq_latch(0), irq_timer(nullptr) +{ +} + @@ -648,7 +657,6 @@ void nes_shuiguan_device::pcb_reset() memset(m_mmc_vrom_bank, 0, sizeof(m_mmc_vrom_bank)); } - void nes_rt01_device::device_start() { common_start(); @@ -664,6 +672,28 @@ void nes_rt01_device::pcb_reset() prg16_cdef(0); } +void nes_yung08_device::device_start() +{ + common_start(); + irq_timer = timer_alloc(TIMER_IRQ); + irq_timer->adjust(attotime::zero, 0, clocks_to_attotime(1)); + + save_item(NAME(m_irq_count)); + save_item(NAME(m_irq_latch)); +} + +void nes_yung08_device::pcb_reset() +{ + prg8_89(1); + prg8_ab(0); + prg8_cd(0); // switchable bank + prg8_ef(8); + chr8(0, CHRROM); + + m_irq_count = 0; + m_irq_latch = 0; +} + /*------------------------------------------------- mapper specific handlers @@ -2021,7 +2051,6 @@ uint8_t nes_shuiguan_device::read_m(offs_t offset) return m_prg[offset & 0x1fff]; } - /*------------------------------------------------- RT-01 @@ -2049,3 +2078,73 @@ uint8_t nes_rt01_device::read_h(offs_t offset) return hi_access_rom(offset); } + +/*------------------------------------------------- + + YUNG-08 + + Games: Super Mario Bros. 2 Pirate (YUNG-08) + + NES 2.0: mapper 368 + + In MAME: Supported. + + -------------------------------------------------*/ + +void nes_yung08_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + if (id == TIMER_IRQ) + { + if (BIT(m_irq_latch, 0)) + { + m_irq_count = (m_irq_count + 1) & 0x0fff; + if (!m_irq_count) + set_irq_line(ASSERT_LINE); + } + } +} + +void nes_yung08_device::write_45(offs_t offset, u8 data) +{ + switch (offset & 0x51ff) + { + case 0x4022: + prg8_cd(data & 1 ? 3 : 4 + ((data & 0x07) >> 1)); + break; + case 0x4122: + m_irq_latch = data & 0x35; + if (!BIT(m_irq_latch, 0)) + { + set_irq_line(CLEAR_LINE); + m_irq_count = 0; + } + break; + } +} + +void nes_yung08_device::write_ex(offs_t offset, u8 data) +{ + LOG_MMC(("yung08 write_ex, offset: %04x, data: %02x\n", offset, data)); + write_45(offset + 0x4020, data); +} + +void nes_yung08_device::write_l(offs_t offset, u8 data) +{ + LOG_MMC(("yung08 write_l, offset: %04x, data: %02x\n", offset, data)); + write_45(offset + 0x4100, data); +} + +u8 nes_yung08_device::read_l(offs_t offset) +{ + LOG_MMC(("yung08 read_l, offset: %04x\n", offset)); + offset += 0x100; + if ((offset & 0x11ff) == 0x0122) // 0x4122 + return m_irq_latch | 0x8a; + return get_open_bus(); +} + +u8 nes_yung08_device::read_m(offs_t offset) +{ + LOG_MMC(("yung08 read_m, offset: %04x\n", offset)); + return m_prg[0x02 * 0x2000 + offset]; // fixed to bank #2 +} diff --git a/src/devices/bus/nes/bootleg.h b/src/devices/bus/nes/bootleg.h index 69ff54bdcb8..131849b1a73 100644 --- a/src/devices/bus/nes/bootleg.h +++ b/src/devices/bus/nes/bootleg.h @@ -652,6 +652,36 @@ protected: }; +// ======================> nes_yung08_device + +class nes_yung08_device : public nes_nrom_device +{ +public: + // construction/destruction + nes_yung08_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + + virtual u8 read_l(offs_t offset) override; + virtual u8 read_m(offs_t offset) override; + virtual void write_ex(offs_t offset, u8 data) override; + virtual void write_l(offs_t offset, u8 data) override; + + virtual void pcb_reset() override; + +protected: + // 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_latch; + + static const device_timer_id TIMER_IRQ = 0; + emu_timer *irq_timer; +}; + + // device type definition DECLARE_DEVICE_TYPE(NES_AX5705, nes_ax5705_device) @@ -682,5 +712,6 @@ DECLARE_DEVICE_TYPE(NES_AC08, nes_ac08_device) DECLARE_DEVICE_TYPE(NES_MMALEE, nes_mmalee_device) DECLARE_DEVICE_TYPE(NES_SHUIGUAN, nes_shuiguan_device) DECLARE_DEVICE_TYPE(NES_RT01, nes_rt01_device) +DECLARE_DEVICE_TYPE(NES_YUNG08, nes_yung08_device) #endif // MAME_BUS_NES_BOOTLEG_H diff --git a/src/devices/bus/nes/nes_carts.cpp b/src/devices/bus/nes/nes_carts.cpp index 5f4ea291fa7..ab162288364 100644 --- a/src/devices/bus/nes/nes_carts.cpp +++ b/src/devices/bus/nes/nes_carts.cpp @@ -301,6 +301,7 @@ void nes_cart(device_slot_interface &device) device.option_add_internal("smb2j", NES_SMB2J); device.option_add_internal("smb2ja", NES_SMB2JA); device.option_add_internal("smb2jb", NES_SMB2JB); + device.option_add_internal("yung08", NES_YUNG08); device.option_add_internal("btl_0353", NES_0353); // used by Lucky (Roger) Rabbit FDS conversion device.option_add_internal("09034a", NES_09034A); device.option_add_internal("batmanfs", NES_BATMANFS); diff --git a/src/devices/bus/nes/nes_ines.hxx b/src/devices/bus/nes/nes_ines.hxx index 9b3d8b1579d..e0e590f5215 100644 --- a/src/devices/bus/nes/nes_ines.hxx +++ b/src/devices/bus/nes/nes_ines.hxx @@ -402,7 +402,7 @@ static const nes_mmc mmc_list[] = // 365 is this asderp95 in nes.xml? // 366 K-3131GS and K-3131SS 4-in-1 carts // 367 7-in-1 cart that is a close variant of mapper 205 - // { 368, BTL_YUNG08 } // SMB2 FDS conversion + { 368, BTL_YUNG08 }, // SMB2 FDS conversion // 369 Super Mario Bros Party multicart // 370 Golden Mario Party II multicart // 371 Spanish PEC-586 computer main cart diff --git a/src/devices/bus/nes/nes_pcb.hxx b/src/devices/bus/nes/nes_pcb.hxx index 11867d11165..384e751fe72 100644 --- a/src/devices/bus/nes/nes_pcb.hxx +++ b/src/devices/bus/nes/nes_pcb.hxx @@ -207,6 +207,7 @@ static const nes_pcb pcb_list[] = { "smb2j", UNL_SMB2J }, { "smb2ja", BTL_SMB2JA }, { "smb2jb", BTL_SMB2JB }, + { "yung08", BTL_YUNG08 }, { "btl_0353", BTL_0353 }, { "09034a", BTL_09034A }, { "batmanfs", BTL_BATMANFS }, diff --git a/src/devices/bus/nes/nes_slot.h b/src/devices/bus/nes/nes_slot.h index 6e255678279..3dd954af03f 100644 --- a/src/devices/bus/nes/nes_slot.h +++ b/src/devices/bus/nes/nes_slot.h @@ -112,7 +112,7 @@ enum // Bootleg boards BTL_SMB2JA, BTL_MARIOBABY, BTL_AISENSHINICOL, BTL_TOBIDASE, BTL_SMB2JB, BTL_09034A, BTL_SMB3, BTL_SBROS11, BTL_DRAGONNINJA, - BTL_PIKACHUY2K, BTL_SHUIGUAN, BTL_0353, BTL_BATMANFS, BTL_PALTHENA, + BTL_PIKACHUY2K, BTL_SHUIGUAN, BTL_0353, BTL_BATMANFS, BTL_PALTHENA, BTL_YUNG08, // Kaiser KAISER_KS202, KAISER_KS7010, KAISER_KS7012, KAISER_KS7013B, KAISER_KS7016, KAISER_KS7016B, KAISER_KS7017, KAISER_KS7021A, diff --git a/src/mame/machine/nes.cpp b/src/mame/machine/nes.cpp index 901d41e2176..8c7d8287d0a 100644 --- a/src/mame/machine/nes.cpp +++ b/src/mame/machine/nes.cpp @@ -83,7 +83,7 @@ void nes_state::machine_start() space.install_read_handler(0x8000, 0xffff, read8sm_delegate(*m_cartslot, FUNC(nes_cart_slot_device::read_h))); } - if (m_cartslot->get_pcb_id() == BTL_SMB2JB || m_cartslot->get_pcb_id() == UNL_AC08 || m_cartslot->get_pcb_id() == UNL_SMB2J) + if (m_cartslot->get_pcb_id() == BTL_SMB2JB || m_cartslot->get_pcb_id() == BTL_YUNG08 || m_cartslot->get_pcb_id() == UNL_AC08 || m_cartslot->get_pcb_id() == UNL_SMB2J) { logerror("write_ex installed!\n"); space.install_write_handler(0x4020, 0x40ff, write8sm_delegate(*m_cartslot, FUNC(nes_cart_slot_device::write_ex))); -- cgit v1.2.3