(MESS) megadriv.c: added support for Legend of Wukong [Fabio Priuli]

This commit is contained in:
Fabio Priuli 2013-02-26 11:33:06 +00:00
parent 794bf96c0c
commit e3a36bad2a
6 changed files with 109 additions and 1 deletions

View File

@ -25747,6 +25747,20 @@ Notice that these are not working on real hardware due to bugged code with VDP i
</software>
<software name="wukong">
<description>Legend of Wukong (Euro, USA)</description>
<year>2008</year>
<publisher>Super Fighter Team</publisher>
<part name="cart" interface="megadriv_cart">
<feature name="slot" value="rom_wukong" />
<dataarea name="rom" size="2228224">
<rom name="legend of wukong (unl).bin" size="2228224" crc="72f11771" sha1="4ef41e4caccab118014abb8e079c7e5668a4f468" offset="000000" loadflag="load16_word_swap" />
</dataarea>
<dataarea name="sram" size="16384">
</dataarea>
</part>
</software>
<software name="wukongc" cloneof="wukong">
<description>Wu Kong Wai Zhuan (Chi)</description>
<year>1996</year>
<publisher>Ming</publisher>
@ -26120,7 +26134,7 @@ Notice that these are not working on real hardware due to bugged code with VDP i
</software>
<software name="beggarp">
<description>Beggar Prince (USA)</description>
<description>Beggar Prince (Euro, USA)</description>
<year>2005</year>
<publisher>Super Fighter Team</publisher>
<part name="cart" interface="megadriv_cart">

View File

@ -305,6 +305,7 @@ static SLOT_INTERFACE_START(md_cart)
SLOT_INTERFACE_INTERNAL("rom_fram", MD_ROM_FRAM)
SLOT_INTERFACE_INTERNAL("rom_hardbl95", MD_ROM_SRAM)
SLOT_INTERFACE_INTERNAL("rom_beggar", MD_ROM_SRAM)
SLOT_INTERFACE_INTERNAL("rom_wukong", MD_ROM_WUKONG)
// EEPROM handling (not supported fully yet)
SLOT_INTERFACE_INTERNAL("rom_eeprom", MD_STD_EEPROM)
SLOT_INTERFACE_INTERNAL("rom_nbajam", MD_EEPROM_NBAJAM)

View File

@ -48,6 +48,7 @@ const device_type MD_ROM_REDCL = &device_creator<md_rom_redcl_device>;
const device_type MD_ROM_SQUIR = &device_creator<md_rom_squir_device>;
const device_type MD_ROM_TOPF = &device_creator<md_rom_topf_device>;
const device_type MD_ROM_RADICA = &device_creator<md_rom_radica_device>;
const device_type MD_ROM_WUKONG = &device_creator<md_rom_wukong_device>;
md_std_rom_device::md_std_rom_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock)
@ -192,6 +193,11 @@ md_rom_radica_device::md_rom_radica_device(const machine_config &mconfig, const
{
}
md_rom_wukong_device::md_rom_wukong_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: md_std_rom_device(mconfig, MD_ROM_WUKONG, "MD Legend of Wukong", tag, owner, clock)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
@ -286,6 +292,12 @@ void md_rom_radica_device::device_start()
save_item(NAME(m_bank));
}
void md_rom_wukong_device::device_start()
{
m_mode = 0;
save_item(NAME(m_mode));
}
/*-------------------------------------------------
mapper specific handlers
-------------------------------------------------*/
@ -1042,3 +1054,55 @@ READ16_MEMBER(md_rom_radica_device::read_a13)
m_bank = offset & 0x3f;
return 0;
}
/*-------------------------------------------------
LEGEND OF WUKONG
This game uses cart which is the same as SEGA_SRAM
+ bankswitch mechanism for last 128k of the image:
first 2MB of ROM is loaded in 0-0x200000 and
mirrored in 0x200000-0x400000, but depending on
bit7 of the value written at 0xe00/2 accesses to
0x200000-0x21ffff go either to the "physical" address
(i.e. last 128K of ROM) or to the "memory" address
(i.e. mirror of first 128K)
-------------------------------------------------*/
READ16_MEMBER(md_rom_wukong_device::read)
{
if (offset >= m_nvram_start/2 && offset <= m_nvram_end/2 && m_nvram_active)
return m_nvram[offset - m_nvram_start/2];
// here can access both last 128K of the ROM and the first 128K, depending of bit7 of m_mode
if (offset >= 0x200000/2 && offset < 0x220000/2)
return !m_mode ? m_rom[offset] : m_rom[offset & 0xffff];
else if (offset < 0x400000/2)
return m_rom[offset & 0xfffff];
else
return 0xffff;
}
WRITE16_MEMBER(md_rom_wukong_device::write)
{
if (offset < 0x100000/2) // it actually writes to 0xe00/2
m_mode = BIT(data, 7);
if (offset >= m_nvram_start/2 && offset <= m_nvram_end/2 && m_nvram_active && !m_nvram_readonly)
m_nvram[offset - m_nvram_start/2] = data;
}
WRITE16_MEMBER(md_rom_wukong_device::write_a13)
{
if (offset == 0xf0/2)
{
/* unsure if this is actually supposed to toggle or just switch on? yet to encounter game that uses this */
m_nvram_active = BIT(data, 0);
m_nvram_readonly = BIT(data, 1);
// since a lot of generic carts ends up here if loaded from fullpath
// we turn on nvram (with m_nvram_handlers_installed) only if they toggle it on by writing here!
if (m_nvram_active)
m_nvram_handlers_installed = 1;
}
}

View File

@ -483,6 +483,26 @@ private:
UINT8 m_bank;
};
// ======================> md_rom_wukong_device
class md_rom_wukong_device : public md_std_rom_device
{
public:
// construction/destruction
md_rom_wukong_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 = "md_rom_wukong"; }
// reading and writing
virtual DECLARE_READ16_MEMBER(read);
virtual DECLARE_WRITE16_MEMBER(write);
virtual DECLARE_WRITE16_MEMBER(write_a13);
UINT8 m_mode;
};
// device type definition
@ -513,5 +533,6 @@ extern const device_type MD_ROM_SSF2;
extern const device_type MD_ROM_SQUIR;
extern const device_type MD_ROM_TOPF;
extern const device_type MD_ROM_RADICA;
extern const device_type MD_ROM_WUKONG;
#endif

View File

@ -241,6 +241,7 @@ static const md_slot slot_list[] =
{ SEGA_FRAM, "rom_fram" },
{ HARDBALL95, "rom_hardbl95" },
{ BEGGAR, "rom_beggar"},
{ WUKONG, "rom_wukong"},
{ SEGA_EEPROM, "rom_eeprom" },
{ NBA_JAM, "rom_nbajam" },
@ -639,6 +640,12 @@ void base_md_cart_slot_device::setup_nvram()
m_cart->m_nvram_active = 1;
m_cart->m_nvram_handlers_installed = 1;
break;
case WUKONG:
m_cart->m_nvram_start = 0x3c0000;
m_cart->m_nvram_end = m_cart->m_nvram_start + 0x3fff;
m_cart->nvram_alloc(machine(), m_cart->m_nvram_end - m_cart->m_nvram_start + 1);
m_cart->m_nvram_active = 1;
break;
}
}

View File

@ -22,6 +22,7 @@ enum
SEGA_SRAM, SEGA_FRAM,
HARDBALL95, /* Hardball 95 uses different sram start address */
BEGGAR, /* Beggar Prince / Xin Qigai Wangzi uses different sram start address and has no valid header */
WUKONG, /* Legend of Wukong uses different sram start address + bankswitch trick for last 128K of ROM */
// EEPROM
SEGA_EEPROM, /* Wonder Boy V / Evander Holyfield's Boxing / Greatest Heavyweights of the Ring / Sports Talk Baseball / Megaman */