From b1dcb15ba28eaee2908f17dcd3355f4415620f0a Mon Sep 17 00:00:00 2001 From: 0kmg <9137159+0kmg@users.noreply.github.com> Date: Thu, 26 Aug 2021 14:56:18 -0800 Subject: [PATCH] bus/nes: Simplified a few related boards by Kasheng and Hosenkan. - Reduced redundant code by making "kasing" device parent class for sglionk/sgboog. The latter are identical save for the extended register/address scrambling. - Eliminated hosenkan device altogether (mapper 182). It is identical to sglionk (mapper 114). --- hash/nes.xml | 12 +-- scripts/src/bus.lua | 2 - src/devices/bus/nes/hosenkan.cpp | 159 ---------------------------- src/devices/bus/nes/hosenkan.h | 39 ------- src/devices/bus/nes/mmc3_clones.cpp | 111 +++++++------------ src/devices/bus/nes/mmc3_clones.h | 49 ++++----- src/devices/bus/nes/nes_carts.cpp | 2 - src/devices/bus/nes/nes_ines.hxx | 2 +- src/devices/bus/nes/nes_pcb.hxx | 1 - src/devices/bus/nes/nes_slot.h | 2 +- 10 files changed, 68 insertions(+), 311 deletions(-) delete mode 100644 src/devices/bus/nes/hosenkan.cpp delete mode 100644 src/devices/bus/nes/hosenkan.h diff --git a/hash/nes.xml b/hash/nes.xml index d7a24ab2913..2dab4a60e94 100644 --- a/hash/nes.xml +++ b/hash/nes.xml @@ -63970,10 +63970,10 @@ We don't include these hacks because they were not burned into real carts nor so Pocohontos (Asia) - 19?? - <unknown> + 1997 + Hosenkan - + @@ -66665,10 +66665,10 @@ All musics were removed in this game. Super Donkey Kong (Asia) - 19?? - <unknown> + 1997? + Hosenkan - + diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index cca26b543e0..ad8853d375c 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -2812,8 +2812,6 @@ if (BUSES["NES"]~=null) then MAME_DIR .. "src/devices/bus/nes/henggedianzi.h", MAME_DIR .. "src/devices/bus/nes/hes.cpp", MAME_DIR .. "src/devices/bus/nes/hes.h", - MAME_DIR .. "src/devices/bus/nes/hosenkan.cpp", - MAME_DIR .. "src/devices/bus/nes/hosenkan.h", MAME_DIR .. "src/devices/bus/nes/irem.cpp", MAME_DIR .. "src/devices/bus/nes/irem.h", MAME_DIR .. "src/devices/bus/nes/jaleco.cpp", diff --git a/src/devices/bus/nes/hosenkan.cpp b/src/devices/bus/nes/hosenkan.cpp deleted file mode 100644 index ae7749b7e9a..00000000000 --- a/src/devices/bus/nes/hosenkan.cpp +++ /dev/null @@ -1,159 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Fabio Priuli -/*********************************************************************************************************** - - - NES/Famicom cartridge emulation for Hosenkan PCBs - - - ***********************************************************************************************************/ - - -#include "emu.h" -#include "hosenkan.h" - -#include "video/ppu2c0x.h" // this has to be included so that IRQ functions can access ppu2c0x_device::BOTTOM_VISIBLE_SCANLINE -#include "screen.h" - - -#ifdef NES_PCB_DEBUG -#define VERBOSE 1 -#else -#define VERBOSE 0 -#endif - -#define LOG_MMC(x) do { if (VERBOSE) logerror x; } while (0) - - -//------------------------------------------------- -// constructor -//------------------------------------------------- - -DEFINE_DEVICE_TYPE(NES_HOSENKAN, nes_hosenkan_device, "nes_hosenkan", "NES Cart HOSENKAN PCB") - - -nes_hosenkan_device::nes_hosenkan_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : nes_nrom_device(mconfig, NES_HOSENKAN, tag, owner, clock) - , m_irq_count(0) - , m_irq_count_latch(0) - , m_irq_clear(0) - , m_irq_enable(0) - , m_latch(0) -{ -} - - - - -void nes_hosenkan_device::device_start() -{ - common_start(); - save_item(NAME(m_irq_enable)); - save_item(NAME(m_irq_count)); - save_item(NAME(m_irq_count_latch)); - save_item(NAME(m_irq_clear)); - save_item(NAME(m_latch)); -} - -void nes_hosenkan_device::pcb_reset() -{ - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - prg32((m_prg_chunks - 1) >> 1); - chr8(0, m_chr_source); - - m_latch = 0; - m_irq_enable = 0; - m_irq_count = m_irq_count_latch = 0; - m_irq_clear = 0; -} - - - -/*------------------------------------------------- - mapper specific handlers - -------------------------------------------------*/ - -/*------------------------------------------------- - - Bootleg Board by Hosenkan - - Games: Pocahontas, Super Donkey Kong - - iNES: mapper 182 - - In MESS: Supported. - - -------------------------------------------------*/ - -// same as MMC3! -void nes_hosenkan_device::hblank_irq( int scanline, int vblank, int blanked ) -{ - if (scanline < ppu2c0x_device::BOTTOM_VISIBLE_SCANLINE) - { - int prior_count = m_irq_count; - if ((m_irq_count == 0) || m_irq_clear) - m_irq_count = m_irq_count_latch; - else - m_irq_count--; - - if (m_irq_enable && !blanked && (m_irq_count == 0) && (prior_count || m_irq_clear)) - { - LOG_MMC(("irq fired, scanline: %d\n", scanline)); - hold_irq_line(); - } - } - m_irq_clear = 0; -} - -void nes_hosenkan_device::write_h(offs_t offset, uint8_t data) -{ - LOG_MMC(("hosenkan write_h, offset: %04x, data: %02x\n", offset, data)); - - switch (offset & 0x7003) - { - case 0x0001: - set_nt_mirroring(BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); - break; - case 0x2000: - m_latch = data; - break; - case 0x4000: - switch (m_latch) - { - case 0: - chr2_0(data >> 1, CHRROM); - break; - case 1: - chr1_5(data, CHRROM); - break; - case 2: - chr2_2(data >> 1, CHRROM); - break; - case 3: - chr1_7(data, CHRROM); - break; - case 4: - prg8_89(data); - break; - case 5: - prg8_ab(data); - break; - case 6: - chr1_4(data, CHRROM); - break; - case 7: - chr1_6(data, CHRROM); - break; - } - break; - case 0x6003: - if (data) - { - m_irq_count = data; - m_irq_enable = 1; - } - else - m_irq_enable = 0; - break; - } -} diff --git a/src/devices/bus/nes/hosenkan.h b/src/devices/bus/nes/hosenkan.h deleted file mode 100644 index 163aef76edc..00000000000 --- a/src/devices/bus/nes/hosenkan.h +++ /dev/null @@ -1,39 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Fabio Priuli -#ifndef MAME_BUS_NES_HOSENKAN_H -#define MAME_BUS_NES_HOSENKAN_H - -#pragma once - -#include "nxrom.h" - - -// ======================> nes_hosenkan_device - -class nes_hosenkan_device : public nes_nrom_device -{ -public: - // construction/destruction - nes_hosenkan_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 hblank_irq(int scanline, int vblank, int blanked) override; - virtual void pcb_reset() override; - -protected: - // device-level overrides - virtual void device_start() override; - -private: - uint16_t m_irq_count, m_irq_count_latch; - uint8_t m_irq_clear; - int m_irq_enable; - - uint8_t m_latch; -}; - -// device type definition -DECLARE_DEVICE_TYPE(NES_HOSENKAN, nes_hosenkan_device) - -#endif // MAME_BUS_NES_HOSENKAN_H diff --git a/src/devices/bus/nes/mmc3_clones.cpp b/src/devices/bus/nes/mmc3_clones.cpp index 67b5f5796ca..7bf1a4ebaf4 100644 --- a/src/devices/bus/nes/mmc3_clones.cpp +++ b/src/devices/bus/nes/mmc3_clones.cpp @@ -124,8 +124,18 @@ nes_8237a_device::nes_8237a_device(const machine_config &mconfig, const char *ta { } +nes_kasing_device::nes_kasing_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) + : nes_txrom_device(mconfig, type, tag, owner, clock), m_mmc3_mode(true) +{ +} + +nes_kasing_device::nes_kasing_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : nes_kasing_device(mconfig, NES_KASING, tag, owner, clock) +{ +} + nes_sglionk_device::nes_sglionk_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) - : nes_txrom_device(mconfig, type, tag, owner, clock), m_mmc3_mode(true), m_board(type == NES_SG_BOOG) + : nes_kasing_device(mconfig, type, tag, owner, clock), m_board(type == NES_SG_BOOG) { } @@ -139,11 +149,6 @@ nes_sgboog_device::nes_sgboog_device(const machine_config &mconfig, const char * { } -nes_kasing_device::nes_kasing_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : nes_txrom_device(mconfig, NES_KASING, tag, owner, clock), m_reg(0) -{ -} - nes_kay_device::nes_kay_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : nes_txrom_device(mconfig, NES_KAY, tag, owner, clock), m_low_reg(0) { @@ -379,35 +384,20 @@ void nes_8237_device::pcb_reset() update_banks(); } -void nes_sglionk_device::device_start() -{ - mmc3_start(); - save_item(NAME(m_mmc3_mode)); -} - -void nes_sglionk_device::pcb_reset() -{ - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - - m_mmc3_mode = true; - mmc3_common_initialize(0xff, 0xff, 0); -} - void nes_kasing_device::device_start() { mmc3_start(); - save_item(NAME(m_reg)); + save_item(NAME(m_mmc3_mode)); } void nes_kasing_device::pcb_reset() { m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - m_reg = 0; + m_mmc3_mode = true; mmc3_common_initialize(0xff, 0xff, 0); } - void nes_kay_device::device_start() { mmc3_start(); @@ -1064,30 +1054,28 @@ void nes_8237_device::write_h(offs_t offset, u8 data) /*------------------------------------------------- - Bootleg Board by Super Game + Bootleg Board by Kasing - Games: The Lion King, Aladdin, Boogerman + Games: AV Jiu Ji Mahjong, Bao Qing Tian, Thunderbolt 2, + Shisen Mahjong 2, Garou Densetsu Special - MMC3 clone with register and address scrambling and - a few extra banking modes by writing 0x6000-0x7fff. + MMC3 clone with extra banking modes at 0x6000-0x7fff. - iNES: mapper 114 + iNES: mapper 115 In MAME: Supported. - TODO: pocohon and sdkong should also work on this device. - -------------------------------------------------*/ -void nes_sglionk_device::prg_cb(int start, int bank) +void nes_kasing_device::prg_cb(int start, int bank) { if (m_mmc3_mode) nes_txrom_device::prg_cb(start, bank); } -void nes_sglionk_device::write_m(offs_t offset, u8 data) +void nes_kasing_device::write_m(offs_t offset, u8 data) { - LOG_MMC(("sglionk write_m, offset: %04x, data: %02x\n", offset, data)); + LOG_MMC(("kasing write_m, offset: %04x, data: %02x\n", offset, data)); if (BIT(offset, 0)) { @@ -1109,6 +1097,23 @@ void nes_sglionk_device::write_m(offs_t offset, u8 data) } } +/*------------------------------------------------- + + Bootleg Boards by Super Game and Hosenkan + + Games: The Lion King, Aladdin, Boogerman, Pocohon, + Super Donkey Kong + + MMC3 clone with register and address scrambling and + a few extra banking modes by writing 0x6000-0x7fff. + This is the same as mapper 115 with scrambling. + + iNES: mapper 114 (and 182) + + In MAME: Supported. + + -------------------------------------------------*/ + void nes_sglionk_device::write_h(offs_t offset, u8 data) { LOG_MMC(("sglionk write_h, offset: %04x, data: %02x\n", offset, data)); @@ -1131,46 +1136,6 @@ void nes_sglionk_device::write_h(offs_t offset, u8 data) txrom_write(addr & 0x6001, data); } -/*------------------------------------------------- - - Bootleg Board by Kasing - - Games: AV Jiu Ji Mahjong, Bao Qing Tian, Thunderbolt 2, - Shisen Mahjong 2 - - MMC3 clone - - iNES: mapper 115 - - In MESS: Supported - - -------------------------------------------------*/ - -void nes_kasing_device::prg_cb(int start, int bank) -{ - if (BIT(m_reg, 7)) - prg32(m_reg >> 1); - else - prg8_x(start, bank); -} - -void nes_kasing_device::write_m(offs_t offset, uint8_t data) -{ - LOG_MMC(("kasing write_m, offset: %04x, data: %02x\n", offset, data)); - - switch (offset & 0x01) - { - case 0x00: - m_reg = data; - set_prg(m_prg_base, m_prg_mask); - break; - case 0x01: - m_chr_base = (data & 0x01) ? 0x100 : 0x000; - set_chr(m_chr_source, m_chr_base, m_chr_mask); - break; - } -} - /*------------------------------------------------- Bootleg Board by Kay (for Panda Prince) diff --git a/src/devices/bus/nes/mmc3_clones.h b/src/devices/bus/nes/mmc3_clones.h index 5a86c613236..551d5552ebb 100644 --- a/src/devices/bus/nes/mmc3_clones.h +++ b/src/devices/bus/nes/mmc3_clones.h @@ -138,29 +138,46 @@ public: }; -// ======================> nes_sglionk_device +// ======================> nes_kasing_device -class nes_sglionk_device : public nes_txrom_device +class nes_kasing_device : public nes_txrom_device { public: // construction/destruction - nes_sglionk_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + nes_kasing_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); virtual void write_m(offs_t offset, u8 data) override; - virtual void write_h(offs_t offset, u8 data) override; virtual void prg_cb(int start, int bank) override; virtual void pcb_reset() override; protected: // construction/destruction - nes_sglionk_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock); + nes_kasing_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock); // device-level overrides virtual void device_start() override; private: bool m_mmc3_mode; +}; + + +// ======================> nes_sglionk_device + +class nes_sglionk_device : public nes_kasing_device +{ +public: + // construction/destruction + nes_sglionk_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + + virtual void write_h(offs_t offset, u8 data) override; + +protected: + // construction/destruction + nes_sglionk_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock); + +private: int m_board; }; @@ -175,28 +192,6 @@ public: }; -// ======================> nes_kasing_device - -class nes_kasing_device : public nes_txrom_device -{ -public: - // construction/destruction - nes_kasing_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - - virtual void write_m(offs_t offset, uint8_t data) override; - virtual void prg_cb(int start, int bank) override; - - virtual void pcb_reset() override; - -protected: - // device-level overrides - virtual void device_start() override; - -private: - uint8_t m_reg; -}; - - // ======================> nes_kay_device class nes_kay_device : public nes_txrom_device diff --git a/src/devices/bus/nes/nes_carts.cpp b/src/devices/bus/nes/nes_carts.cpp index 1c03f5f625a..f42e319c292 100644 --- a/src/devices/bus/nes/nes_carts.cpp +++ b/src/devices/bus/nes/nes_carts.cpp @@ -41,7 +41,6 @@ #include "ggenie.h" #include "hes.h" #include "henggedianzi.h" -#include "hosenkan.h" #include "jy.h" #include "kaiser.h" #include "legacy.h" @@ -250,7 +249,6 @@ void nes_cart(device_slot_interface &device) device.option_add_internal("hengg_xhzs", NES_HENGG_XHZS); device.option_add_internal("hengg_shjy3", NES_HENGG_SHJY3); // mapper 253 device.option_add_internal("hes", NES_HES); - device.option_add_internal("hosenkan", NES_HOSENKAN); device.option_add_internal("ks106c", NES_KS106C); // mapper 352 device.option_add_internal("ks202", NES_KS202); // mapper 56 device.option_add_internal("ks7010", NES_KS7010); // used in Akumajo Dracula (FDS Conversion) diff --git a/src/devices/bus/nes/nes_ines.hxx b/src/devices/bus/nes/nes_ines.hxx index 7da9adc453c..63f435afc52 100644 --- a/src/devices/bus/nes/nes_ines.hxx +++ b/src/devices/bus/nes/nes_ines.hxx @@ -215,7 +215,7 @@ static const nes_mmc mmc_list[] = { 179, HENGG_XHZS }, { 180, UXROM_CC }, // 181 Unused - { 182, HOSENKAN_BOARD }, + { 182, SUPERGAME_LIONKING }, // duplicate of mapper 114 { 183, BTL_SHUIGUAN }, { 184, SUNSOFT_1 }, { 185, STD_CNROM }, diff --git a/src/devices/bus/nes/nes_pcb.hxx b/src/devices/bus/nes/nes_pcb.hxx index c92ad5b49af..c01f523125c 100644 --- a/src/devices/bus/nes/nes_pcb.hxx +++ b/src/devices/bus/nes/nes_pcb.hxx @@ -162,7 +162,6 @@ static const nes_pcb pcb_list[] = { "hengg_xhzs", HENGG_XHZS }, { "hengg_shjy3", HENGG_SHJY3 }, // mapper 253 { "hes", HES_BOARD }, - { "hosenkan", HOSENKAN_BOARD }, { "ks106c", KAISER_KS106C }, // mapper 352 { "ks202", KAISER_KS202 }, // mapper 56 { "ks7010", KAISER_KS7010 }, // used in Akumajo Dracula (FDS Conversion) diff --git a/src/devices/bus/nes/nes_slot.h b/src/devices/bus/nes/nes_slot.h index 80225ea9199..ee3f582ae2a 100644 --- a/src/devices/bus/nes/nes_slot.h +++ b/src/devices/bus/nes/nes_slot.h @@ -136,7 +136,7 @@ enum WAIXING_TYPE_I, WAIXING_TYPE_J, WAIXING_FS304, WAIXING_SGZLZ, WAIXING_SGZ, WAIXING_WXZS, WAIXING_SECURITY, WAIXING_SH2, WAIXING_DQ8, WAIXING_FFV, WAIXING_WXZS2, SUPERGAME_LIONKING, SUPERGAME_BOOGERMAN, - KAY_BOARD, HOSENKAN_BOARD, NITRA_TDA, GOUDER_37017, NANJING_BOARD, ZEMINA_BOARD, + KAY_BOARD, NITRA_TDA, GOUDER_37017, NANJING_BOARD, ZEMINA_BOARD, NOCASH_NOCHR, // homebrew PCB design which uses NTRAM for CHRRAM UNL_ACTION53, // homebrew PCB for homebrew multicarts UNL_CUFROM, UNL_UNROM512, UNL_2A03PURITANS, // homebrew PCBs