From 10a6cfb67e2b1e576964915b9ba528f18a85a4dd Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Wed, 17 Nov 2021 16:17:42 +1100 Subject: frontend: Show more unemulated/imperfect features per-device in warnings menu. --- src/frontend/mame/ui/info.cpp | 255 +++++++++++++++++++++++++----------------- src/frontend/mame/ui/info.h | 3 + 2 files changed, 157 insertions(+), 101 deletions(-) diff --git a/src/frontend/mame/ui/info.cpp b/src/frontend/mame/ui/info.cpp index c93dd024519..1d1e975a143 100644 --- a/src/frontend/mame/ui/info.cpp +++ b/src/frontend/mame/ui/info.cpp @@ -19,6 +19,11 @@ #include "softlist.h" #include "emuopts.h" +#include +#include +#include +#include + namespace ui { @@ -51,6 +56,122 @@ constexpr std::pair FEATURE_NAMES[] = { { device_t::feature::LAN, N_p("emulation-feature", "LAN") }, { device_t::feature::WAN, N_p("emulation-feature", "WAN") } }; +void get_general_warnings(std::ostream &buf, running_machine &machine, machine_flags::type flags, device_t::feature_type unemulated, device_t::feature_type imperfect) +{ + // add a warning if any ROMs were loaded with warnings + bool bad_roms(false); + if (machine.rom_load().warnings() > 0) + { + bad_roms = true; + buf << _("One or more ROMs/CHDs for this machine are incorrect. The machine may not run correctly.\n"); + } + if (!machine.rom_load().software_load_warnings_message().empty()) + { + bad_roms = true; + buf << machine.rom_load().software_load_warnings_message(); + } + + // if we have at least one warning flag, print the general header + if ((machine.rom_load().knownbad() > 0) || (flags & (MACHINE_ERRORS | MACHINE_WARNINGS | MACHINE_BTANB)) || unemulated || imperfect) + { + if (bad_roms) + buf << '\n'; + buf << _("There are known problems with this machine\n\n"); + } + + // add a warning if any ROMs are flagged BAD_DUMP/NO_DUMP + if (machine.rom_load().knownbad() > 0) + buf << _("One or more ROMs/CHDs for this machine have not been correctly dumped.\n"); +} + +void get_device_warnings(std::ostream &buf, device_t::feature_type unemulated, device_t::feature_type imperfect) +{ + // add line for unemulated features + if (unemulated) + { + buf << _("Completely unemulated features: "); + bool first = true; + for (auto const &feature : FEATURE_NAMES) + { + if (unemulated & feature.first) + { + util::stream_format(buf, first ? _("%s") : _(", %s"), _("emulation-feature", feature.second)); + first = false; + } + } + buf << '\n'; + } + + // add line for imperfect features + if (imperfect) + { + buf << _("Imperfectly emulated features: "); + bool first = true; + for (auto const &feature : FEATURE_NAMES) + { + if (imperfect & feature.first) + { + util::stream_format(buf, first ? _("%s") : _(", %s"), _("emulation-feature", feature.second)); + first = false; + } + } + buf << '\n'; + } +} + +void get_system_warnings(std::ostream &buf, running_machine &machine, machine_flags::type flags, device_t::feature_type unemulated, device_t::feature_type imperfect) +{ + // start with the unemulated/imperfect features + get_device_warnings(buf, unemulated, imperfect); + + // add one line per machine warning flag + if (flags & ::machine_flags::NO_COCKTAIL) + buf << _("Screen flipping in cocktail mode is not supported.\n"); + if (flags & ::machine_flags::REQUIRES_ARTWORK) + buf << _("This machine requires external artwork files.\n"); + if (flags & ::machine_flags::IS_INCOMPLETE) + buf << _("This machine was never completed. It may exhibit strange behavior or missing elements that are not bugs in the emulation.\n"); + if (flags & ::machine_flags::NO_SOUND_HW) + buf << _("This machine has no sound hardware, MAME will produce no sounds, this is expected behaviour.\n"); + + // these are more severe warnings + if (flags & ::machine_flags::NOT_WORKING) + buf << _("\nTHIS MACHINE DOESN'T WORK. The emulation for this machine is not yet complete. There is nothing you can do to fix this problem except wait for the developers to improve the emulation.\n"); + if (flags & ::machine_flags::MECHANICAL) + buf << _("\nElements of this machine cannot be emulated as they require physical interaction or consist of mechanical devices. It is not possible to fully experience this machine.\n"); + + if ((flags & MACHINE_ERRORS) || ((machine.system().type.unemulated_features() | machine.system().type.imperfect_features()) & device_t::feature::PROTECTION)) + { + // find the parent of this driver + driver_enumerator drivlist(machine.options()); + int maindrv = drivlist.find(machine.system()); + int clone_of = drivlist.non_bios_clone(maindrv); + if (clone_of != -1) + maindrv = clone_of; + + // scan the driver list for any working clones and add them + bool foundworking = false; + while (drivlist.next()) + { + if (drivlist.current() == maindrv || drivlist.clone() == maindrv) + { + game_driver const &driver(drivlist.driver()); + if (!(driver.flags & MACHINE_ERRORS) && !((driver.type.unemulated_features() | driver.type.imperfect_features()) & device_t::feature::PROTECTION)) + { + // this one works, add a header and display the name of the clone + if (!foundworking) + util::stream_format(buf, _("\n\nThere are working clones of this machine: %s"), driver.name); + else + util::stream_format(buf, _(", %s"), driver.name); + foundworking = true; + } + } + } + if (foundworking) + buf << '\n'; + } +} + } // anonymous namespace @@ -225,105 +346,8 @@ machine_info::machine_info(running_machine &machine) std::string machine_info::warnings_string() const { std::ostringstream buf; - - // add a warning if any ROMs were loaded with warnings - if (m_machine.rom_load().warnings() > 0) - buf << _("One or more ROMs/CHDs for this machine are incorrect. The machine may not run correctly.\n"); - - if (!m_machine.rom_load().software_load_warnings_message().empty()) - buf << m_machine.rom_load().software_load_warnings_message(); - - // if we have at least one warning flag, print the general header - if ((m_machine.rom_load().knownbad() > 0) || (machine_flags() & (MACHINE_ERRORS | MACHINE_WARNINGS | MACHINE_BTANB)) || unemulated_features() || imperfect_features()) - { - if (!buf.str().empty()) - buf << '\n'; - buf << _("There are known problems with this machine\n\n"); - } - - // add a warning if any ROMs are flagged BAD_DUMP/NO_DUMP - if (m_machine.rom_load().knownbad() > 0) - buf << _("One or more ROMs/CHDs for this machine have not been correctly dumped.\n"); - - // add line for unemulated features - if (unemulated_features()) - { - buf << _("Completely unemulated features: "); - bool first = true; - for (auto const &feature : FEATURE_NAMES) - { - if (unemulated_features() & feature.first) - { - util::stream_format(buf, first ? _("%s") : _(", %s"), _("emulation-feature", feature.second)); - first = false; - } - } - buf << '\n'; - } - - // add line for imperfect features - if (imperfect_features()) - { - buf << _("Imperfectly emulated features: "); - bool first = true; - for (auto const &feature : FEATURE_NAMES) - { - if (imperfect_features() & feature.first) - { - util::stream_format(buf, first ? _("%s") : _(", %s"), _("emulation-feature", feature.second)); - first = false; - } - } - buf << '\n'; - } - - // add one line per machine warning flag - if (machine_flags() & ::machine_flags::NO_COCKTAIL) - buf << _("Screen flipping in cocktail mode is not supported.\n"); - if (machine_flags() & ::machine_flags::REQUIRES_ARTWORK) - buf << _("This machine requires external artwork files.\n"); - if (machine_flags() & ::machine_flags::IS_INCOMPLETE) - buf << _("This machine was never completed. It may exhibit strange behavior or missing elements that are not bugs in the emulation.\n"); - if (machine_flags() & ::machine_flags::NO_SOUND_HW) - buf << _("This machine has no sound hardware, MAME will produce no sounds, this is expected behaviour.\n"); - - // these are more severe warnings - if (machine_flags() & ::machine_flags::NOT_WORKING) - buf << _("\nTHIS MACHINE DOESN'T WORK. The emulation for this machine is not yet complete. There is nothing you can do to fix this problem except wait for the developers to improve the emulation.\n"); - if (machine_flags() & ::machine_flags::MECHANICAL) - buf << _("\nElements of this machine cannot be emulated as they require physical interaction or consist of mechanical devices. It is not possible to fully experience this machine.\n"); - - if ((machine_flags() & MACHINE_ERRORS) || ((m_machine.system().type.unemulated_features() | m_machine.system().type.imperfect_features()) & device_t::feature::PROTECTION)) - { - // find the parent of this driver - driver_enumerator drivlist(m_machine.options()); - int maindrv = drivlist.find(m_machine.system()); - int clone_of = drivlist.non_bios_clone(maindrv); - if (clone_of != -1) - maindrv = clone_of; - - // scan the driver list for any working clones and add them - bool foundworking = false; - while (drivlist.next()) - { - if (drivlist.current() == maindrv || drivlist.clone() == maindrv) - { - game_driver const &driver(drivlist.driver()); - if (!(driver.flags & MACHINE_ERRORS) && !((driver.type.unemulated_features() | driver.type.imperfect_features()) & device_t::feature::PROTECTION)) - { - // this one works, add a header and display the name of the clone - if (!foundworking) - util::stream_format(buf, _("\n\nThere are working clones of this machine: %s"), driver.name); - else - util::stream_format(buf, _(", %s"), driver.name); - foundworking = true; - } - } - } - if (foundworking) - buf << '\n'; - } - + get_general_warnings(buf, m_machine, machine_flags(), unemulated_features(), imperfect_features()); + get_system_warnings(buf, m_machine, machine_flags(), unemulated_features(), imperfect_features()); return buf.str(); } @@ -530,9 +554,38 @@ void menu_warn_info::populate_text(std::optional &layout, float &wi { if (!layout || (layout->width() != width)) { - rgb_t const color = ui().colors().text_color(); + std::ostringstream buf; + std::set > seen; + bool first(!machine().rom_load().knownbad()); + + machine_info const &info(ui().machine_info()); + device_t &root(machine().root_device()); + get_general_warnings(buf, machine(), info.machine_flags(), info.unemulated_features(), info.imperfect_features()); + if ((info.machine_flags() & (MACHINE_ERRORS | MACHINE_WARNINGS | MACHINE_BTANB)) || root.type().unemulated_features() || root.type().imperfect_features()) + { + seen.insert(&root.type()); + if (!first) + buf << '\n'; + first = false; + util::stream_format(buf, _("%1$s:\n"), root.name()); + get_system_warnings(buf, machine(), info.machine_flags(), root.type().unemulated_features(), root.type().imperfect_features()); + } + + for (device_t const &device : device_enumerator(root)) + { + if ((device.type().unemulated_features() || device.type().imperfect_features()) && seen.insert(&device.type()).second) + { + if (!first) + buf << '\n'; + first = false; + util::stream_format(buf, _("%1$s:\n"), device.name()); + get_device_warnings(buf, device.type().unemulated_features(), device.type().imperfect_features()); + } + } + + rgb_t const color(ui().colors().text_color()); layout.emplace(ui().create_layout(container(), width)); - layout->add_text(ui().machine_info().warnings_string(), color); + layout->add_text(std::move(buf).str(), color); lines = layout->lines(); } width = layout->actual_width(); diff --git a/src/frontend/mame/ui/info.h b/src/frontend/mame/ui/info.h index 3f9fd7d8edb..b05a1d62639 100644 --- a/src/frontend/mame/ui/info.h +++ b/src/frontend/mame/ui/info.h @@ -15,6 +15,9 @@ #include "ui/textbox.h" +#include + + namespace ui { class machine_static_info -- cgit v1.2.3