Skip to content

Commit

Permalink
TONY: Created a debugger command 'dirty_rects' to show dirty rect are…
Browse files Browse the repository at this point in the history
…as on-screen
  • Loading branch information
dreammaster committed Jun 22, 2012
1 parent 1728908 commit eef6b44
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
14 changes: 14 additions & 0 deletions engines/tony/debugger.cpp
Expand Up @@ -30,6 +30,7 @@ namespace Tony {
Debugger::Debugger() : GUI::Debugger() {
DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit));
DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_Scene));
DCmd_Register("dirty_rects", WRAP_METHOD(Debugger, Cmd_DirtyRects));
}

static int strToInt(const char *s) {
Expand Down Expand Up @@ -113,4 +114,17 @@ bool Debugger::Cmd_Scene(int argc, const char **argv) {
return false;
}

/**
* Turns showing dirty rects on or off
*/
bool Debugger::Cmd_DirtyRects(int argc, const char **argv) {
if (argc != 2) {
DebugPrintf("Usage; %s [on | off]\n", argv[0]);
return true;
} else {
_vm->_window.showDirtyRects(strcmp(argv[1], "on") == 0);
return false;
}
}

} // End of namespace Tony
1 change: 1 addition & 0 deletions engines/tony/debugger.h
Expand Up @@ -35,6 +35,7 @@ class Debugger : public GUI::Debugger {

protected:
bool Cmd_Scene(int argc, const char **argv);
bool Cmd_DirtyRects(int argc, const char **argv);
};

} // End of namespace Tony
Expand Down
16 changes: 16 additions & 0 deletions engines/tony/window.cpp
Expand Up @@ -27,6 +27,7 @@
*/

#include "common/scummsys.h"
#include "graphics/surface.h"
#include "util.h"
#include "tony/window.h"
#include "tony/game.h"
Expand All @@ -40,6 +41,7 @@ namespace Tony {
\****************************************************************************/

RMWindow::RMWindow() {
_showDirtyRects = false;
}

RMWindow::~RMWindow() {
Expand Down Expand Up @@ -126,11 +128,25 @@ void RMWindow::getNewFrame(RMGfxTargetBuffer &bigBuf, Common::Rect *rcBoundEllip
Common::List<Common::Rect> dirtyRects = bigBuf.getDirtyRects();
Common::List<Common::Rect>::iterator i;

// If showing dirty rects, copy the entire screen background and set up a surface pointer
Graphics::Surface *s = NULL;
if (_showDirtyRects) {
g_system->copyRectToScreen(lpBuf, RM_SX * 2, 0, 0, RM_SX, RM_SY);
s = g_system->lockScreen();
}

for (i = dirtyRects.begin(); i != dirtyRects.end(); ++i) {
Common::Rect &r = *i;
const byte *lpSrc = lpBuf + (RM_SX * 2) * r.top + (r.left * 2);
g_system->copyRectToScreen(lpSrc, RM_SX * 2, r.left, r.top, r.width(), r.height());

if (_showDirtyRects)
// Frame the copied area with a rectangle
s->frameRect(r, 0xffffff);
}

if (_showDirtyRects)
g_system->unlockScreen();
}

if (_bGrabThumbnail) {
Expand Down
5 changes: 2 additions & 3 deletions engines/tony/window.h
Expand Up @@ -57,14 +57,12 @@ class RMWindow {
void plotLines(const byte *lpBuf, const Common::Point &center, int x, int y);

protected:
// void * /*LPDIRECTDRAWCLIPPER*/ _MainClipper;
// void * /*LPDIRECTDRAWCLIPPER*/ _BackClipper;

int fps, fcount;
int lastsecond, lastfcount;

int mskRed, mskGreen, mskBlue;
bool _wiping;
bool _showDirtyRects;

bool _bGrabScreenshot;
bool _bGrabThumbnail;
Expand Down Expand Up @@ -99,6 +97,7 @@ class RMWindow {
int getFps() const {
return fps;
}
void showDirtyRects(bool v) { _showDirtyRects = v; }
};

} // End of namespace Tony
Expand Down

0 comments on commit eef6b44

Please sign in to comment.