[Scummvm-cvs-logs] SF.net SVN: scummvm: [30808] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Wed Feb 6 15:05:08 CET 2008


Revision: 30808
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30808&view=rev
Author:   peres001
Date:     2008-02-06 06:05:08 -0800 (Wed, 06 Feb 2008)

Log Message:
-----------
Added experimental debug feature: variables influencing the rendering that can be set via console using the 'set' command. The implementation is still partial. Leveraging on this, the engine can now selectively display the current background mask instead of the background itself.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/debug.cpp
    scummvm/trunk/engines/parallaction/debug.h
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/graphics.h
    scummvm/trunk/engines/parallaction/parallaction.cpp

Modified: scummvm/trunk/engines/parallaction/debug.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/debug.cpp	2008-02-06 13:57:44 UTC (rev 30807)
+++ scummvm/trunk/engines/parallaction/debug.cpp	2008-02-06 14:05:08 UTC (rev 30808)
@@ -45,6 +45,7 @@
 	DCmd_Register("localflags",	WRAP_METHOD(Debugger, Cmd_LocalFlags));
 	DCmd_Register("locations",	WRAP_METHOD(Debugger, Cmd_Locations));
 	DCmd_Register("gfxobjects",	WRAP_METHOD(Debugger, Cmd_GfxObjects));
+	DCmd_Register("set", 		WRAP_METHOD(Debugger, Cmd_Set));
 
 }
 
@@ -204,5 +205,15 @@
 	return true;
 }
 
+bool Debugger::Cmd_Set(int argc, const char** argv) {
 
+	if (argc < 3) {
+		DebugPrintf("set <var name> <value>\n");
+	} else {
+		_vm->_gfx->setVar(Common::String(argv[1]), atoi(argv[2]));
+	}
+
+	return true;
+}
+
 } // namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/debug.h
===================================================================
--- scummvm/trunk/engines/parallaction/debug.h	2008-02-06 13:57:44 UTC (rev 30807)
+++ scummvm/trunk/engines/parallaction/debug.h	2008-02-06 14:05:08 UTC (rev 30808)
@@ -28,6 +28,8 @@
 	bool Cmd_GlobalFlags(int argc, const char **argv);
 	bool Cmd_Locations(int argc, const char **argv);
 	bool Cmd_GfxObjects(int argc, const char **argv);
+	bool Cmd_GfxFeature(int argc, const char** argv);
+	bool Cmd_Set(int argc, const char** argv);
 };
 
 } // End of namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2008-02-06 13:57:44 UTC (rev 30807)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2008-02-06 14:05:08 UTC (rev 30808)
@@ -32,6 +32,40 @@
 
 namespace Parallaction {
 
+
+typedef Common::HashMap<Common::String, int32, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> VarMap;
+VarMap _vars;
+
+void Gfx::registerVar(const Common::String &name, int32 initialValue) {
+	if (_vars.contains(name)) {
+		warning("Variable '%s' already registered, ignoring initial value.\n", name.c_str());
+	} else {
+		_vars.setVal(name, initialValue);
+	}
+}
+
+void Gfx::setVar(const Common::String &name, int32 value) {
+	if (!_vars.contains(name)) {
+		warning("Variable '%s' doesn't exist, skipping assignment.\n", name.c_str());
+	} else {
+		_vars.setVal(name, value);
+	}
+}
+
+int32 Gfx::getVar(const Common::String &name) {
+	int32 v = 0;
+
+	if (!_vars.contains(name)) {
+		warning("Variable '%s' doesn't exist, returning default value.\n", name.c_str());
+	} else {
+		v = _vars.getVal(name);
+	}
+
+	return v;
+}
+
+
+
 #define	LABEL_TRANSPARENT_COLOR 0xFF
 #define	BALLOON_TRANSPARENT_COLOR 2
 
@@ -348,15 +382,52 @@
 	g_system->clearScreen();
 }
 
+void Gfx::beginFrame() {
+
+	int32 oldBackgroundMode = _varBackgroundMode;
+	_varBackgroundMode = getVar("background_mode");
+
+	if (oldBackgroundMode != _varBackgroundMode) {
+		switch (_varBackgroundMode) {
+		case 1:
+			_bitmapMask.free();
+			break;
+		case 2:
+			_bitmapMask.create(_backgroundInfo.width, _backgroundInfo.height, 1);
+			byte *data = (byte*)_bitmapMask.pixels;
+			for (uint y = 0; y < _bitmapMask.h; y++) {
+				for (uint x = 0; x < _bitmapMask.w; x++) {
+					*data++ = _backgroundInfo.mask.getValue(x, y);
+				}
+			}
+			break;
+		}
+	}
+
+
+}
+
 void Gfx::updateScreen() {
 
 	// background may not cover the whole screen, so adjust bulk update size
 	uint w = MIN(_vm->_screenWidth, (int32)_backgroundInfo.width);
 	uint h = MIN(_vm->_screenHeight, (int32)_backgroundInfo.height);
 
-	// TODO: add displacement to source to handle scrolling in BRA
-	g_system->copyRectToScreen((const byte*)_backgroundInfo.bg.pixels, _backgroundInfo.bg.pitch, _backgroundInfo.x, _backgroundInfo.y, w, h);
+	byte *backgroundData;
+	uint16 backgroundPitch;
+	switch (_varBackgroundMode) {
+	case 1:
+		backgroundData = (byte*)_backgroundInfo.bg.pixels;
+		backgroundPitch = _backgroundInfo.bg.pitch;
+		break;
+	case 2:
+		backgroundData = (byte*)_bitmapMask.pixels;
+		backgroundPitch = _bitmapMask.pitch;
+		break;
+	}
+	g_system->copyRectToScreen(backgroundData, backgroundPitch, _backgroundInfo.x, _backgroundInfo.y, w, h);
 
+
 	// TODO: transform objects coordinates to be drawn with scrolling
 	Graphics::Surface *surf = g_system->lockScreen();
 	drawGfxObjects(*surf);
@@ -785,6 +856,9 @@
 
 	_font = NULL;
 
+	registerVar("background_mode", 1);
+	_varBackgroundMode = 1;
+
 	return;
 }
 
@@ -1035,5 +1109,4 @@
 
 }
 
-
 } // namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2008-02-06 13:57:44 UTC (rev 30807)
+++ scummvm/trunk/engines/parallaction/graphics.h	2008-02-06 14:05:08 UTC (rev 30808)
@@ -512,7 +512,12 @@
 	Gfx(Parallaction* vm);
 	virtual ~Gfx();
 
+	void beginFrame();
 
+	void registerVar(const Common::String &name, int32 initialValue);
+	void setVar(const Common::String &name, int32 value);
+	int32 getVar(const Common::String &name);
+
 	void clearScreen();
 	void updateScreen();
 
@@ -530,7 +535,11 @@
 	Common::Point		_hbCirclePos;
 	int				_hbCircleRadius;
 
+	// frame data stored in programmable variables
+	int32				_varBackgroundMode;
+	Graphics::Surface 	_bitmapMask;
 
+
 protected:
 	static int16 _dialogueBalloonX[5];
 
@@ -594,3 +603,4 @@
 
 
 
+

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-02-06 13:57:44 UTC (rev 30807)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-02-06 14:05:08 UTC (rev 30808)
@@ -253,12 +253,16 @@
 		changeLocation(_location._name);
 	}
 
+
+	_gfx->beginFrame();
+
 	if (_inputMode == kInputModeGame) {
 		runScripts();
 		walk();
 		drawAnimations();
 	}
 
+	// change this to endFrame?
 	updateView();
 
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list