|
|
1.1 root 1: /*
2: Hatari - dlgHalt.c - Emulation halt + reset handling alertbox
3:
4: Copyright (C) 2015 by Eero Tamminen
5:
6: This file is distributed under the GNU General Public License, version 2
7: or at your option any later version. Read the file gpl.txt for details.
8: */
9: const char DlgHalt_fileid[] = "Hatari dlgHalt.c : " __DATE__ " " __TIME__;
10:
11: #include <string.h>
12:
13: #include "main.h"
14: #include "reset.h"
15: #include "debugui.h"
16: #include "dialog.h"
17: #include "screen.h"
18: #include "sdlgui.h"
1.1.1.2 root 19: #include "m68000.h"
1.1 root 20:
21: #define DLGHALT_WARM 2
22: #define DLGHALT_COLD 3
23: #define DLGHALT_DEBUG 4
24: #define DLGHALT_QUIT 5
25:
1.1.1.3 ! root 26: #define DLGHALT_MSG "Detected double bus/address error => CPU halted!"
! 27:
1.1 root 28: /* The "Halt"-dialog: */
29: static SGOBJ haltdlg[] = {
30: { SGBOX, 0, 0, 0,0, 52,7, NULL },
1.1.1.3 ! root 31: { SGTEXT, 0, 0, 2,1, 48,1, DLGHALT_MSG },
1.1 root 32: { SGBUTTON, SG_DEFAULT, 0, 6,3, 12,1, "_Warm reset" },
33: { SGBUTTON, 0, 0, 6,5, 12,1, "_Cold reset" },
34: { SGBUTTON, 0, 0, 28,3, 18,1, "Console _debugger" },
35: { SGBUTTON, SG_CANCEL, 0, 28,5, 18,1, "_Quit Hatari" },
1.1.1.2 root 36: { SGSTOP, 0, 0, 0,0, 0,0, NULL }
1.1 root 37: };
38:
39:
40: /*-----------------------------------------------------------------------*/
41: /**
1.1.1.3 ! root 42: * Make Hatari quit
! 43: */
! 44: static void do_quit(int exitval)
! 45: {
! 46: if (bQuitProgram) {
! 47: /* got here again, cold reset emulation to make sure we actually can exit */
! 48: fputs("Halt dialog invoked during Hatari shutdown, doing emulation cold reset...\n", stderr);
! 49: Reset_Cold();
! 50: }
! 51: Main_SetQuitValue(exitval);
! 52: }
! 53:
! 54: /*-----------------------------------------------------------------------*/
! 55: /**
1.1 root 56: * Show the "halt" dialog
57: */
58: void Dialog_HaltDlg(void)
59: {
60: bool show = SDL_ShowCursor(SDL_QUERY);
61: #if WITH_SDL2
62: bool mode = SDL_GetRelativeMouseMode();
63: SDL_SetRelativeMouseMode(SDL_FALSE);
64: #endif
65: SDL_ShowCursor(SDL_ENABLE);
66:
1.1.1.3 ! root 67: /* if we get halt with --run-vbls, just quit right away */
! 68: if (Main_SetRunVBLs(0))
! 69: {
! 70: Log_Printf(LOG_ERROR, DLGHALT_MSG);
! 71: do_quit(1);
! 72: return;
! 73: }
! 74:
! 75: if (SDLGui_SetScreen(sdlscrn))
! 76: return;
1.1 root 77: SDLGui_CenterDlg(haltdlg);
78: switch (SDLGui_DoDialog(haltdlg, NULL, false)) {
79:
80: case DLGHALT_WARM:
81: /* Reset to exit 'halt' state (resets CPU and regs.spcflags) */
82: Reset_Warm();
83: break;
84: case DLGHALT_COLD:
85: /* Warm reset isn't always enough to restore emulated system to working state */
86: Reset_Cold();
87: break;
88: case DLGHALT_DEBUG:
89: /* Call the debugger, restore screen so user sees whats on it */
90: SDL_UpdateRect(sdlscrn, 0,0, 0,0);
91: DebugUI(REASON_CPU_EXCEPTION);
92: break;
1.1.1.3 ! root 93: case DLGHALT_QUIT:
! 94: case SDLGUI_QUIT:
! 95: do_quit(0);
! 96: break;
1.1 root 97: default:
1.1.1.3 ! root 98: /* GUI errors */
! 99: do_quit(1);
1.1 root 100: }
101: SDL_ShowCursor(show);
102: #if WITH_SDL2
103: SDL_SetRelativeMouseMode(mode);
104: #endif
105: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.