From f6d210461d9017263c1f545d786bac24ba5d17d1 Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 25 Dec 2020 19:08:52 +0100 Subject: [PATCH] Remove debug console --- CMakeLists.txt | 2 - src/core/hle/D3D8/Direct3D9/Direct3D9.cpp | 48 +--- src/gui/DbgConsole.cpp | 289 ---------------------- src/gui/DbgConsole.h | 52 ---- 4 files changed, 6 insertions(+), 385 deletions(-) delete mode 100644 src/gui/DbgConsole.cpp delete mode 100644 src/gui/DbgConsole.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9451ef20a..212be2f6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,7 +97,6 @@ file (GLOB CXBXR_HEADER_GUIv1 "${CXBXR_ROOT_DIR}/src/common/input/Button.h" "${CXBXR_ROOT_DIR}/src/common/input/EmuDevice.h" "${CXBXR_ROOT_DIR}/src/common/input/InputWindow.h" - "${CXBXR_ROOT_DIR}/src/gui/DbgConsole.h" "${CXBXR_ROOT_DIR}/src/gui/DlgAbout.h" "${CXBXR_ROOT_DIR}/src/gui/DlgAudioConfig.h" "${CXBXR_ROOT_DIR}/src/gui/DlgInputConfig.h" @@ -227,7 +226,6 @@ file (GLOB CXBXR_SOURCE_COMMON "${CXBXR_ROOT_DIR}/src/common/xdvdfs-tools/buffered_io.cpp" "${CXBXR_ROOT_DIR}/src/common/xdvdfs-tools/xdvdfs.cpp" "${CXBXR_ROOT_DIR}/src/CxbxVersion.cpp" - "${CXBXR_ROOT_DIR}/src/gui/DbgConsole.cpp" "${CXBXR_ROOT_DIR}/src/HighPerformanceGraphicsEnabler.c" ) diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index 7965b0a84..9340ac6cd 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -26,11 +26,6 @@ // ****************************************************************** #define LOG_PREFIX CXBXR_MODULE::D3D8 -#ifdef CXBXR_EMU_EXPORTS // DbgConsole only in Cxbx/cxbxr, not in cxbxr-emu - #undef INCLUDE_DBG_CONSOLE -#else - #define INCLUDE_DBG_CONSOLE -#endif #include "common\util\hasher.h" // For ComputeHash #include #include @@ -42,9 +37,6 @@ #include "core\kernel\init\CxbxKrnl.h" #include "core\kernel\support\Emu.h" #include "EmuShared.h" -#ifdef INCLUDE_DBG_CONSOLE -#include "gui\DbgConsole.h" -#endif #include "core\hle\D3D8\ResourceTracker.h" #include "core\hle\D3D8\Direct3D9\Direct3D9.h" // For LPDIRECTDRAWSURFACE7 #include "core\hle\D3D8\XbVertexBuffer.h" @@ -1737,51 +1729,23 @@ static DWORD WINAPI EmuRenderWindow(LPVOID lpParam) SetFocus(g_hEmuWindow); -#ifdef INCLUDE_DBG_CONSOLE - DbgConsole *dbgConsole = new DbgConsole(); -#endif - SetEvent(*reinterpret_cast(lpParam)); // message processing loop { MSG msg; - - ZeroMemory(&msg, sizeof(msg)); - - bool lPrintfOn = g_bPrintfOn; - - while(msg.message != WM_QUIT) + BOOL bRet; + while((bRet = GetMessage(&msg, NULL, 0U, 0U)) != FALSE) { - if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) + if(bRet == -1) { - TranslateMessage(&msg); - DispatchMessage(&msg); + CxbxKrnlCleanup("GetMessage failed!"); } - else - { - Sleep(0); -#ifdef INCLUDE_DBG_CONSOLE - // if we've just switched back to display off, clear buffer & display prompt - if(!g_bPrintfOn && lPrintfOn) - { - dbgConsole->Reset(); - } -#endif - - lPrintfOn = g_bPrintfOn; - -#ifdef INCLUDE_DBG_CONSOLE - dbgConsole->Process(); -#endif - } + TranslateMessage(&msg); + DispatchMessage(&msg); } -#ifdef INCLUDE_DBG_CONSOLE - delete dbgConsole; -#endif - CxbxKrnlCleanup(nullptr); } diff --git a/src/gui/DbgConsole.cpp b/src/gui/DbgConsole.cpp deleted file mode 100644 index 07e9a4190..000000000 --- a/src/gui/DbgConsole.cpp +++ /dev/null @@ -1,289 +0,0 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check it. -// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com -// ****************************************************************** -// * -// * This file is part of the Cxbx project. -// * -// * Cxbx and Cxbe are free software; you can redistribute them -// * and/or modify them under the terms of the GNU General Public -// * License as published by the Free Software Foundation; either -// * version 2 of the license, or (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have recieved a copy of the GNU General Public License -// * along with this program; see the file COPYING. -// * If not, write to the Free Software Foundation, Inc., -// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA. -// * -// * (c) 2002-2004 Aaron Robinson -// * Kingofc -// * -// * All rights reserved -// * -// ****************************************************************** - -#include "core\kernel\init\CxbxKrnl.h" -#include "core\kernel\support\Emu.h" -#include "DbgConsole.h" -#include "core\hle\D3D8\ResourceTracker.h" - -#include - -DbgConsole::DbgConsole() -{ - m_cur = 0; - - printf("CxbxDbg> "); - fflush(stdout); - - m_szInput[0] = '\0'; -} - -DbgConsole::~DbgConsole() -{ -} - -void DbgConsole::Process() -{ - // process all queued key presses - while(_kbhit()) - { - char c = _getche(); - - if(c == '\r') - { - ParseCommand(); - - printf("CxbxDbg> "); - fflush(stdout); - - m_szInput[0] = '\0'; - m_cur = 0; - } - else if(c == '\b') - { - if(m_cur > 0) - { - printf(" \b"); - - m_szInput[--m_cur] = '\0'; - } - else - { - printf(" "); - } - } - else - { - m_szInput[m_cur++] = c; - m_szInput[m_cur] = '\0'; - } - } -} - -void DbgConsole::Reset() -{ - m_cur = 0; - - fflush(stdout); - - printf("\n"); - - printf("CxbxDbg> "); - fflush(stdout); - - m_szInput[0] = '\0'; -} - -typedef enum _ETAction -{ - ETA_ENABLE = 0, - ETA_DISABLE = 1, - ETA_SHOW = 2 -} -ETAction; - -static void EnableTracker(ResourceTracker &trackTotal, ResourceTracker &tracker, int a, int b, ETAction action) -{ - int v=0; - - trackTotal.Lock(); - - RTNode *cur = trackTotal.getHead(); - - for(v=0;vpNext == NULL)) - break; - - cur = cur->pNext; - } - - if((a == v) && (cur != NULL) && (cur->pNext != NULL)) - { - for(;a<=b;a++) - { - if((cur == NULL) || (cur->pNext == NULL)) - break; - - if(action == ETA_ENABLE) - printf("CxbxDbg: #%.02d (0x%p) enabled\n", a, cur->pResource); - else if(action == ETA_DISABLE) - printf("CxbxDbg: #%.02d (0x%p) disabled\n", a, cur->pResource); - else if(action == ETA_SHOW) - printf("CxbxDbg: #%.02d (0x%p) queued for show info..\n", a, cur->pResource); - - if(action == ETA_ENABLE) - { - tracker.remove(cur->pResource); - } - else - { - tracker.insert(cur->pResource); - } - - cur = cur->pNext; - } - } - else - { - printf("CxbxDbg: # out of range\n"); - } - - trackTotal.Unlock(); - - return; -} - -void DbgConsole::ParseCommand() -{ - printf("\n"); - - char szCmd[32]; - - szCmd[0] = '\0'; - - sscanf(m_szInput, "%s", szCmd); - - // TODO: as command list grows, turn into static string/ptr lookup - - if(_stricmp(szCmd, "h") == 0 || _stricmp(szCmd, "help") == 0) - { - printf("CxbxDbg: \n"); - printf("CxbxDbg: Cxbx-Reloaded Debug Command List:\n"); - printf("CxbxDbg: \n"); - printf("CxbxDbg: Help [H] : Show Command List\n"); - printf("CxbxDbg: Quit/Exit [Q] : Stop Emulation\n"); - printf("CxbxDbg: Trace [T] : Toggle Debug Trace\n"); - - LOG_CHECK_ENABLED_EX(CXBXR_MODULE::VTXB, LOG_LEVEL::DEBUG) { - printf("CxbxDbg: ListVB [LVB] : List Active Vertex Buffers\n"); - printf("CxbxDbg: DisableVB [DVB #] : Disable Active Vertex Buffer(s)\n"); - printf("CxbxDbg: EnableVB [EVB #] : Enable Active Vertex Buffer(s)\n"); - printf("CxbxDbg: DumpStreamCache [DSC] : Dumps the patched streams cache\n"); - } - - #ifdef _DEBUG_ALLOC - printf("CxbxDbg: DumpMem [DMEM] : Dump the heap allocation tracking table\n"); - #endif // _DEBUG_ALLOCC - - printf("CxbxDbg: CLS\n"); - printf("CxbxDbg: \n"); - printf("CxbxDbg: # denotes parameter of form [#] or [#-#]\n"); - printf("CxbxDbg: \n"); - } - else if(_stricmp(szCmd, "q") == 0 || _stricmp(szCmd, "quit") == 0 || _stricmp(szCmd, "exit") == 0) - { - printf("CxbxDbg: Goodbye...\n"); - CxbxKrnlCleanupEx(CXBXR_MODULE::GUI, NULL); - } - else if(_stricmp(szCmd, "t") == 0 || _stricmp(szCmd, "trace") == 0) - { - g_bPrintfOn = !g_bPrintfOn; - printf("CxbxDbg: Trace is now %s\n", g_bPrintfOn ? "ON" : "OFF"); - } - else if(_stricmp(szCmd, "lvb") == 0 || _stricmp(szCmd, "ListVB") == 0) - { - LOG_CHECK_ENABLED_EX(CXBXR_MODULE::VTXB, LOG_LEVEL::DEBUG) { - int v = 0; - - g_VBTrackTotal.Lock(); - - RTNode *cur = g_VBTrackTotal.getHead(); - - while (cur != NULL && cur->pNext != NULL) - { - bool enabled = g_VBTrackDisable.exists(cur->pResource); - - printf("CxbxDbg: %.2d : 0x%p (%s)\n", v++, cur->pResource, enabled ? "enabled" : "disabled"); - - cur = cur->pNext; - } - - g_VBTrackTotal.Unlock(); - } - } - else if(_stricmp(szCmd, "dvb") == 0 || _stricmp(szCmd, "DisableVB") == 0) - { - LOG_CHECK_ENABLED_EX(CXBXR_MODULE::VTXB, LOG_LEVEL::DEBUG) { - int n = 0, m = 0; - - int c = sscanf(m_szInput, "%*s %d-%d", &n, &m); - - if (c == 1) - { - EnableTracker(g_VBTrackTotal, g_VBTrackDisable, n, n, ETA_DISABLE); - } - else if (c == 2) - { - EnableTracker(g_VBTrackTotal, g_VBTrackDisable, n, m, ETA_DISABLE); - } - else - { - printf("CxbxDbg: Syntax Incorrect (dvb #)\n"); - } - } - } - else if(_stricmp(szCmd, "evb") == 0 || _stricmp(szCmd, "EnableVB") == 0) - { - LOG_CHECK_ENABLED_EX(CXBXR_MODULE::VTXB, LOG_LEVEL::DEBUG) { - int n = 0, m = 0; - - int c = sscanf(m_szInput, "%*s %d-%d", &n, &m); - - if (c == 1) - { - EnableTracker(g_VBTrackTotal, g_VBTrackDisable, n, n, ETA_ENABLE); - } - else if (c == 2) - { - EnableTracker(g_VBTrackTotal, g_VBTrackDisable, n, m, ETA_ENABLE); - } - else - { - printf("CxbxDbg: Syntax Incorrect (dvb #)\n"); - } - } - } - #ifdef _DEBUG_ALLOC - else if(_stricmp(szCmd, "dmem") == 0 || _stricmp(szCmd, "DumpMem") == 0) - { - int Full; - int c = sscanf(m_szInput, "%*s %d", &Full); - CxbxAllocDump(Full != 0); - } - #endif // _DEBUG_ALLOC - else if(_stricmp(szCmd, "cls") == 0) - { - // clear screen using system call - system("cls"); - } - else - { - printf("CxbxDbg: Cmd \"%s\" not recognized!\n", szCmd); - } -} diff --git a/src/gui/DbgConsole.h b/src/gui/DbgConsole.h deleted file mode 100644 index 6e4bf985b..000000000 --- a/src/gui/DbgConsole.h +++ /dev/null @@ -1,52 +0,0 @@ -// ****************************************************************** -// * -// * This file is part of the Cxbx project. -// * -// * Cxbx and Cxbe are free software; you can redistribute them -// * and/or modify them under the terms of the GNU General Public -// * License as published by the Free Software Foundation; either -// * version 2 of the license, or (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have recieved a copy of the GNU General Public License -// * along with this program; see the file COPYING. -// * If not, write to the Free Software Foundation, Inc., -// * 59 Temple Place - Suite 330, Bostom, MA 02111-1307, USA. -// * -// * (c) 2002-2003 Aaron Robinson -// * -// * All rights reserved -// * -// ****************************************************************** -#ifndef DBGCONSOLE_H -#define DBGCONSOLE_H - -#include "Cxbx.h" - -// debug console input -class DbgConsole -{ - public: - DbgConsole(); - ~DbgConsole(); - - // process commands - void Process(); - - // parse an individual command - void ParseCommand(); - - // reset input buffer & display prompt - void Reset(); - - private: - // keyboard buffer - char m_szInput[1024]; - unsigned int m_cur; -}; - -#endif