(MESS) gb.c: attempt in emulating protection for Chong Wu Xiao Jing Ling/Pokemon Pikecho. [Fabio Priuli]

This commit is contained in:
Fabio Priuli 2013-02-26 09:58:36 +00:00
parent 324eb6ea48
commit 794bf96c0c
6 changed files with 78 additions and 19 deletions

View File

@ -23361,13 +23361,18 @@ Undumped Pirates:
</software>
<!-- 1byte difference between this and the hacked version... check what is about! -->
<software name="chongwu" supported="no">
<software name="chongwu">
<!-- at 0x1e0 starts a routine which (at 0x1ec) reads from $41c3, then compares
the value with 0x5d. if comparison fails, the code enters a routine at 0x780
where it gets stuck. if comparison works, then the code goes to 0x150 as the
patched version does (because the single modified byte replaces the jump to
0x1e0 with the jump to 0x150). Not sure yet if current workaround is correct... -->
<description>Chong Wu Xiao Jing Ling - Jie Jin Ta Zhi Wang (Chi)</description>
<year>20??</year>
<publisher>&lt;unknown&gt;</publisher>
<info name="alt_title" value="宠物小精灵 结金塔之王"/>
<part name="cart" interface="gameboy_cart">
<feature name="slot" value="rom_mbc5" />
<feature name="slot" value="rom_chong" />
<!-- cartridge ram -->
<dataarea name="rom" size="1048576">
<rom name="chong wu xiao jing ling - jie jin ta zhi wang (unlicensed, chinese) [raw dump].bin" size="1048576" crc="620e785d" sha1="74da832c2eeb27a4260fe6f42514539473f48b11" offset="000000" />
@ -23377,22 +23382,6 @@ Undumped Pirates:
</part>
</software>
<software name="chongwuh" cloneof="chongwu">
<description>Chong Wu Xiao Jing Ling - Jie Jin Ta Zhi Wang (Chi, Hacked)</description>
<year>20??</year>
<publisher>&lt;unknown&gt;</publisher>
<info name="alt_title" value="宠物小精灵 结金塔之王"/>
<part name="cart" interface="gameboy_cart">
<feature name="slot" value="rom_mbc5" />
<!-- cartridge ram -->
<dataarea name="rom" size="1048576">
<rom name="chong wu xiao jing ling - jie jin ta zhi wang (unlicensed, chinese) [fixed].bin" size="1048576" crc="24ee5c85" sha1="9fc1a8a1a75fd535980aee8966f4d5f8609e5ef5" offset="000000" />
</dataarea>
<dataarea name="nvram" size="32768">
</dataarea>
</part>
</software>
<software name="jyqxc2">
<description>Jin Yong Qun Xia Chuan II (Chi)</description>
<year>20??</year>

View File

@ -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)

View File

@ -25,6 +25,7 @@ const device_type GB_ROM_MBC6 = &device_creator<gb_rom_mbc6_device>;
const device_type GB_ROM_MBC7 = &device_creator<gb_rom_mbc7_device>;
const device_type GB_ROM_MMM01 = &device_creator<gb_rom_mmm01_device>;
const device_type GB_ROM_SINTAX = &device_creator<gb_rom_sintax_device>;
const device_type GB_ROM_CHONGWU = &device_creator<gb_rom_chongwu_device>;
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;
}

View File

@ -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

View File

@ -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" }
};

View File

@ -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 */
};