From 0b3f153f4db7ebb63f59bdf2dd098dfea26e1b44 Mon Sep 17 00:00:00 2001 From: AJR Date: Tue, 6 Apr 2021 11:16:47 -0400 Subject: [PATCH] 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. --- src/emu/machine.cpp | 4 ++-- src/frontend/mame/ui/menu.cpp | 5 ++++- src/frontend/mame/ui/ui.cpp | 27 +++++++++++++++++++++++---- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index 510b763b523..aecaf26ed15 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -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); diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp index 2c0ee801f92..c53736b2ab4 100644 --- a/src/frontend/mame/ui/menu.cpp +++ b/src/frontend/mame/ui/menu.cpp @@ -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()) { diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index 64ee74d8f6b..bbc9c1aa6cd 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -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(); + } }