Allow breaking into main menu before the machine fully starts (i.e. just before the initial soft reset) by using the normal "Config Menu" UI input

Note that the minor code shuffling in machine.cpp is necessary to prevent emulation from getting confused if "Select New Game" happens to be selected.
This commit is contained in:
AJR 2021-04-06 11:16:47 -04:00 committed by Vas Crabb
parent d7fa230add
commit 0b3f153f4d
3 changed files with 29 additions and 7 deletions

View File

@ -355,6 +355,8 @@ int running_machine::run(bool quiet)
if (!quiet)
sound().start_recording();
m_hard_reset_pending = false;
// initialize ui lists
// display the startup screens
manager().ui_initialize(*this);
@ -368,8 +370,6 @@ int running_machine::run(bool quiet)
export_http_api();
m_hard_reset_pending = false;
#if defined(__EMSCRIPTEN__)
// break out to our async javascript loop and halt
emscripten_set_running_machine(this);

View File

@ -1174,7 +1174,10 @@ void menu::do_handle()
// add an item to return - this is a really hacky way of doing this
if (!m_parent)
{
item_append(_("Return to Machine"), 0, nullptr);
if (machine().phase() == machine_phase::INIT)
item_append(_("Start Machine"), 0, nullptr);
else
item_append(_("Return to Machine"), 0, nullptr);
}
else if (m_parent->is_special_main_menu())
{

View File

@ -424,8 +424,9 @@ void mame_ui_manager::display_startup_screens(bool first_time)
switch_code_poller poller(machine().input());
std::string warning_text;
rgb_t warning_color;
bool config_menu = false;
auto handler_messagebox_anykey =
[this, &poller, &warning_text, &warning_color] (render_container &container) -> uint32_t
[this, &poller, &warning_text, &warning_color, &config_menu] (render_container &container) -> uint32_t
{
// draw a standard message window
draw_text_box(container, warning_text, ui::text_layout::LEFT, 0.5f, 0.5f, warning_color);
@ -436,6 +437,11 @@ void mame_ui_manager::display_startup_screens(bool first_time)
machine().schedule_exit();
return UI_HANDLER_CANCEL;
}
else if (machine().ui_input().pressed(IPT_UI_CONFIGURE))
{
config_menu = true;
return UI_HANDLER_CANCEL;
}
else if (poller.poll() != INPUT_CODE_INVALID)
{
// if any key is pressed, just exit
@ -561,9 +567,14 @@ void mame_ui_manager::display_startup_screens(bool first_time)
poller.reset();
while (poller.poll() != INPUT_CODE_INVALID) { }
// loop while we have a handler
while (m_handler_callback_type == ui_callback_type::MODAL && !machine().scheduled_event_pending() && !ui::menu::stack_has_special_main_menu(machine()))
machine().video().frame_update();
if (m_handler_callback_type == ui_callback_type::MODAL)
{
config_menu = false;
// loop while we have a handler
while (m_handler_callback_type == ui_callback_type::MODAL && !machine().scheduled_event_pending() && !ui::menu::stack_has_special_main_menu(machine()))
machine().video().frame_update();
}
// clear the handler and force an update
set_handler(ui_callback_type::GENERAL, std::bind(&mame_ui_manager::handler_ingame, this, _1));
@ -577,6 +588,14 @@ void mame_ui_manager::display_startup_screens(bool first_time)
// if we're the empty driver, force the menus on
if (ui::menu::stack_has_special_main_menu(machine()))
show_menu();
else if (config_menu)
{
show_menu();
// loop while we have a handler
while (m_handler_callback_type != ui_callback_type::GENERAL && !machine().scheduled_event_pending())
machine().video().frame_update();
}
}