software_config *software_config_alloc(int driver_index) //, hashfile_error_func error_proc) { const game_driver *driver; software_config *config; // allocate the software_config config = (software_config *)malloc(sizeof(software_config)); memset(config,0,sizeof(software_config)); // allocate the machine config windows_options pCurrentOpts; load_options(pCurrentOpts, OPTIONS_GLOBAL, driver_index); config->mconfig = global_alloc(machine_config(*drivers[driver_index],pCurrentOpts)); // allocate the hash file driver = drivers[driver_index]; while (driver) //&& (!config->hashfile)) { //config->hashfile = hashfile_open(*opts, driver->name, TRUE, error_proc); driver = driver_get_compatible(driver); } // other stuff config->driver_index = driver_index; config->gamedrv = drivers[driver_index]; return config; }
static void command_image_loadcreate(running_machine &machine) { device_image_interface *image; const char *filename; const char *format_name; char buf[128]; const char *file_extensions; astring *filepath; int success; const game_driver *gamedrv; const image_device_format *format = NULL; /* look up the image slot */ image = find_device_by_identity(machine, ¤t_command->u.image_args.device_ident); if (image == NULL) return; file_extensions = image->image_config().file_extensions(); /* is an image format specified? */ format_name = current_command->u.image_args.format; if (format_name != NULL) { if (current_command->command_type != MESSTEST_COMMAND_IMAGE_CREATE) { state = STATE_ABORTED; report_message(MSG_FAILURE, "Cannot specify format unless creating"); return; } /* look up the format name */ format = image->device_get_named_creatable_format(format_name); if (format == NULL) { state = STATE_ABORTED; report_message(MSG_FAILURE, "Unknown device format '%s'", format_name); return; } } /* figure out the filename */ filename = current_command->u.image_args.filename; if (!filename) { snprintf(buf, ARRAY_LENGTH(buf), "%s.%s", current_testcase.name, file_extensions); //osd_get_temp_filename(buf, ARRAY_LENGTH(buf), buf); filename = buf; } success = FALSE; for (gamedrv = machine.system(); !success && gamedrv; gamedrv = driver_get_compatible(gamedrv)) { /* assemble the full path */ filepath = assemble_software_path(astring_alloc(), gamedrv, filename); /* actually create or load the image */ switch(current_command->command_type) { case MESSTEST_COMMAND_IMAGE_CREATE: success = (image->create(astring_c(filepath), format, NULL) == IMAGE_INIT_PASS); break; case MESSTEST_COMMAND_IMAGE_LOAD: success = (image->load(astring_c(filepath)) == IMAGE_INIT_PASS); break; default: fatalerror("Unexpected error"); break; } astring_free(filepath); } if (!success) { state = STATE_ABORTED; report_message(MSG_FAILURE, "Failed to load/create image '%s': %s", filename, image->error()); return; } }