trunk/src/emu/imagedev/floppy.c
r32446 | r32447 | |
871 | 871 | } |
872 | 872 | } |
873 | 873 | |
874 | | astring ui_menu_control_floppy_image::try_file(astring location, astring name, bool has_crc, UINT32 crc) |
875 | | { |
876 | | emu_file fd(machine().options().media_path(), OPEN_FLAG_READ); |
877 | | file_error filerr; |
878 | | if(has_crc) |
879 | | filerr = fd.open(location.cstr(), PATH_SEPARATOR, name.cstr(), crc); |
880 | | else |
881 | | filerr = fd.open(location.cstr(), PATH_SEPARATOR, name.cstr()); |
882 | | if(filerr != FILERR_NONE) |
883 | | return ""; |
884 | | return fd.fullpath(); |
885 | | } |
886 | | |
887 | 874 | void ui_menu_control_floppy_image::hook_load(astring filename, bool softlist) |
888 | 875 | { |
889 | | input_filename = filename; |
890 | 876 | if (softlist) |
891 | 877 | { |
892 | | astring swlist_name, swinfo_name, swpart_name; |
893 | | device_image_interface::software_name_split(filename.cstr(), swlist_name, swinfo_name, swpart_name); |
894 | | software_list_device *swlistdev = software_list_device::find_by_name(machine().config(), swlist_name); |
895 | | software_info *swinfo = swlistdev->find(swinfo_name); |
896 | | software_part *swpart = swinfo->find_part(swpart_name); |
897 | | const char *parentname = swinfo->parentname(); |
898 | | for(const rom_entry *region = swpart->romdata(); region; region = rom_next_region(region)) { |
899 | | const rom_entry *romp = region + 1; |
900 | | UINT32 crc = 0; |
901 | | bool has_crc = hash_collection(ROM_GETHASHDATA(romp)).crc(crc); |
902 | | |
903 | | filename = try_file(astring(swlistdev->list_name()) + PATH_SEPARATOR + astring(swinfo_name), ROM_GETNAME(romp), has_crc, crc); |
904 | | if(filename == "" && parentname) |
905 | | filename = try_file(astring(swlist_name) + PATH_SEPARATOR + astring(parentname), ROM_GETNAME(romp), has_crc, crc); |
906 | | if(filename == "") |
907 | | filename = try_file(swinfo_name, ROM_GETNAME(romp), has_crc, crc); |
908 | | if(filename == "" && parentname) |
909 | | filename = try_file(parentname, ROM_GETNAME(romp), has_crc, crc); |
910 | | if(filename != "") |
911 | | break; |
912 | | } |
| 878 | popmessage("When loaded from software list, the disk is Read-only.\n"); |
| 879 | image->load(filename); |
| 880 | ui_menu::stack_pop(machine()); |
| 881 | return; |
913 | 882 | } |
914 | 883 | |
| 884 | input_filename = filename; |
915 | 885 | input_format = static_cast<floppy_image_device *>(image)->identify(filename); |
916 | | if(!input_format) { |
| 886 | |
| 887 | if (!input_format) |
| 888 | { |
917 | 889 | popmessage("Error: %s\n", image->error()); |
918 | 890 | ui_menu::stack_pop(machine()); |
919 | 891 | return; |