Reduce overhead to load data (roms) in netlist significantly.

The previous solution involved a significant amount of redundant
replication of information and objects.
Now, a rom name specified as 

SOMEROM(x21, "romlabel")

will automatically be loaded from region "netlisttag:romlabel". Examples
are hazl1500 and stuntcyc. [Couriersud]
This commit is contained in:
couriersud 2017-01-27 21:24:37 +01:00
parent bd20222866
commit 563b60a8ab
4 changed files with 31 additions and 106 deletions

View File

@ -29,7 +29,6 @@ const device_type NETLIST_SOUND = &device_creator<netlist_mame_sound_device_t>;
const device_type NETLIST_ANALOG_INPUT = &device_creator<netlist_mame_analog_input_t>;
const device_type NETLIST_INT_INPUT = &device_creator<netlist_mame_int_input_t>;
const device_type NETLIST_ROM_REGION = &device_creator<netlist_mame_rom_t>;
const device_type NETLIST_RAM_POINTER = &device_creator<netlist_ram_pointer_t>;
const device_type NETLIST_LOGIC_INPUT = &device_creator<netlist_mame_logic_input_t>;
const device_type NETLIST_STREAM_INPUT = &device_creator<netlist_mame_stream_input_t>;
@ -219,41 +218,6 @@ void netlist_mame_logic_input_t::device_start()
}
}
// ----------------------------------------------------------------------------------------
// netlist_mame_rom_t
// ----------------------------------------------------------------------------------------
netlist_mame_rom_t::netlist_mame_rom_t(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, NETLIST_ROM_REGION, "Netlist ROM Region", tag, owner, clock, "netlist_rom_region", __FILE__)
, netlist_mame_sub_interface(*owner)
, m_name("")
, m_region_tag(nullptr)
, m_offset(0)
, m_size(0)
{
}
void netlist_mame_rom_t::static_set_params(device_t &device, const char *name, const char* region_tag, std::size_t offset, std::size_t size)
{
netlist_mame_rom_t &r = downcast<netlist_mame_rom_t&>(device);
LOG_DEV_CALLS(("static_set_params %s\n", device.tag()));
r.m_name = pstring(name, pstring::UTF8);
r.m_region_tag = region_tag;
r.m_offset = offset;
r.m_size = size;
}
void netlist_mame_rom_t::custom_netlist_additions(netlist::setup_t &setup)
{
if (memregion(m_region_tag) == nullptr)
fatalerror("device %s region %s not found\n", basetag(), m_region_tag);
setup.register_source(plib::make_unique_base<netlist::source_t, netlist_data_memregion_t>(setup,
m_name, memregion(m_region_tag)->base() + m_offset, m_size));
}
void netlist_mame_rom_t::device_start()
{
}
// ----------------------------------------------------------------------------------------
// netlist_ram_pointer_t
@ -452,6 +416,9 @@ void netlist_mame_device_t::device_start()
}
}
/* add default data provider for roms */
setup().register_source(plib::make_unique_base<netlist::source_t, netlist_data_memregions_t>(setup()));
m_setup_func(setup());
/* let sub-devices tweak the netlist */
@ -787,11 +754,24 @@ std::unique_ptr<plib::pistream> netlist_source_memregion_t::stream(const pstring
return plib::make_unique_base<plib::pistream, plib::pimemstream>(mem->base(), mem->bytes());
}
std::unique_ptr<plib::pistream> netlist_data_memregion_t::stream(const pstring &name)
netlist_data_memregions_t::netlist_data_memregions_t(netlist::setup_t &setup)
: netlist::source_t(setup, netlist::source_t::DATA)
{
if (name == m_name)
return plib::make_unique_base<plib::pistream, plib::pimemstream>(m_ptr, m_size);
else
return std::unique_ptr<plib::pistream>(nullptr);
}
std::unique_ptr<plib::pistream> netlist_data_memregions_t::stream(const pstring &name)
{
memory_region *mem = downcast<netlist_mame_t &>(setup().netlist()).parent().memregion(name.c_str());
//memory_region *mem = downcast<netlist_mame_t &>(setup().netlist()).machine().root_device().memregion(name.c_str());
if (mem != nullptr)
{
return plib::make_unique_base<plib::pistream, plib::pimemstream>(mem->base(), mem->bytes());
}
else
{
// This should be the last data provider being called - last resort
fatalerror("data named %s not found in device rom regions\n", name.c_str());
return std::unique_ptr<plib::pistream>(nullptr);
}
}

View File

@ -49,10 +49,6 @@
MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_INT_INPUT, 0) \
netlist_mame_int_input_t::static_set_params(*device, _name, _mask, _shift);
#define MCFG_NETLIST_ROM_REGION(_basetag, _tag, _region, _name, _offset, _size) \
MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_ROM_REGION, 0) \
netlist_mame_rom_t::static_set_params(*device, _name, ":" _region, _offset, _size);
#define MCFG_NETLIST_RAM_POINTER(_basetag, _tag, _name) \
MCFG_DEVICE_ADD(_basetag ":" _tag, NETLIST_RAM_POINTER, 0) \
netlist_ram_pointer_t::static_set_params(*device, _name ".m_RAM");
@ -102,23 +98,12 @@ private:
pstring m_name;
};
class netlist_data_memregion_t : public netlist::source_t
class netlist_data_memregions_t : public netlist::source_t
{
public:
netlist_data_memregion_t(netlist::setup_t &setup,
pstring name, uint8_t *ptr, std::size_t size)
: netlist::source_t(setup, netlist::source_t::DATA)
, m_name(name)
, m_ptr(ptr)
, m_size(size)
{
}
netlist_data_memregions_t(netlist::setup_t &setup);
virtual std::unique_ptr<plib::pistream> stream(const pstring &name) override;
private:
pstring m_name;
uint8_t *m_ptr;
std::size_t m_size;
};
class netlist_mame_device_t;
@ -563,33 +548,6 @@ private:
pstring m_param_name;
};
// ----------------------------------------------------------------------------------------
// netlist_mame_rom_t
// ----------------------------------------------------------------------------------------
class netlist_mame_rom_t : public device_t,
public netlist_mame_sub_interface
{
public:
// construction/destruction
netlist_mame_rom_t(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual ~netlist_mame_rom_t() { }
static void static_set_params(device_t &device, const char *name, const char* region_tag, std::size_t offset, std::size_t size);
protected:
// device-level overrides
virtual void device_start() override;
virtual void custom_netlist_additions(netlist::setup_t &setup) override;
private:
pstring m_name;
const char* m_region_tag;
std::size_t m_offset;
std::size_t m_size;
};
// ----------------------------------------------------------------------------------------
// netlist_ram_pointer_t
// ----------------------------------------------------------------------------------------
@ -929,7 +887,6 @@ extern const device_type NETLIST_SOUND;
extern const device_type NETLIST_ANALOG_INPUT;
extern const device_type NETLIST_LOGIC_INPUT;
extern const device_type NETLIST_INT_INPUT;
extern const device_type NETLIST_ROM_REGION;
extern const device_type NETLIST_RAM_POINTER;
extern const device_type NETLIST_LOGIC_OUTPUT;

View File

@ -136,8 +136,6 @@ public:
, m_maincpu(*this, "maincpu")
//, m_video(*this, "fixfreq")
, m_probe_screen(*this, "screen")
, m_hf1(*this, "maincpu:hf1")
, m_d7(*this, "maincpu:d7")
, m_probe_bit0(0.0)
, m_probe_bit1(0.0)
, m_probe_bit2(0.0)
@ -174,8 +172,6 @@ private:
required_device<netlist_mame_device_t> m_maincpu;
//required_device<fixedfreq_device> m_video;
required_device<screen_device> m_probe_screen;
required_device<netlist_mame_rom_t> m_hf1;
required_device<netlist_mame_rom_t> m_d7;
int m_probe_bit0;
int m_probe_bit1;
@ -331,9 +327,6 @@ static MACHINE_CONFIG_START( stuntcyc, stuntcyc_state )
MCFG_DEVICE_ADD("maincpu", NETLIST_CPU, STUNTCYC_NL_CLOCK)
MCFG_NETLIST_SETUP(stuntcyc)
MCFG_NETLIST_ROM_REGION("maincpu", "hf1", "hf1", "004275.f1", 0x0000, 0x0200)
MCFG_NETLIST_ROM_REGION("maincpu", "d7", "d7", "004811.d7", 0x0000, 0x0020)
//MCFG_NETLIST_ANALOG_OUTPUT("maincpu", "vid0", "VIDEO_OUT", fixedfreq_device, update_vid, "fixfreq")
MCFG_NETLIST_LOGIC_OUTPUT("maincpu", "probe_bit0", "probe_bit0", stuntcyc_state, probe_bit0_cb, "")
MCFG_NETLIST_LOGIC_OUTPUT("maincpu", "probe_bit1", "probe_bit1", stuntcyc_state, probe_bit1_cb, "")
@ -495,10 +488,10 @@ ROM_END
ROM_START( stuntcyc )
ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASE00 )
ROM_REGION( 0x0200, "hf1", ROMREGION_ERASE00 )
ROM_REGION( 0x0200, "maincpu:004275.f1", ROMREGION_ERASE00 )
ROM_LOAD( "004275.f1", 0x0000, 0x0200, CRC(4ed5a99d) SHA1(1e5f439bce72e78dfff76fd8f61187c6ef484a64) ) // Motorcycle & Bus
ROM_REGION( 0x0020, "d7", ROMREGION_ERASE00 )
ROM_REGION( 0x0020, "maincpu:004811.d7", ROMREGION_ERASE00 )
ROM_LOAD( "004811.d7", 0x0000, 0x0020, CRC(31a09efb) SHA1(fd5d538c9ec1234acf7c74ca0704113d220abbf6) ) // Score Translator
ROM_END

View File

@ -44,10 +44,12 @@ References:
#define MISCKEYS_TAG "misc_keys"
#define SCREEN_TAG "screen"
#define BAUD_PROM_TAG "u39"
#define NL_PROM_TAG "videobrd:u71"
#define NL_EPROM_TAG "videobrd:u78"
#define VIDEO_PROM_TAG "u71"
#define CHAR_EPROM_TAG "u78"
//#define NL_PROM_TAG "videobrd:u71"
//#define NL_EPROM_TAG "videobrd:u78"
// VIDEO_PROM at u71
#define VIDEO_PROM_TAG NETLIST_TAG ":u90_702128_82s129.bin"
// CHAR_EPROM at u78
#define CHAR_EPROM_TAG NETLIST_TAG ":u83_chr.bin"
#define VIDEO_OUT_TAG "videobrd:video_out"
#define VBLANK_OUT_TAG "videobrd:vblank"
#define TVINTERQ_OUT_TAG "videobrd:tvinterq"
@ -79,8 +81,6 @@ public:
: driver_device(mconfig, type, tag)
, m_maincpu(*this, CPU_TAG)
, m_video_board(*this, NETLIST_TAG)
, m_u71(*this, NL_PROM_TAG)
, m_u78(*this, NL_EPROM_TAG)
, m_u9(*this, "videobrd:u9")
, m_u10(*this, "videobrd:u10")
, m_u11(*this, "videobrd:u11")
@ -164,8 +164,6 @@ public:
private:
required_device<cpu_device> m_maincpu;
required_device<netlist_mame_device_t> m_video_board;
required_device<netlist_mame_rom_t> m_u71;
required_device<netlist_mame_rom_t> m_u78;
required_device<netlist_ram_pointer_t> m_u9;
required_device<netlist_ram_pointer_t> m_u10;
required_device<netlist_ram_pointer_t> m_u11;
@ -712,9 +710,6 @@ static MACHINE_CONFIG_START( hazl1500, hazl1500_state )
MCFG_DEVICE_ADD(NETLIST_TAG, NETLIST_CPU, VIDEOBRD_CLOCK)
MCFG_NETLIST_SETUP(hazelvid)
MCFG_NETLIST_ROM_REGION(NETLIST_TAG, VIDEO_PROM_TAG, VIDEO_PROM_TAG, "u90_702128_82s129.bin", 0x0000, 0x0100)
MCFG_NETLIST_ROM_REGION(NETLIST_TAG, CHAR_EPROM_TAG, CHAR_EPROM_TAG, "u83_chr.bin", 0x0000, 0x0800)
// First 1K
MCFG_NETLIST_RAM_POINTER(NETLIST_TAG, "u22", "u22")
MCFG_NETLIST_RAM_POINTER(NETLIST_TAG, "u23", "u23")