예제 #1
0
파일: diimage.cpp 프로젝트: RalfVB/mame
bool device_image_interface::schedule_postload_hard_reset_if_needed()
{
	bool postload_hard_reset_needed = device().machine().time() > attotime::zero && is_reset_on_load();
	if (postload_hard_reset_needed)
		device().machine().schedule_hard_reset();
	return postload_hard_reset_needed;
}
예제 #2
0
파일: diimage.cpp 프로젝트: RalfVB/mame
bool device_image_interface::load_software_part(const std::string &identifier, const software_part *&swpart, std::string *list_name)
{
	// if no match has been found, we suggest similar shortnames
	software_list_device *swlist;
	swpart = find_software_item(identifier, true, &swlist);
	if (swpart == nullptr)
	{
		software_list_device::display_matches(device().machine().config(), image_interface(), identifier);
		return false;
	}

	// I'm not sure what m_init_phase is all about; but for now I'm preserving this behavior
	if (is_reset_on_load())
		set_init_phase();

	// Load the software part
	const char *swname = swpart->info().shortname().c_str();
	const rom_entry *start_entry = swpart->romdata().data();
	const software_list_loader &loader = get_software_list_loader();
	bool result = loader.load_software(*this, *swlist, swname, start_entry);

#ifdef UNUSED_VARIABLE
	// Tell the world which part we actually loaded
	std::string full_sw_name = string_format("%s:%s:%s", swlist.list_name(), swpart->info().shortname(), swpart->name());
#endif

	// check compatibility
	switch (swlist->is_compatible(*swpart))
	{
		case SOFTWARE_IS_COMPATIBLE:
			break;

		case SOFTWARE_IS_INCOMPATIBLE:
			swlist->popmessage("WARNING! the set %s might not work on this system due to incompatible filter(s) '%s'\n", swpart->info().shortname(), swlist->filter());
			break;

		case SOFTWARE_NOT_COMPATIBLE:
			swlist->popmessage("WARNING! the set %s might not work on this system due to missing filter(s) '%s'\n", swpart->info().shortname(), swlist->filter());
			break;
	}

	// check requirements and load those images
	const char *requirement = swpart->feature("requirement");
	if (requirement != nullptr)
	{
		const software_part *req_swpart = find_software_item(requirement, false);
		if (req_swpart != nullptr)
		{
			device_image_interface *req_image = software_list_device::find_mountable_image(device().mconfig(), *req_swpart);
			if (req_image != nullptr)
			{
				req_image->set_init_phase();
				req_image->load(requirement);
			}
		}
	}
	if (list_name != nullptr)
		*list_name = swlist->list_name();
	return result;
}
예제 #3
0
bool device_image_interface::load_internal(const char *path, bool is_create, int create_format, option_resolution *create_args, bool just_load)
{
    UINT32 open_plan[4];
    int i;
	bool softload = FALSE;
	m_from_swlist = FALSE;

	// if the path contains no period, we are using softlists, so we won't create an image
	astring pathstr(path);
	bool filename_has_period = (pathstr.rchr(0, '.') != -1) ? TRUE : FALSE;

    /* first unload the image */
    unload();

    /* clear any possible error messages */
    clear_error();

    /* we are now loading */
    m_is_loading = TRUE;

    /* record the filename */
    m_err = set_image_filename(path);

    if (m_err)
        goto done;

	/* Check if there's a software list defined for this device and use that if we're not creating an image */
	if (!filename_has_period && !just_load)
	{
		softload = load_software_part( device().machine().options(), this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name, &m_software_list_name );
		// if we had launched from softlist with a specified part, e.g. "shortname:part"
		// we would have recorded the wrong name, so record it again based on software_info
		if (m_software_info_ptr && m_full_software_name)
			m_err = set_image_filename(m_full_software_name);

		m_from_swlist = TRUE;
	}

	if (is_create || filename_has_period)
	{
		/* determine open plan */
		determine_open_plan(is_create, open_plan);

		/* attempt to open the file in various ways */
		for (i = 0; !m_file && open_plan[i]; i++)
		{
			/* open the file */
			m_err = load_image_by_path(open_plan[i], path);
			if (m_err && (m_err != IMAGE_ERROR_FILENOTFOUND))
				goto done;
		}
	}

	/* Copy some image information when we have been loaded through a software list */
	if ( m_software_info_ptr )
	{
		m_longname = m_software_info_ptr->longname;
		m_manufacturer = m_software_info_ptr->publisher;
		m_year = m_software_info_ptr->year;
		//m_playable = m_software_info_ptr->supported;
	}

	/* did we fail to find the file? */
	if (!is_loaded() && !softload)
	{
		m_err = IMAGE_ERROR_FILENOTFOUND;
		goto done;
	}

	/* call device load or create */
	m_create_format = create_format;
	m_create_args = create_args;

	if (m_init_phase==FALSE) {
		m_err = (image_error_t)finish_load();
		if (m_err)
			goto done;
	}
    /* success! */

done:
	if (just_load) {
		if(m_err) clear();
		return m_err ? IMAGE_INIT_FAIL : IMAGE_INIT_PASS;
	}
    if (m_err!=0) {
		if (!m_init_phase)
		{
			if (device().machine().phase() == MACHINE_PHASE_RUNNING)
				popmessage("Error: Unable to %s image '%s': %s\n", is_create ? "create" : "load", path, error());
			else
				mame_printf_error("Error: Unable to %s image '%s': %s", is_create ? "create" : "load", path, error());
		}
		clear();
	}
	else {
		/* do we need to reset the CPU? only schedule it if load/create is successful */
		if (device().machine().time() > attotime::zero && is_reset_on_load())
			device().machine().schedule_hard_reset();
		else
		{
			if (!m_init_phase)
			{
				if (device().machine().phase() == MACHINE_PHASE_RUNNING)
					popmessage("Image '%s' was successfully %s.", path, is_create ? "created" : "loaded");
				else
					mame_printf_info("Image '%s' was successfully %s.\n", path, is_create ? "created" : "loaded");
			}
		}
	}
	return m_err ? IMAGE_INIT_FAIL : IMAGE_INIT_PASS;
}
예제 #4
0
파일: diimage.cpp 프로젝트: keshbach/mame
bool device_image_interface::load_internal(const char *path, bool is_create, int create_format, util::option_resolution *create_args, bool just_load)
{
    UINT32 open_plan[4];
    int i;
    bool softload = FALSE;
    m_from_swlist = FALSE;

    // if the path contains no period, we are using softlists, so we won't create an image
    std::string pathstr(path);
    bool filename_has_period = (pathstr.find_last_of('.') != -1) ? TRUE : FALSE;

    // first unload the image
    unload();

    // clear any possible error messages
    clear_error();

    // we are now loading
    m_is_loading = TRUE;

    // record the filename
    m_err = set_image_filename(path);

    if (m_err)
        goto done;

    if (core_opens_image_file())
    {
        // Check if there's a software list defined for this device and use that if we're not creating an image
        if (!filename_has_period && !just_load)
        {
            softload = load_software_part(path, m_software_part_ptr);
            if (softload)
            {
                m_software_info_ptr = &m_software_part_ptr->info();
                m_software_list_name.assign(m_software_info_ptr->list().list_name());
                m_full_software_name.assign(m_software_part_ptr->info().shortname());

                // if we had launched from softlist with a specified part, e.g. "shortname:part"
                // we would have recorded the wrong name, so record it again based on software_info
                if (m_software_info_ptr && !m_full_software_name.empty())
                    m_err = set_image_filename(m_full_software_name.c_str());

                // check if image should be read-only
                const char *read_only = get_feature("read_only");
                if (read_only && !strcmp(read_only, "true")) {
                    make_readonly();
                }

                m_from_swlist = TRUE;
            }
        }

        if (is_create || filename_has_period)
        {
            // determine open plan
            determine_open_plan(is_create, open_plan);

            // attempt to open the file in various ways
            for (i = 0; !m_file && open_plan[i]; i++)
            {
                // open the file
                m_err = load_image_by_path(open_plan[i], path);
                if (m_err && (m_err != IMAGE_ERROR_FILENOTFOUND))
                    goto done;
            }
        }

        // Copy some image information when we have been loaded through a software list
        if ( m_software_info_ptr )
        {
            // sanitize
            if (m_software_info_ptr->longname().empty() || m_software_info_ptr->publisher().empty() || m_software_info_ptr->year().empty())
                fatalerror("Each entry in an XML list must have all of the following fields: description, publisher, year!\n");

            // store
            m_longname = m_software_info_ptr->longname();
            m_manufacturer = m_software_info_ptr->publisher();
            m_year = m_software_info_ptr->year();
            //m_playable = m_software_info_ptr->supported();
        }

        // did we fail to find the file?
        if (!is_loaded() && !softload)
        {
            m_err = IMAGE_ERROR_FILENOTFOUND;
            goto done;
        }
    }

    // call device load or create
    m_create_format = create_format;
    m_create_args = create_args;

    if (m_init_phase==FALSE) {
        m_err = (image_error_t)finish_load();
        if (m_err)
            goto done;
    }
    // success!

done:
    if (just_load) {
        if(m_err) clear();
        return m_err ? IMAGE_INIT_FAIL : IMAGE_INIT_PASS;
    }
    if (m_err!=0) {
        if (!m_init_phase)
        {
            if (device().machine().phase() == MACHINE_PHASE_RUNNING)
                device().popmessage("Error: Unable to %s image '%s': %s", is_create ? "create" : "load", path, error());
            else
                osd_printf_error("Error: Unable to %s image '%s': %s\n", is_create ? "create" : "load", path, error());
        }
        clear();
    }
    else {
        /* do we need to reset the CPU? only schedule it if load/create is successful */
        if (device().machine().time() > attotime::zero && is_reset_on_load())
            device().machine().schedule_hard_reset();
        else
        {
            if (!m_init_phase)
            {
                if (device().machine().phase() == MACHINE_PHASE_RUNNING)
                    device().popmessage("Image '%s' was successfully %s.", path, is_create ? "created" : "loaded");
                else
                    osd_printf_info("Image '%s' was successfully %s.\n", path, is_create ? "created" : "loaded");
            }
        }
    }
    return m_err ? IMAGE_INIT_FAIL : IMAGE_INIT_PASS;
}