this should fix the resets and lockups (at least most of them). sram is still not saved, though... nw.

This commit is contained in:
Fabio Priuli 2013-02-26 14:44:43 +00:00
parent 67793cbffc
commit 46e9a14f4d
6 changed files with 116 additions and 8 deletions

View File

@ -26138,7 +26138,7 @@ Notice that these are not working on real hardware due to bugged code with VDP i
<year>2005</year>
<publisher>Super Fighter Team</publisher>
<part name="cart" interface="megadriv_cart">
<feature name="slot" value="rom_beggar" />
<feature name="slot" value="rom_beggarp" />
<dataarea name="rom" size="4194304">
<rom name="beggar prince (unl).bin" size="4194304" crc="f3af46cd" sha1="f481b970756c482d8f408c4bab8902172837e7d8" offset="000000" loadflag="load16_word_swap" />
</dataarea>
@ -26150,7 +26150,7 @@ Notice that these are not working on real hardware due to bugged code with VDP i
<year>1996</year>
<publisher>C&amp;E</publisher>
<part name="cart" interface="megadriv_cart">
<feature name="slot" value="rom_beggar" />
<feature name="slot" value="rom_xinqig" />
<dataarea name="rom" size="4194304">
<rom name="xin qi gai wang zi (chi) (alt) (unl).bin" size="4194304" crc="da5a4bfe" sha1="75f8003a6388814c1880347882b244549da62158" offset="000000" loadflag="load16_word_swap" />
</dataarea>
@ -26162,7 +26162,7 @@ Notice that these are not working on real hardware due to bugged code with VDP i
<year>1996</year>
<publisher>C&amp;E</publisher>
<part name="cart" interface="megadriv_cart">
<feature name="slot" value="rom_beggar" />
<feature name="slot" value="rom_xinqig" />
<dataarea name="rom" size="4194304">
<rom name="xin qi gai wang zi (chi) (unl).bin" size="4194304" crc="dd2f38b5" sha1="4a7494d8601149f43ba7e3595a0b2340cde2e9ba" offset="000000" loadflag="load16_word_swap" />
</dataarea>

View File

@ -304,7 +304,8 @@ static SLOT_INTERFACE_START(md_cart)
SLOT_INTERFACE_INTERNAL("rom_sramsafe", MD_ROM_SRAM)
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_xinqig", MD_ROM_SRAM)
SLOT_INTERFACE_INTERNAL("rom_beggarp", MD_ROM_BEGGARP)
SLOT_INTERFACE_INTERNAL("rom_wukong", MD_ROM_WUKONG)
// EEPROM handling (not supported fully yet)
SLOT_INTERFACE_INTERNAL("rom_eeprom", MD_STD_EEPROM)

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_BEGGARP = &device_creator<md_rom_beggarp_device>;
const device_type MD_ROM_WUKONG = &device_creator<md_rom_wukong_device>;
@ -193,6 +194,11 @@ md_rom_radica_device::md_rom_radica_device(const machine_config &mconfig, const
{
}
md_rom_beggarp_device::md_rom_beggarp_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: md_std_rom_device(mconfig, MD_ROM_BEGGARP, "MD Beggar Prince", tag, owner, clock)
{
}
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)
{
@ -292,6 +298,14 @@ void md_rom_radica_device::device_start()
save_item(NAME(m_bank));
}
void md_rom_beggarp_device::device_start()
{
m_mode = 0;
m_lock = 0;
save_item(NAME(m_mode));
save_item(NAME(m_lock));
}
void md_rom_wukong_device::device_start()
{
m_mode = 0;
@ -1055,6 +1069,70 @@ READ16_MEMBER(md_rom_radica_device::read_a13)
return 0;
}
/*-------------------------------------------------
BEGGAR PRINCE
This game uses cart which is the same as SEGA_SRAM
+ bankswitch mechanism to remap some 256K chunk of
ROM and to enable/disable SRAM (not yet fully
emulated)
-------------------------------------------------*/
READ16_MEMBER(md_rom_beggarp_device::read)
{
if (m_mode & 2)
{
//000000-03ffff = ROM bank 15 x 256k
//040000-3bffff = ROM banks 2 to 15 x256k
//3c0000-3fffff = ?? SRAM ?? (32k?)
if (offset < 0x040000/2)
return m_rom[offset + 0x380000/2];
else if (offset >= m_nvram_start/2 && offset <= m_nvram_end/2 && m_nvram_active)
return m_nvram[offset & 0x3fff];
else if (offset < 0x400000/2)
return m_rom[offset & 0x1fffff];
}
else
{
// currently not supported
// if (m_mode & 1) //00-40 = unmapped (open bus?)
//00-40 = ROM banks 1 to 16 x256k
if (offset < 0x400000/2)
return m_rom[offset & 0x1fffff];
}
return 0xffff;
}
WRITE16_MEMBER(md_rom_beggarp_device::write)
{
if (offset >= 0x0e00/2 && offset < 0x0f00/2) // it actually writes to 0xe00/2
{
if (!m_lock)
m_mode = (data & 0xc0) >> 6;
m_lock = BIT(data, 5); // lock bankswitch hardware when set, until hard reset
}
// SRAM is only accessible in mode 2
if (offset >= m_nvram_start/2 && offset <= m_nvram_end/2 && m_nvram_active && !m_nvram_readonly && m_mode == 2)
m_nvram[offset & 0x3fff] = data;
}
WRITE16_MEMBER(md_rom_beggarp_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;
}
}
/*-------------------------------------------------
LEGEND OF WUKONG

View File

@ -483,6 +483,26 @@ private:
UINT8 m_bank;
};
// ======================> md_rom_beggarp_device
class md_rom_beggarp_device : public md_std_rom_device
{
public:
// construction/destruction
md_rom_beggarp_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_beggarp"; }
// reading and writing
virtual DECLARE_READ16_MEMBER(read);
virtual DECLARE_WRITE16_MEMBER(write);
virtual DECLARE_WRITE16_MEMBER(write_a13);
UINT8 m_mode, m_lock;
};
// ======================> md_rom_wukong_device
class md_rom_wukong_device : public md_std_rom_device
@ -499,7 +519,7 @@ public:
virtual DECLARE_READ16_MEMBER(read);
virtual DECLARE_WRITE16_MEMBER(write);
virtual DECLARE_WRITE16_MEMBER(write_a13);
UINT8 m_mode;
};
@ -533,6 +553,7 @@ 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_BEGGARP;
extern const device_type MD_ROM_WUKONG;
#endif

View File

@ -240,7 +240,8 @@ static const md_slot slot_list[] =
{ SEGA_SRAM, "rom_sram" },
{ SEGA_FRAM, "rom_fram" },
{ HARDBALL95, "rom_hardbl95" },
{ BEGGAR, "rom_beggar"},
{ XINQIG, "rom_xinqig"},
{ BEGGARP, "rom_beggarp"},
{ WUKONG, "rom_wukong"},
{ SEGA_EEPROM, "rom_eeprom" },
@ -633,13 +634,19 @@ void base_md_cart_slot_device::setup_nvram()
m_cart->m_nvram_active = 1;
m_cart->m_nvram_handlers_installed = 1;
break;
case BEGGAR:
case XINQIG:
m_cart->m_nvram_start = 0x400000;
m_cart->m_nvram_end = m_cart->m_nvram_start + 0xffff;
m_cart->nvram_alloc(machine(), m_cart->m_nvram_end - m_cart->m_nvram_start + 1);
m_cart->m_nvram_active = 1;
m_cart->m_nvram_handlers_installed = 1;
break;
case BEGGARP:
m_cart->m_nvram_start = 0x3c0000;
m_cart->m_nvram_end = m_cart->m_nvram_start + 0xffff;
m_cart->nvram_alloc(machine(), 0x8000); // 32K mirrored
m_cart->m_nvram_active = 1;
break;
case WUKONG:
m_cart->m_nvram_start = 0x3c0000;
m_cart->m_nvram_end = m_cart->m_nvram_start + 0x3fff;

View File

@ -21,7 +21,8 @@ enum
// Cart + NVRAM
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 */
XINQIG, /* Xin Qigai Wangzi uses different sram start address and has no valid header */
BEGGARP, /* Beggar Prince uses different sram start address + bankswitch tricks */
WUKONG, /* Legend of Wukong uses different sram start address + bankswitch trick for last 128K of ROM */
// EEPROM