From f09710a5f732facb7948ea6241735abaf1c55eb6 Mon Sep 17 00:00:00 2001 From: joevt Date: Sun, 5 May 2024 23:40:32 -0700 Subject: [PATCH] viacuda: Do shutdown. Shutdown will enter the debugger or quit depending on the execution mode. Quit is different from shutdown since it is triggered outside the guest by using the host Quit menu item. --- core/hostevents_sdl.cpp | 2 +- cpu/ppc/ppcemu.h | 4 +++- debugger/debugger.cpp | 4 ++++ devices/common/viacuda.cpp | 6 +++++- main.cpp | 9 +++++++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/core/hostevents_sdl.cpp b/core/hostevents_sdl.cpp index 258ee6b..b199a9a 100644 --- a/core/hostevents_sdl.cpp +++ b/core/hostevents_sdl.cpp @@ -41,7 +41,7 @@ void EventManager::poll_events() switch (event.type) { case SDL_QUIT: power_on = false; - power_off_reason = po_shut_down; + power_off_reason = po_quit; break; case SDL_WINDOWEVENT: { diff --git a/cpu/ppc/ppcemu.h b/cpu/ppc/ppcemu.h index 45f35a1..70d3f93 100644 --- a/cpu/ppc/ppcemu.h +++ b/cpu/ppc/ppcemu.h @@ -306,10 +306,12 @@ extern jmp_buf exc_env; enum Po_Cause : int { po_none, po_starting_up, + po_quit, + po_quitting, po_shut_down, po_shutting_down, - po_restarting, po_restart, + po_restarting, po_disassemble_on, po_disassemble_off, po_enter_debugger, diff --git a/debugger/debugger.cpp b/debugger/debugger.cpp index 133586f..456e28c 100644 --- a/debugger/debugger.cpp +++ b/debugger/debugger.cpp @@ -470,6 +470,10 @@ void enter_debugger() { power_off_reason = po_restarting; break; } + if (power_off_reason == po_quit) { + power_off_reason = po_quitting; + break; + } power_on = true; if (power_off_reason == po_starting_up) { diff --git a/devices/common/viacuda.cpp b/devices/common/viacuda.cpp index 1201f86..e732233 100644 --- a/devices/common/viacuda.cpp +++ b/devices/common/viacuda.cpp @@ -733,8 +733,12 @@ void ViaCuda::pseudo_command() { power_on = false; power_off_reason = po_restart; break; - case CUDA_WARM_START: case CUDA_POWER_DOWN: + LOG_F(INFO, "Cuda: system shutdown"); + power_on = false; + power_off_reason = po_shut_down; + break; + case CUDA_WARM_START: case CUDA_MONO_STABLE_RESET: /* really kludge temp code */ LOG_F(INFO, "Cuda: Restart/Shutdown signal sent with command 0x%x!", cmd); diff --git a/main.cpp b/main.cpp index 3922195..d1f58c0 100644 --- a/main.cpp +++ b/main.cpp @@ -211,6 +211,15 @@ int main(int argc, char** argv) { power_on = true; continue; } + if (power_off_reason == po_shutting_down) { + if (execution_mode != debugger) { + LOG_F(INFO, "Shutdown."); + break; + } + LOG_F(INFO, "Shutdown..."); + power_on = true; + continue; + } break; }