From 5c8e06be77c7d7ee72b8eaa3d2dc2bfee427ea1c Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Fri, 12 Nov 2021 18:38:18 +1100 Subject: [PATCH] -osd/windows: Show error message box on a separate thread (see MT08118). -emu/emuopts.cpp: Default to built-in UI language rather than English. * The external English message catalog is a placeholder anyway. -cpu/mcs48: Corrected comments - D87xxH have UVEPROM, not EEPROM. --- src/devices/cpu/mcs48/mcs48.h | 50 +++++++++++++------------- src/emu/emuopts.cpp | 2 +- src/osd/windows/winmain.cpp | 67 +++++++++++++++++++++++++++++++++-- 3 files changed, 90 insertions(+), 29 deletions(-) diff --git a/src/devices/cpu/mcs48/mcs48.h b/src/devices/cpu/mcs48/mcs48.h index df143df239c..bb5d3da44f9 100644 --- a/src/devices/cpu/mcs48/mcs48.h +++ b/src/devices/cpu/mcs48/mcs48.h @@ -70,33 +70,33 @@ enum TYPES ***************************************************************************/ -/* Official Intel MCS-48 parts */ -DECLARE_DEVICE_TYPE(I8021, i8021_device) // 1k internal ROM, 64 bytes internal RAM -DECLARE_DEVICE_TYPE(I8022, i8022_device) // 2k internal ROM, 128 bytes internal RAM -DECLARE_DEVICE_TYPE(I8035, i8035_device) // external ROM, 64 bytes internal RAM -DECLARE_DEVICE_TYPE(I8048, i8048_device) // 1k internal ROM, 64 bytes internal RAM -DECLARE_DEVICE_TYPE(I8648, i8648_device) // 1k internal OTP ROM, 64 bytes internal RAM -DECLARE_DEVICE_TYPE(I8748, i8748_device) // 1k internal EEPROM, 64 bytes internal RAM -DECLARE_DEVICE_TYPE(I8039, i8039_device) // external ROM, 128 bytes internal RAM -DECLARE_DEVICE_TYPE(I8049, i8049_device) // 2k internal ROM, 128 bytes internal RAM -DECLARE_DEVICE_TYPE(I8749, i8749_device) // 2k internal EEPROM, 128 bytes internal RAM -DECLARE_DEVICE_TYPE(I8040, i8040_device) // external ROM, 256 bytes internal RAM -DECLARE_DEVICE_TYPE(I8050, i8050_device) // 4k internal ROM, 256 bytes internal RAM +// Official Intel MCS-48 parts +DECLARE_DEVICE_TYPE(I8021, i8021_device) // 1k internal ROM, 64 bytes internal RAM +DECLARE_DEVICE_TYPE(I8022, i8022_device) // 2k internal ROM, 128 bytes internal RAM +DECLARE_DEVICE_TYPE(I8035, i8035_device) // external ROM, 64 bytes internal RAM +DECLARE_DEVICE_TYPE(I8048, i8048_device) // 1k internal ROM, 64 bytes internal RAM +DECLARE_DEVICE_TYPE(I8648, i8648_device) // 1k internal OTP ROM, 64 bytes internal RAM +DECLARE_DEVICE_TYPE(I8748, i8748_device) // 1k internal UV EPROM, 64 bytes internal RAM +DECLARE_DEVICE_TYPE(I8039, i8039_device) // external ROM, 128 bytes internal RAM +DECLARE_DEVICE_TYPE(I8049, i8049_device) // 2k internal ROM, 128 bytes internal RAM +DECLARE_DEVICE_TYPE(I8749, i8749_device) // 2k internal UV EPROM, 128 bytes internal RAM +DECLARE_DEVICE_TYPE(I8040, i8040_device) // external ROM, 256 bytes internal RAM +DECLARE_DEVICE_TYPE(I8050, i8050_device) // 4k internal ROM, 256 bytes internal RAM -/* Official Intel UPI-41 parts */ -DECLARE_DEVICE_TYPE(I8041A, i8041a_device) // 1k internal ROM, 64 bytes internal RAM -DECLARE_DEVICE_TYPE(I8741A, i8741a_device) // 1k internal EEPROM, 64 bytes internal RAM -DECLARE_DEVICE_TYPE(I8041AH, i8041ah_device) // 1k internal ROM, 128 bytes internal RAM -DECLARE_DEVICE_TYPE(I8741AH, i8741ah_device) // 1k internal EEPROM, 128 bytes internal RAM -DECLARE_DEVICE_TYPE(I8042, i8042_device) // 2k internal ROM, 128 bytes internal RAM -DECLARE_DEVICE_TYPE(I8742, i8742_device) // 2k internal EEPROM, 128 bytes internal RAM -DECLARE_DEVICE_TYPE(I8042AH, i8042ah_device) // 2k internal ROM, 256 bytes internal RAM -DECLARE_DEVICE_TYPE(I8742AH, i8742ah_device) // 2k internal EEPROM, 256 bytes internal RAM +// Official Intel UPI-41 parts +DECLARE_DEVICE_TYPE(I8041A, i8041a_device) // 1k internal ROM, 64 bytes internal RAM +DECLARE_DEVICE_TYPE(I8741A, i8741a_device) // 1k internal UV EPROM, 64 bytes internal RAM +DECLARE_DEVICE_TYPE(I8041AH, i8041ah_device) // 1k internal ROM, 128 bytes internal RAM +DECLARE_DEVICE_TYPE(I8741AH, i8741ah_device) // 1k internal UV EPROM, 128 bytes internal RAM +DECLARE_DEVICE_TYPE(I8042, i8042_device) // 2k internal ROM, 128 bytes internal RAM +DECLARE_DEVICE_TYPE(I8742, i8742_device) // 2k internal UV EPROM, 128 bytes internal RAM +DECLARE_DEVICE_TYPE(I8042AH, i8042ah_device) // 2k internal ROM, 256 bytes internal RAM +DECLARE_DEVICE_TYPE(I8742AH, i8742ah_device) // 2k internal UV EPROM, 256 bytes internal RAM -/* Clones */ -DECLARE_DEVICE_TYPE(MB8884, mb8884_device) // 8035 clone -DECLARE_DEVICE_TYPE(N7751, n7751_device) // 8048 clone -DECLARE_DEVICE_TYPE(M58715, m58715_device) // 8049 clone +// Clones +DECLARE_DEVICE_TYPE(MB8884, mb8884_device) // 8035 clone +DECLARE_DEVICE_TYPE(N7751, n7751_device) // 8048 clone +DECLARE_DEVICE_TYPE(M58715, m58715_device) // 8049 clone diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp index bfe83daec16..8959c00da03 100644 --- a/src/emu/emuopts.cpp +++ b/src/emu/emuopts.cpp @@ -205,7 +205,7 @@ const options_entry emu_options::s_option_entries[] = { OPTION_RAMSIZE ";ram", nullptr, OPTION_STRING, "size of RAM (if supported by driver)" }, { OPTION_CONFIRM_QUIT, "0", OPTION_BOOLEAN, "ask for confirmation before exiting" }, { OPTION_UI_MOUSE, "1", OPTION_BOOLEAN, "display UI mouse cursor" }, - { OPTION_LANGUAGE ";lang", "English", OPTION_STRING, "set UI display language" }, + { OPTION_LANGUAGE ";lang", "", OPTION_STRING, "set UI display language" }, { OPTION_NVRAM_SAVE ";nvwrite", "1", OPTION_BOOLEAN, "save NVRAM data on exit" }, { nullptr, nullptr, OPTION_HEADER, "SCRIPTING OPTIONS" }, diff --git a/src/osd/windows/winmain.cpp b/src/osd/windows/winmain.cpp index 09315e5ca84..b24d2980c19 100644 --- a/src/osd/windows/winmain.cpp +++ b/src/osd/windows/winmain.cpp @@ -25,6 +25,10 @@ #include #include #include +#include +#include +#include +#include // standard windows headers #include @@ -55,6 +59,28 @@ class winui_output_error : public osd_output { +private: + struct ui_state + { + ~ui_state() + { + std::lock_guard guard(mutex); + if (thread) + thread->join(); + } + + std::ostringstream buffer; + std::optional thread; + std::mutex mutex; + bool active; + }; + + static ui_state &get_state() + { + static ui_state state; + return state; + } + public: virtual void output_callback(osd_output_channel channel, const util::format_argument_pack &args) override { @@ -64,12 +90,47 @@ public: if ((video_config.windowed == 0) && !osd_common_t::s_window_list.empty()) winwindow_toggle_full_screen(); - std::ostringstream buffer; - util::stream_format(buffer, args); - win_message_box_utf8(!osd_common_t::s_window_list.empty() ? std::static_pointer_cast(osd_common_t::s_window_list.front())->platform_window() : nullptr, buffer.str().c_str(), emulator_info::get_appname(), MB_OK); + auto &state(get_state()); + std::lock_guard guard(state.mutex); + util::stream_format(state.buffer, args); + if (!state.active) + { + if (state.thread) + { + state.thread->join(); + state.thread = std::nullopt; + } + auto const parent = !osd_common_t::s_window_list.empty() + ? std::static_pointer_cast(osd_common_t::s_window_list.front())->platform_window() + : nullptr; + state.thread.emplace( + [parent] () + { + auto &state(get_state()); + std::string message; + while (true) + { + { + std::lock_guard guard(state.mutex); + message = std::move(state.buffer).str(); + if (message.empty()) + { + state.active = false; + return; + } + state.buffer.str(std::string()); + } + // don't hold any locks lock while calling MessageBox + win_message_box_utf8(parent, message.c_str(), emulator_info::get_appname(), MB_OK); + } + }); + state.active = true; + } } else + { chain_output(channel, args); + } } };