mirror of
https://github.com/holub/mame
synced 2025-04-24 01:11:11 +03:00
bus/mc10: Added minimum ROM size and block size checks for cartridge ROMs. (#12088)
Also cleaned up code and moved cartridge implementations to anonymous namespaces.
This commit is contained in:
parent
1c514cea4b
commit
9f5c9be99d
@ -176,7 +176,7 @@ void device_mc10cart_interface::interface_pre_start()
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
max_rom_length
|
||||
rom size constraints
|
||||
-------------------------------------------------*/
|
||||
|
||||
int device_mc10cart_interface::max_rom_length() const
|
||||
@ -200,7 +200,7 @@ std::pair<std::error_condition, std::string> device_mc10cart_interface::load()
|
||||
void mc10_cart_add_basic_devices(device_slot_interface &device)
|
||||
{
|
||||
// basic devices
|
||||
device.option_add("mcx128", MC10_PAK_MCX128);
|
||||
device.option_add("mcx128", MC10_PAK_MCX128).default_bios("mc10");
|
||||
device.option_add("pak", MC10_PAK);
|
||||
device.option_add("ram", MC10_PAK_RAM);
|
||||
device.option_add("multi", ALICE_MULTIPORTS_EXT);
|
||||
@ -213,7 +213,7 @@ void mc10_cart_add_basic_devices(device_slot_interface &device)
|
||||
void alice_cart_add_basic_devices(device_slot_interface &device)
|
||||
{
|
||||
// basic devices
|
||||
device.option_add("alice128", ALICE_PAK_MCX128);
|
||||
device.option_add("mcx128", MC10_PAK_MCX128).default_bios("alice");
|
||||
device.option_add("pak", MC10_PAK);
|
||||
device.option_add("ram", MC10_PAK_RAM);
|
||||
device.option_add("multi", ALICE_MULTIPORTS_EXT);
|
||||
|
@ -83,6 +83,7 @@ public:
|
||||
virtual ~device_mc10cart_interface();
|
||||
|
||||
virtual int max_rom_length() const;
|
||||
|
||||
virtual std::pair<std::error_condition, std::string> load();
|
||||
|
||||
protected:
|
||||
|
@ -43,15 +43,17 @@
|
||||
//#define VERBOSE (LOG_GENERAL)
|
||||
#include "logmacro.h"
|
||||
|
||||
namespace {
|
||||
|
||||
ROM_START(mc10_mcx128)
|
||||
ROM_START(mcx128)
|
||||
ROM_REGION(0x4000, "eprom", ROMREGION_ERASE00)
|
||||
ROM_LOAD("mcx128bas.rom", 0x0000, 0x4000, CRC(11202e4b) SHA1(36c30d0f198a1bffee88ef29d92f2401447a91f4))
|
||||
ROM_END
|
||||
ROM_DEFAULT_BIOS("mc10")
|
||||
|
||||
ROM_START(alice_mcx128)
|
||||
ROM_REGION(0x4000, "eprom", ROMREGION_ERASE00)
|
||||
ROM_LOAD("alice128bas.rom", 0x0000, 0x4000, CRC(a737544a) SHA1(c8fd92705fc42deb6a0ffac6274e27fd61ecd4cc))
|
||||
ROM_SYSTEM_BIOS(0, "mc10", "Darren Atkinson's MCX-128 cartridge")
|
||||
ROMX_LOAD("mcx128bas.rom", 0x0000, 0x4000, CRC(11202e4b) SHA1(36c30d0f198a1bffee88ef29d92f2401447a91f4), ROM_BIOS(0))
|
||||
|
||||
ROM_SYSTEM_BIOS(1, "alice", "Darren Atkinson's MCX-128 cartridge for Alice")
|
||||
ROMX_LOAD("alice128bas.rom", 0x0000, 0x4000, CRC(a737544a) SHA1(c8fd92705fc42deb6a0ffac6274e27fd61ecd4cc), ROM_BIOS(1))
|
||||
ROM_END
|
||||
|
||||
//**************************************************************************
|
||||
@ -69,18 +71,11 @@ public:
|
||||
mc10_pak_mcx128_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
|
||||
|
||||
protected:
|
||||
// construction/destruction
|
||||
mc10_pak_mcx128_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
|
||||
|
||||
// device_t implementation
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
virtual void device_post_load() override;
|
||||
|
||||
virtual const tiny_rom_entry *device_rom_region() const override
|
||||
{
|
||||
return ROM_NAME(mc10_mcx128);
|
||||
}
|
||||
virtual const tiny_rom_entry *device_rom_region() const override;
|
||||
|
||||
u8 control_register_read(offs_t offset);
|
||||
void control_register_write(offs_t offset, u8 data);
|
||||
@ -108,19 +103,12 @@ private:
|
||||
|
||||
};
|
||||
|
||||
DEFINE_DEVICE_TYPE_PRIVATE(MC10_PAK_MCX128, device_mc10cart_interface, mc10_pak_mcx128_device, "mc10_mcx128", "Darren Atkinson's MCX-128 cartridge")
|
||||
|
||||
//-------------------------------------------------
|
||||
// mc10_pak_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
mc10_pak_mcx128_device::mc10_pak_mcx128_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
|
||||
:mc10_pak_mcx128_device(mconfig, MC10_PAK_MCX128, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
mc10_pak_mcx128_device::mc10_pak_mcx128_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
|
||||
: device_t(mconfig, type, tag, owner, clock)
|
||||
: device_t(mconfig, MC10_PAK_MCX128, tag, owner, clock)
|
||||
, device_mc10cart_interface(mconfig, *this)
|
||||
, m_share(*this, "ext_ram", 1024*128, ENDIANNESS_BIG)
|
||||
, m_view(*this, "mcx_view")
|
||||
@ -128,6 +116,12 @@ mc10_pak_mcx128_device::mc10_pak_mcx128_device(const machine_config &mconfig, de
|
||||
{
|
||||
}
|
||||
|
||||
const tiny_rom_entry * mc10_pak_mcx128_device::device_rom_region() const
|
||||
{
|
||||
return ROM_NAME(mcx128);
|
||||
}
|
||||
|
||||
|
||||
void mc10_pak_mcx128_device::view_map0(address_map &map)
|
||||
{
|
||||
map(0x0004, 0x0007).bankrw("bank0");
|
||||
@ -290,11 +284,6 @@ void mc10_pak_mcx128_device::device_reset()
|
||||
update_banks();
|
||||
}
|
||||
|
||||
void mc10_pak_mcx128_device::device_post_load()
|
||||
{
|
||||
update_banks();
|
||||
}
|
||||
|
||||
void mc10_pak_mcx128_device::write_ram_mirror(address_space &space, offs_t offset, u8 data)
|
||||
{
|
||||
std::optional<int> cur_slot = m_view.entry();
|
||||
@ -345,27 +334,6 @@ void mc10_pak_mcx128_device::update_banks()
|
||||
LOG("view select: %d, bank cr: %d\n", (bank1 << 2) | (rom_map_cr & 0x03), ram_bank_cr & 0x03 );
|
||||
}
|
||||
|
||||
class alice_pak_mcx128_device : public mc10_pak_mcx128_device
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
alice_pak_mcx128_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
|
||||
} // anonymous namespace
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual const tiny_rom_entry *device_rom_region() const override
|
||||
{
|
||||
return ROM_NAME(alice_mcx128);
|
||||
}
|
||||
};
|
||||
|
||||
//-------------------------------------------------
|
||||
// mc10_pak_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
alice_pak_mcx128_device::alice_pak_mcx128_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
|
||||
: mc10_pak_mcx128_device(mconfig, ALICE_PAK_MCX128, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
DEFINE_DEVICE_TYPE_PRIVATE(ALICE_PAK_MCX128, device_mc10cart_interface, alice_pak_mcx128_device, "alice_mcx128", "Darren Atkinson's MCX-128 cartridge (Alice ROM)")
|
||||
DEFINE_DEVICE_TYPE_PRIVATE(MC10_PAK_MCX128, device_mc10cart_interface, mc10_pak_mcx128_device, "mcx128", "Darren Atkinson's MCX-128 cartridge")
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
// device type definition
|
||||
DECLARE_DEVICE_TYPE(MC10_PAK_MCX128, device_mc10cart_interface)
|
||||
DECLARE_DEVICE_TYPE(ALICE_PAK_MCX128, device_mc10cart_interface)
|
||||
|
||||
#endif // MAME_BUS_MC10_MC10_MCX128_H
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:S. Glaize
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
multiports_ext.cpp
|
||||
@ -37,6 +40,7 @@ public:
|
||||
mc10_multiports_ext_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
|
||||
|
||||
virtual int max_rom_length() const override;
|
||||
|
||||
virtual std::pair<std::error_condition, std::string> load() override;
|
||||
|
||||
protected:
|
||||
@ -49,11 +53,9 @@ protected:
|
||||
void control_register_write(offs_t offset, u8 data);
|
||||
|
||||
void multiports_mem(address_map &map);
|
||||
void update_bank();
|
||||
|
||||
private:
|
||||
memory_bank_creator m_bank;
|
||||
uint8_t rom_bank_index;
|
||||
memory_share_creator<u8> m_extention_ram;
|
||||
};
|
||||
|
||||
@ -70,7 +72,6 @@ mc10_multiports_ext_device::mc10_multiports_ext_device(const machine_config &mco
|
||||
: device_t(mconfig, type, tag, owner, clock)
|
||||
, device_mc10cart_interface(mconfig, *this)
|
||||
, m_bank(*this, "cart_bank")
|
||||
, rom_bank_index(0)
|
||||
, m_extention_ram(*this, "ext_ram", 1024 * 16, ENDIANNESS_BIG)
|
||||
{
|
||||
}
|
||||
@ -103,14 +104,32 @@ void mc10_multiports_ext_device::device_reset()
|
||||
void mc10_multiports_ext_device::control_register_write(offs_t offset, u8 data)
|
||||
{
|
||||
if (offset < 0x1000)
|
||||
{
|
||||
m_bank->set_entry(data & 0x07);
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<std::error_condition, std::string> mc10_multiports_ext_device::load()
|
||||
{
|
||||
memory_region *const romregion(memregion("^rom"));
|
||||
if (romregion->bytes() < (0x2000 * 8))
|
||||
return std::make_pair(image_error::INVALIDLENGTH, "Cartridge ROM must be at least 64KB");
|
||||
assert(romregion != nullptr);
|
||||
|
||||
const u32 min_rom_length = 8 * 1024;
|
||||
const u32 block_rom_length = 8 * 1024;
|
||||
const u32 len = romregion->bytes();
|
||||
|
||||
if (len < min_rom_length)
|
||||
{
|
||||
return std::make_pair(
|
||||
image_error::INVALIDLENGTH,
|
||||
util::string_format("Unsupported cartridge size (must be at least %u bytes)", min_rom_length));
|
||||
}
|
||||
else if (len % block_rom_length != 0)
|
||||
{
|
||||
return std::make_pair(
|
||||
image_error::INVALIDLENGTH,
|
||||
util::string_format("Unsupported cartridge size (must be a multiple of %u bytes)", block_rom_length));
|
||||
}
|
||||
|
||||
m_bank->configure_entries(0, 8, romregion->base(), 0x2000);
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include "mc10_cart.h"
|
||||
|
||||
// device type definition
|
||||
DECLARE_DEVICE_TYPE(ALICE_MULTIPORTS_EXT, device_mc10cart_interface)
|
||||
|
||||
#endif // MAME_BUS_MC10_MC10_MULTIPORTS_EXT_H
|
||||
|
@ -11,11 +11,33 @@
|
||||
#include "emu.h"
|
||||
#include "pak.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
//**************************************************************************
|
||||
// GLOBAL VARIABLES
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
DEFINE_DEVICE_TYPE(MC10_PAK, mc10_pak_device, "mc10pak", "MC-10 Program PAK")
|
||||
// ======================> mc10_pak_device
|
||||
|
||||
class mc10_pak_device :
|
||||
public device_t,
|
||||
public device_mc10cart_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
mc10_pak_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
|
||||
|
||||
virtual int max_rom_length() const override;
|
||||
|
||||
virtual std::pair<std::error_condition, std::string> load() override;
|
||||
|
||||
protected:
|
||||
mc10_pak_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
|
||||
|
||||
// device_t implementation
|
||||
virtual void device_start() override;
|
||||
};
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
@ -36,7 +58,7 @@ mc10_pak_device::mc10_pak_device(const machine_config &mconfig, const char *tag,
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// max_rom_length - device-specific startup
|
||||
// rom constraints
|
||||
//-------------------------------------------------
|
||||
|
||||
int mc10_pak_device::max_rom_length() const
|
||||
@ -59,11 +81,14 @@ void mc10_pak_device::device_start()
|
||||
std::pair<std::error_condition, std::string> mc10_pak_device::load()
|
||||
{
|
||||
memory_region *const romregion(memregion("^rom"));
|
||||
if (!romregion)
|
||||
return std::make_pair(image_error::BADSOFTWARE, "Software item lacks 'rom' data area");
|
||||
assert(romregion != nullptr);
|
||||
|
||||
// if the host has supplied a ROM space, install it
|
||||
owning_slot().memspace().install_rom(0x5000, 0x5000 + romregion->bytes(), romregion->base());
|
||||
|
||||
return std::make_pair(std::error_condition(), std::string());
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
DEFINE_DEVICE_TYPE_PRIVATE(MC10_PAK, device_mc10cart_interface, mc10_pak_device, "mc10pak", "MC-10 Program PAK")
|
||||
|
@ -7,31 +7,6 @@
|
||||
|
||||
#include "mc10_cart.h"
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
// ======================> mc10_pak_device
|
||||
|
||||
class mc10_pak_device :
|
||||
public device_t,
|
||||
public device_mc10cart_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
mc10_pak_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
|
||||
|
||||
virtual int max_rom_length() const override;
|
||||
virtual std::pair<std::error_condition, std::string> load() override;
|
||||
|
||||
protected:
|
||||
mc10_pak_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
|
||||
|
||||
// device_t implementation
|
||||
virtual void device_start() override;
|
||||
};
|
||||
|
||||
// device type definitions
|
||||
DECLARE_DEVICE_TYPE(MC10_PAK, mc10_pak_device)
|
||||
DECLARE_DEVICE_TYPE(MC10_PAK, device_mc10cart_interface)
|
||||
|
||||
#endif // MAME_BUS_MC10_MC10_PAK_H
|
||||
|
Loading…
Reference in New Issue
Block a user