-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.
This commit is contained in:
Vas Crabb 2021-11-12 18:38:18 +11:00
parent dc6ddf122c
commit 5c8e06be77
3 changed files with 90 additions and 29 deletions

View File

@ -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

View File

@ -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" },

View File

@ -25,6 +25,10 @@
#include <clocale>
#include <cstdarg>
#include <cstdio>
#include <mutex>
#include <optional>
#include <sstream>
#include <thread>
// standard windows headers
#include <windows.h>
@ -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<std::thread> 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<std::ostream> &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<win_window_info>(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<std::mutex> 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<win_window_info>(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<std::mutex> 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);
}
}
};