Example #1
0
void image_device_init(running_machine &machine)
{
	const char *image_name;

	/* make sure that any required devices have been allocated */
	image_interface_iterator iter(machine.root_device());
	for (device_image_interface *image = iter.first(); image != NULL; image = iter.next())
	{
		/* is an image specified for this image */
		image_name = machine.options().device_option(*image);

		if ((image_name != NULL) && (image_name[0] != '\0'))
		{
			/* mark init state */
			image->set_init_phase();

			/* try to load this image */
			bool result = image->load(image_name);

			/* did the image load fail? */
			if (result)
			{
				/* retrieve image error message */
				astring image_err = astring(image->error());
				astring image_basename(image_name);

				/* unload all images */
				image_unload_all(machine);

				fatalerror_exitcode(machine, MAMERR_DEVICE, "Device %s load (%s) failed: %s",
					image->device().name(),
					image_basename.cstr(),
					image_err.cstr());
			}
		}
	}

	for (device_image_interface *image = iter.first(); image != NULL; image = iter.next())
	{
		/* is an image specified for this image */
		image_name = image->filename();

		if (!((image_name != NULL) && (image_name[0] != '\0')))
		{
			/* no image... must this device be loaded? */
			if (image->must_be_loaded())
			{
				fatalerror_exitcode(machine, MAMERR_DEVICE, "Driver requires that device \"%s\" must have an image to load", image->instance_name());
			}
		}
	}
}
Example #2
0
static mame_file_error open_battery_file(mess_image *image, UINT32 openflags, mame_file **file)
{
	mame_file_error filerr;
	char *basename_noext;
	char *fname;

	basename_noext = strip_extension(image_basename(image));
	if (!basename_noext)
		return FILERR_OUT_OF_MEMORY;
	fname = assemble_4_strings(Machine->gamedrv->name, PATH_SEPARATOR, basename_noext, ".nv");
	filerr = mame_fopen(SEARCHPATH_NVRAM, fname, openflags, file);
	free(fname);
	free(basename_noext);
	return filerr;
}
Example #3
0
const char *image_basename_noext(mess_image *img)
{
	const char *s;
	char *ext;

	if (!img->basename_noext)
	{
		s = image_basename(img);
		if (s)
		{
			img->basename_noext = image_strdup(img, s);
			ext = strrchr(img->basename_noext, '.');
			if (ext)
				*ext = '\0';
		}
	}
	return img->basename_noext;
}
Example #4
0
File: image.cpp Project: Fulg/mame
image_manager::image_manager(running_machine &machine)
	: m_machine(machine)
{
	/* make sure that any required devices have been allocated */
	for (device_image_interface &image : image_interface_iterator(machine.root_device()))
	{
		/* is an image specified for this image */
		const char *image_name = machine.options().value(image.instance_name());
		if (!image.user_loadable())
			continue;

		if ((image_name != nullptr) && (image_name[0] != '\0'))
		{
			/* mark init state */
			image.set_init_phase();

			/* try to load this image */
			bool result = image.load(image_name);

			/* did the image load fail? */
			if (result)
			{
				/* retrieve image error message */
				std::string image_err = std::string(image.error());
				std::string image_basename(image_name);

				/* unload all images */
				unload_all();

				fatalerror_exitcode(machine, EMU_ERR_DEVICE, "Device %s load (%s) failed: %s",
					image.device().name(),
					image_basename.c_str(),
					image_err.c_str());
			}
		}
	}

	machine.configuration().config_register("image_directories", config_saveload_delegate(FUNC(image_manager::config_load), this), config_saveload_delegate(FUNC(image_manager::config_save), this));
}
Example #5
0
int ui_sprintf_image_info(char *buf)
{
    char *dst = buf;
    const struct IODevice *dev;
    int id;

    dst += sprintf(dst, "%s\n\n", Machine->gamedrv->description);

    if (options.ram)
    {
        char buf2[RAM_STRING_BUFLEN];
        dst += sprintf(dst, "RAM: %s\n\n", ram_string(buf2, options.ram));
    }

    for (dev = Machine->devices; dev->type < IO_COUNT; dev++)
    {
        for (id = 0; id < dev->count; id++)
        {
            mess_image *img = image_from_device_and_index(dev, id);
            const char *name = image_filename(img);
            if( name )
            {
                const char *base_filename;
                const char *info;
                char *base_filename_noextension;

                base_filename = image_basename(img);
                base_filename_noextension = strip_extension((char *) base_filename);

                /* display device type and filename */
                dst += sprintf(dst,"%s: %s\n", image_typename_id(img), base_filename);

                /* display long filename, if present and doesn't correspond to name */
                info = image_longname(img);
                if (info && (!base_filename_noextension || mame_stricmp(info, base_filename_noextension)))
                    dst += sprintf(dst,"%s\n", info);

                /* display manufacturer, if available */
                info = image_manufacturer(img);
                if (info)
                {
                    dst += sprintf(dst,"%s", info);
                    info = stripspace(image_year(img));
                    if (info && *info)
                        dst += sprintf(dst,", %s", info);
                    dst += sprintf(dst,"\n");
                }

                /* display playable information, if available */
                info = image_playable(img);
                if (info)
                    dst += sprintf(dst,"%s\n", info);

                if (base_filename_noextension)
                    free(base_filename_noextension);
            }
            else
            {
                dst += sprintf(dst,"%s: ---\n", image_typename_id(img));
            }
        }
    }
    return dst - buf;
}