From 794bf96c0c56af1190ca51f431c61304945d5892 Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Tue, 26 Feb 2013 09:58:36 +0000 Subject: [PATCH] (MESS) gb.c: attempt in emulating protection for Chong Wu Xiao Jing Ling/Pokemon Pikecho. [Fabio Priuli] --- hash/gbcolor.xml | 25 ++++++------------- src/mess/drivers/gb.c | 1 + src/mess/machine/gb_mbc.c | 51 +++++++++++++++++++++++++++++++++++++- src/mess/machine/gb_mbc.h | 18 ++++++++++++++ src/mess/machine/gb_slot.c | 1 + src/mess/machine/gb_slot.h | 1 + 6 files changed, 78 insertions(+), 19 deletions(-) diff --git a/hash/gbcolor.xml b/hash/gbcolor.xml index 555dae31d88..7dd084f7307 100644 --- a/hash/gbcolor.xml +++ b/hash/gbcolor.xml @@ -23361,13 +23361,18 @@ Undumped Pirates: - + + Chong Wu Xiao Jing Ling - Jie Jin Ta Zhi Wang (Chi) 20?? <unknown> - + @@ -23377,22 +23382,6 @@ Undumped Pirates: - - Chong Wu Xiao Jing Ling - Jie Jin Ta Zhi Wang (Chi, Hacked) - 20?? - <unknown> - - - - - - - - - - - - Jin Yong Qun Xia Chuan II (Chi) 20?? diff --git a/src/mess/drivers/gb.c b/src/mess/drivers/gb.c index d4e5c0b560d..ce6f1991b67 100644 --- a/src/mess/drivers/gb.c +++ b/src/mess/drivers/gb.c @@ -646,6 +646,7 @@ static SLOT_INTERFACE_START(gb_cart) SLOT_INTERFACE_INTERNAL("rom_atvrac", GB_ROM_ATVRAC) SLOT_INTERFACE_INTERNAL("rom_camera", GB_STD_ROM) SLOT_INTERFACE_INTERNAL("rom_sintax", GB_ROM_SINTAX) + SLOT_INTERFACE_INTERNAL("rom_chong", GB_ROM_CHONGWU) SLOT_INTERFACE_END static SLOT_INTERFACE_START(megaduck_cart) diff --git a/src/mess/machine/gb_mbc.c b/src/mess/machine/gb_mbc.c index b7049e5c409..da29103d21d 100644 --- a/src/mess/machine/gb_mbc.c +++ b/src/mess/machine/gb_mbc.c @@ -25,6 +25,7 @@ const device_type GB_ROM_MBC6 = &device_creator; const device_type GB_ROM_MBC7 = &device_creator; const device_type GB_ROM_MMM01 = &device_creator; const device_type GB_ROM_SINTAX = &device_creator; +const device_type GB_ROM_CHONGWU = &device_creator; gb_rom_mbc_device::gb_rom_mbc_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) @@ -53,6 +54,11 @@ gb_rom_mbc3_device::gb_rom_mbc3_device(const machine_config &mconfig, const char { } +gb_rom_mbc5_device::gb_rom_mbc5_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) + : gb_rom_mbc_device(mconfig, type, name, tag, owner, clock) +{ +} + gb_rom_mbc5_device::gb_rom_mbc5_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : gb_rom_mbc_device(mconfig, GB_ROM_MBC5, "GB MBC5 Carts", tag, owner, clock) { @@ -78,6 +84,11 @@ gb_rom_sintax_device::gb_rom_sintax_device(const machine_config &mconfig, const { } +gb_rom_chongwu_device::gb_rom_chongwu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : gb_rom_mbc5_device(mconfig, GB_ROM_CHONGWU, "GB Chong Wu Xiao Jing Ling", tag, owner, clock) +{ +} + void gb_rom_mbc_device::device_start() { @@ -275,6 +286,25 @@ void gb_rom_sintax_device::device_start() save_item(NAME(m_xor5)); } +void gb_rom_chongwu_device::device_start() +{ + has_timer = FALSE; + has_rumble = FALSE; + + m_latch_bank = 0; + m_latch_bank2 = 1; + m_ram_bank = 0; + m_ram_enable = 0; + m_mode = 0; + m_protection_checked = 0; + save_item(NAME(m_latch_bank)); + save_item(NAME(m_latch_bank2)); + save_item(NAME(m_ram_bank)); + save_item(NAME(m_ram_enable)); + save_item(NAME(m_mode)); + save_item(NAME(m_protection_checked)); +} + /*------------------------------------------------- mapper specific handlers @@ -727,6 +757,24 @@ WRITE8_MEMBER(gb_rom_mmm01_device::write_bank) } } +// MBC5 variant used by Chong Wu Xiao Jing Ling (this appears to be a re-release of a Li Cheng / Niutoude game, +// given that it contains the Niutoude logo, with most protection checks patched out) + +READ8_MEMBER(gb_rom_chongwu_device::read_rom) +{ + // protection check at the first read here... + if (offset == 0x41c3 && !m_protection_checked) + { + m_protection_checked = 1; + return 0x5d; + } + + if (offset < 0x4000) + return m_rom[rom_bank_map[m_latch_bank] * 0x4000 + (offset & 0x3fff)]; + else + return m_rom[rom_bank_map[m_latch_bank2] * 0x4000 + (offset & 0x3fff)]; +} + // MBC5 variant used by Sintax games void gb_rom_sintax_device::set_xor_for_bank(UINT8 bank) @@ -809,7 +857,7 @@ WRITE8_MEMBER(gb_rom_sintax_device::write_bank) m_sintax_mode = data; write_bank(space, 0x2000, 1); //force a fake bank switch } - printf("sintax mode %x\n", m_sintax_mode & 0xf); +// printf("sintax mode %x\n", m_sintax_mode & 0xf); } else if (offset >= 0x7000) { @@ -848,3 +896,4 @@ WRITE8_MEMBER(gb_rom_sintax_device::write_ram) if (m_ram && m_ram_enable) m_ram[ram_bank_map[m_ram_bank] * 0x2000 + (offset & 0x1fff)] = data; } + diff --git a/src/mess/machine/gb_mbc.h b/src/mess/machine/gb_mbc.h index d66e7a5b42a..9a624b66a14 100644 --- a/src/mess/machine/gb_mbc.h +++ b/src/mess/machine/gb_mbc.h @@ -105,6 +105,7 @@ class gb_rom_mbc5_device : public gb_rom_mbc_device { public: // construction/destruction + gb_rom_mbc5_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock); gb_rom_mbc5_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); // device-level overrides @@ -172,6 +173,22 @@ public: UINT8 m_bank_mask, m_bank, m_reg; }; +// ======================> gb_rom_chongwu_device + +class gb_rom_chongwu_device : public gb_rom_mbc5_device +{ +public: + // construction/destruction + gb_rom_chongwu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // device-level overrides + virtual void device_start(); + virtual void device_config_complete() { m_shortname = "gb_rom_chongwu"; } + + virtual DECLARE_READ8_MEMBER(read_rom); + UINT8 m_protection_checked; +}; + // ======================> gb_rom_sintax_device class gb_rom_sintax_device : public gb_rom_mbc_device { @@ -207,5 +224,6 @@ extern const device_type GB_ROM_MBC6; extern const device_type GB_ROM_MBC7; extern const device_type GB_ROM_MMM01; extern const device_type GB_ROM_SINTAX; +extern const device_type GB_ROM_CHONGWU; #endif diff --git a/src/mess/machine/gb_slot.c b/src/mess/machine/gb_slot.c index fa85465f691..3c6813284b4 100644 --- a/src/mess/machine/gb_slot.c +++ b/src/mess/machine/gb_slot.c @@ -215,6 +215,7 @@ static const gb_slot slot_list[] = { GB_MBC_LASAMA, "rom_lasama" }, { GB_MBC_ATVRACIN, "rom_atvrac" }, { GB_MBC_SINTAX, "rom_sintax" }, + { GB_MBC_CHONGWU, "rom_chong" }, { GB_MBC_CAMERA, "rom_camera" } }; diff --git a/src/mess/machine/gb_slot.h b/src/mess/machine/gb_slot.h index 612c2f5453a..e4988ae4fef 100644 --- a/src/mess/machine/gb_slot.h +++ b/src/mess/machine/gb_slot.h @@ -28,6 +28,7 @@ enum GB_MBC_ATVRACIN, GB_MBC_CAMERA, GB_MBC_SINTAX, + GB_MBC_CHONGWU, GB_MBC_MEGADUCK, /* MEGADUCK style banking */ GB_MBC_UNKNOWN /* Unknown mapper */ };