From 7a7b2b35e2be1e6526d8aeea2576e8c9231aa73c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Mar 2013 22:36:38 -0500 Subject: [PATCH] HOPKINS: Added a debugger command to frame dirty rects --- engines/hopkins/debugger.cpp | 13 +++++++++++++ engines/hopkins/debugger.h | 2 ++ engines/hopkins/graphics.cpp | 14 ++++++++++++++ engines/hopkins/graphics.h | 1 + 4 files changed, 30 insertions(+) diff --git a/engines/hopkins/debugger.cpp b/engines/hopkins/debugger.cpp index 0abfd1f62ef..07a0c92be6d 100644 --- a/engines/hopkins/debugger.cpp +++ b/engines/hopkins/debugger.cpp @@ -30,10 +30,23 @@ namespace Hopkins { Debugger::Debugger() : GUI::Debugger() { DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); + DCmd_Register("rects", WRAP_METHOD(Debugger, cmd_DirtyRects)); } void Debugger::setParent(HopkinsEngine *vm) { _vm = vm; } +// Turns dirty rects on or off +bool Debugger::cmd_DirtyRects(int argc, const char **argv) { + if (argc != 2) { + DebugPrintf("%s: [on | off]\n", argv[0]); + return true; + } else { + _vm->_graphicsManager._showDirtyRects = !strcmp(argv[1], "on"); + return false; + } +} + + } // End of namespace Hopkins diff --git a/engines/hopkins/debugger.h b/engines/hopkins/debugger.h index aabc95c5f1d..1ce018b38c0 100644 --- a/engines/hopkins/debugger.h +++ b/engines/hopkins/debugger.h @@ -38,6 +38,8 @@ public: Debugger(); virtual ~Debugger() {} void setParent(HopkinsEngine *vm); + + bool cmd_DirtyRects(int argc, const char **argv); }; } // End of namespace Hopkins diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0c06ef7f48d..540c18f1b40 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -51,6 +51,7 @@ GraphicsManager::GraphicsManager() { _vesaBuffer = NULL; _screenBuffer = NULL; _isPhysicalPtr = false; + _showDirtyRects = false; _lineNbr2 = 0; Agr_x = Agr_y = 0; @@ -1142,6 +1143,13 @@ void GraphicsManager::displayDirtyRects() { return; lockScreen(); + + // Refresh the entire screen + Graphics::Surface *screenSurface = NULL; + if (_showDirtyRects) { + screenSurface = g_system->lockScreen(); + g_system->copyRectToScreen(_screenBuffer, WinScan, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + } for (uint idx = 0; idx < _dirtyRects.size(); ++idx) { Common::Rect &r = _dirtyRects[idx]; @@ -1176,10 +1184,16 @@ void GraphicsManager::displayDirtyRects() { byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2); g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top, dstRect.width(), dstRect.height()); + + if (_showDirtyRects) + screenSurface->frameRect(dstRect, 0xffffff); } } unlockScreen(); + if (_showDirtyRects) + g_system->unlockScreen(); + resetDirtyRects(); } diff --git a/engines/hopkins/graphics.h b/engines/hopkins/graphics.h index bdd8fee578e..54e41569829 100644 --- a/engines/hopkins/graphics.h +++ b/engines/hopkins/graphics.h @@ -110,6 +110,7 @@ public: */ Common::Array _dirtyRects; Common::Array _refreshRects; + bool _showDirtyRects; int WinScan; byte *PAL_PIXELS;