From 7c078d4be1854fbbfe567d5fda5f764634f62084 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 19 Nov 2020 19:27:04 +0100 Subject: [PATCH] The power off API now actually shuts down the emulator. --- src/win/win_ui.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 4ad451058..51dbb9e46 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -34,6 +34,8 @@ #include <86box/device.h> #include <86box/keyboard.h> #include <86box/mouse.h> +#include <86box/timer.h> +#include <86box/nvr.h> #include <86box/video.h> #include <86box/vid_ega.h> // for update_overscan #include <86box/plat.h> @@ -350,6 +352,7 @@ void plat_power_off(void) { confirm_exit = 0; + nvr_save(); config_save(); /* Deduct a sufficiently large number of cycles that no instructions will @@ -360,6 +363,12 @@ plat_power_off(void) KillTimer(hwndMain, TIMER_1SEC); PostQuitMessage(0); + + /* Cleanly terminate all of the emulator's components so as + to avoid things like threads getting stuck. */ + do_stop(); + + exit(-1); } @@ -401,6 +410,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) pc_reset_hard(); if (i == 10) { confirm_reset = 0; + nvr_save(); config_save(); } } @@ -421,6 +431,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if ((i % 10) == 0) { if (i == 10) { confirm_exit = 0; + nvr_save(); config_save(); } #ifndef NO_KEYBOARD_HOOK @@ -801,6 +812,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if ((i % 10) == 0) { if (i == 10) { confirm_exit = 0; + nvr_save(); config_save(); } #ifndef NO_KEYBOARD_HOOK @@ -849,6 +861,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) pc_reset_hard(); if (i == 10) { confirm_reset = 0; + nvr_save(); config_save(); } } @@ -866,6 +879,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if ((i % 10) == 0) { if (i == 10) { confirm_exit = 0; + nvr_save(); config_save(); } #ifndef NO_KEYBOARD_HOOK