From 7cd142d28d2d7ca416696c0ec96d6640ed5be647 Mon Sep 17 00:00:00 2001 From: "R. Belmont" Date: Sat, 12 Jan 2013 04:46:30 +0000 Subject: [PATCH] diimage: allow image devices to skip core fopen() of the image's filename and handle themselves in call_load() [R. Belmont] --- src/emu/diimage.c | 75 ++++++++++++++++++++++++----------------------- src/emu/diimage.h | 1 + 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/src/emu/diimage.c b/src/emu/diimage.c index f4e7f547564..a8c921d6e4a 100644 --- a/src/emu/diimage.c +++ b/src/emu/diimage.c @@ -936,47 +936,50 @@ bool device_image_interface::load_internal(const char *path, bool is_create, int 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) + if (core_opens_image_file()) { - 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++) + /* 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) { - /* open the file */ - m_err = load_image_by_path(open_plan[i], path); - if (m_err && (m_err != IMAGE_ERROR_FILENOTFOUND)) - goto done; + 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; } - } - /* 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; - } + if (is_create || filename_has_period) + { + /* determine open plan */ + determine_open_plan(is_create, open_plan); - /* did we fail to find the file? */ - if (!is_loaded() && !softload) - { - m_err = IMAGE_ERROR_FILENOTFOUND; - goto done; + /* 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 */ diff --git a/src/emu/diimage.h b/src/emu/diimage.h index fdd9b87c27a..8b17f4f6587 100644 --- a/src/emu/diimage.h +++ b/src/emu/diimage.h @@ -154,6 +154,7 @@ public: virtual void call_display() { } virtual void call_display_info() { } virtual device_image_partialhash_func get_partial_hash() const { return NULL; } + virtual bool core_opens_image_file() const { return TRUE; } virtual iodevice_t image_type() const = 0; virtual bool is_readable() const = 0; virtual bool is_writeable() const = 0;