mirror of
https://github.com/holub/mame
synced 2025-06-10 06:47:18 +03:00
There's no day like today. This just follows up on the last commit: game drivers are less special special - they have configuration instantiated in the usual way.
This commit is contained in:
parent
a6ee791664
commit
89524dd10e
@ -645,6 +645,20 @@ machine_config_constructor device_t::device_mconfig_additions() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// device_add_mconfig - add device-specific
|
||||||
|
// machine configuration
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
void device_t::device_add_mconfig(machine_config &config)
|
||||||
|
{
|
||||||
|
// backwards-compatibility for devices using free functions
|
||||||
|
machine_config_constructor const additions(device_mconfig_additions());
|
||||||
|
if (additions)
|
||||||
|
additions(config, this, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// input_ports - return a pointer to the implicit
|
// input_ports - return a pointer to the implicit
|
||||||
// input ports description for this device
|
// input ports description for this device
|
||||||
|
@ -413,7 +413,6 @@ public:
|
|||||||
const input_device_default *input_ports_defaults() const { return m_input_defaults; }
|
const input_device_default *input_ports_defaults() const { return m_input_defaults; }
|
||||||
const std::vector<rom_entry> &rom_region_vector() const;
|
const std::vector<rom_entry> &rom_region_vector() const;
|
||||||
const rom_entry *rom_region() const { return rom_region_vector().data(); }
|
const rom_entry *rom_region() const { return rom_region_vector().data(); }
|
||||||
machine_config_constructor machine_config_additions() const { return device_mconfig_additions(); }
|
|
||||||
ioport_constructor input_ports() const { return device_input_ports(); }
|
ioport_constructor input_ports() const { return device_input_ports(); }
|
||||||
u8 default_bios() const { return m_default_bios; }
|
u8 default_bios() const { return m_default_bios; }
|
||||||
u8 system_bios() const { return m_system_bios; }
|
u8 system_bios() const { return m_system_bios; }
|
||||||
@ -454,6 +453,7 @@ public:
|
|||||||
std::string parameter(const char *tag) const;
|
std::string parameter(const char *tag) const;
|
||||||
|
|
||||||
// configuration helpers
|
// configuration helpers
|
||||||
|
void add_machine_configuration(machine_config &config) { device_add_mconfig(config); }
|
||||||
static void static_set_clock(device_t &device, u32 clock);
|
static void static_set_clock(device_t &device, u32 clock);
|
||||||
static void static_set_input_default(device_t &device, const input_device_default *config) { device.m_input_defaults = config; }
|
static void static_set_input_default(device_t &device, const input_device_default *config) { device.m_input_defaults = config; }
|
||||||
static void static_set_default_bios_tag(device_t &device, const char *tag) { std::string default_bios_tag(tag); device.m_default_bios_tag = default_bios_tag; }
|
static void static_set_default_bios_tag(device_t &device, const char *tag) { std::string default_bios_tag(tag); device.m_default_bios_tag = default_bios_tag; }
|
||||||
@ -515,6 +515,7 @@ protected:
|
|||||||
// device-level overrides
|
// device-level overrides
|
||||||
virtual const tiny_rom_entry *device_rom_region() const;
|
virtual const tiny_rom_entry *device_rom_region() const;
|
||||||
virtual machine_config_constructor device_mconfig_additions() const;
|
virtual machine_config_constructor device_mconfig_additions() const;
|
||||||
|
virtual void device_add_mconfig(machine_config &config);
|
||||||
virtual ioport_constructor device_input_ports() const;
|
virtual ioport_constructor device_input_ports() const;
|
||||||
virtual void device_config_complete();
|
virtual void device_config_complete();
|
||||||
virtual void device_validity_check(validity_checker &valid) const ATTR_COLD;
|
virtual void device_validity_check(validity_checker &valid) const ATTR_COLD;
|
||||||
|
@ -95,7 +95,6 @@ public:
|
|||||||
const char * parent; // if this is a clone, the name of the parent
|
const char * parent; // if this is a clone, the name of the parent
|
||||||
const char * year; // year the game was released
|
const char * year; // year the game was released
|
||||||
const char * manufacturer; // manufacturer of the game
|
const char * manufacturer; // manufacturer of the game
|
||||||
machine_config_constructor machine_config; // machine driver tokens
|
|
||||||
ioport_constructor ipt; // pointer to constructor for input ports
|
ioport_constructor ipt; // pointer to constructor for input ports
|
||||||
driver_init_helper const & driver_init; // DRIVER_INIT callback
|
driver_init_helper const & driver_init; // DRIVER_INIT callback
|
||||||
const tiny_rom_entry * rom; // pointer to list of ROMs for the game
|
const tiny_rom_entry * rom; // pointer to list of ROMs for the game
|
||||||
@ -118,27 +117,33 @@ public:
|
|||||||
|
|
||||||
// wrappers for declaring and defining game drivers
|
// wrappers for declaring and defining game drivers
|
||||||
#define GAME_NAME(name) driver_##name
|
#define GAME_NAME(name) driver_##name
|
||||||
#define GAME_TRAITS_NAME(name) driver_##name##traits
|
#define GAME_TRAITS_NAME(name) driver_##name##_device
|
||||||
#define GAME_EXTERN(name) extern game_driver const GAME_NAME(name)
|
#define GAME_EXTERN(name) extern game_driver const GAME_NAME(name)
|
||||||
|
|
||||||
// static game traits
|
// static game traits
|
||||||
#define GAME_DRIVER_TRAITS(NAME, FULLNAME) \
|
#define GAME_DRIVER_TRAITS(NAME, FULLNAME, MACHINE, CLASS) \
|
||||||
namespace { \
|
namespace { \
|
||||||
struct GAME_TRAITS_NAME(NAME) { static constexpr char const shortname[] = #NAME, fullname[] = FULLNAME, source[] = __FILE__; }; \
|
class GAME_TRAITS_NAME(NAME) : public CLASS \
|
||||||
|
{ \
|
||||||
|
public: \
|
||||||
|
static constexpr char const shortname[] = #NAME, fullname[] = FULLNAME, source[] = __FILE__; \
|
||||||
|
GAME_TRAITS_NAME(NAME)(const machine_config &mconfig, device_type type, const char *tag) : CLASS(mconfig, type, tag) { } \
|
||||||
|
protected: \
|
||||||
|
virtual void device_add_mconfig(machine_config &config) override { MACHINE_CONFIG_NAME(MACHINE)(config, this, nullptr); } \
|
||||||
|
}; \
|
||||||
constexpr char const GAME_TRAITS_NAME(NAME)::shortname[], GAME_TRAITS_NAME(NAME)::fullname[], GAME_TRAITS_NAME(NAME)::source[]; \
|
constexpr char const GAME_TRAITS_NAME(NAME)::shortname[], GAME_TRAITS_NAME(NAME)::fullname[], GAME_TRAITS_NAME(NAME)::source[]; \
|
||||||
}
|
}
|
||||||
#define GAME_DRIVER_TYPE(NAME, CLASS) driver_device_creator<CLASS, (GAME_TRAITS_NAME(NAME)::shortname), (GAME_TRAITS_NAME(NAME)::fullname), (GAME_TRAITS_NAME(NAME)::source)>
|
#define GAME_DRIVER_TYPE(NAME) driver_device_creator<GAME_TRAITS_NAME(NAME), (GAME_TRAITS_NAME(NAME)::shortname), (GAME_TRAITS_NAME(NAME)::fullname), (GAME_TRAITS_NAME(NAME)::source)>
|
||||||
|
|
||||||
// standard GAME() macro
|
// standard GAME() macro
|
||||||
#define GAME(YEAR,NAME,PARENT,MACHINE,INPUT,CLASS,INIT,MONITOR,COMPANY,FULLNAME,FLAGS) \
|
#define GAME(YEAR,NAME,PARENT,MACHINE,INPUT,CLASS,INIT,MONITOR,COMPANY,FULLNAME,FLAGS) \
|
||||||
GAME_DRIVER_TRAITS(NAME,FULLNAME) \
|
GAME_DRIVER_TRAITS(NAME, FULLNAME, MACHINE, CLASS) \
|
||||||
extern game_driver const GAME_NAME(NAME) \
|
extern game_driver const GAME_NAME(NAME) \
|
||||||
{ \
|
{ \
|
||||||
GAME_DRIVER_TYPE(NAME, CLASS), \
|
GAME_DRIVER_TYPE(NAME), \
|
||||||
#PARENT, \
|
#PARENT, \
|
||||||
#YEAR, \
|
#YEAR, \
|
||||||
COMPANY, \
|
COMPANY, \
|
||||||
MACHINE_CONFIG_NAME(MACHINE), \
|
|
||||||
INPUT_PORTS_NAME(INPUT), \
|
INPUT_PORTS_NAME(INPUT), \
|
||||||
game_driver::make_driver_init(&CLASS::init_##INIT), \
|
game_driver::make_driver_init(&CLASS::init_##INIT), \
|
||||||
ROM_NAME(NAME), \
|
ROM_NAME(NAME), \
|
||||||
@ -150,14 +155,13 @@ extern game_driver const GAME_NAME(NAME) \
|
|||||||
|
|
||||||
// standard macro with additional layout
|
// standard macro with additional layout
|
||||||
#define GAMEL(YEAR,NAME,PARENT,MACHINE,INPUT,CLASS,INIT,MONITOR,COMPANY,FULLNAME,FLAGS,LAYOUT) \
|
#define GAMEL(YEAR,NAME,PARENT,MACHINE,INPUT,CLASS,INIT,MONITOR,COMPANY,FULLNAME,FLAGS,LAYOUT) \
|
||||||
GAME_DRIVER_TRAITS(NAME,FULLNAME) \
|
GAME_DRIVER_TRAITS(NAME, FULLNAME, MACHINE, CLASS) \
|
||||||
extern game_driver const GAME_NAME(NAME) \
|
extern game_driver const GAME_NAME(NAME) \
|
||||||
{ \
|
{ \
|
||||||
GAME_DRIVER_TYPE(NAME, CLASS), \
|
GAME_DRIVER_TYPE(NAME), \
|
||||||
#PARENT, \
|
#PARENT, \
|
||||||
#YEAR, \
|
#YEAR, \
|
||||||
COMPANY, \
|
COMPANY, \
|
||||||
MACHINE_CONFIG_NAME(MACHINE), \
|
|
||||||
INPUT_PORTS_NAME(INPUT), \
|
INPUT_PORTS_NAME(INPUT), \
|
||||||
game_driver::make_driver_init(&CLASS::init_##INIT), \
|
game_driver::make_driver_init(&CLASS::init_##INIT), \
|
||||||
ROM_NAME(NAME), \
|
ROM_NAME(NAME), \
|
||||||
@ -170,14 +174,13 @@ extern game_driver const GAME_NAME(NAME) \
|
|||||||
|
|
||||||
// standard console definition macro
|
// standard console definition macro
|
||||||
#define CONS(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,CLASS,INIT,COMPANY,FULLNAME,FLAGS) \
|
#define CONS(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,CLASS,INIT,COMPANY,FULLNAME,FLAGS) \
|
||||||
GAME_DRIVER_TRAITS(NAME,FULLNAME) \
|
GAME_DRIVER_TRAITS(NAME, FULLNAME, MACHINE, CLASS) \
|
||||||
extern game_driver const GAME_NAME(NAME) \
|
extern game_driver const GAME_NAME(NAME) \
|
||||||
{ \
|
{ \
|
||||||
GAME_DRIVER_TYPE(NAME, CLASS), \
|
GAME_DRIVER_TYPE(NAME), \
|
||||||
#PARENT, \
|
#PARENT, \
|
||||||
#YEAR, \
|
#YEAR, \
|
||||||
COMPANY, \
|
COMPANY, \
|
||||||
MACHINE_CONFIG_NAME(MACHINE), \
|
|
||||||
INPUT_PORTS_NAME(INPUT), \
|
INPUT_PORTS_NAME(INPUT), \
|
||||||
game_driver::make_driver_init(&CLASS::init_##INIT), \
|
game_driver::make_driver_init(&CLASS::init_##INIT), \
|
||||||
ROM_NAME(NAME), \
|
ROM_NAME(NAME), \
|
||||||
@ -189,14 +192,13 @@ extern game_driver const GAME_NAME(NAME) \
|
|||||||
|
|
||||||
// standard computer definition macro
|
// standard computer definition macro
|
||||||
#define COMP(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,CLASS,INIT,COMPANY,FULLNAME,FLAGS) \
|
#define COMP(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,CLASS,INIT,COMPANY,FULLNAME,FLAGS) \
|
||||||
GAME_DRIVER_TRAITS(NAME,FULLNAME) \
|
GAME_DRIVER_TRAITS(NAME, FULLNAME, MACHINE, CLASS) \
|
||||||
extern game_driver const GAME_NAME(NAME) \
|
extern game_driver const GAME_NAME(NAME) \
|
||||||
{ \
|
{ \
|
||||||
GAME_DRIVER_TYPE(NAME, CLASS), \
|
GAME_DRIVER_TYPE(NAME), \
|
||||||
#PARENT, \
|
#PARENT, \
|
||||||
#YEAR, \
|
#YEAR, \
|
||||||
COMPANY, \
|
COMPANY, \
|
||||||
MACHINE_CONFIG_NAME(MACHINE), \
|
|
||||||
INPUT_PORTS_NAME(INPUT), \
|
INPUT_PORTS_NAME(INPUT), \
|
||||||
game_driver::make_driver_init(&CLASS::init_##INIT), \
|
game_driver::make_driver_init(&CLASS::init_##INIT), \
|
||||||
ROM_NAME(NAME), \
|
ROM_NAME(NAME), \
|
||||||
@ -208,14 +210,13 @@ extern game_driver const GAME_NAME(NAME) \
|
|||||||
|
|
||||||
// standard system definition macro
|
// standard system definition macro
|
||||||
#define SYST(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,CLASS,INIT,COMPANY,FULLNAME,FLAGS) \
|
#define SYST(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,CLASS,INIT,COMPANY,FULLNAME,FLAGS) \
|
||||||
GAME_DRIVER_TRAITS(NAME,FULLNAME) \
|
GAME_DRIVER_TRAITS(NAME, FULLNAME, MACHINE, CLASS) \
|
||||||
extern game_driver const GAME_NAME(NAME) \
|
extern game_driver const GAME_NAME(NAME) \
|
||||||
{ \
|
{ \
|
||||||
GAME_DRIVER_TYPE(NAME, CLASS), \
|
GAME_DRIVER_TYPE(NAME), \
|
||||||
#PARENT, \
|
#PARENT, \
|
||||||
#YEAR, \
|
#YEAR, \
|
||||||
COMPANY, \
|
COMPANY, \
|
||||||
MACHINE_CONFIG_NAME(MACHINE), \
|
|
||||||
INPUT_PORTS_NAME(INPUT), \
|
INPUT_PORTS_NAME(INPUT), \
|
||||||
game_driver::make_driver_init(&CLASS::init_##INIT), \
|
game_driver::make_driver_init(&CLASS::init_##INIT), \
|
||||||
ROM_NAME(NAME), \
|
ROM_NAME(NAME), \
|
||||||
|
@ -29,8 +29,8 @@ machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
|
|||||||
m_gamedrv(gamedrv),
|
m_gamedrv(gamedrv),
|
||||||
m_options(options)
|
m_options(options)
|
||||||
{
|
{
|
||||||
// add the root device and construct the config
|
// add the root device
|
||||||
(*gamedrv.machine_config)(*this, device_add(nullptr, "root", gamedrv.type, 0), nullptr);
|
device_add(nullptr, "root", gamedrv.type, 0);
|
||||||
|
|
||||||
// intialize slot devices - make sure that any required devices have been allocated
|
// intialize slot devices - make sure that any required devices have been allocated
|
||||||
for (device_slot_interface &slot : slot_interface_iterator(root_device()))
|
for (device_slot_interface &slot : slot_interface_iterator(root_device()))
|
||||||
@ -139,26 +139,25 @@ device_t *machine_config::device_add(device_t *owner, const char *tag, device_ty
|
|||||||
std::string part(tag, next-tag);
|
std::string part(tag, next-tag);
|
||||||
owner = owner->subdevices().find(part);
|
owner = owner->subdevices().find(part);
|
||||||
if (owner == nullptr)
|
if (owner == nullptr)
|
||||||
throw emu_fatalerror("Could not find %s when looking up path for device %s\n",
|
throw emu_fatalerror("Could not find %s when looking up path for device %s\n", part.c_str(), orig_tag);
|
||||||
part.c_str(), orig_tag);
|
|
||||||
tag = next+1;
|
tag = next+1;
|
||||||
}
|
}
|
||||||
assert(tag[0] != '\0');
|
assert(tag[0] != '\0');
|
||||||
|
|
||||||
if (owner != nullptr)
|
if (owner != nullptr)
|
||||||
{
|
{
|
||||||
// allocate the new device
|
// allocate the new device and append it to the owner's list
|
||||||
std::unique_ptr<device_t> device = type(*this, tag, owner, clock);
|
device_t *const device = &owner->subdevices().m_list.append(*type(*this, tag, owner, clock).release());
|
||||||
|
device->add_machine_configuration(*this);
|
||||||
// append it to the owner's list
|
return device;
|
||||||
return &config_new_device(owner->subdevices().m_list.append(*device.release()));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// allocate the root device directly
|
// allocate the root device directly
|
||||||
assert(!m_root_device);
|
assert(!m_root_device);
|
||||||
m_root_device = type(*this, tag, nullptr, clock);
|
m_root_device = type(*this, tag, nullptr, clock);
|
||||||
return &config_new_device(*m_root_device);
|
m_root_device->add_machine_configuration(*this);
|
||||||
|
return m_root_device.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,11 +186,10 @@ device_t *machine_config::device_replace(device_t *owner, const char *tag, devic
|
|||||||
// remove references to the old device
|
// remove references to the old device
|
||||||
remove_references(*old_device);
|
remove_references(*old_device);
|
||||||
|
|
||||||
// allocate the new device
|
// allocate the new device and substitute it for the old one in the owner's list
|
||||||
std::unique_ptr<device_t> new_device = type(*this, tag, owner, clock);
|
device_t *const new_device = &owner->subdevices().m_list.replace_and_remove(*type(*this, tag, owner, clock).release(), *old_device);
|
||||||
|
new_device->add_machine_configuration(*this);
|
||||||
// substitute it for the old one in the owner's list
|
return new_device;
|
||||||
return &config_new_device(owner->subdevices().m_list.replace_and_remove(*new_device.release(), *old_device));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,20 +252,3 @@ void machine_config::remove_references(ATTR_UNUSED device_t &device)
|
|||||||
for (device_t &scan : device_iterator(root_device()))
|
for (device_t &scan : device_iterator(root_device()))
|
||||||
scan.subdevices().m_tagmap.clear(); //remove(&device);
|
scan.subdevices().m_tagmap.clear(); //remove(&device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
|
||||||
// config_new_device - helper for recursive
|
|
||||||
// configuration of newly added devices
|
|
||||||
//-------------------------------------------------
|
|
||||||
|
|
||||||
device_t &machine_config::config_new_device(device_t &device)
|
|
||||||
{
|
|
||||||
// apply any machine configuration owned by the device now
|
|
||||||
machine_config_constructor additions = device.machine_config_additions();
|
|
||||||
if (additions != nullptr)
|
|
||||||
(*additions)(*this, &device, nullptr);
|
|
||||||
|
|
||||||
// return the new device
|
|
||||||
return device;
|
|
||||||
}
|
|
||||||
|
@ -81,7 +81,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
// internal helpers
|
// internal helpers
|
||||||
void remove_references(ATTR_UNUSED device_t &device);
|
void remove_references(ATTR_UNUSED device_t &device);
|
||||||
device_t &config_new_device(device_t &device);
|
|
||||||
|
|
||||||
// internal state
|
// internal state
|
||||||
const game_driver & m_gamedrv;
|
const game_driver & m_gamedrv;
|
||||||
|
Loading…
Reference in New Issue
Block a user