Permalink
Browse files

Merge pull request #1370 from npwoods/conditionally_support_cmdline_i…

…magecreate

Allows devices to indicate whether image creation should be supported at the command line
  • Loading branch information...
cuavas committed Sep 9, 2016
2 parents 211e5f5 + 98df223 commit c083e36c41bba27522364c0c05e5c95aeb1c94e8
Showing with 44 additions and 0 deletions.
  1. +38 −0 src/emu/diimage.cpp
  2. +2 −0 src/emu/diimage.h
  3. +4 −0 src/emu/image.cpp
View
@@ -539,6 +539,34 @@ UINT32 device_image_interface::crc()
return crc;
}
//-------------------------------------------------
// support_command_line_image_creation - do we
// want to support image creation from the front
// end command line?
//-------------------------------------------------
bool device_image_interface::support_command_line_image_creation() const
{
bool result;
switch (image_type())
{
case IO_PRINTER:
case IO_SERIAL:
case IO_PARALLEL:
// going by the assumption that these device image types should support this
// behavior; ideally we'd get rid of IO_* and just push this to the specific
// devices
result = true;
break;
default:
result = false;
break;
}
return result;
}
// ****************************************************************************
// Battery functions
//
@@ -1158,6 +1186,16 @@ image_init_result device_image_interface::finish_load()
}
//-------------------------------------------------
// create - create a image
//-------------------------------------------------
image_init_result device_image_interface::create(const std::string &path)
{
return create(path, nullptr, nullptr);
}
//-------------------------------------------------
// create - create a image
//-------------------------------------------------
View
@@ -158,6 +158,7 @@ class device_image_interface : public device_interface
virtual bool is_creatable() const = 0;
virtual bool must_be_loaded() const = 0;
virtual bool is_reset_on_load() const = 0;
virtual bool support_command_line_image_creation() const;
virtual const char *image_interface() const { return nullptr; }
virtual const char *file_extensions() const = 0;
virtual const option_guide *create_option_guide() const { return nullptr; }
@@ -235,6 +236,7 @@ class device_image_interface : public device_interface
image_init_result finish_load();
void unload();
image_init_result create(const std::string &path, const image_device_format *create_format, util::option_resolution *create_args);
image_init_result create(const std::string &path);
bool load_software(software_list_device &swlist, const char *swname, const rom_entry *entry);
int reopen_for_write(const std::string &path);
View
@@ -55,6 +55,10 @@ image_manager::image_manager(running_machine &machine)
if (result != image_init_result::PASS)
result = image.load(image_name);
// failing that, try creating it (if appropriate)
if (result != image_init_result::PASS && image.support_command_line_image_creation())
result = image.create(image_name);
// did the image load fail?
if (result != image_init_result::PASS)
{

0 comments on commit c083e36

Please sign in to comment.