diff options
| author | 2016-07-30 10:59:54 -0400 | |
|---|---|---|
| committer | 2016-07-30 10:59:54 -0400 | |
| commit | 81c8de57ca596c2bf186d79636ec3c7d8fc56b69 (patch) | |
| tree | a0b5f356516a9e3d68badcac57d944677cd608e9 /src/emu/image.cpp | |
| parent | d59b0a1a5157c487bf591867c9de0b666a6552df (diff) | |
Changed device_image_interface::load() so that it is no longer responsible for both loading images and softlist items; now the latter
is done through a new method - device_image_interface::load_software()
Diffstat (limited to 'src/emu/image.cpp')
| -rw-r--r-- | src/emu/image.cpp | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/src/emu/image.cpp b/src/emu/image.cpp index 707c36ba0a5..129fc197717 100644 --- a/src/emu/image.cpp +++ b/src/emu/image.cpp @@ -2,13 +2,15 @@ // copyright-holders:Nathan Woods, Miodrag Milanovic /*************************************************************************** - image.c + image.cpp Core image functions and definitions. ***************************************************************************/ + #include <ctype.h> +#include <regex> #include "emu.h" #include "emuopts.h" @@ -17,6 +19,13 @@ #include "xmlfile.h" //************************************************************************** +// STATIC VARIABLES +//************************************************************************** + +static std::regex s_softlist_regex("\\w+\\:\\w+\\:\\w+"); + + +//************************************************************************** // IMAGE MANAGER //************************************************************************** @@ -27,35 +36,42 @@ image_manager::image_manager(running_machine &machine) : m_machine(machine) { - /* make sure that any required devices have been allocated */ + // 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()); + // ignore things not user loadable if (!image.user_loadable()) continue; - if ((image_name != nullptr) && (image_name[0] != '\0')) + // is an image specified for this image + const char *image_name_ptr = machine.options().value(image.instance_name()); + if ((image_name_ptr != nullptr) && (image_name_ptr[0] != '\0')) { - /* mark init state */ + std::string image_name(image_name_ptr); + + // mark init state image.set_init_phase(); - /* try to load this image */ - bool result = image.load(image_name); + // is this image really a softlist part? + bool is_softlist_part = std::regex_match(image_name, s_softlist_regex); + + // try to load this image + bool result = is_softlist_part + ? image.load_software(image_name) + : image.load(image_name.c_str()); - /* did the image load fail? */ + // did the image load fail? if (result) { - /* retrieve image error message */ + // retrieve image error message std::string image_err = std::string(image.error()); - std::string image_basename(image_name); - /* unload all images */ + // 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_name.c_str(), image_err.c_str()); } } |
