summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/megadrive
diff options
context:
space:
mode:
author etabeta78 <doge.fabio@gmail.com>2016-05-17 07:57:39 +0200
committer etabeta78 <doge.fabio@gmail.com>2016-05-17 07:57:39 +0200
commit4d0e3033a7be22b75ff48133a200f6fc363a4a14 (patch)
treeb6975a1fb62e732c99781d198d90401144bd2729 /src/devices/bus/megadrive
parent1007a0730cb8c5c0216dbb78328f321ff01126c6 (diff)
misc. nw.
Diffstat (limited to 'src/devices/bus/megadrive')
-rw-r--r--src/devices/bus/megadrive/md_carts.cpp5
-rw-r--r--src/devices/bus/megadrive/md_slot.cpp24
-rw-r--r--src/devices/bus/megadrive/md_slot.h1
-rw-r--r--src/devices/bus/megadrive/rom.cpp127
-rw-r--r--src/devices/bus/megadrive/rom.h23
5 files changed, 168 insertions, 12 deletions
diff --git a/src/devices/bus/megadrive/md_carts.cpp b/src/devices/bus/megadrive/md_carts.cpp
index fd5a9032ac3..4c9f1b9b2e0 100644
--- a/src/devices/bus/megadrive/md_carts.cpp
+++ b/src/devices/bus/megadrive/md_carts.cpp
@@ -18,8 +18,9 @@ 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_xinqig", MD_ROM_SRAM)
- SLOT_INTERFACE_INTERNAL("rom_beggarp", MD_ROM_BEGGARP)
- SLOT_INTERFACE_INTERNAL("rom_wukong", MD_ROM_WUKONG)
+ SLOT_INTERFACE_INTERNAL("rom_sf001", MD_ROM_BEGGARP)
+ SLOT_INTERFACE_INTERNAL("rom_sf002", MD_ROM_WUKONG)
+ SLOT_INTERFACE_INTERNAL("rom_sf004", MD_ROM_STARODYS)
// EEPROM handling (not supported fully yet)
SLOT_INTERFACE_INTERNAL("rom_eeprom", MD_STD_EEPROM)
SLOT_INTERFACE_INTERNAL("rom_nbajam", MD_EEPROM_NBAJAM)
diff --git a/src/devices/bus/megadrive/md_slot.cpp b/src/devices/bus/megadrive/md_slot.cpp
index 2d7bc239968..84228207d5e 100644
--- a/src/devices/bus/megadrive/md_slot.cpp
+++ b/src/devices/bus/megadrive/md_slot.cpp
@@ -235,8 +235,9 @@ static const md_slot slot_list[] =
{ SEGA_FRAM, "rom_fram" },
{ HARDBALL95, "rom_hardbl95" },
{ XINQIG, "rom_xinqig"},
- { BEGGARP, "rom_beggarp"},
- { WUKONG, "rom_wukong"},
+ { BEGGARP, "rom_sf001"},
+ { WUKONG, "rom_sf002"},
+ { STARODYS, "rom_sf004"},
{ SEGA_EEPROM, "rom_eeprom" },
{ NBA_JAM, "rom_nbajam" },
@@ -526,7 +527,7 @@ int base_md_cart_slot_device::load_nonlist()
// STEP 4: determine the cart type (to deal with sram/eeprom & pirate mappers)
- m_type = get_cart_type(ROM, len);
+ m_type = get_cart_type(ROM, tmplen - offset);
// handle mirroring of ROM, unless it's SSF2 or Pier Solar
if (m_type != SSF2 && m_type != PSOLAR)
@@ -667,6 +668,12 @@ void base_md_cart_slot_device::setup_nvram()
m_cart->nvram_alloc(m_cart->m_nvram_end - m_cart->m_nvram_start + 1);
m_cart->m_nvram_active = 1;
break;
+ case STARODYS:
+ m_cart->m_nvram_start = 0x200000;
+ m_cart->m_nvram_end = m_cart->m_nvram_start + 0xfffff;
+ m_cart->nvram_alloc(0x8000/2); // 32K mirrored
+ m_cart->m_nvram_active = 1;
+ break;
case NBA_JAM_ALT:
m_cart->nvram_alloc(0x100);
break;
@@ -816,6 +823,9 @@ int base_md_cart_slot_device::get_cart_type(UINT8 *ROM, UINT32 len)
if (!memcmp((char *)&ROM[0x0150], "Virtua Racing", 13))
type = SEGA_SVP;
+ if (!memcmp((char *)&ROM[0x0180], "SF-004", 6)) // Star Odyssey
+ type = STARODYS;
+
break;
case 0x200005:
@@ -823,6 +833,11 @@ int base_md_cart_slot_device::get_cart_type(UINT8 *ROM, UINT32 len)
type = REDCL_EN;
break;
+ case 0x220000:
+ if (!memcmp((char *)&ROM[0x0180], "SF-002", 6)) // Legend of Wukong
+ type = WUKONG;
+ break;
+
case 0x300000:
if (!memcmp(&ROM[0x220], sdk_sig, sizeof(sdk_sig)))
type = LIONK3;
@@ -858,6 +873,9 @@ int base_md_cart_slot_device::get_cart_type(UINT8 *ROM, UINT32 len)
if (!memcmp((char *)&ROM[0x0180], "GM T-81476", 10)) // Big Hurt Baseball
type = C_SLAM;
+ if (!memcmp((char *)&ROM[0x0180], "SF-001", 6)) // Beggar Prince
+ type = BEGGARP;
+
break;
case 0x500000:
diff --git a/src/devices/bus/megadrive/md_slot.h b/src/devices/bus/megadrive/md_slot.h
index 099b17e9d51..a033daec607 100644
--- a/src/devices/bus/megadrive/md_slot.h
+++ b/src/devices/bus/megadrive/md_slot.h
@@ -26,6 +26,7 @@ enum
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 */
+ STARODYS, /* Star Odyssey */
// EEPROM
SEGA_EEPROM, /* Wonder Boy V / Evander Holyfield's Boxing / Greatest Heavyweights of the Ring / Sports Talk Baseball / Megaman */
diff --git a/src/devices/bus/megadrive/rom.cpp b/src/devices/bus/megadrive/rom.cpp
index 2ce6d353e35..5d38557ea86 100644
--- a/src/devices/bus/megadrive/rom.cpp
+++ b/src/devices/bus/megadrive/rom.cpp
@@ -61,6 +61,7 @@ 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>;
+const device_type MD_ROM_STARODYS = &device_creator<md_rom_starodys_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, const char *shortname, const char *source)
@@ -235,6 +236,11 @@ md_rom_wukong_device::md_rom_wukong_device(const machine_config &mconfig, const
{
}
+md_rom_starodys_device::md_rom_starodys_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : md_std_rom_device(mconfig, MD_ROM_STARODYS, "MD Star Odyssey", tag, owner, clock, "md_rom_starodys", __FILE__), m_mode(0), m_lock(0), m_ram_enable(0), m_base(0)
+{
+}
+
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
@@ -416,6 +422,22 @@ void md_rom_wukong_device::device_reset()
m_mode = 0;
}
+void md_rom_starodys_device::device_start()
+{
+ save_item(NAME(m_mode));
+ save_item(NAME(m_lock));
+ save_item(NAME(m_ram_enable));
+ save_item(NAME(m_base));
+}
+
+void md_rom_starodys_device::device_reset()
+{
+ m_mode = 0;
+ m_lock = 0;
+ m_ram_enable = 1;
+ m_base = 0;
+}
+
/*-------------------------------------------------
mapper specific handlers
-------------------------------------------------*/
@@ -1356,16 +1378,14 @@ WRITE16_MEMBER(md_rom_beggarp_device::write)
m_nvram[offset & 0x3fff] = data;
}
+// this works the same as in standard SRAM carts
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;
}
@@ -1388,7 +1408,7 @@ 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
+ // here can access both last 128K of the ROM and the first 128K, depending 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)
@@ -1406,17 +1426,110 @@ WRITE16_MEMBER(md_rom_wukong_device::write)
m_nvram[offset - m_nvram_start/2] = data;
}
+// this works the same as in standard SRAM carts
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;
}
}
+
+
+/*-------------------------------------------------
+ STAR ODYSSEY
+ This game uses a slightly more complex mapper:
+ not only RAM can be enabled / disabled, but also
+ ROM can be mapped in three different modes.
+ In what we call Mode0 the first 256K are mirrored
+ into area 0x000000-0x1fffff; in Mode1 cart gives
+ access to 5x256K banks into area 0x000000-0x13ffff
+ and open bus into 0x140000-0x1fffff; in Mode2 the
+ ROM is disabled and the whole 0x000000-0x1fffff
+ gives open bus
+-------------------------------------------------*/
+
+READ16_MEMBER(md_rom_starodys_device::read)
+{
+ if (offset >= m_nvram_start/2 && offset <= m_nvram_end/2 && m_nvram_active && m_ram_enable)
+ return m_nvram[offset & 0x3fff];
+
+ if (offset < 0x200000/2)
+ {
+ if (m_mode == 0)
+ return m_rom[offset & 0x3ffff];
+ else if (m_mode == 1 && offset < 0x140000/2)
+ return m_rom[m_base * 0x40000/2 + offset];
+ else
+ return 0xffff;
+ }
+ else if (offset < 0x400000/2)
+ return m_rom[offset & 0xfffff];
+ else
+ return 0xffff;
+}
+
+WRITE16_MEMBER(md_rom_starodys_device::write)
+{
+ if (offset >= m_nvram_start/2 && offset <= m_nvram_end/2 && m_nvram_active && !m_nvram_readonly && m_ram_enable)
+ m_nvram[offset & 0x3fff] = data;
+
+ if (offset < 0x10000/2)
+ {
+ UINT32 prot_offs = (offset * 2) & 0xf00;
+ if (!m_lock)
+ {
+ if (prot_offs == 0xd00)
+ {
+ //printf("RAM enable %s!\n", BIT(data, 7) ? "Yes" : "No");
+ m_ram_enable = BIT(data, 7);
+ }
+ if (prot_offs == 0xe00)
+ {
+ if (BIT(data, 5))
+ m_mode = 2;
+ else if (BIT(data, 6))
+ m_mode = 1;
+ else
+ m_mode = 0;
+ //printf("ROM mode %d!\n", m_mode);
+
+ if (!BIT(data, 7))
+ {
+ //printf("LOCK BANKSWITCH!\n");
+ m_lock = 1;
+ }
+ }
+ if (prot_offs == 0xf00)
+ {
+ m_base = ((data >> 4) & 7);
+ m_mode = 1;
+ //printf("ROM base %d!\n", m_base);
+ }
+ }
+ }
+
+}
+
+READ16_MEMBER(md_rom_starodys_device::read_a13)
+{
+ return m_base << 4;
+}
+
+// this works the same as in standard SRAM carts
+WRITE16_MEMBER(md_rom_starodys_device::write_a13)
+{
+ if (offset == 0xf0/2)
+ {
+ m_nvram_active = BIT(data, 0);
+ m_nvram_readonly = BIT(data, 1);
+
+ if (m_nvram_active)
+ m_nvram_handlers_installed = 1;
+ }
+}
+
diff --git a/src/devices/bus/megadrive/rom.h b/src/devices/bus/megadrive/rom.h
index 796b29dc9fb..4e9b656e08a 100644
--- a/src/devices/bus/megadrive/rom.h
+++ b/src/devices/bus/megadrive/rom.h
@@ -545,6 +545,28 @@ private:
UINT8 m_mode;
};
+// ======================> md_rom_starodys_device
+
+class md_rom_starodys_device : public md_std_rom_device
+{
+public:
+ // construction/destruction
+ md_rom_starodys_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ // device-level overrides
+ virtual void device_start() override;
+ virtual void device_reset() override;
+
+ // reading and writing
+ virtual DECLARE_READ16_MEMBER(read) override;
+ virtual DECLARE_WRITE16_MEMBER(write) override;
+ virtual DECLARE_READ16_MEMBER(read_a13) override;
+ virtual DECLARE_WRITE16_MEMBER(write_a13) override;
+
+private:
+ UINT8 m_mode, m_lock, m_ram_enable, m_base;
+};
+
// device type definition
@@ -581,5 +603,6 @@ 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;
+extern const device_type MD_ROM_STARODYS;
#endif