Previous 199869 Revisions Next

r32447 Sunday 28th September, 2014 at 08:25:23 UTC by Fabio Priuli
(MESS) floppy.c: fixed disks not being launched if loaded
from softlist through File Manager. [Fabio Priuli]

out of whatsnew: until we support writing changes to diff, it is
also safer to treat disks in softlists as read-only :)
[src/emu/imagedev]floppy.c floppy.h

trunk/src/emu/imagedev/floppy.c
r32446r32447
871871   }
872872}
873873
874astring 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
887874void ui_menu_control_floppy_image::hook_load(astring filename, bool softlist)
888875{
889   input_filename = filename;
890876   if (softlist)
891877   {
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;
913882   }
914883
884   input_filename = filename;
915885   input_format = static_cast<floppy_image_device *>(image)->identify(filename);
916   if(!input_format) {
886
887   if (!input_format)
888   {
917889      popmessage("Error: %s\n", image->error());
918890      ui_menu::stack_pop(machine());
919891      return;
trunk/src/emu/imagedev/floppy.h
r32446r32447
198198
199199   void do_load_create();
200200   virtual void hook_load(astring filename, bool softlist);
201   astring try_file(astring location, astring name, bool has_crc, UINT32 crc);
202201};
203202
204203

Previous 199869 Revisions Next


© 1997-2024 The MAME Team