Ejemplo n.º 1
0
machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
	: m_minimum_quantum(attotime::zero),
		m_watchdog_vblank_count(0),
		m_watchdog_time(attotime::zero),
		m_nvram_handler(NULL),
		m_memcard_handler(NULL),
		m_default_layout(NULL),
		m_gamedrv(gamedrv),
		m_options(options)
{
	// construct the config
	(*gamedrv.machine_config)(*this, NULL, NULL);

	bool is_selected_driver = mame_stricmp(gamedrv.name,options.system_name())==0;
	// intialize slot devices - make sure that any required devices have been allocated
	slot_interface_iterator slotiter(root_device());
	for (device_slot_interface *slot = slotiter.first(); slot != NULL; slot = slotiter.next())
	{
		device_t &owner = slot->device();
		astring temp;
		const char *selval = options.main_value(temp, owner.tag()+1);
		bool isdefault = (options.priority(owner.tag()+1)==OPTION_PRIORITY_DEFAULT);
		if (!is_selected_driver || !options.exists(owner.tag()+1))
			selval = slot->default_option();

		if (selval != NULL && *selval != 0)
		{
			const device_slot_option *option = slot->option(selval);

			if (option && (isdefault || option->selectable()))
			{
				device_t *new_dev = device_add(&owner, option->name(), option->devtype(), option->clock());

				const char *default_bios = option->default_bios();
				if (default_bios != NULL)
					device_t::static_set_default_bios_tag(*new_dev, default_bios);

				machine_config_constructor additions = option->machine_config();
				if (additions != NULL)
					(*additions)(const_cast<machine_config &>(*this), new_dev, new_dev);

				const input_device_default *input_device_defaults = option->input_device_defaults();
				if (input_device_defaults)
					device_t::static_set_input_default(*new_dev, input_device_defaults);
			}
			else
				throw emu_fatalerror("Unknown slot option '%s' in slot '%s'", selval, owner.tag()+1);
		}
	}

	// when finished, set the game driver
	driver_device::static_set_game(*m_root_device, gamedrv);

	// then notify all devices that their configuration is complete
	device_iterator iter(root_device());
	for (device_t *device = iter.first(); device != NULL; device = iter.next())
		if (!device->configured())
			device->config_complete();
}
Ejemplo n.º 2
0
machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
	: m_minimum_quantum(attotime::zero),
		m_default_layout(nullptr),
		m_gamedrv(gamedrv),
		m_options(options)
{
	// construct the config
	(*gamedrv.machine_config)(*this, nullptr, nullptr);

	bool is_selected_driver = core_stricmp(gamedrv.name,options.system_name())==0;
	// intialize slot devices - make sure that any required devices have been allocated

	for (device_slot_interface &slot : slot_interface_iterator(root_device()))
	{
		device_t &owner = slot.device();
		std::string selval;
		bool isdefault = (options.priority(owner.tag()+1)==OPTION_PRIORITY_DEFAULT);
		if (is_selected_driver && options.exists(owner.tag()+1))
			selval = options.main_value(owner.tag()+1);
		else if (slot.default_option() != nullptr)
			selval.assign(slot.default_option());

		if (!selval.empty())
		{
			const device_slot_option *option = slot.option(selval.c_str());

			if (option && (isdefault || option->selectable()))
			{
				device_t *new_dev = device_add(&owner, option->name(), option->devtype(), option->clock());

				const char *default_bios = option->default_bios();
				if (default_bios != nullptr)
					device_t::static_set_default_bios_tag(*new_dev, default_bios);

				machine_config_constructor additions = option->machine_config();
				if (additions != nullptr)
					(*additions)(const_cast<machine_config &>(*this), new_dev, new_dev);

				const input_device_default *input_device_defaults = option->input_device_defaults();
				if (input_device_defaults)
					device_t::static_set_input_default(*new_dev, input_device_defaults);
			}
			else
				throw emu_fatalerror("Unknown slot option '%s' in slot '%s'", selval.c_str(), owner.tag()+1);
		}
	}

	// when finished, set the game driver
	driver_device::static_set_game(*m_root_device, gamedrv);

	// then notify all devices that their configuration is complete
	for (device_t &device : device_iterator(root_device()))
		if (!device.configured())
			device.config_complete();
}
Ejemplo n.º 3
0
machine_config::machine_config(const game_driver &gamedrv, emu_options &options)
	: m_minimum_quantum(attotime::zero),
		m_watchdog_vblank_count(0),
		m_watchdog_time(attotime::zero),
		m_nvram_handler(NULL),
		m_memcard_handler(NULL),
		m_video_attributes(0),
		m_gfxdecodeinfo(NULL),
		m_total_colors(0),
		m_default_layout(NULL),
		m_gamedrv(gamedrv),
		m_options(options),
		m_root_device(NULL)
{
	// construct the config
	(*gamedrv.machine_config)(*this, NULL);

	bool is_selected_driver = strcmp(gamedrv.name,options.system_name())==0;
	// intialize slot devices - make sure that any required devices have been allocated
	slot_interface_iterator slotiter(root_device());
	for (device_slot_interface *slot = slotiter.first(); slot != NULL; slot = slotiter.next())
	{
		const slot_interface *intf = slot->get_slot_interfaces();
		if (intf != NULL)
		{
			device_t &owner = slot->device();
			astring temp;
			const char *selval = options.main_value(temp, owner.tag()+1);
			bool isdefault = (options.priority(owner.tag()+1)==OPTION_PRIORITY_DEFAULT);
			if (!is_selected_driver || !options.exists(owner.tag()+1))
				selval = slot->get_default_card();

			if (selval != NULL && *selval != 0)
			{
				bool found = false;
				for (int i = 0; intf[i].name != NULL; i++)
				{
					if (strcmp(selval, intf[i].name) == 0)
					{
						if ((!intf[i].internal) || (isdefault && intf[i].internal))
						{
							const char *def = slot->get_default_card();
							bool is_default = (def != NULL && strcmp(def, selval) == 0);
							device_t *new_dev = device_add(&owner, intf[i].name, intf[i].devtype, is_default ? slot->default_clock() : 0);
							found = true;
							if (is_default) {
								device_t::static_set_input_default(*new_dev, slot->input_ports_defaults());
								if (slot->default_config()) {
									device_t::static_set_static_config(*new_dev, slot->default_config());
								}
							}
						}
					}
				}
				if (!found)
					throw emu_fatalerror("Unknown slot option '%s' in slot '%s'", selval, owner.tag()+1);
			}
		}
	}

	// when finished, set the game driver
	driver_device::static_set_game(*m_root_device, gamedrv);

	// then notify all devices that their configuration is complete
	device_iterator iter(root_device());
	for (device_t *device = iter.first(); device != NULL; device = iter.next())
		if (!device->configured())
			device->config_complete();
}