From 64889acf0dec050fb21ab2016e1cc3d47608f5e1 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 15 Aug 2021 09:59:33 +0300 Subject: [PATCH] Force restart if quickstart model or expansions are changed on the fly. --- devices.cpp | 49 ++++++++++++++++++++++++------------------- include/devices.h | 1 + main.cpp | 6 +++--- od-win32/win32gui.cpp | 40 ++++++++++++++++++++++------------- 4 files changed, 56 insertions(+), 40 deletions(-) diff --git a/devices.cpp b/devices.cpp index c6de8950..4c58a13a 100644 --- a/devices.cpp +++ b/devices.cpp @@ -284,46 +284,38 @@ void devices_update_sync(double svpos, double syncadjust) cd32_fmv_set_sync(svpos, syncadjust); } -void do_leave_program (void) +void virtualdevice_free(void) { #ifdef WITH_PPC // must be first uae_ppc_free(); #endif free_traps(); - sampler_free (); - graphics_leave (); - inputdevice_close (); - DISK_free (); - close_sound (); - dump_counts (); + sampler_free(); + inputdevice_close(); + DISK_free(); + dump_counts(); #ifdef SERIAL_PORT - serial_exit (); -#endif - if (! no_gui) - gui_exit (); -#ifdef USE_SDL - SDL_Quit (); + serial_exit(); #endif #ifdef AUTOCONFIG - expansion_cleanup (); + expansion_cleanup(); #endif #ifdef FILESYS - filesys_cleanup (); + filesys_cleanup(); #endif #ifdef BSDSOCKET - bsdlib_reset (); + bsdlib_reset(); #endif device_func_free(); #ifdef WITH_LUA - uae_lua_free (); + uae_lua_free(); #endif gfxboard_free(); - savestate_free (); - memory_cleanup (); - free_shm (); - cfgfile_addcfgparam (0); - machdep_free (); + savestate_free(); + memory_cleanup(); + free_shm(); + cfgfile_addcfgparam(0); driveclick_free(); ethernet_enumerate_free(); rtarea_free(); @@ -331,6 +323,19 @@ void do_leave_program (void) execute_device_items(device_leaves, device_leave_cnt); } +void do_leave_program (void) +{ + virtualdevice_free(); + graphics_leave(); + close_sound(); + if (! no_gui) + gui_exit(); +#ifdef USE_SDL + SDL_Quit(); +#endif + machdep_free(); +} + void virtualdevice_init (void) { reset_device_items(); diff --git a/include/devices.h b/include/devices.h index a1edf7ea..bc96a4e9 100644 --- a/include/devices.h +++ b/include/devices.h @@ -13,6 +13,7 @@ void devices_update_sound(double clk, double syncadjust); void devices_update_sync(double svpos, double syncadjust); void do_leave_program(void); void virtualdevice_init(void); +void virtualdevice_free(void); void devices_restore_start(void); void device_check_config(void); void devices_pause(void); diff --git a/main.cpp b/main.cpp index 791be8ab..6304b5bc 100644 --- a/main.cpp +++ b/main.cpp @@ -784,11 +784,11 @@ void uae_quit (void) target_quit (); } -/* 0 = normal, 1 = nogui, -1 = disable nogui */ +/* 0 = normal, 1 = nogui, -1 = disable nogui, -2 = autorestart */ void uae_restart (int opengui, const TCHAR *cfgfile) { uae_quit (); - restart_program = opengui > 0 ? 1 : (opengui == 0 ? 2 : 3); + restart_program = opengui == -2 ? 4 : (opengui > 0 ? 1 : (opengui == 0 ? 2 : 3)); restart_config[0] = 0; default_config = 0; if (cfgfile) @@ -1110,7 +1110,7 @@ static int real_main2 (int argc, TCHAR **argv) copy_prefs(&currprefs, &changed_prefs); no_gui = ! currprefs.start_gui; - if (restart_program == 2) + if (restart_program == 2 || restart_program == 4) no_gui = 1; else if (restart_program == 3) no_gui = 0; diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 713ade3c..4cadd56c 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -7060,21 +7060,22 @@ static INT_PTR CALLBACK PathsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM struct amigamodels { int compalevels; int id; + int resetlevels[6]; }; static struct amigamodels amodels[] = { - { 4, IDS_QS_MODEL_A500 }, // "Amiga 500" - { 4, IDS_QS_MODEL_A500P }, // "Amiga 500+" - { 4, IDS_QS_MODEL_A600 }, // "Amiga 600" - { 4, IDS_QS_MODEL_A1000 }, // "Amiga 1000" - { 5, IDS_QS_MODEL_A1200 }, // "Amiga 1200" - { 2, IDS_QS_MODEL_A3000 }, // "Amiga 3000" - { 1, IDS_QS_MODEL_A4000 }, // "Amiga 4000" + { 4, IDS_QS_MODEL_A500, { 0, 0, 0, 0, 0, 0 } }, // "Amiga 500" + { 4, IDS_QS_MODEL_A500P, { 0, 0, 0, 0, 0, 0 } }, // "Amiga 500+" + { 4, IDS_QS_MODEL_A600, { 0, 0, 1, 0, 0, 0 } }, // "Amiga 600" + { 4, IDS_QS_MODEL_A1000, { 0, 0, 0, 0, 0, 0 } }, // "Amiga 1000" + { 5, IDS_QS_MODEL_A1200, { 0, 1, 2, 3, 4, 5 } }, // "Amiga 1200" + { 2, IDS_QS_MODEL_A3000, { 0, 0, 0, 0, 0, 0 } }, // "Amiga 3000" + { 1, IDS_QS_MODEL_A4000, { 0, 0, 1, 0, 0, 0 } }, // "Amiga 4000" { 0, }, //{ 1, IDS_QS_MODEL_A4000T }, // "Amiga 4000T" - { 4, IDS_QS_MODEL_CD32 }, // "CD32" - { 4, IDS_QS_MODEL_CDTV }, // "CDTV" - { 4, IDS_QS_MODEL_ARCADIA }, // "Arcadia" - { 1, IDS_QS_MODEL_MACROSYSTEM }, - { 1, IDS_QS_MODEL_UAE }, // "Expanded UAE example configuration" + { 4, IDS_QS_MODEL_CD32, { 0, 0, 1, 0, 0, 0 } }, // "CD32" + { 4, IDS_QS_MODEL_CDTV, { 0, 0, 1, 0, 0, 0 } }, // "CDTV" + { 4, IDS_QS_MODEL_ARCADIA, { 0, 0, 0, 0, 0, 0 } }, // "Arcadia" + { 1, IDS_QS_MODEL_MACROSYSTEM, { 0, 0, 0, 0, 0, 0 } }, + { 1, IDS_QS_MODEL_UAE, { 0, 0, 0, 0, 0, 0 } }, // "Expanded UAE example configuration" { -1 } }; @@ -7430,20 +7431,24 @@ static INT_PTR CALLBACK QuickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, L if (quickstart) load_quickstart (hDlg, 1); if (quickstart && !full_property_sheet) - qs_request_reset = 2; + qs_request_reset |= 4; } } break; case IDC_QUICKSTART_CONFIGURATION: val = SendDlgItemMessage (hDlg, IDC_QUICKSTART_CONFIGURATION, CB_GETCURSEL, 0, 0L); if (val != CB_ERR && val != quickstart_conf) { + int rslevel = amodels[quickstart_model].resetlevels[quickstart_conf]; quickstart_conf = val; + if (!full_property_sheet && amodels[quickstart_model].resetlevels[quickstart_conf] != rslevel) { + qs_request_reset |= 4; + } quickstart_model_confstore[quickstart_model] = quickstart_conf; init_quickstartdlg (hDlg); if (quickstart) load_quickstart (hDlg, 1); if (quickstart && !full_property_sheet) - qs_request_reset = 2; + qs_request_reset |= 2; } break; case IDC_QUICKSTART_HOSTCONFIG: @@ -22195,7 +22200,12 @@ gui_exit: if (quit_program) { psresult = -2; } else if (qs_request_reset && quickstart) { - uae_reset(qs_request_reset == 2 ? 1 : 0, 1); + if (qs_request_reset & 4) { + copy_prefs(&changed_prefs, &currprefs); + uae_restart(-2, NULL); + } else { + uae_reset((qs_request_reset & 2) ? 1 : 0, 1); + } } if (psresult > 0 && config_pathfilename[0]) { DISK_history_add(config_pathfilename, -1, HISTORY_CONFIGFILE, false); -- 2.47.3