diff --git a/src/emu/clifront.cpp b/src/emu/clifront.cpp index 96f21ba27e2..465ad6f0981 100644 --- a/src/emu/clifront.cpp +++ b/src/emu/clifront.cpp @@ -1612,7 +1612,7 @@ void cli_frontend::execute_commands(const char *exename) validity_checker valid(m_options); bool result = valid.check_all(); if (!result) - throw emu_fatalerror(MAMERR_FAILED_VALIDITY, "Validity check failed!\n"); + throw emu_fatalerror(MAMERR_FAILED_VALIDITY, "Validity check failed (%d errors, %d warnings in total)\n", valid.errors(), valid.warnings()); return; } diff --git a/src/emu/mame.cpp b/src/emu/mame.cpp index f3ca9059a8d..b952c7ef624 100644 --- a/src/emu/mame.cpp +++ b/src/emu/mame.cpp @@ -194,6 +194,7 @@ int machine_manager::execute() if (system != nullptr) { validity_checker valid(m_options); + valid.set_verbose(false); valid.check_shared_source(*system); } diff --git a/src/emu/validity.cpp b/src/emu/validity.cpp index 345b47d010c..52db138da8f 100644 --- a/src/emu/validity.cpp +++ b/src/emu/validity.cpp @@ -125,6 +125,7 @@ validity_checker::validity_checker(emu_options &options) : m_drivlist(options), m_errors(0), m_warnings(0), + m_print_verbose(options.verbose()), m_current_driver(nullptr), m_current_config(nullptr), m_current_device(nullptr), @@ -194,19 +195,15 @@ bool validity_checker::check_all() validate_inlines(); // if we had warnings or errors, output - if (m_errors > 0 || m_warnings > 0) + if (m_errors > 0 || m_warnings > 0 || !m_verbose_text.empty()) { output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "Core: %d errors, %d warnings\n", m_errors, m_warnings); if (m_errors > 0) - { - strreplace(m_error_text, "\n", "\n "); - output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "Errors:\n %s", m_error_text.c_str()); - } + output_indented_errors(m_error_text, "Errors"); if (m_warnings > 0) - { - strreplace(m_warning_text, "\n", "\n "); - output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "Warnings:\n %s", m_warning_text.c_str()); - } + output_indented_errors(m_warning_text, "Warnings"); + if (!m_verbose_text.empty()) + output_indented_errors(m_verbose_text, "Messages"); output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "\n"); } @@ -277,6 +274,7 @@ void validity_checker::validate_one(const game_driver &driver) int start_warnings = m_warnings; m_error_text.clear(); m_warning_text.clear(); + m_verbose_text.clear(); // wrap in try/except to catch fatalerrors try @@ -295,20 +293,16 @@ void validity_checker::validate_one(const game_driver &driver) } // if we had warnings or errors, output - if (m_errors > start_errors || m_warnings > start_warnings) + if (m_errors > start_errors || m_warnings > start_warnings || !m_verbose_text.empty()) { std::string tempstr; output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "Driver %s (file %s): %d errors, %d warnings\n", driver.name, core_filename_extract_base(tempstr, driver.source_file).c_str(), m_errors - start_errors, m_warnings - start_warnings); if (m_errors > start_errors) - { - strreplace(m_error_text, "\n", "\n "); - output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "Errors:\n %s", m_error_text.c_str()); - } + output_indented_errors(m_error_text, "Errors"); if (m_warnings > start_warnings) - { - strreplace(m_warning_text, "\n", "\n "); - output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "Warnings:\n %s", m_warning_text.c_str()); - } + output_indented_errors(m_warning_text, "Warnings"); + if (!m_verbose_text.empty()) + output_indented_errors(m_verbose_text, "Messages"); output_via_delegate(OSD_OUTPUT_CHANNEL_ERROR, "\n"); } @@ -1089,6 +1083,17 @@ void validity_checker::output_callback(osd_output_channel channel, const char *m strcatvprintf(output, msg, args); m_warning_text.append(output); break; + case OSD_OUTPUT_CHANNEL_VERBOSE: + // if we're not verbose, skip it + if (!m_print_verbose) break; + + // output the source(driver) device 'tag' + build_output_prefix(output); + + // generate the string and output to the original target + strcatvprintf(output, msg, args); + m_verbose_text.append(output); + break; default: chain_output(channel, msg, args); break; diff --git a/src/emu/validity.h b/src/emu/validity.h index fa38bb20f93..924e600668a 100644 --- a/src/emu/validity.h +++ b/src/emu/validity.h @@ -40,6 +40,9 @@ public: int errors() const { return m_errors; } int warnings() const { return m_warnings; } + // setter + void set_verbose(bool verbose) { m_print_verbose = verbose; } + // operations void check_driver(const game_driver &driver); void check_shared_source(const game_driver &driver); @@ -88,8 +91,10 @@ private: // error tracking int m_errors; int m_warnings; + bool m_print_verbose; std::string m_error_text; std::string m_warning_text; + std::string m_verbose_text; // maps for finding duplicates game_driver_map m_names_map; diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp index 39767eb6210..f6dc6aabdae 100644 --- a/src/osd/modules/lib/osdobj_common.cpp +++ b/src/osd/modules/lib/osdobj_common.cpp @@ -13,8 +13,6 @@ #include "osdepend.h" #include "modules/lib/osdobj_common.h" -extern bool g_print_verbose; - const options_entry osd_options::s_option_entries[] = { { NULL, NULL, OPTION_HEADER, "OSD KEYBOARD MAPPING OPTIONS" }, @@ -155,6 +153,7 @@ osd_options::osd_options() osd_common_t::osd_common_t(osd_options &options) : osd_output(), m_machine(NULL), m_options(options), + m_print_verbose(false), m_sound(NULL), m_debugger(NULL) { @@ -278,10 +277,12 @@ void osd_common_t::output_callback(osd_output_channel channel, const char *msg, vfprintf(stderr, msg, args); break; case OSD_OUTPUT_CHANNEL_INFO: - case OSD_OUTPUT_CHANNEL_VERBOSE: case OSD_OUTPUT_CHANNEL_LOG: vfprintf(stdout, msg, args); break; + case OSD_OUTPUT_CHANNEL_VERBOSE: + if (verbose()) vfprintf(stdout, msg, args); + break; case OSD_OUTPUT_CHANNEL_DEBUG: #ifdef MAME_DEBUG vfprintf(stdout, msg, args); @@ -333,7 +334,7 @@ void osd_common_t::init(running_machine &machine) osd_options &options = downcast(machine.options()); // extract the verbose printing option if (options.verbose()) - g_print_verbose = true; + set_verbose(true); // ensure we get called on the way out machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_common_t::osd_exit), this)); diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h index d1aca5f4e43..a73931f3fa1 100644 --- a/src/osd/modules/lib/osdobj_common.h +++ b/src/osd/modules/lib/osdobj_common.h @@ -202,7 +202,6 @@ public: // getters running_machine &machine() { assert(m_machine != nullptr); return *m_machine; } - virtual void debugger_update(); virtual void init_subsystems(); @@ -228,6 +227,8 @@ public: // osd_output interface ... virtual void output_callback(osd_output_channel channel, const char *msg, va_list args) override; + bool verbose() const { return m_print_verbose; } + void set_verbose(bool print_verbose) { m_print_verbose = print_verbose; } protected: virtual bool input_init(); @@ -238,6 +239,8 @@ private: running_machine * m_machine; osd_options& m_options; + bool m_print_verbose; + osd_module_manager m_mod_man; font_module *m_font_module; diff --git a/src/osd/osdcore.cpp b/src/osd/osdcore.cpp index 91ba3fc4266..632124e2e7c 100644 --- a/src/osd/osdcore.cpp +++ b/src/osd/osdcore.cpp @@ -3,8 +3,6 @@ #include "osdcore.h" -bool g_print_verbose = false; - static const int MAXSTACK = 10; static osd_output *m_stack[MAXSTACK]; static int m_ptr = -1; @@ -104,10 +102,6 @@ void CLIB_DECL osd_printf_verbose(const char *format, ...) { va_list argptr; - /* if we're not verbose, skip it */ - if (!g_print_verbose) - return; - /* do the output */ va_start(argptr, format); if (m_ptr >= 0) m_stack[m_ptr]->output_callback(OSD_OUTPUT_CHANNEL_VERBOSE, format, argptr);