Пример #1
0
void emu_options::set_system_name(const char *name)
{
	// remember the original system name
	std::string old_system_name(system_name());

	// if the system name changed, fix up the device options
	if (old_system_name.compare(name)!=0)
	{
		// first set the new name
		astring error;
		set_value(OPTION_SYSTEMNAME, name, OPTION_PRIORITY_CMDLINE, error);
		assert(error.empty());

		// remove any existing device options and then add them afresh
		remove_device_options();
		if (add_slot_options(true))
			while (add_slot_options(false)) { }

		// then add the options
		add_device_options(true);
		int num = 0;
		do {
			num = options_count();
			update_slot_options();
		} while(num != options_count());
	}
}
Пример #2
0
void emu_options::set_system_name(const char *name)
{
	// remember the original system name
	astring old_system_name(system_name());

	// if the system name changed, fix up the device options
	if (old_system_name != name)
	{
		// first set the new name
		astring error;
		set_value(OPTION_SYSTEMNAME, name, OPTION_PRIORITY_CMDLINE, error);
		assert(!error);
		// remove any existing device options
		remove_device_options();

		bool isfirst = true;
		while (add_slot_options(isfirst)) {
			isfirst = false;
		}
		// then add the options
		add_device_options(true);
		update_slot_options();
		while (add_slot_options(false));
		add_device_options(true);
	}
}
Пример #3
0
bool emu_options::parse_command_line(int argc, char *argv[], astring &error_string)
{
	// remember the original system name
	astring old_system_name(system_name());

	// parse as normal
	bool result = core_options::parse_command_line(argc, argv, OPTION_PRIORITY_CMDLINE, error_string);

	// if the system name changed, fix up the device options
	if (old_system_name != system_name())
	{
		// remove any existing device options
		result = parse_slot_devices(argc, argv, error_string, NULL, NULL);
	}
	return result;
}
Пример #4
0
int machine_manager::execute()
{
	bool started_empty = false;

	bool firstgame = true;
	bool firstrun = true;

	// loop across multiple hard resets
	bool exit_pending = false;
	int error = MAMERR_NONE;

	if (m_options.console()) {
		m_lua->start_console();
	}
	while (error == MAMERR_NONE && !exit_pending)
	{
		m_new_driver_pending = nullptr;

		// if no driver, use the internal empty driver
		const game_driver *system = m_options.system();
		if (system == nullptr)
		{
			system = &GAME_NAME(___empty);
			if (firstgame)
				started_empty = true;
		}

		firstgame = false;

		// parse any INI files as the first thing
		if (m_options.read_config())
		{
			m_options.revert(OPTION_PRIORITY_INI);
			std::string errors;
			m_options.parse_standard_inis(errors);
		}

		// otherwise, perform validity checks before anything else
		if (system != nullptr)
		{
			validity_checker valid(m_options);
			valid.set_verbose(false);
			valid.check_shared_source(*system);
		}

		// create the machine configuration
		machine_config config(*system, m_options);

		// create the machine structure and driver
		running_machine machine(config, *this);

		set_machine(&machine);

		// run the machine
		error = machine.run(firstrun);
		firstrun = false;

		// check the state of the machine
		if (m_new_driver_pending)
		{
			std::string old_system_name(m_options.system_name());
			bool new_system = (old_system_name.compare(m_new_driver_pending->name)!=0);
			// first: if we scheduled a new system, remove device options of the old system
			// notice that, if we relaunch the same system, there is no effect on the emulation
			if (new_system)
				m_options.remove_device_options();
			// second: set up new system name (and the related device options)
			m_options.set_system_name(m_new_driver_pending->name);
			// third: if we scheduled a new system, take also care of ramsize options
			if (new_system)
			{
				std::string error_string;
				m_options.set_value(OPTION_RAMSIZE, "", OPTION_PRIORITY_CMDLINE, error_string);
			}
			firstrun = true;
			if (m_options.software_name())
			{
				std::string sw_load(m_options.software_name());
				std::string sw_list, sw_name, sw_part, sw_instance, option_errors, error_string;
				int left = sw_load.find_first_of(':');
				int middle = sw_load.find_first_of(':', left + 1);
				int right = sw_load.find_last_of(':');

				sw_list = sw_load.substr(0, left - 1);
				sw_name = sw_load.substr(left + 1, middle - left - 1);
				sw_part = sw_load.substr(middle + 1, right - middle - 1);
				sw_instance = sw_load.substr(right + 1);
				sw_load.assign(sw_load.substr(0, right));

				char arg[] = "ume";
				char *argv = &arg[0];
				m_options.set_value(OPTION_SOFTWARENAME, sw_name.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
				m_options.parse_slot_devices(1, &argv, option_errors, sw_instance.c_str(), sw_load.c_str());
			}
		}
		else
		{
			if (machine.exit_pending()) m_options.set_system_name("");
		}

		if (machine.exit_pending() && (!started_empty || (system == &GAME_NAME(___empty))))
			exit_pending = true;

		// machine will go away when we exit scope
		set_machine(nullptr);
	}
	// return an error
	return error;
}
Пример #5
0
void emu_options::set_system_name(const char *name)
{
	// remember the original system name
	std::string old_system_name(system_name());
	bool new_system = old_system_name.compare(name)!=0;

	// if the system name changed, fix up the device options
	if (new_system)
	{
		// first set the new name
		std::string error;
		set_value(OPTION_SYSTEMNAME, name, OPTION_PRIORITY_CMDLINE, error);
		assert(error.empty());

		// remove any existing device options
		remove_device_options();
	}
	else
	{
		// revert device options set for the old software
		revert(OPTION_PRIORITY_SUBCMD, OPTION_PRIORITY_SUBCMD);
	}

	// get the new system
	const game_driver *cursystem = system();
	if (cursystem == nullptr)
		return;

	if (*software_name() != 0)
	{
		std::string sw_load(software_name());
		std::string sw_list, sw_name, sw_part, sw_instance, option_errors, error_string;
		int left = sw_load.find_first_of(':');
		int middle = sw_load.find_first_of(':', left + 1);
		int right = sw_load.find_last_of(':');

		sw_list = sw_load.substr(0, left - 1);
		sw_name = sw_load.substr(left + 1, middle - left - 1);
		sw_part = sw_load.substr(middle + 1, right - middle - 1);
		sw_instance = sw_load.substr(right + 1);
		sw_load.assign(sw_load.substr(0, right));

		// look up the software part
		machine_config config(*cursystem, *this);
		software_list_device *swlist = software_list_device::find_by_name(config, sw_list.c_str());
		software_info *swinfo = swlist != nullptr ? swlist->find(sw_name.c_str()) : nullptr;
		software_part *swpart = swinfo != nullptr ? swinfo->find_part(sw_part.c_str()) : nullptr;

		// then add the options
		if (new_system)
		{
			while (add_slot_options(swpart)) { }
			add_device_options();
		}

		set_value(OPTION_SOFTWARENAME, sw_name.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
		if (exists(sw_instance.c_str()))
			set_value(sw_instance.c_str(), sw_load.c_str(), OPTION_PRIORITY_SUBCMD, error_string);

		int num;
		do {
			num = options_count();
			update_slot_options(swpart);
		} while(num != options_count());
	}
	else if (new_system)
	{
		// add the options afresh
		while (add_slot_options()) { }
		add_device_options();
		int num;
		do {
			num = options_count();
			update_slot_options();
		} while(num != options_count());
	}
}
Пример #6
0
int machine_manager::execute()
{
	bool started_empty = false;

	bool firstgame = true;
	bool firstrun = true;

	// loop across multiple hard resets
	bool exit_pending = false;
	int error = MAMERR_NONE;

	m_lua.initialize();
	if (m_options.console()) {
		m_lua.start_console();
	}
	while (error == MAMERR_NONE && !exit_pending)
	{
		m_new_driver_pending = NULL;

		// if no driver, use the internal empty driver
		const game_driver *system = m_options.system();
		if (system == NULL)
		{
			system = &GAME_NAME(___empty);
			if (firstgame)
				started_empty = true;
		}

		firstgame = false;

		// parse any INI files as the first thing
		if (m_options.read_config())
		{
			m_options.revert(OPTION_PRIORITY_INI);
			astring errors;
			m_options.parse_standard_inis(errors);
		}

		// otherwise, perform validity checks before anything else
		if (system != NULL)
		{
			validity_checker valid(m_options);
			valid.check_shared_source(*system);
		}

		// create the machine configuration
		machine_config config(*system, m_options);

		//Set up client/server as appropriate
		if(m_options.client())
		  {
		    deleteGlobalClient();
		    createGlobalClient(m_options.username());
		  }
		else if(m_options.server())
		  {
		    deleteGlobalServer();
		    createGlobalServer(m_options.username(),
                           (unsigned short)m_options.port(),
                           m_options.baseDelay(),
                           m_options.rollback());
		    netServer->setSyncTransferTime(m_options.syncTransferSeconds());
		  }

		// create the machine structure and driver
		running_machine machine(config, *this);

		set_machine(&machine);

		// run the machine
		error = machine.run(firstrun);
		firstrun = false;

		deleteGlobalClient();
		deleteGlobalServer();

		// check the state of the machine
		if (m_new_driver_pending)
		{
			astring old_system_name(m_options.system_name());
			bool new_system = (old_system_name != m_new_driver_pending->name);
			// first: if we scheduled a new system, remove device options of the old system
			// notice that, if we relaunch the same system, there is no effect on the emulation
			if (new_system)
				m_options.remove_device_options();
			// second: set up new system name (and the related device options)
			m_options.set_system_name(m_new_driver_pending->name);
			// third: if we scheduled a new system, take also care of ramsize options
			if (new_system)
			{
				astring error_string;
				m_options.set_value(OPTION_RAMSIZE, "", OPTION_PRIORITY_CMDLINE, error_string);
			}
			firstrun = true;
		}
		else
		{
			if (machine.exit_pending()) m_options.set_system_name("");
		}

		if (machine.exit_pending() && (!started_empty || (system == &GAME_NAME(___empty))))
			exit_pending = true;

		// machine will go away when we exit scope
		set_machine(NULL);
	}
	// return an error
	return error;
}