diff options
author | Vas Crabb <vas@vastheman.com> | 2021-10-15 09:42:35 +1100 |
---|---|---|
committer | Vas Crabb <vas@vastheman.com> | 2021-10-15 10:12:56 +1100 |
commit | 22bc3486c3ef8f2230e99daf49785a89ac8a1182 (patch) | |
tree | 4f10f7386b7b0a32c9d560395399e8b7632df34c /src/emu | |
parent | 3e8763bea5a93f3139204fcb8a0c74c2ac364af5 (diff) |
More user experience improvements:
frontend: Made it possible to cancel a media audit while it's in
progress. Also made the media audit multi-threaded so it's faster.
frontend: Made the DIP switches in the DIP switch preview clickable.
frontend: Made the system and software selection menus leave focus on
the same system when clearing the search rather than jumping to the
first item. Also fixed a couple of bugs in the logic for keeping the
selected item visible.
frontend: Fixed a few places that weren't showing localised system
names.
frontend: Made UI Cancel clear a search in the file manager the same way
it does on the system and sofware selection menus.
frontend: Made it possible for plugin menus to handle UI Cancel more
naturally, backing up to the previous plugin menu rather than dropping
straight back to the list of plugins. Updated the autofire, cheat and
cheatfind plugins, and fixed a few other issues in the cheatfind plugin.
debugger: Made the mount and unmount commands accept instance names as
well as brief instance names. Also updated another page of debugger
documentation.
Diffstat (limited to 'src/emu')
-rw-r--r-- | src/emu/debug/debugcmd.cpp | 53 | ||||
-rw-r--r-- | src/emu/debug/debughlp.cpp | 36 | ||||
-rw-r--r-- | src/emu/softlist.cpp | 71 |
3 files changed, 95 insertions, 65 deletions
diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index e7ca864988d..fe5bce41841 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -23,6 +23,7 @@ #include "emuopts.h" #include "natkeyboard.h" #include "render.h" +#include "softlist.h" #include "corestr.h" @@ -4126,9 +4127,26 @@ void debugger_commands::execute_images(const std::vector<std::string> ¶ms) { image_interface_enumerator iter(m_machine.root_device()); for (device_image_interface &img : iter) - m_console.printf("%s: %s\n", img.brief_instance_name(), img.exists() ? img.filename() : "[empty slot]"); - if (iter.first() == nullptr) - m_console.printf("No image devices in this driver\n"); + { + if (!img.exists()) + { + m_console.printf("%s: [no media]\n", img.brief_instance_name()); + } + else if (img.loaded_through_softlist()) + { + m_console.printf("%s: %s:%s:%s\n", + img.brief_instance_name(), + img.software_list_name(), + img.software_entry()->shortname(), + img.part_entry()->name()); + } + else + { + m_console.printf("%s: %s\n", img.brief_instance_name(), img.filename()); + } + } + if (!iter.first()) + m_console.printf("No image devices present\n"); } /*------------------------------------------------- @@ -4137,21 +4155,18 @@ void debugger_commands::execute_images(const std::vector<std::string> ¶ms) void debugger_commands::execute_mount(const std::vector<std::string> ¶ms) { - bool done = false; for (device_image_interface &img : image_interface_enumerator(m_machine.root_device())) { - if (img.brief_instance_name() == params[0]) + if ((img.instance_name() == params[0]) || (img.brief_instance_name() == params[0])) { if (img.load(params[1]) != image_init_result::PASS) m_console.printf("Unable to mount file %s on %s\n", params[1], params[0]); else m_console.printf("File %s mounted on %s\n", params[1], params[0]); - done = true; - break; + return; } } - if (!done) - m_console.printf("There is no image device :%s\n", params[0]); + m_console.printf("No image instance %s\n", params[0]); } /*------------------------------------------------- @@ -4160,19 +4175,23 @@ void debugger_commands::execute_mount(const std::vector<std::string> ¶ms) void debugger_commands::execute_unmount(const std::vector<std::string> ¶ms) { - bool done = false; for (device_image_interface &img : image_interface_enumerator(m_machine.root_device())) { - if (img.brief_instance_name() == params[0]) + if ((img.instance_name() == params[0]) || (img.brief_instance_name() == params[0])) { - img.unload(); - m_console.printf("Unmounted file from : %s\n", params[0]); - done = true; - break; + if (img.exists()) + { + img.unload(); + m_console.printf("Unmounted media from %s\n", params[0]); + } + else + { + m_console.printf("No media mounted on %s\n", params[0]); + } + return; } } - if (!done) - m_console.printf("There is no image device :%s\n", params[0]); + m_console.printf("No image instance %s\n", params[0]); } diff --git a/src/emu/debug/debughlp.cpp b/src/emu/debug/debughlp.cpp index 13a0b2d1216..ef19f91c3a9 100644 --- a/src/emu/debug/debughlp.cpp +++ b/src/emu/debug/debughlp.cpp @@ -259,9 +259,9 @@ const help_item f_static_help_list[] = "Image Commands\n" "Type help <command> for further details on each command\n" "\n" - " images -- lists all image devices and mounted files\n" - " mount <device>,<filename> -- mounts file to named device\n" - " unmount <device> -- unmounts file from named device\n" + " images -- lists all image devices and mounted mounted media\n" + " mount <instance>,<filename> -- mounts file to specified device\n" + " unmount <instance> -- unmounts media from specified device\n" }, { "do", @@ -1767,37 +1767,47 @@ const help_item f_static_help_list[] = "\n" " images\n" "\n" - "Used to display list of available image devices.\n" + "Lists the instance names for media images devices in the system and the currently mounted " + "media images, if any. Brief instance names, as allowed for command line media options, " + "are listed.\n" "\n" "Examples:\n" "\n" "images\n" - " Show list of devices and mounted files for current driver.\n" + " Lists image device instance names and mounted media.\n" }, { "mount", "\n" - " mount <device>,<filename>\n" + " mount <instance>,<filename>\n" "\n" - "Mount <filename> to image <device>.\n" - "<filename> can be softlist item or full path to file.\n" + "Mounts a file on a media device. The device may be specified by its instance name or " + "brief instance name, as allowed for command line media options.\n" + "\n" + "Some media devices allow software list items to be mounted using this command by supplying " + "the short name of the software list item in place of a filename for the <filename> " + "parameter.\n" "\n" "Examples:\n" "\n" - "mount cart,aladdin\n" - " Mounts softlist item aladdin on cart device.\n" + "mount flop1,os1xutls.td0\n" + " Mount the file 'os1xutls.td0' on the media device with instance name 'flop1'.\n" + "mount cart,10yard\n" + " Mount the software list item with short name '10yard' on the media device with instance " + "name 'cart'.\n" }, { "unmount", "\n" - " unmount <device>\n" + " unmount <instance>\n" "\n" - "Unmounts file from image <device>.\n" + "Unmounts the mounted media image (if any) from a device. The device may be specified by " + "its instance name or brief instance name, as allowed for command line media options.\n" "\n" "Examples:\n" "\n" "unmount cart\n" - " Unmounts any file mounted on device named cart.\n" + " Unmounts any media image mounted on the device with instance name 'cart'.\n" } }; diff --git a/src/emu/softlist.cpp b/src/emu/softlist.cpp index 72f299c4c29..4892a5ca5d8 100644 --- a/src/emu/softlist.cpp +++ b/src/emu/softlist.cpp @@ -15,6 +15,7 @@ #include "expat.h" +#include <array> #include <cstring> #include <regex> @@ -215,8 +216,8 @@ private: void unknown_attribute(const char *attrname) { parse_error("Unknown attribute: %s", attrname); } // internal helpers - template <typename T> std::vector<std::string> parse_attributes(const char **attributes, const T &attrlist); - bool parse_name_and_value(const char **attributes, std::string &name, std::string &value); + template <size_t N> std::array<std::string_view, N> parse_attributes(const char **attributes, const char *const (&attrlist)[N]); + bool parse_name_and_value(const char **attributes, std::string_view &name, std::string_view &value); void add_rom_entry(std::string &&name, std::string &&hashdata, u32 offset, u32 length, u32 flags); // expat callbacks @@ -325,10 +326,10 @@ inline void softlist_parser::parse_error(Format &&fmt, Params &&... args) // attributes into a list of strings //------------------------------------------------- -template <typename T> -std::vector<std::string> softlist_parser::parse_attributes(const char **attributes, const T &attrlist) +template <size_t N> +std::array<std::string_view, N> softlist_parser::parse_attributes(const char **attributes, const char *const (&attrlist)[N]) { - std::vector<std::string> outlist(std::distance(std::begin(attrlist), std::end(attrlist))); + std::array<std::string_view, N> outlist; // iterate over attribute/value pairs for( ; attributes[0]; attributes += 2) @@ -361,7 +362,7 @@ std::vector<std::string> softlist_parser::parse_attributes(const char **attribut // latter to be defined as an empty string) //------------------------------------------------- -bool softlist_parser::parse_name_and_value(const char **attributes, std::string &name, std::string &value) +bool softlist_parser::parse_name_and_value(const char **attributes, std::string_view &name, std::string_view &value) { bool found_value = false; @@ -559,7 +560,7 @@ void softlist_parser::parse_main_start(const char *tagname, const char **attribu if (!attrvalues[0].empty()) { - m_infolist.emplace_back(std::move(attrvalues[0]), std::move(attrvalues[1]), attrvalues[2].c_str()); + m_infolist.emplace_back(std::string(attrvalues[0]), std::string(attrvalues[1]), attrvalues[2]); m_current_info = &m_infolist.back(); } else @@ -613,10 +614,10 @@ void softlist_parser::parse_soft_start(const char *tagname, const char **attribu // <info name='' value=''> else if (strcmp(tagname, "info") == 0) { - std::string infoname, infovalue; + std::string_view infoname, infovalue; if (parse_name_and_value(attributes, infoname, infovalue)) - m_current_info->m_info.emplace_back(std::move(infoname), std::move(infovalue)); + m_current_info->m_info.emplace_back(std::string(infoname), std::string(infovalue)); else parse_error("Incomplete other_info definition"); } @@ -624,11 +625,11 @@ void softlist_parser::parse_soft_start(const char *tagname, const char **attribu // <sharedfeat name='' value=''> else if (strcmp(tagname, "sharedfeat") == 0) { - std::string featname, featvalue; + std::string_view featname, featvalue; if (parse_name_and_value(attributes, featname, featvalue)) { - if (!m_current_info->m_shared_features.emplace(std::move(featname), std::move(featvalue)).second) + if (!m_current_info->m_shared_features.emplace(std::string(featname), std::string(featvalue)).second) parse_error("Duplicate sharedfeat name"); } else @@ -645,7 +646,7 @@ void softlist_parser::parse_soft_start(const char *tagname, const char **attribu if (!attrvalues[0].empty() && !attrvalues[1].empty()) { - m_current_info->m_partdata.emplace_back(*m_current_info, std::move(attrvalues[0]), std::move(attrvalues[1])); + m_current_info->m_partdata.emplace_back(*m_current_info, std::string(attrvalues[0]), std::string(attrvalues[1])); m_current_part = &m_current_info->m_partdata.back(); } else @@ -679,8 +680,8 @@ void softlist_parser::parse_part_start(const char *tagname, const char **attribu if (!attrvalues[0].empty() && !attrvalues[1].empty()) { // handle region attributes - const std::string &width = attrvalues[2]; - const std::string &endianness = attrvalues[3]; + const auto &width = attrvalues[2]; + const auto &endianness = attrvalues[3]; u32 regionflags = ROMENTRYTYPE_REGION; if (!width.empty()) @@ -706,7 +707,7 @@ void softlist_parser::parse_part_start(const char *tagname, const char **attribu parse_error("Invalid dataarea endianness"); } - add_rom_entry(std::move(attrvalues[0]), "", 0, strtol(attrvalues[1].c_str(), nullptr, 0), regionflags); + add_rom_entry(std::string(attrvalues[0]), "", 0, strtol(attrvalues[1].data(), nullptr, 0), regionflags); } else parse_error("Incomplete dataarea definition"); @@ -719,7 +720,7 @@ void softlist_parser::parse_part_start(const char *tagname, const char **attribu auto attrvalues = parse_attributes(attributes, attrnames); if (!attrvalues[0].empty()) - add_rom_entry(std::move(attrvalues[0]), "", 0, 1, ROMENTRYTYPE_REGION | ROMREGION_DATATYPEDISK); + add_rom_entry(std::string(attrvalues[0]), "", 0, 1, ROMENTRYTYPE_REGION | ROMREGION_DATATYPEDISK); else parse_error("Incomplete diskarea definition"); } @@ -727,11 +728,11 @@ void softlist_parser::parse_part_start(const char *tagname, const char **attribu // <feature name='' value=''> else if (strcmp(tagname, "feature") == 0) { - std::string featname, featvalue; + std::string_view featname, featvalue; if (parse_name_and_value(attributes, featname, featvalue)) { - if (!m_current_part->m_features.emplace(std::move(featname), std::move(featvalue)).second) + if (!m_current_part->m_features.emplace(std::string(featname), std::string(featvalue)).second) parse_error("Duplicate feature name"); } else @@ -768,18 +769,18 @@ void softlist_parser::parse_data_start(const char *tagname, const char **attribu static char const *const attrnames[] = { "name", "size", "crc", "sha1", "offset", "value", "status", "loadflag" }; auto attrvalues = parse_attributes(attributes, attrnames); - std::string &name = attrvalues[0]; - const std::string &sizestr = attrvalues[1]; - const std::string &crc = attrvalues[2]; - const std::string &sha1 = attrvalues[3]; - const std::string &offsetstr = attrvalues[4]; - std::string &value = attrvalues[5]; - const std::string &status = attrvalues[6]; - const std::string &loadflag = attrvalues[7]; + const std::string_view &name = attrvalues[0]; + const std::string_view &sizestr = attrvalues[1]; + const std::string_view &crc = attrvalues[2]; + const std::string_view &sha1 = attrvalues[3]; + const std::string_view &offsetstr = attrvalues[4]; + const std::string_view &value = attrvalues[5]; + const std::string_view &status = attrvalues[6]; + const std::string_view &loadflag = attrvalues[7]; if (!sizestr.empty()) { - u32 length = strtol(sizestr.c_str(), nullptr, 0); - u32 offset = offsetstr.empty() ? 0 : strtol(offsetstr.c_str(), nullptr, 0); + u32 length = strtol(sizestr.data(), nullptr, 0); + u32 offset = offsetstr.empty() ? 0 : strtol(offsetstr.data(), nullptr, 0); if (loadflag == "reload") add_rom_entry("", "", offset, length, ROMENTRYTYPE_RELOAD | ROM_INHERITFLAGS); @@ -788,7 +789,7 @@ void softlist_parser::parse_data_start(const char *tagname, const char **attribu else if (loadflag == "continue") add_rom_entry("", "", offset, length, ROMENTRYTYPE_CONTINUE | ROM_INHERITFLAGS); else if (loadflag == "fill") - add_rom_entry("", std::move(value), offset, length, ROMENTRYTYPE_FILL); + add_rom_entry("", std::string(value), offset, length, ROMENTRYTYPE_FILL); else if (loadflag == "ignore") add_rom_entry("", "", 0, length, ROMENTRYTYPE_IGNORE | ROM_INHERITFLAGS); else if (!name.empty()) @@ -824,7 +825,7 @@ void softlist_parser::parse_data_start(const char *tagname, const char **attribu else if (loadflag == "load32_byte") romflags = ROM_SKIP(3); - add_rom_entry(std::move(name), std::move(hashdata), offset, length, ROMENTRYTYPE_ROM | romflags); + add_rom_entry(std::string(name), std::move(hashdata), offset, length, ROMENTRYTYPE_ROM | romflags); } else parse_error("Rom name missing"); @@ -839,10 +840,10 @@ void softlist_parser::parse_data_start(const char *tagname, const char **attribu static char const *const attrnames[] = { "name", "sha1", "status", "writeable" }; auto attrvalues = parse_attributes(attributes, attrnames); - std::string &name = attrvalues[0]; - const std::string &sha1 = attrvalues[1]; - const std::string &status = attrvalues[2]; - const std::string &writeablestr = attrvalues[3]; + const std::string_view &name = attrvalues[0]; + const std::string_view &sha1 = attrvalues[1]; + const std::string_view &status = attrvalues[2]; + const std::string_view &writeablestr = attrvalues[3]; if (!name.empty() && !sha1.empty()) { const bool baddump = (status == "baddump"); @@ -850,7 +851,7 @@ void softlist_parser::parse_data_start(const char *tagname, const char **attribu const bool writeable = (writeablestr == "yes"); std::string hashdata = string_format("%c%s%s", util::hash_collection::HASH_SHA1, sha1, (nodump ? NO_DUMP : (baddump ? BAD_DUMP : ""))); - add_rom_entry(std::move(name), std::move(hashdata), 0, 0, ROMENTRYTYPE_ROM | (writeable ? DISK_READWRITE : DISK_READONLY)); + add_rom_entry(std::string(name), std::move(hashdata), 0, 0, ROMENTRYTYPE_ROM | (writeable ? DISK_READWRITE : DISK_READONLY)); } else if (status != "nodump") // a no_dump chd is not an incomplete entry parse_error("Incomplete disk definition"); |