bus/gameboy: Added support for Liebao Technology cartridges.

gameboy.xml: Changed default NVRAM fill for dbzgeki to 0xff - this will
cause it to treat the three save files as empty rather than starting in
a glitchy state.

New working software list items
-------------------------------
Dragon Ball Z English [lana_chan_, taizou]
This commit is contained in:
Vas Crabb 2022-11-12 03:39:21 +11:00
parent 2e5a0c183f
commit 6c0257b1a1
8 changed files with 207 additions and 1 deletions

View file

@ -5851,6 +5851,25 @@ license:CC0
<rom name="dragon ball z - gokuu gekitouden (japan).bin" size="0x80000" crc="ff3c027d" sha1="1f7a08d2e51e90d770d9dbf4092166b2bfa5697e" />
</dataarea>
<dataarea name="nvram" size="0x2000">
<rom value="0xff" size="0x2000" loadflag="fill" />
</dataarea>
</part>
</software>
<!-- unlicensed English translation of Dragon Ball Z - Gokuu Gekitouden -->
<software name="dbzeng" cloneof="dbzgeki" supported="partial">
<description>Dragon Ball Z English</description> <!-- title screen -->
<year>2001</year>
<publisher>Liebao Technology?</publisher>
<info name="alt_title" value="Dragon Ball Z 3" /> <!-- cartridge label? -->
<part name="cart" interface="gameboy_cart">
<feature name="enhancement" value="sgb" />
<feature name="slot" value="rom_liebao" />
<dataarea name="rom" size="0x100000">
<rom name="dragon ball z english.gb" size="0x100000" crc="71b8ea17" sha1="c43eb3906f77dda5fee94a0fce0b6d783461238c" />
</dataarea>
<dataarea name="nvram" size="0x2000">
<rom value="0xff" size="0x2000" loadflag="fill" />
</dataarea>
</part>
</software>

View file

@ -3719,6 +3719,8 @@ if (BUSES["GAMEBOY"]~=null) then
MAME_DIR .. "src/devices/bus/gameboy/huc1.h",
MAME_DIR .. "src/devices/bus/gameboy/huc3.cpp",
MAME_DIR .. "src/devices/bus/gameboy/huc3.h",
MAME_DIR .. "src/devices/bus/gameboy/liebao.cpp",
MAME_DIR .. "src/devices/bus/gameboy/liebao.h",
MAME_DIR .. "src/devices/bus/gameboy/mbc.cpp",
MAME_DIR .. "src/devices/bus/gameboy/mbc.h",
MAME_DIR .. "src/devices/bus/gameboy/mbc2.cpp",

View file

@ -13,6 +13,7 @@
#include "gbck003.h"
#include "huc1.h"
#include "huc3.h"
#include "liebao.h"
#include "mbc.h"
#include "mbc2.h"
#include "mbc3.h"
@ -55,6 +56,7 @@ char const *const GB_CHONGWU = "rom_chong";
char const *const GB_LICHENG = "rom_licheng";
char const *const GB_NEWGBCHK = "rom_newgbchk";
char const *const GB_VF001 = "rom_vf001";
char const *const GB_LIEBAO = "rom_liebao";
char const *const GB_NTNEW = "rom_ntnew";
char const *const GB_SLMULTI = "rom_slmulti";
char const *const GB_GBCK003 = "rom_gbck003";
@ -98,6 +100,7 @@ void gameboy_cartridges(device_slot_interface &device)
device.option_add_internal(slotoptions::GB_LICHENG, GB_ROM_LICHENG);
device.option_add_internal(slotoptions::GB_NEWGBCHK, GB_ROM_NEWGBCHK);
device.option_add_internal(slotoptions::GB_VF001, GB_ROM_VF001);
device.option_add_internal(slotoptions::GB_LIEBAO, GB_ROM_LIEBAO);
device.option_add_internal(slotoptions::GB_NTNEW, GB_ROM_NTNEW);
device.option_add_internal(slotoptions::GB_SLMULTI, GB_ROM_SLMULTI);
device.option_add_internal(slotoptions::GB_GBCK003, GB_ROM_GBCK003);

View file

@ -45,6 +45,7 @@ extern char const *const GB_CHONGWU;
extern char const *const GB_LICHENG;
extern char const *const GB_NEWGBCHK;
extern char const *const GB_VF001;
extern char const *const GB_LIEBAO;
extern char const *const GB_NTNEW;
extern char const *const GB_SLMULTI;
extern char const *const GB_GBCK003;

View file

@ -746,6 +746,9 @@ std::optional<char const *> probe_gbx_footer(std::string_view tag, util::random_
case gbxfile::TYPE_VF001:
result = slotoptions::GB_VF001;
break;
case gbxfile::TYPE_LIEBAO:
result = slotoptions::GB_LIEBAO;
break;
case gbxfile::TYPE_NTNEW:
result = slotoptions::GB_NTNEW;
break;

View file

@ -24,7 +24,7 @@
* Program ROM size in bytes (4 bytes).
* Cartridge RAM size in bytes (4 bytes).
There is additional data between the leader and trailer that contains
There is additional data between the leader and trailer that can hold
additional wiring or configuration details for the cartridge if necessary.
In general, it's 32 bytes long, and unused portions are filled with 0x00.
It seems to be entirely unused for most cartridge types.
@ -55,6 +55,7 @@ enum : u32
TYPE_HUC3 = 0x48554333, // 'HUC3'
TYPE_SLMULTI = 0x4c424d43, // 'LBMC'
TYPE_LICHENG = 0x4c494348, // 'LICH'
TYPE_LIEBAO = 0x4c494241, // 'LIBA'
TYPE_M161 = 0x4d313631, // 'M161'
TYPE_MBC1_COLL = 0x4d42314d, // 'MB1M'
TYPE_MBC1 = 0x4d424331, // 'MBC1'

View file

@ -0,0 +1,159 @@
// license:BSD-3-Clause
// copyright-holders:Vas Crabb
/***************************************************************************
Memory controller used by Liebao Technology
Supports switching 8 KiB pages at 0x4000 and 0x6000 independently. Only
even pages can be mapped at 0x4000, and only odd pages can be mapped at
0x6000. Everything here is guesswork based on the behaviour of a single
game.
***************************************************************************/
#include "emu.h"
#include "liebao.h"
#include "cartbase.ipp"
//#define VERBOSE 1
//#define LOG_OUTPUT_FUNC osd_printf_info
#include "logmacro.h"
namespace bus::gameboy {
namespace {
class liebao_device : public mbc_ram_device_base<mbc_8k_device_base>
{
public:
liebao_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock);
virtual image_init_result load(std::string &message) override ATTR_COLD;
protected:
virtual void device_start() override ATTR_COLD;
virtual void device_reset() override ATTR_COLD;
private:
void enable_ram(offs_t offset, u8 data);
void bank_switch_rom(offs_t offset, u8 data);
void bank_switch_ram(u8 data);
void bank_switch_rom_high(offs_t offset, u8 data);
memory_view m_view_ram;
u8 m_bank_high_set;
};
liebao_device::liebao_device(
machine_config const &mconfig,
char const *tag,
device_t *owner,
u32 clock) :
mbc_ram_device_base<mbc_8k_device_base>(mconfig, GB_ROM_LIEBAO, tag, owner, clock),
m_view_ram(*this, "ram"),
m_bank_high_set(0U)
{
}
image_init_result liebao_device::load(std::string &message)
{
// set up ROM and RAM
set_bank_bits_rom(9);
set_bank_bits_ram(4);
if (!check_rom(message) || !check_ram(message))
return image_init_result::FAIL;
cart_space()->install_view(0xa000, 0xbfff, m_view_ram);
install_rom(*cart_space(), *cart_space(), *cart_space());
install_ram(m_view_ram[0]);
// install handlers
cart_space()->install_write_handler(
0x0000, 0x1fff,
write8sm_delegate(*this, FUNC(liebao_device::enable_ram)));
cart_space()->install_write_handler(
0x2000, 0x2fff,
write8sm_delegate(*this, FUNC(liebao_device::bank_switch_rom)));
cart_space()->install_write_handler(
0x4000, 0x5fff,
write8smo_delegate(*this, FUNC(liebao_device::bank_switch_ram)));
cart_space()->install_write_handler(
0x7000, 0x7fff,
write8sm_delegate(*this, FUNC(liebao_device::bank_switch_rom_high)));
// all good
return image_init_result::PASS;
}
void liebao_device::device_start()
{
mbc_ram_device_base<mbc_8k_device_base>::device_start();
save_item(NAME(m_bank_high_set));
}
void liebao_device::device_reset()
{
mbc_ram_device_base<mbc_8k_device_base>::device_reset();
m_view_ram.disable();
m_bank_high_set = 0U;
set_bank_rom_low(2);
set_bank_rom_high(3);
set_bank_ram(0);
}
void liebao_device::enable_ram(offs_t offset, u8 data)
{
// TODO: how many bits are checked?
bool const enable = 0x0a == (data & 0x0f);
LOG(
"%s: Cartridge RAM %s\n",
machine().describe_context(),
enable ? "enabled" : "disabled");
if (enable)
m_view_ram.select(0);
else
m_view_ram.disable();
}
void liebao_device::bank_switch_rom(offs_t offset, u8 data)
{
set_bank_rom_low(u16(data) << 1);
if (m_bank_high_set || ((offset & 0x00ff) == 0x00d2))
m_bank_high_set = 0U;
else
set_bank_rom_high((u16(data) << 1) | 0x01);
}
void liebao_device::bank_switch_ram(u8 data)
{
set_bank_ram(data & 0x0f);
}
void liebao_device::bank_switch_rom_high(offs_t offset, u8 data)
{
if ((offset & 0x00ff) == 0x00d2)
{
m_bank_high_set = 1U;
set_bank_rom_high((u16(data) << 1) | 0x01);
}
}
} // anonymous namespace
} // namespace bus::gameboy
DEFINE_DEVICE_TYPE_PRIVATE(GB_ROM_LIEBAO, device_gb_cart_interface, bus::gameboy::liebao_device, "gb_rom_liebao", "Game Boy Liebao Technology Cartridge")

View file

@ -0,0 +1,18 @@
// license:BSD-3-Clause
// copyright-holders:Vas Crabb
/***************************************************************************
Memory controller used by Liebao Technology
***************************************************************************/
#ifndef MAME_BUS_GAMEBOY_LIEBAO_H
#define MAME_BUS_GAMEBOY_LIEBAO_H
#pragma once
#include "slot.h"
DECLARE_DEVICE_TYPE(GB_ROM_LIEBAO, device_gb_cart_interface)
#endif // MAME_BUS_GAMEBOY_LIEBAO_H