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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Mon Jan 28 18:28:16 CET 2008


Revision: 30681
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30681&view=rev
Author:   peres001
Date:     2008-01-28 09:28:16 -0800 (Mon, 28 Jan 2008)

Log Message:
-----------
Move low level background management into Gfx.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/callables_ns.cpp
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/graphics.h
    scummvm/trunk/engines/parallaction/gui_ns.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp
    scummvm/trunk/engines/parallaction/parser_br.cpp
    scummvm/trunk/engines/parallaction/walk.h

Modified: scummvm/trunk/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables_ns.cpp	2008-01-28 16:52:41 UTC (rev 30680)
+++ scummvm/trunk/engines/parallaction/callables_ns.cpp	2008-01-28 17:28:16 UTC (rev 30681)
@@ -330,7 +330,7 @@
 
 void Parallaction_ns::_c_setMask(void *parm) {
 
-	memset(_backgroundInfo->mask.data + 3600, 0, 3600);
+	memset(_gfx->_backgroundInfo->mask.data + 3600, 0, 3600);
 	_gfx->_bgLayers[1] = 500;
 
 	return;
@@ -586,7 +586,7 @@
 		newx = _rightHandPositions[2*index];
 	}
 
-	Graphics::drawLine(oldx, oldy, newx, newy, 0, zeroMask, _backgroundInfo);
+	Graphics::drawLine(oldx, oldy, newx, newy, 0, zeroMask, _gfx->_backgroundInfo);
 
 	_rightHandAnim->_left = newx;
 	_rightHandAnim->_top = newy - 20;
@@ -608,11 +608,11 @@
 		_rightHandAnim->_top
 	);
 
-	uint16 _di = r.left/4 + r.top * _backgroundInfo->mask.internalWidth;
+	uint16 _di = r.left/4 + r.top * _gfx->_backgroundInfo->mask.internalWidth;
 
 	for (uint16 _si = r.top; _si < r.bottom; _si++) {
-		memset(_backgroundInfo->mask.data + _di, 0, r.width()/4+1);
-		_di += _backgroundInfo->mask.internalWidth;
+		memset(_gfx->_backgroundInfo->mask.data + _di, 0, r.width()/4+1);
+		_di += _gfx->_backgroundInfo->mask.internalWidth;
 	}
 
 	return;

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2008-01-28 16:52:41 UTC (rev 30680)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2008-01-28 17:28:16 UTC (rev 30681)
@@ -345,6 +345,7 @@
 }
 
 void Gfx::updateScreen() {
+#if 0
 	if (_halfbrite) {
 		Graphics::Surface *surf = g_system->lockScreen();
 		byte *src = (byte*)_buffers[kBitFront]->pixels;
@@ -359,6 +360,8 @@
 	} else {
 		g_system->copyRectToScreen((const byte*)_buffers[kBitFront]->pixels, _buffers[kBitFront]->pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight);
 	}
+#endif
+	g_system->copyRectToScreen((const byte*)_buffers[kBit2]->pixels, _buffers[kBit2]->pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight);
 
 	Graphics::Surface *surf = g_system->lockScreen();
 	drawGfxObjects(*surf);
@@ -900,6 +903,7 @@
 	_hbCircleRadius = 0;
 
 	_font = NULL;
+	_backgroundInfo = new BackgroundInfo;
 
 	return;
 }
@@ -908,6 +912,9 @@
 
 	freeBuffers();
 
+	freeBackground();
+	delete _backgroundInfo;
+
 	return;
 }
 
@@ -1173,4 +1180,41 @@
 
 }
 
+void Gfx::freeBackground() {
+
+	if (!_backgroundInfo)
+		return;
+
+	_backgroundInfo->bg.free();
+	_backgroundInfo->mask.free();
+	_backgroundInfo->path.free();
+
+}
+
+void Gfx::setBackground(uint type, const char* name, const char* mask, const char* path) {
+
+	if (type == kBackgroundLocation) {
+
+		_disk->loadScenery(*_backgroundInfo, name, mask, path);
+
+		setPalette(_backgroundInfo->palette);
+		_palette.clone(_backgroundInfo->palette);
+		setBackground(&_backgroundInfo->bg);
+
+		if (_backgroundInfo->mask.data)
+			setMask(&_backgroundInfo->mask);
+
+	} else {
+
+		_disk->loadSlide(*_backgroundInfo, name);
+
+		setPalette(_backgroundInfo->palette);
+		setBackground(&_backgroundInfo->bg);
+
+	}
+
+	return;
+}
+
+
 } // namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2008-01-28 16:52:41 UTC (rev 30680)
+++ scummvm/trunk/engines/parallaction/graphics.h	2008-01-28 17:28:16 UTC (rev 30681)
@@ -152,6 +152,41 @@
 
 };
 
+
+struct PathBuffer {
+	// handles a 1-bit depth buffer used for masking non-walkable areas
+
+	uint16	w;
+	uint16  internalWidth;
+	uint16	h;
+	uint	size;
+	byte	*data;
+
+public:
+	PathBuffer() : w(0), internalWidth(0), h(0), size(0), data(0) {
+	}
+
+	void create(uint16 width, uint16 height) {
+		w = width;
+		internalWidth = w >> 3;
+		h = height;
+		size = (internalWidth * h);
+		data = (byte*)calloc(size, 1);
+	}
+
+	void free() {
+		::free(data);
+		data = 0;
+		w = 0;
+		h = 0;
+		internalWidth = 0;
+		size = 0;
+	}
+
+	inline byte getValue(uint16 x, uint16 y);
+};
+
+
 class Palette {
 
 	byte	_data[768];
@@ -290,9 +325,25 @@
 	void release();
 };
 
-
 typedef Common::List<GfxObj*> GfxObjList;
 
+struct BackgroundInfo {
+	uint width;
+	uint height;
+
+	Graphics::Surface	bg;
+	MaskBuffer			mask;
+	PathBuffer			path;
+
+	Palette				palette;
+};
+
+
+enum {
+	kBackgroundLocation = 1,
+	kBackgroundSlide = 2
+};
+
 class Gfx {
 
 public:
@@ -315,6 +366,10 @@
 	void drawGfxObjects(Graphics::Surface &surf);
 	void sortAnimations();
 
+	BackgroundInfo	*_backgroundInfo;
+	void freeBackground();
+	void setBackground(uint type, const char* name, const char* mask, const char* path);
+
 public:
 
 	// balloons and text

Modified: scummvm/trunk/engines/parallaction/gui_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_ns.cpp	2008-01-28 16:52:41 UTC (rev 30680)
+++ scummvm/trunk/engines/parallaction/gui_ns.cpp	2008-01-28 17:28:16 UTC (rev 30681)
@@ -178,11 +178,12 @@
 	showSlide("intro");
 	_gfx->updateScreen();
 	g_system->delayMillis(2000);
+	freeBackground();
 
 	showSlide("minintro");
 	_gfx->updateScreen();
 	g_system->delayMillis(2000);
-
+	freeBackground();
 }
 
 int Parallaction_ns::guiNewGame() {

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-01-28 16:52:41 UTC (rev 30680)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-01-28 17:28:16 UTC (rev 30681)
@@ -118,9 +118,6 @@
 Parallaction::~Parallaction() {
 	delete _debugger;
 
-	freeBackground();
-	delete _backgroundInfo;
-
 	delete _globalTable;
 
 	delete _callableNames;
@@ -160,14 +157,11 @@
 	_location._comment = NULL;
 	_location._endComment = NULL;
 
-	_backgroundInfo = 0;
 	_pathBuffer = 0;
 	_activeZone = 0;
 
 	_screenSize = _screenWidth * _screenHeight;
 
-	_backgroundInfo = new BackgroundInfo;
-
 	strcpy(_characterName1, "null");
 
 	memset(_locationNames, 0, NUM_LOCATIONS * 32);
@@ -725,6 +719,7 @@
 	_location._walkNodes.clear();
 
 	_gfx->clearGfxObjects();
+	freeBackground();
 
 	freeZones();
 	freeAnimations();
@@ -743,31 +738,16 @@
 
 void Parallaction::freeBackground() {
 
-	if (!_backgroundInfo)
-		return;
-
-	_backgroundInfo->bg.free();
-	_backgroundInfo->mask.free();
-	_backgroundInfo->path.free();
-
+	_gfx->freeBackground();
 	_pathBuffer = 0;
 
 }
 
 void Parallaction::setBackground(const char* name, const char* mask, const char* path) {
 
-	_disk->loadScenery(*_backgroundInfo, name, mask, path);
+	_gfx->setBackground(kBackgroundLocation, name, mask, path);
+	_pathBuffer = &_gfx->_backgroundInfo->path;
 
-	_gfx->setPalette(_backgroundInfo->palette);
-	_gfx->_palette.clone(_backgroundInfo->palette);
-	_gfx->setBackground(&_backgroundInfo->bg);
-
-	if (_backgroundInfo->mask.data)
-		_gfx->setMask(&_backgroundInfo->mask);
-
-	if (_backgroundInfo->path.data)
-		_pathBuffer = &_backgroundInfo->path;
-
 	return;
 }
 

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2008-01-28 16:52:41 UTC (rev 30680)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2008-01-28 17:28:16 UTC (rev 30681)
@@ -237,17 +237,7 @@
 
 
 
-struct BackgroundInfo {
-	uint width;
-	uint height;
 
-	Graphics::Surface	bg;
-	MaskBuffer			mask;
-	PathBuffer			path;
-
-	Palette				palette;
-};
-
 class Opcode {
 
 public:
@@ -453,8 +443,6 @@
 	bool		_hasLocationSound;
 	char		_locationSound[50];
 
-	BackgroundInfo	*_backgroundInfo;
-
 	Zone		*_hoverZone;
 
 

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-01-28 16:52:41 UTC (rev 30680)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-01-28 17:28:16 UTC (rev 30681)
@@ -266,24 +266,7 @@
 
 
 void Parallaction_ns::showSlide(const char *name) {
-
-	BackgroundInfo info;
-
-	_disk->loadSlide(info, name);
-
-	// TODO: avoid using screen buffers for displaying slides. Using a generic buffer
-	// allows for positioning of graphics as needed by Big Red Adventure.
-	// The main problem lies with menu, which relies on multiple buffers, mainly because
-	// it is crappy code.
-	_gfx->setBackground(&info.bg);
-	_gfx->setPalette(info.palette);
-	_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
-
-	info.bg.free();
-	info.mask.free();
-	info.path.free();
-
-	return;
+	_gfx->setBackground(kBackgroundSlide, name, 0, 0);
 }
 
 //	changeLocation handles transitions between locations, and is able to display slides
@@ -315,6 +298,7 @@
 		_gfx->showLabel(id, CENTER_LABEL_HORIZONTAL, 14);
 		waitUntilLeftClick();
 		_gfx->freeLabels();
+		freeBackground();
 	}
 
 	if (locname.hasCharacter()) {

Modified: scummvm/trunk/engines/parallaction/parser_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_br.cpp	2008-01-28 16:52:41 UTC (rev 30680)
+++ scummvm/trunk/engines/parallaction/parser_br.cpp	2008-01-28 17:28:16 UTC (rev 30681)
@@ -125,7 +125,7 @@
 	} else {
 		nextToken = 2;
 	}
-
+#if 0
 	_disk->loadScenery(*_backgroundInfo, _location._name, NULL, NULL);
 
 //	if (flip) {
@@ -135,8 +135,8 @@
 	_gfx->setBackground(&_backgroundInfo->bg);
 	_gfx->_palette.clone(_backgroundInfo->palette);
 	_gfx->setPalette(_backgroundInfo->palette);
+#endif
 
-
 	if (_tokens[nextToken][0] != '\0') {
 		_char._ani._left = atoi(_tokens[nextToken]);
 		nextToken++;
@@ -271,21 +271,23 @@
 
 DECLARE_LOCATION_PARSER(mask)  {
 	debugC(7, kDebugParser, "LOCATION_PARSER(mask) ");
-
+#if 0
 	_disk->loadScenery(*_backgroundInfo, NULL, _tokens[1], NULL);
 	_gfx->setMask(&_backgroundInfo->mask);
 
 	_gfx->_bgLayers[0] = atoi(_tokens[2]);
 	_gfx->_bgLayers[1] = atoi(_tokens[3]);
 	_gfx->_bgLayers[2] = atoi(_tokens[4]);
+#endif
 }
 
 
 DECLARE_LOCATION_PARSER(path)  {
 	debugC(7, kDebugParser, "LOCATION_PARSER(path) ");
-
+#if 0
 	_disk->loadScenery(*_backgroundInfo, NULL, NULL, _tokens[1]);
 	_pathBuffer = &_backgroundInfo->path;
+#endif
 }
 
 

Modified: scummvm/trunk/engines/parallaction/walk.h
===================================================================
--- scummvm/trunk/engines/parallaction/walk.h	2008-01-28 16:52:41 UTC (rev 30680)
+++ scummvm/trunk/engines/parallaction/walk.h	2008-01-28 17:28:16 UTC (rev 30681)
@@ -47,40 +47,6 @@
 typedef ManagedList<WalkNode*> WalkNodeList;
 
 
-struct PathBuffer {
-	// handles a 1-bit depth buffer used for masking non-walkable areas
-
-	uint16	w;
-	uint16  internalWidth;
-	uint16	h;
-	uint	size;
-	byte	*data;
-
-public:
-	PathBuffer() : w(0), internalWidth(0), h(0), size(0), data(0) {
-	}
-
-	void create(uint16 width, uint16 height) {
-		w = width;
-		internalWidth = w >> 3;
-		h = height;
-		size = (internalWidth * h);
-		data = (byte*)calloc(size, 1);
-	}
-
-	void free() {
-		::free(data);
-		data = 0;
-		w = 0;
-		h = 0;
-		internalWidth = 0;
-		size = 0;
-	}
-
-	inline byte getValue(uint16 x, uint16 y);
-};
-
-
 class PathBuilder {
 
 	Animation		*_anim;


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