Beispiel #1
0
void info_xml_creator::output_switches(const ioport_list &portlist, const char *root_tag, int type, const char *outertag, const char *innertag)
{
	// iterate looking for DIP switches
	for (ioport_port *port = portlist.first(); port != NULL; port = port->next())
		for (ioport_field *field = port->first_field(); field != NULL; field = field->next())
			if (field->type() == type)
			{
				astring output;

				astring newtag(port->tag()), oldtag(":");
				newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len());

				// output the switch name information
				astring normalized_field_name(xml_normalize_string(field->name()));
				astring normalized_newtag(xml_normalize_string(newtag));
				output.catprintf("\t\t<%s name=\"%s\" tag=\"%s\" mask=\"%u\">\n", outertag, normalized_field_name.cstr(), normalized_newtag.cstr(), field->mask());

				// loop over settings
				for (ioport_setting *setting = field->first_setting(); setting != NULL; setting = setting->next())
				{
					output.catprintf("\t\t\t<%s name=\"%s\" value=\"%u\"%s/>\n", innertag, xml_normalize_string(setting->name()), setting->value(), setting->value() == field->defvalue() ? " default=\"yes\"" : "");
				}

				// terminate the switch entry
				output.catprintf("\t\t</%s>\n", outertag);

				fprintf(m_output, "%s", output.cstr());
			}
}
Beispiel #2
0
void info_xml_creator::output_chips(device_t &device, const char *root_tag)
{
	// iterate over executable devices
	execute_interface_iterator execiter(device);
	for (device_execute_interface *exec = execiter.first(); exec != NULL; exec = execiter.next())
	{
		if (strcmp(exec->device().tag(), device.tag()))
		{
			astring newtag(exec->device().tag()), oldtag(":");
			newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len());

			fprintf(m_output, "\t\t<chip");
			fprintf(m_output, " type=\"cpu\"");
			fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag));
			fprintf(m_output, " name=\"%s\"", xml_normalize_string(exec->device().name()));
			fprintf(m_output, " clock=\"%d\"", exec->device().clock());
			fprintf(m_output, "/>\n");
		}
	}

	// iterate over sound devices
	sound_interface_iterator sounditer(device);
	for (device_sound_interface *sound = sounditer.first(); sound != NULL; sound = sounditer.next())
	{
		if (strcmp(sound->device().tag(), device.tag()))
		{
			astring newtag(sound->device().tag()), oldtag(":");
			newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len());

			fprintf(m_output, "\t\t<chip");
			fprintf(m_output, " type=\"audio\"");
			fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag));
			fprintf(m_output, " name=\"%s\"", xml_normalize_string(sound->device().name()));
			if (sound->device().clock() != 0)
				fprintf(m_output, " clock=\"%d\"", sound->device().clock());
			fprintf(m_output, "/>\n");
		}
	}
}
Beispiel #3
0
void info_xml_creator::output_images(device_t &device, const char *root_tag)
{
	image_interface_iterator iter(device);
	for (const device_image_interface *imagedev = iter.first(); imagedev != NULL; imagedev = iter.next())
	{
		if (strcmp(imagedev->device().tag(), device.tag()))
		{
			astring newtag(imagedev->device().tag()), oldtag(":");
			newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len());

			// print m_output device type
			fprintf(m_output, "\t\t<device type=\"%s\"", xml_normalize_string(imagedev->image_type_name()));

			// does this device have a tag?
			if (imagedev->device().tag())
				fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag));

			// is this device mandatory?
			if (imagedev->must_be_loaded())
				fprintf(m_output, " mandatory=\"1\"");

			if (imagedev->image_interface() && imagedev->image_interface()[0])
				fprintf(m_output, " interface=\"%s\"", xml_normalize_string(imagedev->image_interface()));

			// close the XML tag
			fprintf(m_output, ">\n");

			const char *name = imagedev->instance_name();
			const char *shortname = imagedev->brief_instance_name();

			fprintf(m_output, "\t\t\t<instance");
			fprintf(m_output, " name=\"%s\"", xml_normalize_string(name));
			fprintf(m_output, " briefname=\"%s\"", xml_normalize_string(shortname));
			fprintf(m_output, "/>\n");

			astring extensions(imagedev->file_extensions());

			char *ext = strtok((char *)extensions.cstr(), ",");
			while (ext != NULL)
			{
				fprintf(m_output, "\t\t\t<extension");
				fprintf(m_output, " name=\"%s\"", xml_normalize_string(ext));
				fprintf(m_output, "/>\n");
				ext = strtok(NULL, ",");
			}

			fprintf(m_output, "\t\t</device>\n");
		}
	}
}
Beispiel #4
0
void info_xml_creator::output_slots(device_t &device, const char *root_tag)
{
	slot_interface_iterator iter(device);
	for (const device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next())
	{
		if (slot->fixed()) continue;    // or shall we list these as non-configurable?

		if (strcmp(slot->device().tag(), device.tag()))
		{
			std::string newtag(slot->device().tag()), oldtag(":");
			newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length());

			// print m_output device type
			fprintf(m_output, "\t\t<slot name=\"%s\">\n", xml_normalize_string(newtag.c_str()));

			/*
			 if (slot->slot_interface()[0])
			 fprintf(m_output, " interface=\"%s\"", xml_normalize_string(slot->slot_interface()));
			 */

			for (const device_slot_option *option = slot->first_option(); option != NULL; option = option->next())
			{
				if (option->selectable())
				{
					device_t *dev = const_cast<machine_config &>(m_drivlist.config()).device_add(&m_drivlist.config().root_device(), "dummy", option->devtype(), 0);
					if (!dev->configured())
						dev->config_complete();

					fprintf(m_output, "\t\t\t<slotoption");
					fprintf(m_output, " name=\"%s\"", xml_normalize_string(option->name()));
					fprintf(m_output, " devname=\"%s\"", xml_normalize_string(dev->shortname()));
					if (slot->default_option())
					{
						if (strcmp(slot->default_option(),option->name())==0)
							fprintf(m_output, " default=\"yes\"");
					}
					fprintf(m_output, "/>\n");
					const_cast<machine_config &>(m_drivlist.config()).device_remove(&m_drivlist.config().root_device(), "dummy");
				}
			}

			fprintf(m_output, "\t\t</slot>\n");
		}
	}
}
Beispiel #5
0
void info_xml_creator::output_slots(device_t &device, const char *root_tag)
{
	slot_interface_iterator iter(device);
	for (const device_slot_interface *slot = iter.first(); slot != NULL; slot = iter.next())
	{
		if (slot->fixed()) continue;    // or shall we list these as non-configurable?

		if (strcmp(slot->device().tag(), device.tag()))
		{
			astring newtag(slot->device().tag()), oldtag(":");
			newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len());

			// print m_output device type
			fprintf(m_output, "\t\t<slot name=\"%s\">\n", xml_normalize_string(newtag));

			/*
			 if (slot->slot_interface()[0])
			 fprintf(m_output, " interface=\"%s\"", xml_normalize_string(slot->slot_interface()));
			 */

			const slot_interface* intf = slot->get_slot_interfaces();
			for (int i = 0; intf && intf[i].name != NULL && !intf[i].internal; i++)
			{
				device_t *dev = const_cast<machine_config &>(m_drivlist.config()).device_add(&m_drivlist.config().root_device(), "dummy", intf[i].devtype, 0);
				if (!dev->configured())
					dev->config_complete();

				fprintf(m_output, "\t\t\t<slotoption");
				fprintf(m_output, " name=\"%s\"", xml_normalize_string(intf[i].name));
				fprintf(m_output, " devname=\"%s\"", xml_normalize_string(dev->shortname()));
				if (slot->get_default_card())
				{
					if (strcmp(slot->get_default_card(),intf[i].name)==0)
						fprintf(m_output, " default=\"yes\"");
				}
				fprintf(m_output, "/>\n");
				const_cast<machine_config &>(m_drivlist.config()).device_remove(&m_drivlist.config().root_device(), "dummy");
			}

			fprintf(m_output, "\t\t</slot>\n");
		}
	}
}
Beispiel #6
0
void info_xml_creator::output_display(device_t &device, const char *root_tag)
{
	// iterate over screens
	screen_device_iterator iter(device);
	for (const screen_device *screendev = iter.first(); screendev != NULL; screendev = iter.next())
	{
		if (strcmp(screendev->tag(), device.tag()))
		{
			astring newtag(screendev->tag()), oldtag(":");
			newtag.substr(newtag.find(oldtag.cat(root_tag)) + oldtag.len());

			fprintf(m_output, "\t\t<display");
			fprintf(m_output, " tag=\"%s\"", xml_normalize_string(newtag));

			switch (screendev->screen_type())
			{
				case SCREEN_TYPE_RASTER:    fprintf(m_output, " type=\"raster\"");  break;
				case SCREEN_TYPE_VECTOR:    fprintf(m_output, " type=\"vector\"");  break;
				case SCREEN_TYPE_LCD:       fprintf(m_output, " type=\"lcd\"");     break;
				default:                    fprintf(m_output, " type=\"unknown\""); break;
			}

			// output the orientation as a string
			switch (m_drivlist.driver().flags & ORIENTATION_MASK)
			{
				case ORIENTATION_FLIP_X:
					fprintf(m_output, " rotate=\"0\" flipx=\"yes\"");
					break;
				case ORIENTATION_FLIP_Y:
					fprintf(m_output, " rotate=\"180\" flipx=\"yes\"");
					break;
				case ORIENTATION_FLIP_X|ORIENTATION_FLIP_Y:
					fprintf(m_output, " rotate=\"180\"");
					break;
				case ORIENTATION_SWAP_XY:
					fprintf(m_output, " rotate=\"90\" flipx=\"yes\"");
					break;
				case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_X:
					fprintf(m_output, " rotate=\"90\"");
					break;
				case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_Y:
					fprintf(m_output, " rotate=\"270\"");
					break;
				case ORIENTATION_SWAP_XY|ORIENTATION_FLIP_X|ORIENTATION_FLIP_Y:
					fprintf(m_output, " rotate=\"270\" flipx=\"yes\"");
					break;
				default:
					fprintf(m_output, " rotate=\"0\"");
					break;
			}

			// output width and height only for games that are not vector
			if (screendev->screen_type() != SCREEN_TYPE_VECTOR)
			{
				const rectangle &visarea = screendev->visible_area();
				fprintf(m_output, " width=\"%d\"", visarea.width());
				fprintf(m_output, " height=\"%d\"", visarea.height());
			}

			// output refresh rate
			fprintf(m_output, " refresh=\"%f\"", ATTOSECONDS_TO_HZ(screendev->refresh_attoseconds()));

			// output raw video parameters only for games that are not vector
			// and had raw parameters specified
			if (screendev->screen_type() != SCREEN_TYPE_VECTOR && !screendev->oldstyle_vblank_supplied())
			{
				int pixclock = screendev->width() * screendev->height() * ATTOSECONDS_TO_HZ(screendev->refresh_attoseconds());

				fprintf(m_output, " pixclock=\"%d\"", pixclock);
				fprintf(m_output, " htotal=\"%d\"", screendev->width());
				fprintf(m_output, " hbend=\"%d\"", screendev->visible_area().min_x);
				fprintf(m_output, " hbstart=\"%d\"", screendev->visible_area().max_x+1);
				fprintf(m_output, " vtotal=\"%d\"", screendev->height());
				fprintf(m_output, " vbend=\"%d\"", screendev->visible_area().min_y);
				fprintf(m_output, " vbstart=\"%d\"", screendev->visible_area().max_y+1);
			}
			fprintf(m_output, " />\n");
		}
	}
}