[Scummvm-cvs-logs] scummvm master -> 369f886477407f3b91aeaf5a0aae4c65c5d45bea

dreammaster dreammaster at scummvm.org
Fri May 10 09:33:57 CEST 2013


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
369f886477 HOPKINS: Added a zones debugger command


Commit: 369f886477407f3b91aeaf5a0aae4c65c5d45bea
    https://github.com/scummvm/scummvm/commit/369f886477407f3b91aeaf5a0aae4c65c5d45bea
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2013-05-10T00:33:03-07:00

Commit Message:
HOPKINS: Added a zones debugger command

Changed paths:
    engines/hopkins/debugger.cpp
    engines/hopkins/debugger.h
    engines/hopkins/graphics.cpp
    engines/hopkins/graphics.h
    engines/hopkins/lines.h



diff --git a/engines/hopkins/debugger.cpp b/engines/hopkins/debugger.cpp
index 246270c..762df0a 100644
--- a/engines/hopkins/debugger.cpp
+++ b/engines/hopkins/debugger.cpp
@@ -34,6 +34,7 @@ Debugger::Debugger(HopkinsEngine *vm) : GUI::Debugger() {
 	DCmd_Register("rects", WRAP_METHOD(Debugger, cmd_DirtyRects));
 	DCmd_Register("teleport", WRAP_METHOD(Debugger, cmd_Teleport));
 	DCmd_Register("show_room", WRAP_METHOD(Debugger, cmd_ShowCurrentRoom));
+	DCmd_Register("zones", WRAP_METHOD(Debugger, cmd_Zones));
 }
 
 // Turns dirty rects on or off
@@ -64,4 +65,14 @@ bool Debugger::cmd_ShowCurrentRoom(int argc, const char **argv) {
 	return true;
 }
 
+bool Debugger::cmd_Zones(int argc, const char **argv) {
+if (argc != 2) {
+		DebugPrintf("%s: [on | off]\n", argv[0]);
+		return true;
+	} else {
+		_vm->_graphicsMan->_showZones = !strcmp(argv[1], "on");
+		return false;
+	}
+}
+
 } // End of namespace Hopkins
diff --git a/engines/hopkins/debugger.h b/engines/hopkins/debugger.h
index 7f7bffd..16b5f87 100644
--- a/engines/hopkins/debugger.h
+++ b/engines/hopkins/debugger.h
@@ -41,6 +41,7 @@ public:
 	bool cmd_DirtyRects(int argc, const char **argv);
 	bool cmd_Teleport(int argc, const char **argv);
 	bool cmd_ShowCurrentRoom(int argc, const char **argv);
+	bool cmd_Zones(int argc, const char **argv);
 };
 
 } // End of namespace Hopkins
diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp
index c2c8b42..aa71b2c 100644
--- a/engines/hopkins/graphics.cpp
+++ b/engines/hopkins/graphics.cpp
@@ -73,6 +73,7 @@ GraphicsManager::GraphicsManager(HopkinsEngine *vm) {
 	_zoomOutFactor = 0;
 	_width = 0;
 	_specialWidth = 0;
+	_showZones = false;
 
 	Common::fill(&_paletteBuffer[0], &_paletteBuffer[PALETTE_SIZE * 2], 0);
 	Common::fill(&_colorTable[0], &_colorTable[PALETTE_EXT_BLOCK_SIZE], 0);
@@ -663,11 +664,14 @@ uint16 GraphicsManager::mapRGB(byte r, byte g, byte b) {
 }
 
 void GraphicsManager::updateScreen() {
-	// TODO: Is this okay here?
 	// Display any aras of the screen that need refreshing
 	displayDirtyRects();
 	displayRefreshRects();
 
+	// Extra checks for debug information
+	if (_showZones)
+		displayZones();
+
 	// Update the screen
 	g_system->updateScreen();
 }
@@ -1140,6 +1144,7 @@ void GraphicsManager::displayRefreshRects() {
 		screenSurface = g_system->lockScreen();
 		g_system->copyRectToScreen(_screenBuffer, _screenLineSize, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
 	}
+
 	// Loop through copying over any  specified rects to the screen
 	for (uint idx = 0; idx < _refreshRects.size(); ++idx) {
 		const Common::Rect &r = _refreshRects[idx];
@@ -1157,6 +1162,50 @@ void GraphicsManager::displayRefreshRects() {
 	resetRefreshRects();
 }
 
+/**
+ * Display any zones for the current room
+ */
+void GraphicsManager::displayZones() {
+	Graphics::Surface *screenSurface = g_system->lockScreen();
+
+	for (int bobZoneId = 0; bobZoneId <= 48; bobZoneId++) {
+		int bobId = _vm->_linesMan->_bobZone[bobZoneId];
+		if (bobId) {
+			// Get the rectangle for the zone
+			Common::Rect r(_vm->_objectsMan->_bob[bobId]._oldX, _vm->_objectsMan->_bob[bobId]._oldY,
+				_vm->_objectsMan->_bob[bobId]._oldX + _vm->_objectsMan->_bob[bobId]._oldWidth,
+				_vm->_objectsMan->_bob[bobId]._oldY + _vm->_objectsMan->_bob[bobId]._oldHeight);
+				
+			displayDebugRect(screenSurface, r);
+		}
+	}
+
+	for (int squareZoneId = 0; squareZoneId <= 99; squareZoneId++) {
+		if (_vm->_linesMan->_zone[squareZoneId]._enabledFl && _vm->_linesMan->_squareZone[squareZoneId]._enabledFl) {
+			Common::Rect r(_vm->_linesMan->_squareZone[squareZoneId]._left, _vm->_linesMan->_squareZone[squareZoneId]._top,
+				_vm->_linesMan->_squareZone[squareZoneId]._right, _vm->_linesMan->_squareZone[squareZoneId]._bottom);
+
+			displayDebugRect(screenSurface, r);
+		}
+	}
+
+	g_system->unlockScreen();
+}
+
+void GraphicsManager::displayDebugRect(Graphics::Surface *surface, const Common::Rect &srcRect) {
+	Common::Rect r = srcRect;
+
+	// Move for scrolling offset and adjust to crop on-screen
+	r.translate(-_scrollPosX, 0);
+	r.left = MAX(r.left, (int16)0);
+	r.top = MAX(r.top, (int16)0);
+	r.right = MIN(r.right, (int16)SCREEN_WIDTH);
+	r.bottom = MIN(r.bottom, (int16)SCREEN_HEIGHT);
+				
+	// If there's an on-screen portion, display it
+	if (r.isValidRect())
+		surface->frameRect(r, 0xffffff);
+}
 
 /**
  * Fast Display of either a compressed or vesa sprite
diff --git a/engines/hopkins/graphics.h b/engines/hopkins/graphics.h
index b7d7eaa..142de12 100644
--- a/engines/hopkins/graphics.h
+++ b/engines/hopkins/graphics.h
@@ -118,6 +118,7 @@ public:
 	Common::Array<Common::Rect> _dirtyRects;
 	Common::Array<Common::Rect> _refreshRects;
 	bool _showDirtyRects;
+	bool _showZones;
 
 	byte *_palettePixels;
 public:
@@ -135,6 +136,8 @@ public:
 	void addRectToArray(Common::Array<Common::Rect> &rects, const Common::Rect &newRect);
 	void displayDirtyRects();
 	void displayRefreshRects();
+	void displayZones();
+	void displayDebugRect(Graphics::Surface *surface, const Common::Rect &srcRect);
 	void copySurface(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY);
 	void loadImage(const Common::String &file);
 	void loadVgaImage(const Common::String &file);
diff --git a/engines/hopkins/lines.h b/engines/hopkins/lines.h
index 2eeafda..27229aa 100644
--- a/engines/hopkins/lines.h
+++ b/engines/hopkins/lines.h
@@ -115,7 +115,6 @@ private:
 	Directions _smoothMoveDirection;
 	LigneZoneItem _zoneLine[MAX_LINES+1];
 	SegmentItem _segment[101];
-	SquareZoneItem _squareZone[101];
 	int _currentSegmentId;
 	int _maxLineIdx;
 	int _lastLine;
@@ -168,6 +167,7 @@ public:
 	int _bobZone[105];
 	bool _bobZoneFl[105];
 	ZoneItem _zone[106];
+	SquareZoneItem _squareZone[101];
 
 	LinesManager(HopkinsEngine *vm);
 	~LinesManager();






More information about the Scummvm-git-logs mailing list