Skip to content

Commit

Permalink
funtech/supracan.cpp: preliminary cart interface, add NVRAM support f…
Browse files Browse the repository at this point in the history
…or games requiring it
  • Loading branch information
angelosa committed Sep 10, 2024
1 parent 55c9a27 commit 1f06e6b
Show file tree
Hide file tree
Showing 7 changed files with 409 additions and 44 deletions.
45 changes: 30 additions & 15 deletions hash/supracan.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ license:CC0-1.0
]]></notes>
<info name="serial" value="F001" />
<info name="alt_title" value="福爾摩沙大對決" />
<part name="cart" interface="supracan_cart">
<part name="cart" interface="superacan_cart">
<dataarea name="rom" width="16" endianness="big" size="0x100000">
<rom loadflag="load16_word_swap" name="Formosa Duel (Taiwan).bin" size="0x100000" crc="b2bf31dc" sha1="8d0680e1322af21b20d5cee2c100b05cf4217815" offset="0" />
</dataarea>
Expand All @@ -33,7 +33,7 @@ license:CC0-1.0
]]></notes>
<info name="serial" value="F002" />
<info name="alt_title" value="三國志 武將爭霸" />
<part name="cart" interface="supracan_cart">
<part name="cart" interface="superacan_cart">
<dataarea name="rom" width="16" endianness="big" size="3145728">
<rom loadflag="load16_word_swap" name="sangofgt.bin" size="3145728" crc="a4de6dde" sha1="f4bed63775130a75eb9c50b32e0cf50d1a7b8f50" offset="0" />
</dataarea>
Expand All @@ -53,11 +53,13 @@ Broken [video] during intro, uses bitmap mode
]]></notes>
<info name="serial" value="F003" />
<info name="alt_title" value="邪惡之子" />
<part name="cart" interface="supracan_cart">
<!-- TODO: sram -->
<part name="cart" interface="superacan_cart">
<dataarea name="rom" width="16" endianness="big" size="2097152">
<rom loadflag="load16_word_swap" name="16005.cu5" size="2097152" crc="9f6119a7" sha1="67ae9e7f99e1c3054ea54d53dbbba7792ef45134" offset="0" />
</dataarea>
<!-- TODO: unconfirmed size -->
<dataarea name="nvram" size="0x8000">
</dataarea>
</part>
</software>

Expand All @@ -74,7 +76,7 @@ Broken [video] during intro, uses bitmap mode
]]></notes>
<info name="serial" value="F004" />
<info name="alt_title" value="音速飛龍" />
<part name="cart" interface="supracan_cart">
<part name="cart" interface="superacan_cart">
<dataarea name="rom" width="16" endianness="big" size="2097152">
<rom loadflag="load16_word_swap" name="speedydgn.bin" size="2097152" crc="f631383c" sha1="fbd62b5d287aa82ef27f400ab2a6b3da0308192a" offset="0" />
</dataarea>
Expand All @@ -92,11 +94,13 @@ Broken [video] during intro, uses bitmap mode
]]></notes>
<info name="serial" value="F005" />
<info name="alt_title" value="超級中華職棒聯盟" />
<part name="cart" interface="supracan_cart">
<!-- TODO: sram -->
<part name="cart" interface="superacan_cart">
<dataarea name="rom" width="16" endianness="big" size="2097152">
<rom loadflag="load16_word_swap" name="16005.0" size="2097152" crc="ccf6829b" sha1="17a413803d8749fbe9643ca56d703afd64569b9f" offset="0" />
</dataarea>
<!-- TODO: unconfirmed size -->
<dataarea name="nvram" size="0x8000">
</dataarea>
</part>
</software>

Expand All @@ -109,7 +113,7 @@ Can potentially hang, [maincpu] tight loops for $e80300 bit 7 high (verify)
]]></notes>
<info name="serial" value="F006" />
<info name="alt_title" value="嘻遊記" />
<part name="cart" interface="supracan_cart">
<part name="cart" interface="superacan_cart">
<dataarea name="rom" width="16" endianness="big" size="2097152">
<rom loadflag="load16_word_swap" name="16002.cu2" size="2097152" crc="cee25eea" sha1="fc82fc3a7d55571494cd62d8807160e22cf437bc" offset="0" />
</dataarea>
Expand All @@ -126,12 +130,15 @@ Can potentially hang, [maincpu] tight loops for $e80300 bit 7 high (verify)
]]></notes>
<info name="serial" value="F007" />
<info name="alt_title" value="超級光明戰史" />
<part name="cart" interface="supracan_cart">
<!-- TODO: sram -->
<part name="cart" interface="superacan_cart">
<dataarea name="rom" width="16" endianness="big" size="3145728">
<rom loadflag="load16_word_swap" name="16007.0" size="2097152" crc="56c1c3fb" sha1="249e2ad6d8d40ecd31eda5a1bd5e5d0f47174a27" offset="000000" />
<rom loadflag="load16_word_swap" name="08007.1" size="1048576" crc="fc79f05f" sha1="7ce2e23ea3fd25764935708be4d47bf1a9843938" offset="0x200000" />
</dataarea>

<!-- TODO: unconfirmed size -->
<dataarea name="nvram" size="0x8000">
</dataarea>
</part>
</software>

Expand All @@ -141,11 +148,14 @@ Can potentially hang, [maincpu] tight loops for $e80300 bit 7 high (verify)
<publisher>Panda Entertainment Technology</publisher>
<info name="serial" value="F008" />
<info name="alt_title" value="非洲探險" />
<part name="cart" interface="supracan_cart">
<!-- TODO: sram -->
<part name="cart" interface="superacan_cart">
<dataarea name="rom" width="16" endianness="big" size="1048576">
<rom loadflag="load16_word_swap" name="08003.bin" size="1048576" crc="dc3b7b84" sha1="6dcbd7923203da7892915595d65ee668afbf0339" offset="0" />
</dataarea>

<!-- TODO: unconfirmed size -->
<dataarea name="nvram" size="0x8000">
</dataarea>
</part>
</software>

Expand All @@ -160,10 +170,15 @@ Erratic gameplay speed, controls [irq 3] as FRC, show [video] missing/glitched t
]]></notes>
<info name="serial" value="F009" />
<info name="alt_title" value="賭霸" />
<part name="cart" interface="supracan_cart">
<part name="cart" interface="superacan_cart">
<dataarea name="rom" width="16" endianness="big" size="2097152">
<rom loadflag="load16_word_swap" name="16006.bin" size="2097152" crc="ac4fa721" sha1="0fda223817f0b50f0ce9687076d29df3d1b86960" offset="0" />
</dataarea>

<!-- TODO: unconfirmed size and actual presence -->
<!-- Story mode would be impossible to run in one setting otherwise? -->
<dataarea name="nvram" size="0x8000">
</dataarea>
</part>
</software>

Expand All @@ -179,7 +194,7 @@ Erratic gameplay speed, controls [irq 3] as FRC
]]></notes>
<info name="serial" value="F010" />
<info name="alt_title" value="魔棒撞球" />
<part name="cart" interface="supracan_cart">
<part name="cart" interface="superacan_cart">
<dataarea name="rom" width="16" endianness="big" size="2097152">
<rom loadflag="load16_word_swap" name="08004.bin" size="2097152" crc="aed4e4f8" sha1="6be79db9006c46ea21f5dbe1add755ce2e413796" offset="0" />
</dataarea>
Expand All @@ -196,7 +211,7 @@ Uses [video] clipping for layer 1 during intro

<info name="serial" value="F011" />
<info name="alt_title" value="爆爆動物園" />
<part name="cart" interface="supracan_cart">
<part name="cart" interface="superacan_cart">
<dataarea name="rom" width="16" endianness="big" size="524288">
<rom loadflag="load16_word_swap" name="boomzoo.bin" size="524288" crc="6099bb44" sha1="0b5fbe2117bb77a827453c5489b3af691e5c7ade" offset="0" />
</dataarea>
Expand Down
14 changes: 14 additions & 0 deletions scripts/src/bus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2576,6 +2576,20 @@ if (BUSES["SS50"]~=null) then
}
end

---------------------------------------------------
--
--@src/devices/bus/supracan/slot.h,BUSES["SUPRACAN"] = true
---------------------------------------------------

if (BUSES["SUPRACAN"]~=null) then
files {
MAME_DIR .. "src/devices/bus/supracan/slot.cpp",
MAME_DIR .. "src/devices/bus/supracan/slot.h",
MAME_DIR .. "src/devices/bus/supracan/rom.cpp",
MAME_DIR .. "src/devices/bus/supracan/rom.h",
}
end


---------------------------------------------------
--
Expand Down
96 changes: 96 additions & 0 deletions src/devices/bus/supracan/rom.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// license:BSD-3-Clause
// copyright-holders:

#include "emu.h"
#include "rom.h"


//-------------------------------------------------
// superacan_rom_device - constructor
//-------------------------------------------------

DEFINE_DEVICE_TYPE(SUPERACAN_ROM_STD, superacan_rom_device, "superacan_rom", "Super A'Can Standard Cart")


superacan_rom_device::superacan_rom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, type, tag, owner, clock), device_superacan_cart_interface(mconfig, *this)
, m_rom_base(nullptr)
, m_nvram_base(nullptr)
, m_rom_size(0)
, m_nvram_size(0)
{
}

superacan_rom_device::superacan_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: superacan_rom_device(mconfig, SUPERACAN_ROM_STD, tag, owner, clock)
{
}


void superacan_rom_device::device_start()
{
}

void superacan_rom_device::device_add_mconfig(machine_config &config)
{
// TODO: move UM6650 from funtech folder
}

std::error_condition superacan_rom_device::load()
{
memory_region *const romregion = memregion("^rom");
m_rom_base = reinterpret_cast<const u16 *>(romregion->base());
m_rom_size = romregion->bytes() / 2;

// if (m_rom_size > 0x40'0000)
// return std::make_pair(image_error::INVALIDLENGTH, "Unsupported cartridge size (must be no larger than 4M)");

memory_region *const nvramregion = memregion("^nvram");
if (nvramregion)
{
m_nvram_base = reinterpret_cast<u8 *>(nvramregion->base());
m_nvram_size = nvramregion->bytes();

if (m_nvram_size & (m_nvram_size - 1))
return image_error::BADSOFTWARE;

save_pointer(NAME(m_nvram_base), m_nvram_size);
battery_load(m_nvram_base, m_nvram_size, 0xff);
}

return std::error_condition();
}


void superacan_rom_device::unload()
{
if (m_nvram_base)
battery_save(m_nvram_base, m_nvram_size);
}


/*-------------------------------------------------
read/write
-------------------------------------------------*/

u16 superacan_rom_device::rom_r(offs_t offset)
{
if (offset < m_rom_size)
return m_rom_base[offset];
else
return 0xffff;
}

u8 superacan_rom_device::nvram_r(offs_t offset)
{
if (m_nvram_base)
return m_nvram_base[offset & (m_nvram_size - 1)];
else
return 0xff;
}

void superacan_rom_device::nvram_w(offs_t offset, u8 data)
{
if (m_nvram_base)
m_nvram_base[offset & (m_nvram_size - 1)] = data;
}
46 changes: 46 additions & 0 deletions src/devices/bus/supracan/rom.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// license:BSD-3-Clause
// copyright-holders:
#ifndef MAME_BUS_SUPERACAN_ROM_H
#define MAME_BUS_SUPERACAN_ROM_H

#pragma once

#include "slot.h"


// ======================> superacan_rom_device

class superacan_rom_device : public device_t,
public device_superacan_cart_interface
{
public:
// construction/destruction
superacan_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);

// load/unload
virtual std::error_condition load() override;
virtual void unload() override;

// read/write
virtual u16 rom_r(offs_t offset) override;
virtual u8 nvram_r(offs_t offset) override;
virtual void nvram_w(offs_t offset, u8 data) override;

protected:
superacan_rom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);

virtual void device_start() override;

virtual void device_add_mconfig(machine_config &config) override;

private:
const u16 *m_rom_base;
u8 *m_nvram_base;
u32 m_rom_size;
u32 m_nvram_size;
};


DECLARE_DEVICE_TYPE(SUPERACAN_ROM_STD, superacan_rom_device)

#endif // MAME_BUS_SUPERACAN_ROM_H
Loading

0 comments on commit 1f06e6b

Please sign in to comment.