src/emu/video.c
| r10015 | r10016 | |
| 1101 | 1101 | { |
| 1102 | 1102 | // handle defaults |
| 1103 | 1103 | const char *snapname = options_get_string(m_machine.options(), OPTION_SNAPNAME); |
| 1104 | |
| 1104 | 1105 | if (snapname == NULL || snapname[0] == 0) |
| 1105 | 1106 | snapname = "%g/%i"; |
| 1106 | 1107 | astring snapstr(snapname); |
| 1107 | 1108 | |
| 1108 | | // strip any extension in the provided name and add our own |
| 1109 | // strip any extension in the provided name |
| 1109 | 1110 | int index = snapstr.rchr(0, '.'); |
| 1110 | 1111 | if (index != -1) |
| 1111 | 1112 | 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 |
| 1112 | 1185 | snapstr.cat(".").cat(extension); |
| 1113 | 1186 | |
| 1114 | 1187 | // substitute path and gamename up front |
docs/messnew.txt
| r10015 | r10016 | |
| 1 | | 0.141.1 |
| 1 | 0.141.1 |
| 2 | 2 | |
| 3 | 3 | New System Drivers Supported: |
| 4 | 4 | ----------------------------- |
| r10015 | r10016 | |
| 33 | 33 | |
| 34 | 34 | Source Changes: |
| 35 | 35 | ---------------- |
| 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 | |
| 36 | 48 | - softlists: Added new lists, new dumps and info [anondumper, Barry Rodewald, |
| 37 | 49 | Curt Coder, MESSfan, Fabio Priuli] |
| 38 | 50 | |