mirror of
https://github.com/holub/mame
synced 2025-04-22 16:31:49 +03:00
bus/mononcol: Get rid of a pile of copy/pasted crud.
This commit is contained in:
parent
2905b8c24a
commit
ecb080f006
@ -5,33 +5,34 @@
|
||||
#include "rom.h"
|
||||
|
||||
//-------------------------------------------------
|
||||
// constructor
|
||||
// device type definitions
|
||||
//-------------------------------------------------
|
||||
|
||||
DEFINE_DEVICE_TYPE(MONONCOL_ROM_PLAIN, mononcol_rom_plain_device, "mononcol_rom_plain", "Monon Color ROM cartridge")
|
||||
|
||||
void mononcol_rom_device::device_start()
|
||||
{
|
||||
}
|
||||
|
||||
mononcol_rom_device::mononcol_rom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
|
||||
: device_t(mconfig, type, tag, owner, clock), device_mononcol_cart_interface(mconfig, *this)
|
||||
//-------------------------------------------------
|
||||
// constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
mononcol_rom_plain_device::mononcol_rom_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
||||
: mononcol_rom_plain_device(mconfig, MONONCOL_ROM_PLAIN, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
mononcol_rom_plain_device::mononcol_rom_plain_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
|
||||
: mononcol_rom_device(mconfig, type, tag, owner, clock)
|
||||
: device_t(mconfig, type, tag, owner, clock)
|
||||
, device_mononcol_cart_interface(mconfig, *this)
|
||||
, m_spi(*this, "spi")
|
||||
{
|
||||
}
|
||||
|
||||
mononcol_rom_plain_device::mononcol_rom_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
||||
: mononcol_rom_plain_device(mconfig, MONONCOL_ROM_PLAIN, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void mononcol_rom_plain_device::device_add_mconfig(machine_config &config)
|
||||
{
|
||||
GENERIC_SPI_FLASH(config, m_spi, 0);
|
||||
}
|
||||
|
||||
void mononcol_rom_plain_device::device_start()
|
||||
{
|
||||
}
|
||||
|
@ -9,22 +9,10 @@
|
||||
|
||||
#include "machine/generic_spi_flash.h"
|
||||
|
||||
// ======================> mononcol_rom_device
|
||||
|
||||
class mononcol_rom_device : public device_t, public device_mononcol_cart_interface
|
||||
{
|
||||
protected:
|
||||
// construction/destruction
|
||||
mononcol_rom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
// device-level overrides
|
||||
virtual void device_start() override;
|
||||
};
|
||||
|
||||
|
||||
// ======================> mononcol_rom_plain_device
|
||||
|
||||
class mononcol_rom_plain_device : public mononcol_rom_device
|
||||
class mononcol_rom_plain_device : public device_t, public device_mononcol_cart_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
@ -34,22 +22,23 @@ public:
|
||||
DECLARE_WRITE_LINE_MEMBER(dir_w) override { m_spi->dir_w(state); }
|
||||
void write(uint8_t data) override { m_spi->write(data); }
|
||||
void set_ready() override { m_spi->set_ready(); }
|
||||
void set_spi_region(uint8_t* region) override { m_spi->set_rom_ptr(region); }
|
||||
void set_spi_size(size_t size) override { m_spi->set_rom_size(size); }
|
||||
|
||||
void set_spi_region(uint8_t *region, size_t size) override { m_spi->set_rom_ptr(region); m_spi->set_rom_size(size); }
|
||||
|
||||
protected:
|
||||
mononcol_rom_plain_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
// device_t implementation
|
||||
virtual void device_add_mconfig(machine_config &config) override;
|
||||
virtual void device_start() override;
|
||||
|
||||
private:
|
||||
required_device<generic_spi_flash_device> m_spi;
|
||||
|
||||
};
|
||||
|
||||
// device type definition
|
||||
DECLARE_DEVICE_TYPE(MONONCOL_ROM_PLAIN, mononcol_rom_plain_device)
|
||||
|
||||
// device type declarations
|
||||
DECLARE_DEVICE_TYPE(MONONCOL_ROM_PLAIN, mononcol_rom_plain_device)
|
||||
|
||||
#endif // MAME_BUS_MONONCOL_ROM_H
|
||||
|
@ -20,9 +20,7 @@ DEFINE_DEVICE_TYPE(MONONCOL_CARTSLOT, mononcol_cartslot_device, "mononcol_cartsl
|
||||
//**************************************************************************
|
||||
|
||||
device_mononcol_cart_interface::device_mononcol_cart_interface(machine_config const &mconfig, device_t &device) :
|
||||
device_interface(device, "genslot"),
|
||||
m_rom(nullptr),
|
||||
m_rom_size(0)
|
||||
device_interface(device, "mononcart")
|
||||
{
|
||||
}
|
||||
|
||||
@ -30,29 +28,6 @@ device_mononcol_cart_interface::~device_mononcol_cart_interface()
|
||||
{
|
||||
}
|
||||
|
||||
void device_mononcol_cart_interface::rom_alloc(u32 size, int width, endianness_t endian)
|
||||
{
|
||||
if (m_rom)
|
||||
{
|
||||
throw emu_fatalerror(
|
||||
"%s: Request to allocate ROM when already allocated (allocated size %u, requested size %u)\n",
|
||||
device().tag(),
|
||||
m_rom_size,
|
||||
size);
|
||||
}
|
||||
|
||||
std::string fulltag = device().subtag("^cart:rom");
|
||||
|
||||
device().logerror("Allocating %u byte ROM region with tag '%s' (width %d)\n", size, fulltag, width);
|
||||
m_rom = device().machine().memory().region_alloc(fulltag, size, width, endian)->base();
|
||||
m_rom_size = size;
|
||||
|
||||
if (!(m_rom_size && !(m_rom_size & (m_rom_size - 1))))
|
||||
{
|
||||
fatalerror("m_rom_size is NOT a power of 2");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
@ -61,7 +36,7 @@ void device_mononcol_cart_interface::rom_alloc(u32 size, int width, endianness_t
|
||||
|
||||
mononcol_cartslot_device::mononcol_cartslot_device(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, u32 clock) :
|
||||
device_t(mconfig, type, tag, owner, clock),
|
||||
device_rom_image_interface(mconfig, *this),
|
||||
device_cartrom_image_interface(mconfig, *this),
|
||||
device_single_card_slot_interface<device_mononcol_cart_interface>(mconfig, *this),
|
||||
m_cart(nullptr)
|
||||
{
|
||||
@ -91,17 +66,34 @@ image_init_result mononcol_cartslot_device::call_load()
|
||||
{
|
||||
if (m_cart)
|
||||
{
|
||||
u32 len = common_get_size("rom");
|
||||
memory_region *romregion(loaded_through_softlist() ? memregion("rom") : nullptr);
|
||||
if (loaded_through_softlist() && !romregion)
|
||||
{
|
||||
seterror(image_error::INVALIDIMAGE, "Software list item has no 'rom' data area");
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
|
||||
rom_alloc(len, 1, ENDIANNESS_LITTLE);
|
||||
common_load_rom(get_rom_base(), len, "rom");
|
||||
const u32 len = loaded_through_softlist() ? get_software_region_length("rom") : length();
|
||||
if (!len || ((len - 1) & len))
|
||||
{
|
||||
seterror(image_error::INVALIDIMAGE, "Cartridge ROM size is not a power of 2");
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
|
||||
m_cart->set_spi_region(get_rom_base());
|
||||
m_cart->set_spi_size(get_rom_size());
|
||||
if (!loaded_through_softlist())
|
||||
{
|
||||
LOG("Allocating %u byte cartridge ROM region\n", len);
|
||||
romregion = machine().memory().region_alloc(subtag("rom"), len, 4, ENDIANNESS_LITTLE);
|
||||
const u32 cnt = fread(romregion->base(), len);
|
||||
if (cnt != len)
|
||||
{
|
||||
seterror(image_error::UNSPECIFIED, "Error reading cartridge file");
|
||||
return image_init_result::FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return image_init_result::PASS;
|
||||
m_cart->set_spi_region(romregion->base(), romregion->bytes());
|
||||
}
|
||||
|
||||
return image_init_result::PASS;
|
||||
}
|
||||
|
||||
@ -115,43 +107,3 @@ std::string mononcol_cartslot_device::get_default_card_software(get_default_card
|
||||
{
|
||||
return software_get_default_slot("rom");
|
||||
}
|
||||
|
||||
|
||||
/**************************************************
|
||||
|
||||
Implementation
|
||||
|
||||
**************************************************/
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
common_get_size - it gets image file size both
|
||||
for fullpath and for softlist
|
||||
-------------------------------------------------*/
|
||||
|
||||
u32 mononcol_cartslot_device::common_get_size(char const *region)
|
||||
{
|
||||
// if we are loading from softlist, you have to specify a region
|
||||
assert(!loaded_through_softlist() || (region != nullptr));
|
||||
|
||||
return !loaded_through_softlist() ? length() : get_software_region_length(region);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
common_load_rom - it loads from image file both
|
||||
for fullpath and for softlist
|
||||
-------------------------------------------------*/
|
||||
|
||||
void mononcol_cartslot_device::common_load_rom(u8 *ROM, u32 len, char const *region)
|
||||
{
|
||||
// basic sanity check
|
||||
assert((ROM != nullptr) && (len > 0));
|
||||
|
||||
// if we are loading from softlist, you have to specify a region
|
||||
assert(!loaded_through_softlist() || (region != nullptr));
|
||||
|
||||
if (!loaded_through_softlist())
|
||||
fread(ROM, len);
|
||||
else
|
||||
memcpy(ROM, get_software_region(region), len);
|
||||
}
|
||||
|
@ -21,30 +21,21 @@ public:
|
||||
virtual ~device_mononcol_cart_interface();
|
||||
|
||||
// reading and writing
|
||||
virtual void rom_alloc(u32 size, int width, endianness_t end);
|
||||
|
||||
u8 *get_rom_base() { return m_rom; }
|
||||
u32 get_rom_size() { return m_rom_size; }
|
||||
|
||||
virtual uint8_t read() = 0;
|
||||
virtual DECLARE_WRITE_LINE_MEMBER(dir_w) = 0;
|
||||
virtual void write(uint8_t data) = 0;
|
||||
virtual void set_ready() = 0;
|
||||
|
||||
virtual void set_spi_region(uint8_t* region) = 0;
|
||||
virtual void set_spi_size(size_t size) = 0;
|
||||
// configuration
|
||||
virtual void set_spi_region(uint8_t *region, size_t size) = 0;
|
||||
|
||||
protected:
|
||||
device_mononcol_cart_interface(machine_config const &mconfig, device_t &device);
|
||||
|
||||
// internal state
|
||||
u8 *m_rom;
|
||||
u32 m_rom_size;
|
||||
};
|
||||
|
||||
|
||||
class mononcol_cartslot_device : public device_t,
|
||||
public device_rom_image_interface,
|
||||
public device_cartrom_image_interface,
|
||||
public device_single_card_slot_interface<device_mononcol_cart_interface>
|
||||
{
|
||||
public:
|
||||
@ -69,26 +60,6 @@ public:
|
||||
// slot interface overrides
|
||||
virtual std::string get_default_card_software(get_default_card_software_hook &hook) const override;
|
||||
|
||||
u32 common_get_size(char const *region);
|
||||
void common_load_rom(u8 *ROM, u32 len, char const *region);
|
||||
|
||||
virtual void rom_alloc(u32 size, int width, endianness_t end) { if (m_cart) m_cart->rom_alloc(size, width, end); }
|
||||
|
||||
u8* get_rom_base()
|
||||
{
|
||||
if (!m_cart)
|
||||
return nullptr;
|
||||
|
||||
return m_cart->get_rom_base();
|
||||
}
|
||||
u32 get_rom_size()
|
||||
{
|
||||
if (!m_cart)
|
||||
return 0U;
|
||||
|
||||
return m_cart->get_rom_size();
|
||||
}
|
||||
|
||||
uint8_t read()
|
||||
{
|
||||
return m_cart->read();
|
||||
@ -109,9 +80,6 @@ public:
|
||||
m_cart->write(data);
|
||||
}
|
||||
|
||||
void set_spi_region(uint8_t* region) { m_cart->set_spi_region(region); }
|
||||
void set_spi_size(size_t size) { m_cart->set_spi_size(size); }
|
||||
|
||||
|
||||
protected:
|
||||
mononcol_cartslot_device(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, u32 clock);
|
||||
@ -120,10 +88,6 @@ protected:
|
||||
virtual void device_start() override ATTR_COLD;
|
||||
|
||||
device_mononcol_cart_interface *m_cart;
|
||||
|
||||
virtual const char *image_type_name() const noexcept override { return "cartridge"; }
|
||||
virtual const char *image_brief_type_name() const noexcept override { return "cart"; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -11,8 +11,11 @@
|
||||
#include "emu.h"
|
||||
#include "gamebooster.h"
|
||||
|
||||
#include "bus/gameboy/carts.h"
|
||||
|
||||
#include "softlist_dev.h"
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE DEFINITIONS
|
||||
//**************************************************************************
|
||||
@ -119,43 +122,10 @@ void psx_gamebooster_device::exp_w(offs_t offset, uint16_t data, uint16_t mem_ma
|
||||
}
|
||||
}
|
||||
|
||||
static void gb_cart(device_slot_interface &device)
|
||||
{
|
||||
device.option_add_internal("rom", GB_STD_ROM);
|
||||
device.option_add_internal("rom_mbc1", GB_ROM_MBC1);
|
||||
device.option_add_internal("rom_mbc1col", GB_ROM_MBC1);
|
||||
device.option_add_internal("rom_mbc2", GB_ROM_MBC2);
|
||||
device.option_add_internal("rom_mbc3", GB_ROM_MBC3);
|
||||
device.option_add_internal("rom_huc1", GB_ROM_MBC3);
|
||||
device.option_add_internal("rom_huc3", GB_ROM_MBC3);
|
||||
device.option_add_internal("rom_mbc5", GB_ROM_MBC5);
|
||||
device.option_add_internal("rom_mbc6", GB_ROM_MBC6);
|
||||
device.option_add_internal("rom_mbc7", GB_ROM_MBC7);
|
||||
device.option_add_internal("rom_tama5", GB_ROM_TAMA5);
|
||||
device.option_add_internal("rom_mmm01", GB_ROM_MMM01);
|
||||
device.option_add_internal("rom_m161", GB_ROM_M161);
|
||||
device.option_add_internal("rom_sachen1", GB_ROM_SACHEN1);
|
||||
device.option_add_internal("rom_sachen2", GB_ROM_SACHEN2);
|
||||
device.option_add_internal("rom_wisdom", GB_ROM_WISDOM);
|
||||
device.option_add_internal("rom_yong", GB_ROM_YONG);
|
||||
device.option_add_internal("rom_lasama", GB_ROM_LASAMA);
|
||||
device.option_add_internal("rom_atvrac", GB_ROM_ATVRAC);
|
||||
device.option_add_internal("rom_camera", GB_STD_ROM);
|
||||
device.option_add_internal("rom_188in1", GB_ROM_188IN1);
|
||||
device.option_add_internal("rom_sintax", GB_ROM_SINTAX);
|
||||
device.option_add_internal("rom_chong", GB_ROM_CHONGWU);
|
||||
device.option_add_internal("rom_licheng", GB_ROM_LICHENG);
|
||||
device.option_add_internal("rom_digimon", GB_ROM_DIGIMON);
|
||||
device.option_add_internal("rom_rock8", GB_ROM_ROCKMAN8);
|
||||
device.option_add_internal("rom_sm3sp", GB_ROM_SM3SP);
|
||||
// device.option_add_internal("rom_dkong5", GB_ROM_DKONG5);
|
||||
// device.option_add_internal("rom_unk01", GB_ROM_UNK01);
|
||||
}
|
||||
|
||||
void psx_gamebooster_device::device_add_mconfig(machine_config &config)
|
||||
{
|
||||
/* cartslot */
|
||||
GB_CART_SLOT(config, m_cartslot, gb_cart, nullptr);
|
||||
// cartslot
|
||||
GB_CART_SLOT(config, m_cartslot, gameboy_cartridges, nullptr);
|
||||
|
||||
SOFTWARE_LIST(config, "cart_list").set_original("gameboy");
|
||||
SOFTWARE_LIST(config, "gbc_list").set_compatible("gbcolor");
|
||||
|
@ -6,10 +6,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "parallel.h"
|
||||
#include "bus/gameboy/rom.h"
|
||||
#include "bus/gameboy/mbc.h"
|
||||
|
||||
#include "bus/gameboy/gb_slot.h"
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
|
@ -15,6 +15,9 @@
|
||||
#include "emu.h"
|
||||
#include "sgb.h"
|
||||
|
||||
#include "bus/gameboy/carts.h"
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// sns_rom_sgb_device - constructor
|
||||
//-------------------------------------------------
|
||||
@ -23,8 +26,8 @@ DEFINE_DEVICE_TYPE(SNS_LOROM_SUPERGB, sns_rom_sgb1_device, "sns_rom_sgb", "SNE
|
||||
DEFINE_DEVICE_TYPE(SNS_LOROM_SUPERGB2, sns_rom_sgb2_device, "sns_rom_sgb2", "SNES Super Game Boy 2 Cart")
|
||||
|
||||
|
||||
sns_rom_sgb_device::sns_rom_sgb_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
|
||||
: sns_rom_device(mconfig, type, tag, owner, clock),
|
||||
sns_rom_sgb_device::sns_rom_sgb_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
|
||||
sns_rom_device(mconfig, type, tag, owner, clock),
|
||||
m_sgb_cpu(*this, "sgb_cpu"),
|
||||
m_sgb_apu(*this, "sgb_apu"),
|
||||
m_sgb_ppu(*this, "sgb_ppu"),
|
||||
@ -154,13 +157,6 @@ void sns_rom_sgb_device::gb_timer_callback(uint8_t data)
|
||||
}
|
||||
|
||||
|
||||
static void supergb_cart(device_slot_interface &device)
|
||||
{
|
||||
device.option_add_internal("rom", GB_STD_ROM);
|
||||
device.option_add_internal("rom_mbc1", GB_ROM_MBC1);
|
||||
}
|
||||
|
||||
|
||||
void sns_rom_sgb1_device::device_add_mconfig(machine_config &config)
|
||||
{
|
||||
LR35902(config, m_sgb_cpu, 4295454); /* 4.295454 MHz */
|
||||
@ -172,7 +168,7 @@ void sns_rom_sgb1_device::device_add_mconfig(machine_config &config)
|
||||
|
||||
DMG_APU(config, m_sgb_apu, 4295454);
|
||||
|
||||
GB_CART_SLOT(config, m_cartslot, supergb_cart, nullptr);
|
||||
GB_CART_SLOT(config, m_cartslot, gameboy_cartridges, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@ -199,7 +195,7 @@ void sns_rom_sgb2_device::device_add_mconfig(machine_config &config)
|
||||
|
||||
DMG_APU(config, m_sgb_apu, XTAL(4'194'304));
|
||||
|
||||
GB_CART_SLOT(config, m_cartslot, supergb_cart, nullptr);
|
||||
GB_CART_SLOT(config, m_cartslot, gameboy_cartridges, nullptr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,8 +10,6 @@
|
||||
|
||||
#include "cpu/lr35902/lr35902.h"
|
||||
#include "bus/gameboy/gb_slot.h"
|
||||
#include "bus/gameboy/rom.h"
|
||||
#include "bus/gameboy/mbc.h"
|
||||
#include "video/gb_lcd.h"
|
||||
#include "sound/gb.h"
|
||||
|
||||
|
@ -23764,7 +23764,7 @@ tankbatl // (c) 1992 Microprose Games Inc.
|
||||
@source:beehive/microb.cpp
|
||||
dm3270 //
|
||||
|
||||
@source:misc/micom_mahjong.cpp
|
||||
@source:tvgames/micom_mahjong.cpp
|
||||
mmahjong
|
||||
|
||||
@source:misc/microdar.cpp
|
||||
|
@ -479,7 +479,6 @@ miltonbradley/vectrex.cpp
|
||||
mips/mips.cpp
|
||||
misc/3do.cpp
|
||||
misc/eva.cpp
|
||||
misc/micom_mahjong.cpp
|
||||
misc/monon_color.cpp
|
||||
mit/tx0.cpp
|
||||
mits/altair.cpp
|
||||
@ -1112,6 +1111,7 @@ tvgames/generalplus_gpl16250_spi_direct.cpp
|
||||
tvgames/generalplus_gpl162xx_lcdtype.cpp
|
||||
tvgames/generalplus_gpl32612.cpp
|
||||
tvgames/magiceyes_pollux_vr3520f.cpp
|
||||
tvgames/micom_mahjong.cpp
|
||||
tvgames/monkey_king_3b.cpp
|
||||
tvgames/pubint_storyreader.cpp
|
||||
tvgames/spg110.cpp
|
||||
|
Loading…
Reference in New Issue
Block a user