From 3cc3198d767af7672b1a7aa7afaae8318c93e2f8 Mon Sep 17 00:00:00 2001 From: dinkc64 Date: Mon, 20 May 2019 00:36:46 -0400 Subject: [PATCH] add option to disable console debug window on debug builds. update whatsnew --- src/burner/win32/app.rc | 3 +++ src/burner/win32/burner_win32.h | 3 +++ src/burner/win32/cona.cpp | 9 +++++++++ src/burner/win32/main.cpp | 35 ++++++++++++++++++++++----------- src/burner/win32/menu.cpp | 3 +++ src/burner/win32/resource.h | 1 + src/burner/win32/scrn.cpp | 6 ++++++ whatsnew.html | 14 ++++++------- 8 files changed, 55 insertions(+), 19 deletions(-) diff --git a/src/burner/win32/app.rc b/src/burner/win32/app.rc index 011392c570..cac78c6617 100644 --- a/src/burner/win32/app.rc +++ b/src/burner/win32/app.rc @@ -1187,6 +1187,9 @@ BEGIN MENUITEM "Low", MENU_PRIORITY_LOW END MENUITEM "Enable high resolution system timer", MENU_HIGHRESTIMER +#ifdef FBNEO_DEBUG + MENUITEM "Show Debug console (requires restart)", MENU_DEBUGCONSOLE +#endif MENUITEM SEPARATOR #ifdef BUILD_A68K MENUITEM "Use assembly MC68000 core (this session only)", MENU_ASSEMBLYCORE diff --git a/src/burner/win32/burner_win32.h b/src/burner/win32/burner_win32.h index 927b8d6487..182f47a609 100644 --- a/src/burner/win32/burner_win32.h +++ b/src/burner/win32/burner_win32.h @@ -91,6 +91,9 @@ INT32 Dx9Core_Init(); // --------------------------------------------------------------------------- // main.cpp +#if defined (FBNEO_DEBUG) +extern bool bDisableDebugConsole; // Disable debug console? +#endif extern HINSTANCE hAppInst; // Application Instance extern HANDLE hMainThread; // Handle to the main thread extern long int nMainThreadID; // ID of the main thread diff --git a/src/burner/win32/cona.cpp b/src/burner/win32/cona.cpp index e8540641bf..35688d79b6 100644 --- a/src/burner/win32/cona.cpp +++ b/src/burner/win32/cona.cpp @@ -178,6 +178,10 @@ int ConfigAppLoad() VAR(nSplashTime); +#if defined (FBNEO_DEBUG) + VAR(bDisableDebugConsole); +#endif + VAR(bDrvSaveAll); VAR(nAppThreadPriority); VAR(bAlwaysProcessKeyboardInput); @@ -536,6 +540,11 @@ int ConfigAppSave() _ftprintf(h, _T("\n// Minimum length of time to display the splash screen (in milliseconds)\n")); VAR(nSplashTime); +#if defined (FBNEO_DEBUG) + _ftprintf(h, _T("\n// Disable the text-debug console (hint: needed for debugging with gdb!)\n")); + VAR(bDisableDebugConsole); +#endif + _ftprintf(h, _T("\n// If non-zero, load and save all ram (the state)\n")); VAR(bDrvSaveAll); _ftprintf(h, _T("\n// The thread priority for the application. Do *NOT* edit this manually\n")); diff --git a/src/burner/win32/main.cpp b/src/burner/win32/main.cpp index 02c97c9fa8..6de0d1a828 100644 --- a/src/burner/win32/main.cpp +++ b/src/burner/win32/main.cpp @@ -20,6 +20,10 @@ #endif #endif +#if defined (FBNEO_DEBUG) +bool bDisableDebugConsole = true; +#endif + #include "version.h" HINSTANCE hAppInst = NULL; // Application Instance @@ -279,7 +283,7 @@ static int __cdecl AppDebugPrintf(int nStatus, TCHAR* pszFormat, ...) fflush(DebugLog); } - if (!DebugLog || bEchoLog) { + if (!bDisableDebugConsole && (!DebugLog || bEchoLog)) { _vsntprintf(szConsoleBuffer, 1024, pszFormat, vaFormat); if (nStatus != nPrevConsoleStatus) { @@ -332,7 +336,9 @@ int dprintf(TCHAR* pszFormat, ...) if (DebugLog) { _ftprintf(DebugLog, _T("
")); } - SetConsoleTextAttribute(DebugBuffer, FOREGROUND_INTENSITY); + if (!bDisableDebugConsole) { + SetConsoleTextAttribute(DebugBuffer, FOREGROUND_INTENSITY); + } nPrevConsoleStatus = PRINT_UI; } @@ -342,7 +348,9 @@ int dprintf(TCHAR* pszFormat, ...) } tcharstrreplace(szConsoleBuffer, _T(SEPERATOR_1), _T(" * ")); - WriteConsole(DebugBuffer, szConsoleBuffer, _tcslen(szConsoleBuffer), NULL, NULL); + if (!bDisableDebugConsole) { + WriteConsole(DebugBuffer, szConsoleBuffer, _tcslen(szConsoleBuffer), NULL, NULL); + } va_end(vaFormat); #else (void)pszFormat; @@ -362,12 +370,14 @@ void CloseDebugLog() DebugLog = NULL; } - if (DebugBuffer) { - CloseHandle(DebugBuffer); - DebugBuffer = NULL; - } + if (!bDisableDebugConsole) { + if (DebugBuffer) { + CloseHandle(DebugBuffer); + DebugBuffer = NULL; + } - FreeConsole(); + FreeConsole(); + } #endif } @@ -426,6 +436,7 @@ int OpenDebugLog() } #endif + if (!bDisableDebugConsole) { // Initialise the debug console @@ -607,10 +618,6 @@ static int AppInit() _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF); // #endif -#if defined (FBNEO_DEBUG) - OpenDebugLog(); -#endif - // Create a handle to the main thread of execution DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, 0, false, DUPLICATE_SAME_ACCESS); @@ -620,6 +627,10 @@ static int AppInit() // Load config for the application ConfigAppLoad(); +#if defined (FBNEO_DEBUG) + OpenDebugLog(); +#endif + FBALocaliseInit(szLocalisationTemplate); BurnerDoGameListLocalisation(); diff --git a/src/burner/win32/menu.cpp b/src/burner/win32/menu.cpp index 891cbf04ea..3f9ef6520a 100644 --- a/src/burner/win32/menu.cpp +++ b/src/burner/win32/menu.cpp @@ -974,6 +974,9 @@ void MenuUpdate() CheckMenuItem(hMenu, MENU_MODELESS, bModelessMenu ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hMenu, MENU_NOCHANGENUMLOCK, bNoChangeNumLock ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hMenu, MENU_HIGHRESTIMER, bEnableHighResTimer ? MF_CHECKED : MF_UNCHECKED); +#if defined (FBNEO_DEBUG) + CheckMenuItem(hMenu, MENU_DEBUGCONSOLE, bDisableDebugConsole ? MF_UNCHECKED : MF_CHECKED); +#endif CheckMenuItem(hMenu, MENU_CREATEDIRS, bAlwaysCreateSupportFolders ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hMenu, MENU_AUTOLOADGAMELIST, bAutoLoadGameList ? MF_CHECKED : MF_UNCHECKED); CheckMenuItem(hMenu, MENU_SAVEHISCORES, EnableHiscores ? MF_CHECKED : MF_UNCHECKED); diff --git a/src/burner/win32/resource.h b/src/burner/win32/resource.h index 81d13fea99..a511793ac6 100644 --- a/src/burner/win32/resource.h +++ b/src/burner/win32/resource.h @@ -553,6 +553,7 @@ #define MENU_SNAPFACT 10317 #define MENU_SAVESNAP 10318 #define MENU_HIGHRESTIMER 10319 +#define MENU_DEBUGCONSOLE 10320 #define MENU_ASSOCIATE 10330 #define MENU_DISASSOCIATE 10331 #define MENU_SAVEGAMEINPUTNOW 10332 diff --git a/src/burner/win32/scrn.cpp b/src/burner/win32/scrn.cpp index fb8c613ea3..82507e23a3 100644 --- a/src/burner/win32/scrn.cpp +++ b/src/burner/win32/scrn.cpp @@ -1983,6 +1983,12 @@ static void OnCommand(HWND /*hDlg*/, int id, HWND /*hwndCtl*/, UINT codeNotify) EnableHighResolutionTiming(); // use new setting. break; +#if defined (FBNEO_DEBUG) + case MENU_DEBUGCONSOLE: + bDisableDebugConsole = !bDisableDebugConsole; + break; +#endif + case MENU_CREATEDIRS: bAlwaysCreateSupportFolders = !bAlwaysCreateSupportFolders; break; diff --git a/whatsnew.html b/whatsnew.html index 146ff6d59d..d44a265536 100644 --- a/whatsnew.html +++ b/whatsnew.html @@ -3,7 +3,7 @@ -FB Alpha - What's New +FinalBurn Neo - What's New