示例#1
0
static multicart_open_error load_ram_resource(emu_options &options, multicart_load_state *state, xml_data_node *resource_node,
	multicart_resource *resource)
{
	const char *length_string;
	const char *ram_type;
	const char *ram_filename;

	astring *ram_pathname;

	/* locate the 'length' attribute */
	length_string = xml_get_attribute_string(resource_node, "length", NULL);
	if (length_string == NULL)
		return MCERR_MISSING_RAM_LENGTH;

	/* ...and parse it */
	resource->length = ram_parse_string(length_string);
	if (resource->length <= 0)
		return MCERR_INVALID_RAM_SPEC;

	/* allocate bytes for this resource */
	resource->ptr = pool_malloc_lib(state->multicart->data->pool, resource->length);
	if (resource->ptr == NULL)
		return MCERR_OUT_OF_MEMORY;

	/* Is this a persistent RAM resource? Then try to load it. */
	ram_type = xml_get_attribute_string(resource_node, "type", NULL);
	if (ram_type != NULL)
	{
		if (strcmp(ram_type, "persistent")==0)
		{
			astring tmp;

			/* Get the file name. */
			ram_filename = xml_get_attribute_string(resource_node, "file", NULL);
			if (ram_filename==NULL)
				return MCERR_XML_ERROR;

			ram_pathname = astring_assemble_3(&tmp, state->multicart->gamedrv_name, PATH_SEPARATOR, ram_filename);

			/* Save the file name so that we can write the contents on unloading.
               If the RAM resource has no filename, we know that it was volatile only. */
			resource->filename = pool_strdup_lib(state->multicart->data->pool, astring_c(ram_pathname));

			if (resource->filename == NULL)
				return MCERR_OUT_OF_MEMORY;

			image_battery_load_by_name(options, resource->filename, resource->ptr, resource->length, 0x00);
		}
		/* else this type is volatile, in which case we just have
            a memory expansion */
	}
	return MCERR_NONE;
}
示例#2
0
void info_xml_creator::output_ramoptions()
{
	for (const device_t *device = m_drivlist.config().devicelist().first(RAM); device != NULL; device = device->typenext())
	{
		ram_config *ram = (ram_config *)downcast<const legacy_device_base *>(device)->inline_config();
		fprintf(m_output, "\t\t<ramoption default=\"1\">%u</ramoption>\n", ram_parse_string(ram->default_size));

		if (ram->extra_options != NULL)
		{
			astring options(ram->extra_options);
			for (int start = 0, end = options.chr(0, ','); ; start = end + 1, end = options.chr(start, ','))
			{
				astring option;
				option.cpysubstr(options, start, (end == -1) ? -1 : end - start);
				fprintf(m_output, "\t\t<ramoption>%u</ramoption>\n", ram_parse_string(option));
				if (end == -1)
					break;
			}
		}
	}
}
示例#3
0
void node_testmess(xml_data_node *node)
{
	xml_data_node *child_node;
	xml_attribute_node *attr_node;
	int result;

	pile_init(&command_pile);
	pool_init(&command_pool);

	memset(&new_command, 0, sizeof(new_command));
	command_count = 0;

	/* 'driver' attribute */
	attr_node = xml_get_attribute(node, "driver");
	if (!attr_node)
	{
		error_missingattribute("driver");
		return;
	}
	current_testcase.driver = attr_node->value;

	/* 'name' attribute */
	attr_node = xml_get_attribute(node, "name");
	current_testcase.name = attr_node ? attr_node->value : current_testcase.driver;

	/* 'ramsize' attribute */
	attr_node = xml_get_attribute(node, "ramsize");
	current_testcase.ram = attr_node ? ram_parse_string(attr_node->value) : 0;

	/* 'wavwrite' attribute */
	attr_node = xml_get_attribute(node, "wavwrite");
	current_testcase.wavwrite = attr_node && (atoi(attr_node->value) != 0);

	/* report the beginning of the test case */
	report_testcase_begin(current_testcase.name);
	current_testcase.commands = NULL;

	for (child_node = node->child; child_node; child_node = child_node->next)
	{
		if (!strcmp(child_node->name, "wait"))
			node_wait(child_node);
		else if (!strcmp(child_node->name, "input"))
			node_input(child_node);
		else if (!strcmp(child_node->name, "rawinput"))
			node_rawinput(child_node);
		else if (!strcmp(child_node->name, "switch"))
			node_switch(child_node);
		else if (!strcmp(child_node->name, "screenshot"))
			node_screenshot(child_node);
		else if (!strcmp(child_node->name, "checkblank"))
			node_checkblank(child_node);
		else if (!strcmp(child_node->name, "imagecreate"))
			node_imagecreate(child_node);
		else if (!strcmp(child_node->name, "imageload"))
			node_imageload(child_node);
		else if (!strcmp(child_node->name, "memverify"))
			node_memverify(child_node);
		else if (!strcmp(child_node->name, "imageverify"))
			node_imageverify(child_node);
		else if (!strcmp(child_node->name, "trace"))
			node_trace(child_node);
	}

	memset(&new_command, 0, sizeof(new_command));
	new_command.command_type = MESSTEST_COMMAND_END;
	if (!append_command())
	{
		error_outofmemory();
		return;
	}

	result = run_test(0, NULL);
	report_testcase_ran(result);

	pile_delete(&command_pile);
	pool_exit(&command_pool);
}
static BOOL RamPopulateControl(datamap *map, HWND dialog, HWND control, windows_options *opts, const char *option_name)
{
	int i, current_index, driver_index;
	const game_driver *gamedrv;
	UINT32 ram, current_ram;
	const char *this_ram_string;
	TCHAR* t_ramstring;
	const device_t *device;

	// identify the driver
	driver_index = PropertiesCurrentGame(dialog);
	gamedrv = &driver_list::driver(driver_index);

	// clear out the combo box
	(void)ComboBox_ResetContent(control);

	// allocate the machine config
	machine_config cfg(*gamedrv,*opts);

	// identify how many options that we have
	device = cfg.devicelist().first(RAM);

	EnableWindow(control, (device != NULL));
	i = 0;
	// we can only do something meaningful if there is more than one option
	if (device != NULL)
	{
		ram_config *config = (ram_config *)downcast<const legacy_device_base *>(device)->inline_config();

		// identify the current amount of RAM
		this_ram_string = opts->value(OPTION_RAMSIZE);
		current_ram = (this_ram_string != NULL) ? ram_parse_string(this_ram_string) : 0;
		if (current_ram == 0)
			current_ram = ram_parse_string(config->default_size);

		// by default, assume index 0
		current_index = 0;

		{
			ram = ram_parse_string(config->default_size);
			t_ramstring = tstring_from_utf8(config->default_size);
			if( !t_ramstring )
				return FALSE;

			(void)ComboBox_InsertString(control, i, win_tstring_strdup(t_ramstring));
			(void)ComboBox_SetItemData(control, i, ram);

			osd_free(t_ramstring);
		}
		if (config->extra_options != NULL)
		{
			int j;
			int size = strlen(config->extra_options);
			char * const s = mame_strdup(config->extra_options);
			char * const e = s + size;
			char *p = s;
			for (j=0;j<size;j++) {
				if (p[j]==',') p[j]=0;
			}

			/* try to parse each option */
			while(p <= e)
			{
				i++;
				// identify this option
				ram = ram_parse_string(p);

				this_ram_string = p;

				t_ramstring = tstring_from_utf8(this_ram_string);
				if( !t_ramstring )
					return FALSE;

				// add this option to the combo box
				(void)ComboBox_InsertString(control, i, win_tstring_strdup(t_ramstring));
				(void)ComboBox_SetItemData(control, i, ram);

				osd_free(t_ramstring);

				// is this the current option?  record the index if so
				if (ram == current_ram)
					current_index = i;

				p+= strlen(p);
				if (p == e)
					break;

				p += 1;
			}

			osd_free(s);
		}

		// set the combo box
		(void)ComboBox_SetCurSel(control, current_index);
	}
	return TRUE;
}