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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sat Dec 13 18:31:48 CET 2008


Revision: 35342
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35342&view=rev
Author:   peres001
Date:     2008-12-13 17:31:48 +0000 (Sat, 13 Dec 2008)

Log Message:
-----------
Restructuring of rendering code.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/dialogue.cpp
    scummvm/trunk/engines/parallaction/gfxbase.cpp
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/graphics.h
    scummvm/trunk/engines/parallaction/gui_br.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp

Modified: scummvm/trunk/engines/parallaction/dialogue.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/dialogue.cpp	2008-12-13 16:35:14 UTC (rev 35341)
+++ scummvm/trunk/engines/parallaction/dialogue.cpp	2008-12-13 17:31:48 UTC (rev 35342)
@@ -82,6 +82,7 @@
 	bool			isNpc;
 	GfxObj			*_questioner;
 	GfxObj			*_answerer;
+	int				_faceId;
 
 	Question		*_q;
 
@@ -194,24 +195,24 @@
 		displayAnswer(i);
 	}
 
+	int mood = 0;
+
 	if (_askPassword) {
 		resetPassword();
-//		_vm->_balloonMan->setDialogueBalloon(_q->_answers[0]->_text, 1, 3);
-		int id = _vm->_gfx->setItem(_answerer, _ballonPos._answerChar.x, _ballonPos._answerChar.y);
-		_vm->_gfx->setItemFrame(id, 0);
 	} else
 	if (_numVisAnswers == 1) {
-		int id = _vm->_gfx->setItem(_answerer, _ballonPos._answerChar.x, _ballonPos._answerChar.y);
-		_vm->_gfx->setItemFrame(id, _q->_answers[0]->_mood & 0xF);
+		mood = _q->_answers[0]->_mood & 0xF;
 		_vm->_balloonMan->setBalloonText(0, _q->_answers[_visAnswers[0]]->_text.c_str(), BalloonManager::kNormalColor);
 	} else
 	if (_numVisAnswers > 1) {
-		int id = _vm->_gfx->setItem(_answerer, _ballonPos._answerChar.x, _ballonPos._answerChar.y);
-		_vm->_gfx->setItemFrame(id, _q->_answers[_visAnswers[0]]->_mood & 0xF);
+		mood = _q->_answers[_visAnswers[0]]->_mood & 0xF;
 		_oldSelection = -1;
 		_selection = 0;
 	}
 
+	_faceId = _vm->_gfx->setItem(_answerer, _ballonPos._answerChar.x, _ballonPos._answerChar.y);
+	_vm->_gfx->setItemFrame(_faceId, mood);
+
 	return _numVisAnswers > 0;
 }
 
@@ -219,8 +220,8 @@
 	if (!_q->_text.compareToIgnoreCase("NULL")) return false;
 
 	_vm->_balloonMan->setSingleBalloon(_q->_text.c_str(), _ballonPos._questionBalloon.x, _ballonPos._questionBalloon.y, _q->_mood & 0x10, BalloonManager::kNormalColor);
-	int id = _vm->_gfx->setItem(_questioner, _ballonPos._questionChar.x, _ballonPos._questionChar.y);
-	_vm->_gfx->setItemFrame(id, _q->_mood & 0xF);
+	_faceId = _vm->_gfx->setItem(_questioner, _ballonPos._questionChar.x, _ballonPos._questionChar.y);
+	_vm->_gfx->setItemFrame(_faceId, _q->_mood & 0xF);
 
 	return true;
 }
@@ -291,7 +292,7 @@
 
 		if (_selection != -1) {
 			_vm->_balloonMan->setBalloonText(_selection, _q->_answers[_visAnswers[_selection]]->_text.c_str(), BalloonManager::kSelectedColor);
-			_vm->_gfx->setItemFrame(0, _q->_answers[_visAnswers[_selection]]->_mood & 0xF);
+			_vm->_gfx->setItemFrame(_faceId, _q->_answers[_visAnswers[_selection]]->_mood & 0xF);
 		}
 	}
 

Modified: scummvm/trunk/engines/parallaction/gfxbase.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gfxbase.cpp	2008-12-13 16:35:14 UTC (rev 35341)
+++ scummvm/trunk/engines/parallaction/gfxbase.cpp	2008-12-13 17:31:48 UTC (rev 35342)
@@ -165,7 +165,7 @@
 }
 
 
-void Gfx::drawGfxObject(GfxObj *obj, Graphics::Surface &surf, bool scene) {
+void Gfx::drawGfxObject(GfxObj *obj, Graphics::Surface &surf) {
 	if (!obj->isVisible()) {
 		return;
 	}
@@ -200,7 +200,7 @@
 	GfxObjList::iterator e = _gfxobjList.end();
 
 	for (; b != e; b++) {
-		drawGfxObject(*b, surf, true);
+		drawGfxObject(*b, surf);
 	}
 }
 

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2008-12-13 16:35:14 UTC (rev 35341)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2008-12-13 17:31:48 UTC (rev 35342)
@@ -332,30 +332,16 @@
 	copyRectToScreen(data, r.width(), r.left, r.top, r.width(), r.height());
 }
 
-void Gfx::drawItems() {
-	if (_numItems == 0) {
+void Gfx::drawList(Graphics::Surface &surface, GfxObjArray &list) {
+	if (list.size() == 0) {
 		return;
 	}
 
-	Graphics::Surface *surf = lockScreen();
-	for (uint i = 0; i < _numItems; i++) {
-		drawGfxObject(_items[i].data, *surf, false);
+	for (uint i = 0; i < list.size(); i++) {
+		drawGfxObject(list[i], surface);
 	}
-	unlockScreen();
 }
 
-void Gfx::drawBalloons() {
-	if (_balloons.size() == 0) {
-		return;
-	}
-
-	Graphics::Surface *surf = lockScreen();
-	for (uint i = 0; i < _balloons.size(); i++) {
-		drawGfxObject(_balloons[i], *surf, false);
-	}
-	unlockScreen();
-}
-
 void Gfx::beginFrame() {
 	_skipBackground = (_backgroundInfo->bg.pixels == 0);	// don't render frame if background is missing
 
@@ -507,46 +493,58 @@
 
 	_varRenderMode = _varAnimRenderMode;
 
-	// TODO: transform objects coordinates to be drawn with scrolling
 	Graphics::Surface *surf = lockScreen();
-	drawGfxObjects(*surf);
+		// draws animations frames and screen items
+		drawGfxObjects(*surf);
 
-	if (_halfbrite) {
-		// FIXME: the implementation of halfbrite is now largely sub-optimal in that a full screen
-		// rewrite is needed to apply the effect. Also, we are manipulating the frame buffer. Is it a good idea?
-		byte *buf = (byte*)surf->pixels;
-		for (int i = 0; i < surf->w*surf->h; i++) {
-			*buf++ |= 0x20;
-		}
-		if (_nextProjectorPos) {
-			int16 x = *_nextProjectorPos++;
-			int16 y = *_nextProjectorPos++;
-			if (x == -1 && y == -1) {
-				_nextProjectorPos = 0;
-			} else {
-				setProjectorPos(x, y);
-			}
-		}
-		if (_hbCircleRadius > 0) {
-			drawCircle(_hbCirclePos.x, _hbCirclePos.y, _hbCircleRadius, 0, &halfbritePixel, surf->pixels);
-		}
-	}
+		// special effects
+		applyHalfbriteEffect_NS(*surf);
 
+		// draws inventory, labels and dialogue items
+		drawOverlay(*surf);
 	unlockScreen();
 
+	updateScreenIntern();
+}
+
+void Gfx::applyHalfbriteEffect_NS(Graphics::Surface &surf) {
+	if (!_halfbrite) {
+		return;
+	}
+
+	byte *buf = (byte*)surf.pixels;
+	for (int i = 0; i < surf.w*surf.h; i++) {
+		*buf++ |= 0x20;
+	}
+
+	if (_nextProjectorPos) {
+		int16 x = *_nextProjectorPos++;
+		int16 y = *_nextProjectorPos++;
+		if (x == -1 && y == -1) {
+			_nextProjectorPos = 0;
+		} else {
+			setProjectorPos(x, y);
+		}
+	}
+	if (_hbCircleRadius > 0) {
+		drawCircle(_hbCirclePos.x, _hbCirclePos.y, _hbCircleRadius, 0, &halfbritePixel, surf.pixels);
+	}
+}
+
+void Gfx::drawOverlay(Graphics::Surface &surf) {
 	// the following items are handled in screen coordinates, so they need translation before
 	// being drawn
 	_overlayMode = true;
+
 	drawInventory();
-	drawItems();
-	drawBalloons();
-	drawLabels();
 
-	updateScreenIntern();
+	updateFloatingLabel();
+
+	drawList(surf, _items);
+	drawList(surf, _balloons);
+	drawList(surf, _labels);
 }
 
-
-
 //
 //	graphic primitives
 //
@@ -759,22 +757,8 @@
 	_floatingLabel = NO_FLOATING_LABEL;
 }
 
-void Gfx::drawLabels() {
-	if (_labels.size() == 0) {
-		return;
-	}
 
-	updateFloatingLabel();
 
-	Graphics::Surface* surf = lockScreen();
-	for (uint i = 0; i < _labels.size(); i++) {
-		drawGfxObject(_labels[i], *surf, false);
-	}
-	unlockScreen();
-}
-
-
-
 void Gfx::copyRect(const Common::Rect &r, Graphics::Surface &src, Graphics::Surface &dst) {
 
 	byte *s = (byte*)src.getBasePtr(r.left, r.top);
@@ -805,12 +789,8 @@
 
 	setPalette(_palette);
 
-	_numItems = 0;
 	_floatingLabel = NO_FLOATING_LABEL;
 
-	_screenX = 0;
-	_screenY = 0;
-
 	_backgroundInfo = 0;
 
 	_halfbrite = false;
@@ -853,23 +833,23 @@
 
 
 int Gfx::setItem(GfxObj* frames, uint16 x, uint16 y, byte transparentColor) {
-	int id = _numItems;
+	int id = _items.size();
 
-	_items[id].data = frames;
-	_items[id].data->x = x;
-	_items[id].data->y = y;
-	_items[id].data->layer = LAYER_FOREGROUND;
-	_items[id].data->transparentKey = transparentColor;
+	frames->x = x;
+	frames->y = y;
+	frames->transparentKey = transparentColor;
+	frames->layer = LAYER_FOREGROUND;
+	frames->setFlags(kGfxObjVisible);
 
-	_numItems++;
+	_items.insert_at(id, frames);
 
+	setItemFrame(id, 0);
+
 	return id;
 }
 
 void Gfx::setItemFrame(uint item, uint16 f) {
-	assert(item < _numItems);
-	_items[item].data->frame = f;
-	_items[item].data->setFlags(kGfxObjVisible);
+	_items[item]->frame = f;
 }
 
 
@@ -894,7 +874,7 @@
 }
 
 void Gfx::freeItems() {
-	_numItems = 0;
+	_items.clear();
 }
 
 void Gfx::setBackground(uint type, BackgroundInfo *info) {

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2008-12-13 16:35:14 UTC (rev 35341)
+++ scummvm/trunk/engines/parallaction/graphics.h	2008-12-13 17:31:48 UTC (rev 35342)
@@ -518,7 +518,6 @@
 	int setItem(GfxObj* obj, uint16 x, uint16 y, byte transparentColor = 0);
 	void setItemFrame(uint item, uint16 f);
 	void hideDialogueStuff();
-	void freeBalloons();
 	void freeItems();
 
 	// background surface
@@ -536,6 +535,7 @@
 	void animatePalette();
 
 	// amiga specific
+	void applyHalfbriteEffect_NS(Graphics::Surface &surf);
 	void setHalfbriteMode(bool enable);
 	void setProjectorPos(int x, int y);
 	void setProjectorProgram(int16 *data);
@@ -558,9 +558,6 @@
 public:
 	Palette				_palette;
 
-	uint				_screenX;		// scrolling position
-	uint				_screenY;
-
 	byte				*_unpackedBitmap;
 
 protected:
@@ -596,29 +593,23 @@
 
 	// overlay mode enables drawing of graphics with automatic screen-to-game coordinate translation
 	bool				_overlayMode;
+	void				drawOverlay(Graphics::Surface &surf);
 
 public:
 
-	struct Item {
-		GfxObj *data;
-	} _items[14];
-
-	uint	_numItems;
-
 	#define MAX_NUM_LABELS	20
 	#define NO_FLOATING_LABEL	1000
 
 	typedef Common::Array<GfxObj*> GfxObjArray;
 	GfxObjArray	_labels;
 	GfxObjArray _balloons;
+	GfxObjArray	_items;
 
 	uint _floatingLabel;
 
 	void drawInventory();
 	void updateFloatingLabel();
-	void drawLabels();
-	void drawItems();
-	void drawBalloons();
+	void drawList(Graphics::Surface &surface, GfxObjArray &list);
 
 	void copyRect(const Common::Rect &r, Graphics::Surface &src, Graphics::Surface &dst);
 
@@ -628,7 +619,7 @@
 	// low level text and patches
 	void drawText(Font *font, Graphics::Surface* surf, uint16 x, uint16 y, const char *text, byte color);
 
-	void drawGfxObject(GfxObj *obj, Graphics::Surface &surf, bool scene);
+	void drawGfxObject(GfxObj *obj, Graphics::Surface &surf);
     void blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor);
 	void unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor);
 

Modified: scummvm/trunk/engines/parallaction/gui_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_br.cpp	2008-12-13 16:35:14 UTC (rev 35341)
+++ scummvm/trunk/engines/parallaction/gui_br.cpp	2008-12-13 17:31:48 UTC (rev 35342)
@@ -234,8 +234,7 @@
 		// TODO: keep track of and destroy menu item frames/surfaces
 		for (i = 0; i < _availItems; i++) {
 			_lines[i] = new GfxObj(0, renderMenuItem(_menuStrings[i]), "MenuItem");
-			uint id = _vm->_gfx->setItem(_lines[i], MENUITEMS_X, MENUITEMS_Y + MENUITEM_HEIGHT * i, 0xFF);
-			_vm->_gfx->setItemFrame(id, 0);
+			_vm->_gfx->setItem(_lines[i], MENUITEMS_X, MENUITEMS_Y + MENUITEM_HEIGHT * i, 0xFF);
 		}
 		_selection = -1;
 		_vm->_input->setArrowCursor();

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-12-13 16:35:14 UTC (rev 35341)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-12-13 17:31:48 UTC (rev 35342)
@@ -572,7 +572,6 @@
 
 	// TODO: move this balloons stuff into DialogueManager and BalloonManager
 	if (getGameType() == GType_Nippon) {
-		int id;
 		if (data->_filename) {
 			if (data->_cnv == 0) {
 				data->_cnv = _disk->loadStatic(data->_filename);
@@ -582,20 +581,16 @@
 			_balloonMan->setSingleBalloon(data->_description.c_str(), 0, 90, 0, BalloonManager::kNormalColor);
 			Common::Rect r;
 			data->_cnv->getRect(0, r);
-			id = _gfx->setItem(data->_cnv, 140, (_screenHeight - r.height())/2);
-			_gfx->setItemFrame(id, 0);
-			id = _gfx->setItem(_char._head, 100, 152);
-			_gfx->setItemFrame(id, 0);
+			_gfx->setItem(data->_cnv, 140, (_screenHeight - r.height())/2);
+			_gfx->setItem(_char._head, 100, 152);
 		} else {
 			_balloonMan->setSingleBalloon(data->_description.c_str(), 140, 10, 0, BalloonManager::kNormalColor);
-			id = _gfx->setItem(_char._talk, 190, 80);
-			_gfx->setItemFrame(id, 0);
+			_gfx->setItem(_char._talk, 190, 80);
 		}
 	} else
 	if (getGameType() == GType_BRA) {
 		_balloonMan->setSingleBalloon(data->_description.c_str(), 0, 0, 1, BalloonManager::kNormalColor);
-		int id = _gfx->setItem(_char._talk, 10, 80);
-		_gfx->setItemFrame(id, 0);
+		_gfx->setItem(_char._talk, 10, 80);
 	}
 
 	_input->_inputMode = Input::kInputModeComment;


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