Previous 15994 Revisions Next

r10016 Wednesday 12th January, 2011 at 22:21:30 UTC by Fabio Priuli
Added a new template to -snapname to use software names for snapshots.
It is now possible to save snaps whose names are based on software filenames
(both softlists and fullpath loading supported). Read messnew.txt for details.
[docs]messnew.txt
[src/emu]video.c

src/emu/video.c
r10015r10016
11011101{
11021102   // handle defaults
11031103   const char *snapname = options_get_string(m_machine.options(), OPTION_SNAPNAME);
1104
11041105   if (snapname == NULL || snapname[0] == 0)
11051106      snapname = "%g/%i";
11061107   astring snapstr(snapname);
11071108
1108   // strip any extension in the provided name and add our own
1109   // strip any extension in the provided name
11091110   int index = snapstr.rchr(0, '.');
11101111   if (index != -1)
11111112      snapstr.substr(0, index);
1113
1114   // handle %d in the template (for image devices)
1115   astring snapdev("%d_");
1116   int pos = snapstr.find(0, snapdev);
1117
1118   if (pos != -1)
1119   {
1120      // if more %d are found, revert to default and ignore them all
1121      if (snapstr.find(pos + 3, snapdev) != -1)
1122         snapstr.cpy("%g/%i");
1123      // else if there is a single %d, try to create the correct snapname
1124      else
1125      {
1126         int name_found = 0;
1127
1128         // find length of the device name
1129         int end1 = snapstr.find(pos + 3, "/");
1130         int end2 = snapstr.find(pos + 3, "%");
1131         int end = -1;
1132
1133         if ((end1 != -1) && (end2 != -1))
1134            end = MIN(end1, end2);
1135         else if (end1 != -1)
1136            end = end1;
1137         else if (end2 != -1)
1138            end = end2;
1139         else
1140            end = snapstr.len();
1141
1142         if (end - pos < 3)
1143            fatalerror("Something very wrong is going on!!!");
1144
1145         // copy the device name to an astring
1146         astring snapdevname;
1147         snapdevname.cpysubstr(snapstr, pos + 3, end - pos - 3);
1148         //printf("check template: %s\n", snapdevname.cstr());
1149
1150         // verify that there is such a device for this system
1151         device_image_interface *image = NULL;
1152         for (bool gotone = m_machine.m_devicelist.first(image); gotone; gotone = image->next(image))
1153         {
1154            // get the device name
1155            astring tempdevname(image->image_config().brief_instance_name());
1156            //printf("check device: %s\n", tempdevname.cstr());
1157
1158            if (snapdevname.cmp(tempdevname) == 0)
1159            {
1160               // verify that such a device has an image mounted
1161               if (image->basename() != NULL)
1162               {
1163                  astring filename(image->basename());
1164
1165                  // strip extension
1166                  filename.substr(0, filename.rchr(0, '.'));
1167
1168                  // setup snapname and remove the %d_
1169                  snapstr.replace(0, snapdevname, filename);
1170                  snapstr.del(pos, 3);
1171                  //printf("check image: %s\n", filename.cstr());
1172
1173                  name_found = 1;
1174               }
1175            }
1176         }
1177
1178         // or fallback to default
1179         if (name_found == 0)
1180            snapstr.cpy("%g/%i");
1181      }
1182   }
1183
1184   // add our own extension
11121185   snapstr.cat(".").cat(extension);
11131186
11141187   // substitute path and gamename up front
docs/messnew.txt
r10015r10016
10.141.1
10.141.1
22
33New System Drivers Supported:
44-----------------------------
r10015r10016
3333
3434Source Changes:
3535----------------
36- Added support for a new template to -snapname to use software names for
37  snapshots. It is now possible to use %d_XXXX to name snaps after the name
38  of the file mounted in the device XXXX, being XXXX the brief name of any
39  device. E.g. you can use "-snapname %d_cart" to use the name of the game
40  mounted in the cartslot, or "-snapname %d_flop2" to use the name of the game
41  mounted in the second floppy drive, etc. If you are loading software through
42  software lists, its shortname will be used; if you are using the fullpath of
43  the software, its filename is used. Any combination of the new template with
44  the old "/", "%g" and "%i" templates is supported as well. Notice that if you
45  specify an invalid device, or if you have no software mounted in the chosen
46  device, MESS will revert to the default template "%g/%i". [Fabio Priuli]
47
3648- softlists: Added new lists, new dumps and info [anondumper, Barry Rodewald,
3749  Curt Coder, MESSfan, Fabio Priuli]
3850

Previous 15994 Revisions Next


© 1998-2018 The MESS Team