From 9445f1d8311db820dc0984e85c9c1450ce1807cd Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Wed, 2 Sep 2020 17:29:21 +1000 Subject: frontend: Added option to skip repeated imperfect emulation warnings. The option is called skip_warnings, and it must be set in ui.ini (it can be set using the internal UI). Red warnings cannot be skipped; yellow warning can be skipped under certain circumstances. For a yellow warning to be skipped, the system must have been launched in a way that allows warnings to be displayed, in a configuration with the same set of devices flagged with unemulated/imperfect features, within the last seven days, and the warning must have been displayed within the past 14 days. Also fixed a bug with display of the MACHINE_NO_COCKTAIL flag in the internal UI, and increased the size of XML integer attributes to 64 bits. --- src/frontend/mame/infoxml.cpp | 475 ++++++++++++++++++++++-------------------- 1 file changed, 250 insertions(+), 225 deletions(-) (limited to 'src/frontend/mame/infoxml.cpp') diff --git a/src/frontend/mame/infoxml.cpp b/src/frontend/mame/infoxml.cpp index 926feffbc08..59b3a637aee 100644 --- a/src/frontend/mame/infoxml.cpp +++ b/src/frontend/mame/infoxml.cpp @@ -25,234 +25,282 @@ #include "xmlfile.h" +#include #include #include -#include -#include #include +#include +#include +#include +#include #define XML_ROOT "mame" #define XML_TOP "machine" +namespace { + //************************************************************************** // ANONYMOUS NAMESPACE PROTOTYPES //************************************************************************** -namespace +class device_type_compare { - class device_type_compare - { - public: - bool operator()(const std::add_pointer_t &lhs, const std::add_pointer_t &rhs) const; - }; - - typedef std::set, device_type_compare> device_type_set; - - std::string normalize_string(const char *string); - - // internal helper - void output_header(std::ostream &out, bool dtd); - void output_footer(std::ostream &out); - - void output_one(std::ostream &out, driver_enumerator &drivlist, const game_driver &driver, device_type_set *devtypes); - void output_sampleof(std::ostream &out, device_t &device); - void output_bios(std::ostream &out, device_t const &device); - void output_rom(std::ostream &out, driver_enumerator *drivlist, const game_driver *driver, device_t &device); - void output_device_refs(std::ostream &out, device_t &root); - void output_sample(std::ostream &out, device_t &device); - void output_chips(std::ostream &out, device_t &device, const char *root_tag); - void output_display(std::ostream &out, device_t &device, machine_flags::type const *flags, const char *root_tag); - void output_sound(std::ostream &out, device_t &device); - void output_ioport_condition(std::ostream &out, const ioport_condition &condition, unsigned indent); - void output_input(std::ostream &out, const ioport_list &portlist); - void output_switches(std::ostream &out, const ioport_list &portlist, const char *root_tag, int type, const char *outertag, const char *loctag, const char *innertag); - void output_ports(std::ostream &out, const ioport_list &portlist); - void output_adjusters(std::ostream &out, const ioport_list &portlist); - void output_driver(std::ostream &out, game_driver const &driver, device_t::feature_type unemulated, device_t::feature_type imperfect); - void output_features(std::ostream &out, device_type type, device_t::feature_type unemulated, device_t::feature_type imperfect); - void output_images(std::ostream &out, device_t &device, const char *root_tag); - void output_slots(std::ostream &out, machine_config &config, device_t &device, const char *root_tag, device_type_set *devtypes); - void output_software_lists(std::ostream &out, device_t &root, const char *root_tag); - void output_ramoptions(std::ostream &out, device_t &root); - - void output_one_device(std::ostream &out, machine_config &config, device_t &device, const char *devtag); - void output_devices(std::ostream &out, emu_options &lookup_options, device_type_set const *filter); - - const char *get_merge_name(driver_enumerator &drivlist, const game_driver &driver, util::hash_collection const &romhashes); +public: + bool operator()(const std::add_pointer_t &lhs, const std::add_pointer_t &rhs) const; }; +typedef std::set, device_type_compare> device_type_set; + +std::string normalize_string(const char *string); + +// internal helper +void output_header(std::ostream &out, bool dtd); +void output_footer(std::ostream &out); + +void output_one(std::ostream &out, driver_enumerator &drivlist, const game_driver &driver, device_type_set *devtypes); +void output_sampleof(std::ostream &out, device_t &device); +void output_bios(std::ostream &out, device_t const &device); +void output_rom(std::ostream &out, driver_enumerator *drivlist, const game_driver *driver, device_t &device); +void output_device_refs(std::ostream &out, device_t &root); +void output_sample(std::ostream &out, device_t &device); +void output_chips(std::ostream &out, device_t &device, const char *root_tag); +void output_display(std::ostream &out, device_t &device, machine_flags::type const *flags, const char *root_tag); +void output_sound(std::ostream &out, device_t &device); +void output_ioport_condition(std::ostream &out, const ioport_condition &condition, unsigned indent); +void output_input(std::ostream &out, const ioport_list &portlist); +void output_switches(std::ostream &out, const ioport_list &portlist, const char *root_tag, int type, const char *outertag, const char *loctag, const char *innertag); +void output_ports(std::ostream &out, const ioport_list &portlist); +void output_adjusters(std::ostream &out, const ioport_list &portlist); +void output_driver(std::ostream &out, game_driver const &driver, device_t::feature_type unemulated, device_t::feature_type imperfect); +void output_features(std::ostream &out, device_type type, device_t::feature_type unemulated, device_t::feature_type imperfect); +void output_images(std::ostream &out, device_t &device, const char *root_tag); +void output_slots(std::ostream &out, machine_config &config, device_t &device, const char *root_tag, device_type_set *devtypes); +void output_software_lists(std::ostream &out, device_t &root, const char *root_tag); +void output_ramoptions(std::ostream &out, device_t &root); + +void output_one_device(std::ostream &out, machine_config &config, device_t &device, const char *devtag); +void output_devices(std::ostream &out, emu_options &lookup_options, device_type_set const *filter); + +const char *get_merge_name(driver_enumerator &drivlist, const game_driver &driver, util::hash_collection const &romhashes); + //************************************************************************** // GLOBAL VARIABLES //************************************************************************** // DTD string describing the data -static const char s_dtd_string[] = -"\n" -"\t\n" -"\t\n" -"\t\n" -"\t\n" -"\t\t\n" -"\t\t\n" -"\t\t\n" -"\t\t\n" -"\t\t\n" -"\t\t\n" -"\t\t\n" -"\t\t\n" -"\t\t\n" -"\t\t\n" -"\t\t\n" -"\t\t\n" -"\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\n" -"\t\t\t\n" -"\t\t\n" -"\t\t\t\n" -"\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\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t\n" -"\t\t\t\t\n" -"\t\t\t\t\n" -"\t\t\t\t\n" -"\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"\t\t\n" -"\t\t\t\n" -"\t\t\t\n" -"]>"; +constexpr char f_dtd_string[] = + "\n" + "\t\n" + "\t\n" + "\t\n" + "\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\n" + "\t\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "\t\t\n" + "\t\t\t\n" + "\t\t\t\n" + "]>"; + + +// XML feature names +constexpr std::pair f_feature_names[] = { + { device_t::feature::PROTECTION, "protection" }, + { device_t::feature::TIMING, "timing" }, + { device_t::feature::GRAPHICS, "graphics" }, + { device_t::feature::PALETTE, "palette" }, + { device_t::feature::SOUND, "sound" }, + { device_t::feature::CAPTURE, "capture" }, + { device_t::feature::CAMERA, "camera" }, + { device_t::feature::MICROPHONE, "microphone" }, + { device_t::feature::CONTROLS, "controls" }, + { device_t::feature::KEYBOARD, "keyboard" }, + { device_t::feature::MOUSE, "mouse" }, + { device_t::feature::MEDIA, "media" }, + { device_t::feature::DISK, "disk" }, + { device_t::feature::PRINTER, "printer" }, + { device_t::feature::TAPE, "tape" }, + { device_t::feature::PUNCH, "punch" }, + { device_t::feature::DRUM, "drum" }, + { device_t::feature::ROM, "rom" }, + { device_t::feature::COMMS, "comms" }, + { device_t::feature::LAN, "lan" }, + { device_t::feature::WAN, "wan" } }; + +} // anonymous namespace //************************************************************************** // INFO XML CREATOR //************************************************************************** + +//------------------------------------------------- +// get_feature_name - get XML name for feature +//------------------------------------------------- + +char const *info_xml_creator::feature_name(device_t::feature_type feature) +{ + auto const found = std::lower_bound( + std::begin(f_feature_names), + std::end(f_feature_names), + std::underlying_type_t(feature), + [] (auto const &a, auto const &b) + { + return std::underlying_type_t(a.first) < b; + }); + return ((std::end(f_feature_names) != found) && (found->first == feature)) ? found->second : nullptr; +} + + //------------------------------------------------- // info_xml_creator - constructor //------------------------------------------------- @@ -478,7 +526,7 @@ void output_header(std::ostream &out, bool dtd) { // output the DTD out << "\n"; - std::string dtd(s_dtd_string); + std::string dtd(f_dtd_string); strreplace(dtd, "__XML_ROOT__", XML_ROOT); strreplace(dtd, "__XML_TOP__", XML_TOP); @@ -1771,31 +1819,8 @@ void output_driver(std::ostream &out, game_driver const &driver, device_t::featu void output_features(std::ostream &out, device_type type, device_t::feature_type unemulated, device_t::feature_type imperfect) { - static constexpr std::pair features[] = { - { device_t::feature::PROTECTION, "protection" }, - { device_t::feature::TIMING, "timing" }, - { device_t::feature::GRAPHICS, "graphics" }, - { device_t::feature::PALETTE, "palette" }, - { device_t::feature::SOUND, "sound" }, - { device_t::feature::CAPTURE, "capture" }, - { device_t::feature::CAMERA, "camera" }, - { device_t::feature::MICROPHONE, "microphone" }, - { device_t::feature::CONTROLS, "controls" }, - { device_t::feature::KEYBOARD, "keyboard" }, - { device_t::feature::MOUSE, "mouse" }, - { device_t::feature::MEDIA, "media" }, - { device_t::feature::DISK, "disk" }, - { device_t::feature::PRINTER, "printer" }, - { device_t::feature::TAPE, "tape" }, - { device_t::feature::PUNCH, "punch" }, - { device_t::feature::DRUM, "drum" }, - { device_t::feature::ROM, "rom" }, - { device_t::feature::COMMS, "comms" }, - { device_t::feature::LAN, "lan" }, - { device_t::feature::WAN, "wan" } }; - device_t::feature_type const flags(type.unemulated_features() | type.imperfect_features() | unemulated | imperfect); - for (auto const &feature : features) + for (auto const &feature : f_feature_names) { if (flags & feature.first) { -- cgit v1.2.3