src/mess/tools/messtest/testmess.c
| r8345 | r8346 | |
| 356 | 356 | /* get the path */ |
| 357 | 357 | fullpath = assemble_software_path(astring_alloc(), driver, current_command->u.image_args.filename); |
| 358 | 358 | |
| 359 | | /* get the option name */ |
| 360 | | device_opt = device_typename(current_command->u.image_args.device_ident.type); |
| 359 | /* get the option name */ |
| 360 | device_opt = device_config_image_interface::device_typename(current_command->u.image_args.device_ident.type); |
| 361 | 361 | |
| 362 | 362 | /* set the option */ |
| 363 | 363 | options_set_string(opts, device_opt, astring_c(fullpath), OPTION_PRIORITY_CMDLINE); |
| r8345 | r8346 | |
| 493 | 493 | |
| 494 | 494 | /* find switch with the name */ |
| 495 | 495 | found = FALSE; |
| 496 | | for (port = machine->portlist.first(); !found && (port != NULL); port = port->next) |
| 496 | for (port = machine->portlist.first(); !found && (port != NULL); port = port->next()) |
| 497 | 497 | { |
| 498 | 498 | for (field = port->fieldlist; !found && (field != NULL); field = field->next) |
| 499 | 499 | { |
| r8345 | r8346 | |
| 701 | 701 | |
| 702 | 702 | |
| 703 | 703 | |
| 704 | | static running_device *find_device_by_identity(running_machine *machine, const messtest_device_identity *ident) |
| 704 | static device_image_interface *find_device_by_identity(running_machine *machine, const messtest_device_identity *ident) |
| 705 | 705 | { |
| 706 | | running_device *device = NULL; |
| 706 | device_image_interface *device = NULL; |
| 707 | 707 | |
| 708 | 708 | /* look up the image slot */ |
| 709 | 709 | if (ident->type == IO_UNKNOWN) |
| 710 | 710 | { |
| 711 | 711 | /* no device_type was specified; use the new preferred mechanism */ |
| 712 | | device = devtag_get_device(machine, ident->tag); |
| 712 | device = dynamic_cast<device_image_interface *>(devtag_get_device(machine, ident->tag)); |
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | /* did the image slot lookup fail? */ |
| r8345 | r8346 | |
| 717 | 717 | { |
| 718 | 718 | state = STATE_ABORTED; |
| 719 | 719 | report_message(MSG_FAILURE, "Device '%s %i' does not exist", |
| 720 | | device_typename(ident->type), ident->slot); |
| 720 | device_config_image_interface::device_typename(ident->type), ident->slot); |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | return device; |
| r8345 | r8346 | |
| 727 | 727 | |
| 728 | 728 | static void command_image_loadcreate(running_machine *machine) |
| 729 | 729 | { |
| 730 | | running_device *image; |
| 730 | device_image_interface *image; |
| 731 | 731 | const char *filename; |
| 732 | 732 | const char *format_name; |
| 733 | 733 | char buf[128]; |
| 734 | | image_device_info info; |
| 735 | 734 | const char *file_extensions; |
| 736 | 735 | astring *filepath; |
| 737 | 736 | int success; |
| r8345 | r8346 | |
| 743 | 742 | if (image == NULL) |
| 744 | 743 | return; |
| 745 | 744 | |
| 746 | | info = image_device_getinfo(machine->config, image); |
| 747 | | file_extensions = info.file_extensions; |
| 745 | file_extensions = image->image_config().file_extensions(); |
| 748 | 746 | |
| 749 | 747 | /* is an image format specified? */ |
| 750 | 748 | format_name = current_command->u.image_args.format; |
| r8345 | r8346 | |
| 758 | 756 | } |
| 759 | 757 | |
| 760 | 758 | /* look up the format name */ |
| 761 | | format = image_device_get_named_creatable_format(image, format_name); |
| 759 | format = image->device_get_named_creatable_format(format_name); |
| 762 | 760 | if (format == NULL) |
| 763 | 761 | { |
| 764 | 762 | state = STATE_ABORTED; |
| r8345 | r8346 | |
| 787 | 785 | switch(current_command->command_type) |
| 788 | 786 | { |
| 789 | 787 | case MESSTEST_COMMAND_IMAGE_CREATE: |
| 790 | | success = (image_create(image, astring_c(filepath), format, NULL) == IMAGE_INIT_PASS); |
| 788 | success = (image->create(astring_c(filepath), format, NULL) == IMAGE_INIT_PASS); |
| 791 | 789 | break; |
| 792 | 790 | |
| 793 | 791 | case MESSTEST_COMMAND_IMAGE_LOAD: |
| 794 | | success = (image_load(image, astring_c(filepath)) == IMAGE_INIT_PASS); |
| 792 | success = (image->load(astring_c(filepath)) == IMAGE_INIT_PASS); |
| 795 | 793 | break; |
| 796 | 794 | |
| 797 | 795 | default: |
| r8345 | r8346 | |
| 803 | 801 | if (!success) |
| 804 | 802 | { |
| 805 | 803 | state = STATE_ABORTED; |
| 806 | | report_message(MSG_FAILURE, "Failed to load/create image '%s': %s", filename, image_error(image)); |
| 804 | report_message(MSG_FAILURE, "Failed to load/create image '%s': %s", filename, image->error()); |
| 807 | 805 | return; |
| 808 | 806 | } |
| 809 | 807 | } |
| r8345 | r8346 | |
| 879 | 877 | size_t verify_data_size; |
| 880 | 878 | size_t offset, offset_start, offset_end; |
| 881 | 879 | const char *filename; |
| 882 | | running_device *image; |
| 880 | device_image_interface *image; |
| 883 | 881 | FILE *f; |
| 884 | 882 | UINT8 c; |
| 885 | 883 | char filename_buf[512]; |
| r8345 | r8346 | |
| 892 | 890 | if (image == NULL) |
| 893 | 891 | return; |
| 894 | 892 | |
| 895 | | filename = image_filename(image); |
| 893 | filename = image->filename(); |
| 896 | 894 | if (filename == NULL) |
| 897 | 895 | { |
| 898 | 896 | state = STATE_ABORTED; |
| r8345 | r8346 | |
| 903 | 901 | /* very dirty hack - we unload the image because we cannot access it |
| 904 | 902 | * because the file is locked */ |
| 905 | 903 | strcpy(filename_buf, filename); |
| 906 | | image_unload(image); |
| 904 | image->unload(); |
| 907 | 905 | filename = filename_buf; |
| 908 | 906 | |
| 909 | 907 | f = fopen(filename, "r"); |
| r8345 | r8346 | |
| 1248 | 1246 | { |
| 1249 | 1247 | s2 = attr_node->value; |
| 1250 | 1248 | |
| 1251 | | ident->type = device_typeid(s2); |
| 1249 | ident->type = device_config_image_interface::device_typeid(s2); |
| 1252 | 1250 | if (ident->type <= IO_UNKNOWN) |
| 1253 | 1251 | { |
| 1254 | 1252 | error_baddevicetype(s2); |