void ui_menu_control_device_image::handle()
{
	switch(state) {
	case START_FILE: {
		bool can_create = false;
		if(image->is_creatable()) {
			zippath_directory *directory = NULL;
			file_error err = zippath_opendir(current_directory, &directory);
			can_create = err == FILERR_NONE && !zippath_is_zip(directory);
			if(directory)
				zippath_closedir(directory);
		}
		submenu_result = -1;
		ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_selector(machine(), container, image, current_directory, current_file, true, image->image_interface()!=NULL, can_create, &submenu_result)));
		state = SELECT_FILE;
		break;
	}

	case START_SOFTLIST:
		sld = 0;
		ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software(machine(), container, image->image_interface(), &sld)));
		state = SELECT_SOFTLIST;
		break;

	case START_OTHER_PART: {
		submenu_result = -1;
		ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, swi, swp->interface_, &swp, true, &submenu_result)));
		state = SELECT_OTHER_PART;
		break;
	}

	case SELECT_SOFTLIST:
		if(!sld) {
			ui_menu::stack_pop(machine());
			break;
		}
		software_info_name = "";
		ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_list(machine(), container, sld, image->image_interface(), software_info_name)));
		state = SELECT_PARTLIST;
		break;

	case SELECT_PARTLIST:
		swl = software_list_open(machine().options(), sld->list_name(), false, NULL);
		swi = software_list_find(swl, software_info_name, NULL);
		if(swinfo_has_multiple_parts(swi, image->image_interface())) {
			submenu_result = -1;
			swp = 0;
			ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_software_parts(machine(), container, swi, image->image_interface(), &swp, false, &submenu_result)));
			state = SELECT_ONE_PART;
		} else {
			swp = software_find_part(swi, NULL, NULL);
			load_software_part();
			software_list_close(swl);
			ui_menu::stack_pop(machine());
		}
		break;

	case SELECT_ONE_PART:
		switch(submenu_result) {
		case ui_menu_software_parts::T_ENTRY: {
			load_software_part();
			software_list_close(swl);
			ui_menu::stack_pop(machine());
			break;
		}

		case -1: // return to list
			software_list_close(swl);
			state = SELECT_SOFTLIST;
			break;

		}
		break;

	case SELECT_OTHER_PART:
		switch(submenu_result) {
		case ui_menu_software_parts::T_ENTRY: {
			load_software_part();
			break;
		}

		case ui_menu_software_parts::T_FMGR:
			state = START_FILE;
			handle();
			break;

		case -1: // return to system
			ui_menu::stack_pop(machine());
			break;

		}
		break;

	case SELECT_FILE:
		switch(submenu_result) {
		case ui_menu_file_selector::R_EMPTY:
			image->unload();
			ui_menu::stack_pop(machine());
			break;

		case ui_menu_file_selector::R_FILE:
			hook_load(current_file, false);
			break;

		case ui_menu_file_selector::R_CREATE:
			ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_file_create(machine(), container, image, current_directory, current_file)));
			state = CREATE_FILE;
			break;

		case ui_menu_file_selector::R_SOFTLIST:
			state = START_SOFTLIST;
			handle();
			break;

		case -1: // return to system
			ui_menu::stack_pop(machine());
			break;
		}
		break;

	case CREATE_FILE: {
		bool can_create, need_confirm;
		test_create(can_create, need_confirm);
		if(can_create) {
			if(need_confirm) {
				ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_confirm_save_as(machine(), container, &create_confirmed)));
				state = CREATE_CONFIRM;
			} else {
				state = DO_CREATE;
				handle();
			}
		} else {
			state = START_FILE;
			handle();
		}
		break;
	}

	case CREATE_CONFIRM: {
		state = create_confirmed ? DO_CREATE : START_FILE;
		handle();
		break;
	}

	case DO_CREATE: {
		astring path;
		zippath_combine(path, current_directory, current_file);
		int err = image->create(path, 0, NULL);
		if (err != 0)
			popmessage("Error: %s", image->error());
		ui_menu::stack_pop(machine());
		break;
	}
	}
}
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;
}
示例#3
0
bool legacy_image_device_base::load_internal(const char *path, bool is_create, int create_format, option_resolution *create_args)
{
    image_error_t err;
    UINT32 open_plan[4];
    int i;
	bool softload = FALSE;

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

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

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

    /* record the filename */
    err = set_image_filename(path);
    if (err)
        goto done;

	/* Check if there's a software list defined for this device and use that if we're not creating an image */
	softload = load_software_part( this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name );
	if (is_create || (!softload  && m_software_info_ptr==NULL))
	{
		/* 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 */
			err = load_image_by_path(open_plan[i], path);
			if (err && (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)
	{
		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) {
		err = (image_error_t)finish_load();
		if (err)
			goto done;
	}
    /* success! */

done:
    if (m_err) {
		if (!m_init_phase)
		{
			if (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 ((attotime_compare(timer_get_time(device().machine), attotime_zero) > 0) && m_image_config.is_reset_on_load())
			device().machine->schedule_hard_reset();
		else
		{
			if (!m_init_phase)
			{
				if (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 err ? IMAGE_INIT_FAIL : IMAGE_INIT_PASS;
}
示例#4
0
文件: diimage.cpp 项目: RalfVB/mame
image_init_result device_image_interface::load_software(const std::string &software_identifier)
{
	// Prepare to load
	unload();
	clear_error();
	m_is_loading = true;

	// Check if there's a software list defined for this device and use that if we're not creating an image
	std::string list_name;
	bool softload = load_software_part(software_identifier, m_software_part_ptr, &list_name);
	if (!softload)
	{
		m_is_loading = false;
		return image_init_result::FAIL;
	}

	// set up softlist stuff
	m_software_info_ptr = &m_software_part_ptr->info();
	m_software_list_name = std::move(list_name);
	m_full_software_name = m_software_part_ptr->info().shortname();

	// specify image name with softlist-derived names
	m_image_name = m_full_software_name;
	m_basename = m_full_software_name;
	m_basename_noext = m_full_software_name;
	m_filetype = use_software_list_file_extension_for_filetype() && m_mame_file != nullptr
		? core_filename_extract_extension(m_mame_file->filename(), true)
		: "";

	// check if image should be read-only
	const char *read_only = get_feature("read_only");
	if (read_only && !strcmp(read_only, "true"))
	{
		// 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();

			// set file type
			std::string filename = (m_mame_file != nullptr) && (m_mame_file->filename() != nullptr)
				? m_mame_file->filename()
				: "";
			m_filetype = core_filename_extract_extension(filename, true);
		}
	}

	// call finish_load if necessary
	if (m_init_phase == false && (finish_load() != image_init_result::PASS))
		return image_init_result::FAIL;

	// do we need to reset the CPU? only schedule it if load is successful
	if (!schedule_postload_hard_reset_if_needed())
	{
		if (!m_init_phase)
		{
			if (device().machine().phase() == MACHINE_PHASE_RUNNING)
				device().popmessage("Image '%s' was successfully loaded.", software_identifier);
			else
				osd_printf_info("Image '%s' was successfully loaded.\n", software_identifier.c_str());
		}
	}

	return image_init_result::PASS;
}
示例#5
0
void menu_control_device_image::handle()
{
	switch(m_state)
	{
	case START_FILE:
		m_submenu_result.filesel = menu_file_selector::result::INVALID;
		menu::stack_push<menu_file_selector>(ui(), container(), &m_image, m_current_directory, m_current_file, true, m_image.image_interface()!=nullptr, m_image.is_creatable(), m_submenu_result.filesel);
		m_state = SELECT_FILE;
		break;

	case START_SOFTLIST:
		m_sld = nullptr;
		menu::stack_push<menu_software>(ui(), container(), m_image.image_interface(), &m_sld);
		m_state = SELECT_SOFTLIST;
		break;

	case START_OTHER_PART:
		m_submenu_result.swparts = menu_software_parts::result::INVALID;
		menu::stack_push<menu_software_parts>(ui(), container(), m_swi, m_swp->interface().c_str(), &m_swp, true, m_submenu_result.swparts);
		m_state = SELECT_OTHER_PART;
		break;

	case SELECT_SOFTLIST:
		if (!m_sld)
		{
			stack_pop();
			break;
		}
		m_software_info_name.clear();
		menu::stack_push<menu_software_list>(ui(), container(), m_sld, m_image.image_interface(), m_software_info_name);
		m_state = SELECT_PARTLIST;
		break;

	case SELECT_PARTLIST:
		m_swi = m_sld->find(m_software_info_name.c_str());
		if (!m_swi)
			m_state = START_SOFTLIST;
		else if (m_swi->has_multiple_parts(m_image.image_interface()))
		{
			m_submenu_result.swparts = menu_software_parts::result::INVALID;
			m_swp = nullptr;
			menu::stack_push<menu_software_parts>(ui(), container(), m_swi, m_image.image_interface(), &m_swp, false, m_submenu_result.swparts);
			m_state = SELECT_ONE_PART;
		}
		else
		{
			m_swp = m_swi->find_part("", m_image.image_interface());
			load_software_part();
		}
		break;

	case SELECT_ONE_PART:
		switch(m_submenu_result.swparts) {
		case menu_software_parts::result::ENTRY: {
			load_software_part();
			break;
		}

		default: // return to list
			m_state = SELECT_SOFTLIST;
			break;

		}
		break;

	case SELECT_OTHER_PART:
		switch(m_submenu_result.swparts) {
		case menu_software_parts::result::ENTRY:
			load_software_part();
			break;

		case menu_software_parts::result::FMGR:
			m_state = START_FILE;
			handle();
			break;

		case menu_software_parts::result::EMPTY:
			m_image.unload();
			stack_pop();
			break;

		case menu_software_parts::result::SWLIST:
			m_state = START_SOFTLIST;
			handle();
			break;

		case menu_software_parts::result::INVALID: // return to system
			stack_pop();
			break;

		}
		break;

	case SELECT_FILE:
		switch(m_submenu_result.filesel)
		{
		case menu_file_selector::result::EMPTY:
			m_image.unload();
			stack_pop();
			break;

		case menu_file_selector::result::FILE:
			hook_load(m_current_file);
			break;

		case menu_file_selector::result::CREATE:
			menu::stack_push<menu_file_create>(ui(), container(), &m_image, m_current_directory, m_current_file, m_create_ok);
			m_state = CHECK_CREATE;
			break;

		case menu_file_selector::result::SOFTLIST:
			m_state = START_SOFTLIST;
			handle();
			break;

		default: // return to system
			stack_pop();
			break;
		}
		break;

	case CREATE_FILE: {
		bool can_create, need_confirm;
		test_create(can_create, need_confirm);
		if(can_create) {
			if(need_confirm) {
				menu::stack_push<menu_confirm_save_as>(ui(), container(), &m_create_confirmed);
				m_state = CREATE_CONFIRM;
			} else {
				m_state = DO_CREATE;
				handle();
			}
		} else {
			m_state = START_FILE;
			handle();
		}
		break;
	}

	case CREATE_CONFIRM:
		m_state = m_create_confirmed ? DO_CREATE : START_FILE;
		handle();
		break;

	case CHECK_CREATE:
		m_state = m_create_ok ? CREATE_FILE : START_FILE;
		handle();
		break;

	case DO_CREATE: {
		auto path = util::zippath_combine(m_current_directory, m_current_file);
		image_init_result err = m_image.create(path, nullptr, nullptr);
		if (err != image_init_result::PASS)
			machine().popmessage("Error: %s", m_image.error());
		stack_pop();
		break;
	}
	}
}
示例#6
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;
}
示例#7
0
文件: imgcntrl.cpp 项目: ndpduc/mame
void ui_menu_control_device_image::handle()
{
	switch(state) {
	case START_FILE: {
		bool can_create = false;
		if(image->is_creatable()) {
			zippath_directory *directory = nullptr;
			osd_file::error err = zippath_opendir(current_directory.c_str(), &directory);
			can_create = err == osd_file::error::NONE && !zippath_is_zip(directory);
			if(directory)
				zippath_closedir(directory);
		}
		submenu_result = -1;
		ui_menu::stack_push(global_alloc_clear<ui_menu_file_selector>(machine(), container, image, current_directory, current_file, true, image->image_interface()!=nullptr, can_create, &submenu_result));
		state = SELECT_FILE;
		break;
	}

	case START_SOFTLIST:
		sld = nullptr;
		ui_menu::stack_push(global_alloc_clear<ui_menu_software>(machine(), container, image->image_interface(), &sld));
		state = SELECT_SOFTLIST;
		break;

	case START_OTHER_PART: {
		submenu_result = -1;
		ui_menu::stack_push(global_alloc_clear<ui_menu_software_parts>(machine(), container, swi, swp->interface(), &swp, true, &submenu_result));
		state = SELECT_OTHER_PART;
		break;
	}

	case SELECT_SOFTLIST:
		if(!sld) {
			ui_menu::stack_pop(machine());
			break;
		}
		software_info_name = "";
		ui_menu::stack_push(global_alloc_clear<ui_menu_software_list>(machine(), container, sld, image->image_interface(), software_info_name));
		state = SELECT_PARTLIST;
		break;

	case SELECT_PARTLIST:
		swi = sld->find(software_info_name.c_str());
		if (!swi)
			state = START_SOFTLIST;
		else if(swi->has_multiple_parts(image->image_interface()))
		{
			submenu_result = -1;
			swp = nullptr;
			ui_menu::stack_push(global_alloc_clear<ui_menu_software_parts>(machine(), container, swi, image->image_interface(), &swp, false, &submenu_result));
			state = SELECT_ONE_PART;
		}
		else
		{
			swp = swi->first_part();
			load_software_part();
		}
		break;

	case SELECT_ONE_PART:
		switch(submenu_result) {
		case ui_menu_software_parts::T_ENTRY: {
			load_software_part();
			break;
		}

		case -1: // return to list
			state = SELECT_SOFTLIST;
			break;

		}
		break;

	case SELECT_OTHER_PART:
		switch(submenu_result) {
		case ui_menu_software_parts::T_ENTRY:
			load_software_part();
			break;

		case ui_menu_software_parts::T_FMGR:
			state = START_FILE;
			handle();
			break;

		case ui_menu_software_parts::T_EMPTY:
			image->unload();
			ui_menu::stack_pop(machine());
			break;

		case ui_menu_software_parts::T_SWLIST:
			state = START_SOFTLIST;
			handle();
			break;

		case -1: // return to system
			ui_menu::stack_pop(machine());
			break;

		}
		break;

	case SELECT_FILE:
		switch(submenu_result) {
		case ui_menu_file_selector::R_EMPTY:
			image->unload();
			ui_menu::stack_pop(machine());
			break;

		case ui_menu_file_selector::R_FILE:
			hook_load(current_file, false);
			break;

		case ui_menu_file_selector::R_CREATE:
			ui_menu::stack_push(global_alloc_clear<ui_menu_file_create>(machine(), container, image, current_directory, current_file, &create_ok));
			state = CHECK_CREATE;
			break;

		case ui_menu_file_selector::R_SOFTLIST:
			state = START_SOFTLIST;
			handle();
			break;

		case -1: // return to system
			ui_menu::stack_pop(machine());
			break;
		}
		break;

	case CREATE_FILE: {
		bool can_create, need_confirm;
		test_create(can_create, need_confirm);
		if(can_create) {
			if(need_confirm) {
				ui_menu::stack_push(global_alloc_clear<ui_menu_confirm_save_as>(machine(), container, &create_confirmed));
				state = CREATE_CONFIRM;
			} else {
				state = DO_CREATE;
				handle();
			}
		} else {
			state = START_FILE;
			handle();
		}
		break;
	}

	case CREATE_CONFIRM:
		state = create_confirmed ? DO_CREATE : START_FILE;
		handle();
		break;

	case CHECK_CREATE:
		state = create_ok ? CREATE_FILE : START_FILE;
		handle();
		break;

	case DO_CREATE: {
		std::string path;
		zippath_combine(path, current_directory.c_str(), current_file.c_str());
		int err = image->create(path.c_str(), nullptr, nullptr);
		if (err != 0)
			machine().popmessage("Error: %s", image->error());
		ui_menu::stack_pop(machine());
		break;
	}
	}
}