diff options
Diffstat (limited to 'src/emu/diimage.c')
-rw-r--r-- | src/emu/diimage.c | 622 |
1 files changed, 311 insertions, 311 deletions
diff --git a/src/emu/diimage.c b/src/emu/diimage.c index ef6614efaba..f4e7f547564 100644 --- a/src/emu/diimage.c +++ b/src/emu/diimage.c @@ -50,23 +50,23 @@ //************************************************************************** const image_device_type_info device_image_interface::m_device_info_array[] = { - { IO_UNKNOWN, "unknown", "unkn" }, - { IO_CARTSLOT, "cartridge", "cart" }, /* 0 */ - { IO_FLOPPY, "floppydisk", "flop" }, /* 1 */ - { IO_HARDDISK, "harddisk", "hard" }, /* 2 */ - { IO_CYLINDER, "cylinder", "cyln" }, /* 3 */ - { IO_CASSETTE, "cassette", "cass" }, /* 4 */ - { IO_PUNCHCARD, "punchcard", "pcrd" }, /* 5 */ - { IO_PUNCHTAPE, "punchtape", "ptap" }, /* 6 */ - { IO_PRINTER, "printer", "prin" }, /* 7 */ - { IO_SERIAL, "serial", "serl" }, /* 8 */ - { IO_PARALLEL, "parallel", "parl" }, /* 9 */ - { IO_SNAPSHOT, "snapshot", "dump" }, /* 10 */ - { IO_QUICKLOAD, "quickload", "quik" }, /* 11 */ - { IO_MEMCARD, "memcard", "memc" }, /* 12 */ + { IO_UNKNOWN, "unknown", "unkn" }, + { IO_CARTSLOT, "cartridge", "cart" }, /* 0 */ + { IO_FLOPPY, "floppydisk", "flop" }, /* 1 */ + { IO_HARDDISK, "harddisk", "hard" }, /* 2 */ + { IO_CYLINDER, "cylinder", "cyln" }, /* 3 */ + { IO_CASSETTE, "cassette", "cass" }, /* 4 */ + { IO_PUNCHCARD, "punchcard", "pcrd" }, /* 5 */ + { IO_PUNCHTAPE, "punchtape", "ptap" }, /* 6 */ + { IO_PRINTER, "printer", "prin" }, /* 7 */ + { IO_SERIAL, "serial", "serl" }, /* 8 */ + { IO_PARALLEL, "parallel", "parl" }, /* 9 */ + { IO_SNAPSHOT, "snapshot", "dump" }, /* 10 */ + { IO_QUICKLOAD, "quickload", "quik" }, /* 11 */ + { IO_MEMCARD, "memcard", "memc" }, /* 12 */ { IO_CDROM, "cdrom", "cdrm" }, /* 13 */ - { IO_MAGTAPE, "magtape", "magt" }, /* 14 */ - { IO_ROM, "romimage", "rom" }, /* 15 */ + { IO_MAGTAPE, "magtape", "magt" }, /* 14 */ + { IO_ROM, "romimage", "rom" }, /* 15 */ }; @@ -80,16 +80,16 @@ const image_device_type_info device_image_interface::m_device_info_array[] = device_image_interface::device_image_interface(const machine_config &mconfig, device_t &device) : device_interface(device), - m_file(NULL), - m_mame_file(NULL), - m_full_software_name(NULL), - m_software_info_ptr(NULL), - m_software_part_ptr(NULL), - m_software_list_name(NULL), - m_readonly(false), - m_created(false), - m_formatlist(NULL), - m_is_loading(FALSE) + m_file(NULL), + m_mame_file(NULL), + m_full_software_name(NULL), + m_software_info_ptr(NULL), + m_software_part_ptr(NULL), + m_software_list_name(NULL), + m_readonly(false), + m_created(false), + m_formatlist(NULL), + m_is_loading(FALSE) { } @@ -100,7 +100,7 @@ device_image_interface::device_image_interface(const machine_config &mconfig, de device_image_interface::~device_image_interface() { - image_device_format **formatptr = &m_formatlist; + image_device_format **formatptr = &m_formatlist; /* free all entries */ while (*formatptr != NULL) @@ -187,8 +187,8 @@ void device_image_interface::device_compute_hash(hash_collection &hashes, const image_error_t device_image_interface::set_image_filename(const char *filename) { - m_image_name = filename; - zippath_parent(m_working_directory, filename); + m_image_name = filename; + zippath_parent(m_working_directory, filename); m_basename.cpy(m_image_name); int loc1 = m_image_name.rchr(0,'\\'); @@ -215,7 +215,7 @@ image_error_t device_image_interface::set_image_filename(const char *filename) m_filetype = m_filetype.substr(loc + 1,m_filetype.len()-loc); } - return IMAGE_ERROR_SUCCESS; + return IMAGE_ERROR_SUCCESS; } /**************************************************************************** @@ -230,10 +230,10 @@ image_error_t device_image_interface::set_image_filename(const char *filename) const image_device_format *device_image_interface::device_get_indexed_creatable_format(int index) { - const image_device_format *format = device_get_creatable_formats(); - while(index-- && (format != NULL)) - format = format->m_next; - return format; + const image_device_format *format = device_get_creatable_formats(); + while(index-- && (format != NULL)) + format = format->m_next; + return format; } @@ -246,10 +246,10 @@ const image_device_format *device_image_interface::device_get_indexed_creatable_ const image_device_format *device_image_interface::device_get_named_creatable_format(const char *format_name) { - const image_device_format *format = device_get_creatable_formats(); - while((format != NULL) && strcmp(format->m_name, format_name)) - format = format->m_next; - return format; + const image_device_format *format = device_get_creatable_formats(); + while((format != NULL) && strcmp(format->m_name, format_name)) + format = format->m_next; + return format; } /**************************************************************************** @@ -263,11 +263,11 @@ const image_device_format *device_image_interface::device_get_named_creatable_fo void device_image_interface::clear_error() { - m_err = IMAGE_ERROR_SUCCESS; - if (m_err_message) - { - m_err_message.reset(); - } + m_err = IMAGE_ERROR_SUCCESS; + if (m_err_message) + { + m_err_message.reset(); + } } @@ -290,7 +290,7 @@ static const char *const messages[] = const char *device_image_interface::error() { - return (m_err_message) ? m_err_message.cstr() : messages[m_err]; + return (m_err_message) ? m_err_message.cstr() : messages[m_err]; } @@ -301,12 +301,12 @@ const char *device_image_interface::error() void device_image_interface::seterror(image_error_t err, const char *message) { - clear_error(); - m_err = err; - if (message != NULL) - { - m_err_message = message; - } + clear_error(); + m_err = err; + if (message != NULL) + { + m_err_message = message; + } } @@ -318,18 +318,18 @@ void device_image_interface::seterror(image_error_t err, const char *message) void device_image_interface::message(const char *format, ...) { - va_list args; - char buffer[256]; - - /* format the message */ - va_start(args, format); - vsnprintf(buffer, ARRAY_LENGTH(buffer), format, args); - va_end(args); - - /* display the popup for a standard amount of time */ - ui_popup_time(5, "%s: %s", - basename(), - buffer); + va_list args; + char buffer[256]; + + /* format the message */ + va_start(args, format); + vsnprintf(buffer, ARRAY_LENGTH(buffer), format, args); + va_end(args); + + /* display the popup for a standard amount of time */ + ui_popup_time(5, "%s: %s", + basename(), + buffer); } @@ -344,31 +344,31 @@ void device_image_interface::message(const char *format, ...) -------------------------------------------------*/ bool device_image_interface::try_change_working_directory(const char *subdir) { - osd_directory *directory; - const osd_directory_entry *entry; - bool success = FALSE; - bool done = FALSE; - - directory = osd_opendir(m_working_directory.cstr()); - if (directory != NULL) - { - while(!done && (entry = osd_readdir(directory)) != NULL) - { - if (!mame_stricmp(subdir, entry->name)) - { - done = TRUE; - success = entry->type == ENTTYPE_DIR; - } - } - - osd_closedir(directory); - } - - /* did we successfully identify the directory? */ - if (success) - zippath_combine(m_working_directory, m_working_directory, subdir); - - return success; + osd_directory *directory; + const osd_directory_entry *entry; + bool success = FALSE; + bool done = FALSE; + + directory = osd_opendir(m_working_directory.cstr()); + if (directory != NULL) + { + while(!done && (entry = osd_readdir(directory)) != NULL) + { + if (!mame_stricmp(subdir, entry->name)) + { + done = TRUE; + success = entry->type == ENTTYPE_DIR; + } + } + + osd_closedir(directory); + } + + /* did we successfully identify the directory? */ + if (success) + zippath_combine(m_working_directory, m_working_directory, subdir); + + return success; } /*------------------------------------------------- setup_working_directory - sets up the working @@ -380,19 +380,19 @@ void device_image_interface::setup_working_directory() char *dst = NULL; osd_get_full_path(&dst,"."); - /* first set up the working directory to be the starting directory */ - m_working_directory = dst; - - /* now try browsing down to "software" */ - if (try_change_working_directory("software")) - { - /* now down to a directory for this computer */ - int gamedrv = driver_list::find(device().machine().system()); - while(gamedrv != -1 && !try_change_working_directory(driver_list::driver(gamedrv).name)) - { - gamedrv = driver_list::compatible_with(gamedrv); - } - } + /* first set up the working directory to be the starting directory */ + m_working_directory = dst; + + /* now try browsing down to "software" */ + if (try_change_working_directory("software")) + { + /* now down to a directory for this computer */ + int gamedrv = driver_list::find(device().machine().system()); + while(gamedrv != -1 && !try_change_working_directory(driver_list::driver(gamedrv).name)) + { + gamedrv = driver_list::compatible_with(gamedrv); + } + } osd_free(dst); } @@ -404,11 +404,11 @@ void device_image_interface::setup_working_directory() const char * device_image_interface::working_directory() { - /* check to see if we've never initialized the working directory */ - if (!m_working_directory) - setup_working_directory(); + /* check to see if we've never initialized the working directory */ + if (!m_working_directory) + setup_working_directory(); - return m_working_directory; + return m_working_directory; } @@ -434,10 +434,10 @@ UINT8 *device_image_interface::get_software_region(const char *tag) UINT32 device_image_interface::get_software_region_length(const char *tag) { - char full_tag[256]; + char full_tag[256]; - sprintf( full_tag, "%s:%s", device().tag(), tag ); - return device().machine().root_device().memregion( full_tag )->bytes(); + sprintf( full_tag, "%s:%s", device().tag(), tag ); + return device().machine().root_device().memregion( full_tag )->bytes(); } @@ -469,66 +469,66 @@ const char *device_image_interface::get_feature(const char *feature_name) ****************************************************************************/ void device_image_interface::run_hash(void (*partialhash)(hash_collection &, const unsigned char *, unsigned long, const char *), - hash_collection &hashes, const char *types) + hash_collection &hashes, const char *types) { - UINT32 size; - UINT8 *buf = NULL; + UINT32 size; + UINT8 *buf = NULL; - hashes.reset(); - size = (UINT32) length(); + hashes.reset(); + size = (UINT32) length(); - buf = (UINT8*)malloc(size); + buf = (UINT8*)malloc(size); memset(buf,0,size); - /* read the file */ - fseek(0, SEEK_SET); - fread(buf, size); + /* read the file */ + fseek(0, SEEK_SET); + fread(buf, size); - if (partialhash) - partialhash(hashes, buf, size, types); - else - hashes.compute(buf, size, types); + if (partialhash) + partialhash(hashes, buf, size, types); + else + hashes.compute(buf, size, types); - /* cleanup */ - free(buf); - fseek(0, SEEK_SET); + /* cleanup */ + free(buf); + fseek(0, SEEK_SET); } void device_image_interface::image_checkhash() { - device_image_partialhash_func partialhash; + device_image_partialhash_func partialhash; - /* only calculate CRC if it hasn't been calculated, and the open_mode is read only */ - UINT32 crcval; - if (!m_hash.crc(crcval) && m_readonly && !m_created) - { - /* do not cause a linear read of 600 megs please */ - /* TODO: use SHA1 in the CHD header as the hash */ - if (image_type() == IO_CDROM) - return; + /* only calculate CRC if it hasn't been calculated, and the open_mode is read only */ + UINT32 crcval; + if (!m_hash.crc(crcval) && m_readonly && !m_created) + { + /* do not cause a linear read of 600 megs please */ + /* TODO: use SHA1 in the CHD header as the hash */ + if (image_type() == IO_CDROM) + return; /* Skip calculating the hash when we have an image mounted through a software list */ if ( m_software_info_ptr ) return; - /* retrieve the partial hash func */ - partialhash = get_partial_hash(); + /* retrieve the partial hash func */ + partialhash = get_partial_hash(); - run_hash(partialhash, m_hash, hash_collection::HASH_TYPES_ALL); - } - return; + run_hash(partialhash, m_hash, hash_collection::HASH_TYPES_ALL); + } + return; } UINT32 device_image_interface::crc() { - UINT32 crc = 0; + UINT32 crc = 0; image_checkhash(); - m_hash.crc(crc); + m_hash.crc(crc); - return crc; + return crc; } /**************************************************************************** @@ -547,9 +547,9 @@ UINT32 device_image_interface::crc() -------------------------------------------------*/ void device_image_interface::battery_load(void *buffer, int length, int fill) { - astring fname(device().machine().system().name, PATH_SEPARATOR, m_basename_noext, ".nv"); + astring fname(device().machine().system().name, PATH_SEPARATOR, m_basename_noext, ".nv"); - image_battery_load_by_name(device().machine().options(), fname, buffer, length, fill); + image_battery_load_by_name(device().machine().options(), fname, buffer, length, fill); } /*------------------------------------------------- @@ -560,9 +560,9 @@ void device_image_interface::battery_load(void *buffer, int length, int fill) -------------------------------------------------*/ void device_image_interface::battery_save(const void *buffer, int length) { - astring fname(device().machine().system().name, PATH_SEPARATOR, m_basename_noext, ".nv"); + astring fname(device().machine().system().name, PATH_SEPARATOR, m_basename_noext, ".nv"); - image_battery_save_by_name(device().machine().options(), fname, buffer, length); + image_battery_save_by_name(device().machine().options(), fname, buffer, length); } //------------------------------------------------- @@ -572,10 +572,10 @@ void device_image_interface::battery_save(const void *buffer, int length) bool device_image_interface::uses_file_extension(const char *file_extension) const { - bool result = FALSE; + bool result = FALSE; if (file_extension[0] == '.') - file_extension++; + file_extension++; /* find the extensions */ astring extensions(file_extensions()); @@ -583,13 +583,13 @@ bool device_image_interface::uses_file_extension(const char *file_extension) con while (ext != NULL) { if (!mame_stricmp(ext, file_extension)) - { - result = TRUE; - break; - } + { + result = TRUE; + break; + } ext = strtok (NULL, ","); } - return result; + return result; } /**************************************************************************** @@ -603,7 +603,7 @@ bool device_image_interface::uses_file_extension(const char *file_extension) con bool device_image_interface::is_loaded() { - return (m_file != NULL); + return (m_file != NULL); } /*------------------------------------------------- @@ -613,53 +613,53 @@ bool device_image_interface::is_loaded() image_error_t device_image_interface::load_image_by_path(UINT32 open_flags, const char *path) { - file_error filerr = FILERR_NOT_FOUND; - image_error_t err = IMAGE_ERROR_FILENOTFOUND; - astring revised_path; - - /* attempt to read the file */ - filerr = zippath_fopen(path, open_flags, m_file, revised_path); - - /* did the open succeed? */ - switch(filerr) - { - case FILERR_NONE: - /* success! */ - m_readonly = (open_flags & OPEN_FLAG_WRITE) ? 0 : 1; - m_created = (open_flags & OPEN_FLAG_CREATE) ? 1 : 0; - err = IMAGE_ERROR_SUCCESS; - break; - - case FILERR_NOT_FOUND: - case FILERR_ACCESS_DENIED: - /* file not found (or otherwise cannot open); continue */ - err = IMAGE_ERROR_FILENOTFOUND; - break; - - case FILERR_OUT_OF_MEMORY: - /* out of memory */ - err = IMAGE_ERROR_OUTOFMEMORY; - break; - - case FILERR_ALREADY_OPEN: - /* this shouldn't happen */ - err = IMAGE_ERROR_ALREADYOPEN; - break; - - case FILERR_FAILURE: - case FILERR_TOO_MANY_FILES: - case FILERR_INVALID_DATA: - default: - /* other errors */ - err = IMAGE_ERROR_INTERNAL; - break; - } - - /* if successful, set the file name */ - if (filerr == FILERR_NONE) - set_image_filename(revised_path); - - return err; + file_error filerr = FILERR_NOT_FOUND; + image_error_t err = IMAGE_ERROR_FILENOTFOUND; + astring revised_path; + + /* attempt to read the file */ + filerr = zippath_fopen(path, open_flags, m_file, revised_path); + + /* did the open succeed? */ + switch(filerr) + { + case FILERR_NONE: + /* success! */ + m_readonly = (open_flags & OPEN_FLAG_WRITE) ? 0 : 1; + m_created = (open_flags & OPEN_FLAG_CREATE) ? 1 : 0; + err = IMAGE_ERROR_SUCCESS; + break; + + case FILERR_NOT_FOUND: + case FILERR_ACCESS_DENIED: + /* file not found (or otherwise cannot open); continue */ + err = IMAGE_ERROR_FILENOTFOUND; + break; + + case FILERR_OUT_OF_MEMORY: + /* out of memory */ + err = IMAGE_ERROR_OUTOFMEMORY; + break; + + case FILERR_ALREADY_OPEN: + /* this shouldn't happen */ + err = IMAGE_ERROR_ALREADYOPEN; + break; + + case FILERR_FAILURE: + case FILERR_TOO_MANY_FILES: + case FILERR_INVALID_DATA: + default: + /* other errors */ + err = IMAGE_ERROR_INTERNAL; + break; + } + + /* if successful, set the file name */ + if (filerr == FILERR_NONE) + set_image_filename(revised_path); + + return err; } int device_image_interface::reopen_for_write(const char *path) @@ -667,53 +667,53 @@ int device_image_interface::reopen_for_write(const char *path) if(m_file) core_fclose(m_file); - file_error filerr = FILERR_NOT_FOUND; - image_error_t err = IMAGE_ERROR_FILENOTFOUND; - astring revised_path; - - /* attempt to open the file for writing*/ - filerr = zippath_fopen(path, OPEN_FLAG_READ|OPEN_FLAG_WRITE|OPEN_FLAG_CREATE, m_file, revised_path); - - /* did the open succeed? */ - switch(filerr) - { - case FILERR_NONE: - /* success! */ - m_readonly = 0; - m_created = 1; - err = IMAGE_ERROR_SUCCESS; - break; - - case FILERR_NOT_FOUND: - case FILERR_ACCESS_DENIED: - /* file not found (or otherwise cannot open); continue */ - err = IMAGE_ERROR_FILENOTFOUND; - break; - - case FILERR_OUT_OF_MEMORY: - /* out of memory */ - err = IMAGE_ERROR_OUTOFMEMORY; - break; - - case FILERR_ALREADY_OPEN: - /* this shouldn't happen */ - err = IMAGE_ERROR_ALREADYOPEN; - break; - - case FILERR_FAILURE: - case FILERR_TOO_MANY_FILES: - case FILERR_INVALID_DATA: - default: - /* other errors */ - err = IMAGE_ERROR_INTERNAL; - break; - } - - /* if successful, set the file name */ - if (filerr == FILERR_NONE) - set_image_filename(revised_path); - - return err; + file_error filerr = FILERR_NOT_FOUND; + image_error_t err = IMAGE_ERROR_FILENOTFOUND; + astring revised_path; + + /* attempt to open the file for writing*/ + filerr = zippath_fopen(path, OPEN_FLAG_READ|OPEN_FLAG_WRITE|OPEN_FLAG_CREATE, m_file, revised_path); + + /* did the open succeed? */ + switch(filerr) + { + case FILERR_NONE: + /* success! */ + m_readonly = 0; + m_created = 1; + err = IMAGE_ERROR_SUCCESS; + break; + + case FILERR_NOT_FOUND: + case FILERR_ACCESS_DENIED: + /* file not found (or otherwise cannot open); continue */ + err = IMAGE_ERROR_FILENOTFOUND; + break; + + case FILERR_OUT_OF_MEMORY: + /* out of memory */ + err = IMAGE_ERROR_OUTOFMEMORY; + break; + + case FILERR_ALREADY_OPEN: + /* this shouldn't happen */ + err = IMAGE_ERROR_ALREADYOPEN; + break; + + case FILERR_FAILURE: + case FILERR_TOO_MANY_FILES: + case FILERR_INVALID_DATA: + default: + /* other errors */ + err = IMAGE_ERROR_INTERNAL; + break; + } + + /* if successful, set the file name */ + if (filerr == FILERR_NONE) + set_image_filename(revised_path); + + return err; } /*------------------------------------------------- @@ -723,18 +723,18 @@ int device_image_interface::reopen_for_write(const char *path) void device_image_interface::determine_open_plan(int is_create, UINT32 *open_plan) { - int i = 0; - - /* emit flags */ - if (!is_create && is_readable() && is_writeable()) - open_plan[i++] = OPEN_FLAG_READ | OPEN_FLAG_WRITE; - if (!is_create && !is_readable() && is_writeable()) - open_plan[i++] = OPEN_FLAG_WRITE; - if (!is_create && is_readable()) - open_plan[i++] = OPEN_FLAG_READ; - if (is_writeable() && is_creatable()) - open_plan[i++] = OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE; - open_plan[i] = 0; + int i = 0; + + /* emit flags */ + if (!is_create && is_readable() && is_writeable()) + open_plan[i++] = OPEN_FLAG_READ | OPEN_FLAG_WRITE; + if (!is_create && !is_readable() && is_writeable()) + open_plan[i++] = OPEN_FLAG_WRITE; + if (!is_create && is_readable()) + open_plan[i++] = OPEN_FLAG_READ; + if (is_writeable() && is_creatable()) + open_plan[i++] = OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE; + open_plan[i] = 0; } /*------------------------------------------------- @@ -896,7 +896,7 @@ bool device_image_interface::load_software(char *swlist, char *swname, rom_entry break; // load first item for start } - romp++; /* something else; skip */ + romp++; /* something else; skip */ } } if (warningcount > 0) @@ -912,8 +912,8 @@ bool device_image_interface::load_software(char *swlist, char *swname, rom_entry 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; + UINT32 open_plan[4]; + int i; bool softload = FALSE; m_from_swlist = FALSE; @@ -921,20 +921,20 @@ bool device_image_interface::load_internal(const char *path, bool is_create, int astring pathstr(path); bool filename_has_period = (pathstr.rchr(0, '.') != -1) ? TRUE : FALSE; - /* first unload the image */ - unload(); + /* first unload the image */ + unload(); - /* clear any possible error messages */ - clear_error(); + /* clear any possible error messages */ + clear_error(); - /* we are now loading */ - m_is_loading = TRUE; + /* we are now loading */ + m_is_loading = TRUE; - /* record the filename */ - m_err = set_image_filename(path); + /* record the filename */ + m_err = set_image_filename(path); - if (m_err) - goto done; + 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) @@ -988,14 +988,14 @@ bool device_image_interface::load_internal(const char *path, bool is_create, int if (m_err) goto done; } - /* success! */ + /* success! */ done: if (just_load) { if(m_err) clear(); return m_err ? IMAGE_INIT_FAIL : IMAGE_INIT_PASS; } - if (m_err!=0) { + if (m_err!=0) { if (!m_init_phase) { if (device().machine().phase() == MACHINE_PHASE_RUNNING) @@ -1031,7 +1031,7 @@ done: bool device_image_interface::load(const char *path) { - return load_internal(path, FALSE, 0, NULL, FALSE); + return load_internal(path, FALSE, 0, NULL, FALSE); } /*------------------------------------------------- @@ -1059,40 +1059,40 @@ bool device_image_interface::open_image_file(emu_options &options) bool device_image_interface::finish_load() { - bool err = IMAGE_INIT_PASS; + bool err = IMAGE_INIT_PASS; - if (m_is_loading) - { + if (m_is_loading) + { image_checkhash(); if (m_from_swlist) call_display_info(); if (has_been_created()) - { - err = call_create(m_create_format, m_create_args); - if (err) - { - if (!m_err) - m_err = IMAGE_ERROR_UNSPECIFIED; - } - } - else - { - /* using device load */ - err = call_load(); - if (err) - { - if (!m_err) - m_err = IMAGE_ERROR_UNSPECIFIED; - } - } - } - m_is_loading = FALSE; - m_create_format = 0; - m_create_args = NULL; + { + err = call_create(m_create_format, m_create_args); + if (err) + { + if (!m_err) + m_err = IMAGE_ERROR_UNSPECIFIED; + } + } + else + { + /* using device load */ + err = call_load(); + if (err) + { + if (!m_err) + m_err = IMAGE_ERROR_UNSPECIFIED; + } + } + } + m_is_loading = FALSE; + m_create_format = 0; + m_create_args = NULL; m_init_phase = FALSE; - return err; + return err; } /*------------------------------------------------- @@ -1101,8 +1101,8 @@ bool device_image_interface::finish_load() bool device_image_interface::create(const char *path, const image_device_format *create_format, option_resolution *create_args) { - int format_index = (create_format != NULL) ? create_format->m_index : 0; - return load_internal(path, TRUE, format_index, create_args, FALSE); + int format_index = (create_format != NULL) ? create_format->m_index : 0; + return load_internal(path, TRUE, format_index, create_args, FALSE); } @@ -1114,7 +1114,7 @@ bool device_image_interface::create(const char *path, const image_device_format void device_image_interface::clear() { if (m_mame_file) - { + { global_free(m_mame_file); m_mame_file = NULL; m_file = NULL; @@ -1126,15 +1126,15 @@ void device_image_interface::clear() } } - m_image_name.reset(); - m_readonly = false; - m_created = false; + m_image_name.reset(); + m_readonly = false; + m_created = false; - m_longname.reset(); - m_manufacturer.reset(); - m_year.reset(); + m_longname.reset(); + m_manufacturer.reset(); + m_year.reset(); m_basename.reset(); - m_basename_noext.reset(); + m_basename_noext.reset(); m_filetype.reset(); m_full_software_name = NULL; @@ -1153,7 +1153,7 @@ void device_image_interface::unload() { call_unload(); } - clear(); + clear(); clear_error(); } |