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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Wed Nov 21 21:04:14 CET 2007


Revision: 29593
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29593&view=rev
Author:   peres001
Date:     2007-11-21 12:04:14 -0800 (Wed, 21 Nov 2007)

Log Message:
-----------
* moved label drawing into Gfx, to be drawn directly in the framebuffer
* changed low level blitting function to accept Graphics::Surface to ease development
* temporarily disabled labels/subtitles in BRA

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/exec_br.cpp
    scummvm/trunk/engines/parallaction/exec_ns.cpp
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/graphics.h
    scummvm/trunk/engines/parallaction/objects.cpp
    scummvm/trunk/engines/parallaction/objects.h
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp

Modified: scummvm/trunk/engines/parallaction/exec_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_br.cpp	2007-11-21 16:55:24 UTC (rev 29592)
+++ scummvm/trunk/engines/parallaction/exec_br.cpp	2007-11-21 20:04:14 UTC (rev 29593)
@@ -106,8 +106,6 @@
 		_subtitle1._pos.x = (_gfx->_screenX << 2) + ((640 - _subtitle1._cnv.w) >> 1);
 
 	if (_jDisplaySubtitle == 0) {
-		_subtitle0._old.x = -1000;
-		_subtitle0._old.y = -1000;
 		_jDisplaySubtitle = addJob(kJobDisplaySubtitle, 0, 1);
 		_jEraseSubtitle = addJob(kJobEraseSubtitle, 0, 20);
 	}
@@ -427,11 +425,12 @@
 
 
 void Parallaction_br::jobDisplaySubtitle(void *parm, Job *job) {
-	_gfx->drawLabel(_subtitle0);
-	_gfx->drawLabel(_subtitle1);
+//	_gfx->drawLabel(_subtitle0);
+//	_gfx->drawLabel(_subtitle1);
 }
 
 void Parallaction_br::jobEraseSubtitle(void *parm, Job *job) {
+#if 0
 	Common::Rect r;
 
 	if (_subtitle0._old.x != -1000) {
@@ -451,6 +450,7 @@
 		_gfx->restoreBackground(r);
 	}
 	_subtitle1._old = _subtitle1._pos;
+#endif
 }
 
 DECLARE_INSTRUCTION_OPCODE(text) {

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2007-11-21 16:55:24 UTC (rev 29592)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2007-11-21 20:04:14 UTC (rev 29593)
@@ -844,67 +844,4 @@
 }
 
 
-
-void Parallaction_ns::drawLabel() {
-
-	if (!_label)
-		return;
-
-	if (_deletingLabel)
-		return;
-
-	debugC(9, kDebugExec, "jobDisplayLabel (%p)", (void *) _label);
-
-	_gfx->drawLabel(*_label);
-
-	return;
-}
-
-void Parallaction_ns::eraseLabel() {
-
-	static uint16 count = 0;
-
-	if (!_label)
-		return;
-
-	debugC(9, kDebugExec, "jobEraseLabel (%p)", (void *) _label);
-
-	int16 _si, _di;
-
-	if (_activeItem._id != 0) {
-		_si = _mousePos.x + 16 - _label->_cnv.w/2;
-		_di = _mousePos.y + 34;
-	} else {
-		_si = _mousePos.x + 8 - _label->_cnv.w/2;
-		_di = _mousePos.y + 21;
-	}
-
-	if (_si < 0) _si = 0;
-	if (_di > 190) _di = 190;
-
-	if (_label->_cnv.w + _si > _screenWidth)
-		_si = _screenWidth - _label->_cnv.w;
-
-	Common::Rect r;
-	_label->getRect(r, true);
-	_gfx->restoreBackground(r);
-
-	_label->_old = _label->_pos;
-	_label->_pos.x = _si;
-	_label->_pos.y = _di;
-
-	if (_deletingLabel) {
-		count++;
-		if (count == 2) {
-			count = 0;
-			_engineFlags &= ~kEngineBlockInput;
-			_deletingLabel = false;
-			_label = 0;
-		}
-	}
-
-	return;
-}
-
-
 }	// namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2007-11-21 16:55:24 UTC (rev 29592)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2007-11-21 20:04:14 UTC (rev 29593)
@@ -214,7 +214,7 @@
 	winding = (winding == 0 ? 1 : 0);
 	Common::Rect s(BALLOON_TAIL_WIDTH, BALLOON_TAIL_HEIGHT);
 	s.moveTo(r.left + (r.width()+5)/2 - 5, r.bottom - 1);
-	flatBlit(s, _resBalloonTail[winding], kBitFront, 2);
+	flatBlit(s, _resBalloonTail[winding], _buffers[kBitFront], 2);
 
 	return;
 }
@@ -285,17 +285,25 @@
 #endif
 }
 
+void Gfx::drawInventory() {
+
+	if ((_engineFlags & kEngineInventory) == 0) {
+		return;
+	}
+
+	Common::Rect r;
+	_vm->_inventoryRenderer->getRect(r);
+	byte *data = _vm->_inventoryRenderer->getData();
+
+	g_system->copyRectToScreen(data, r.width(), r.left, r.top, r.width(), r.height());
+}
+
 void Gfx::updateScreen() {
 	g_system->copyRectToScreen((const byte*)_buffers[kBitFront]->pixels, _buffers[kBitFront]->pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight);
 
-	if (_engineFlags & kEngineInventory) {
-		Common::Rect r;
-		_vm->_inventoryRenderer->getRect(r);
-		byte *data = _vm->_inventoryRenderer->getData();
+	drawInventory();
+	drawLabel();
 
-		g_system->copyRectToScreen(data, r.width(), r.left, r.top, r.width(), r.height());
-	}
-
 	g_system->updateScreen();
 	return;
 }
@@ -358,36 +366,26 @@
 
 }
 
-void Gfx::screenClip(Common::Rect& r, Common::Point& p) {
+void Gfx::flatBlit(const Common::Rect& r, byte *data, Graphics::Surface *surf, byte transparentColor) {
 
-	int32 x = r.left;
-	int32 y = r.top;
+	Common::Point dp;
+	Common::Rect q(r);
 
-	Common::Rect screen(0, 0, _vm->_screenWidth, _vm->_screenHeight);
+	Common::Rect clipper(surf->w, surf->h);
 
-	r.clip(screen);
+	q.clip(clipper);
+	if (!q.isValidRect()) return;
 
-	if (!r.isValidRect()) return;
+	dp.x = q.left;
+	dp.y = q.top;
 
-	p.x = r.left;
-	p.y = r.top;
+	q.translate(-r.left, -r.top);
 
-	r.translate(screen.left - x, screen.top - y);
-
-}
-
-void Gfx::flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer, byte transparentColor) {
-
-	Common::Point dp;
-	Common::Rect q(r);
-
-	screenClip(q, dp);
-
 	byte *s = data + q.left + q.top * r.width();
-	byte *d = (byte*)_buffers[buffer]->getBasePtr(dp.x, dp.y);
+	byte *d = (byte*)surf->getBasePtr(dp.x, dp.y);
 
 	uint sPitch = r.width() - q.width();
-	uint dPitch = _backgroundWidth - q.width();
+	uint dPitch = surf->w - q.width();
 
 	for (uint16 i = q.top; i < q.bottom; i++) {
 		for (uint16 j = q.left; j < q.right; j++) {
@@ -404,20 +402,30 @@
 
 	return;
 
+
 }
 
-void Gfx::blit(const Common::Rect& r, uint16 z, byte *data, Gfx::Buffers buffer) {
+void Gfx::blit(const Common::Rect& r, uint16 z, byte *data, Graphics::Surface *surf) {
 
 	Common::Point dp;
 	Common::Rect q(r);
 
-	screenClip(q, dp);
+	Common::Rect clipper(surf->w, surf->h);
 
+	q.clip(clipper);
+	if (!q.isValidRect()) return;
+
+	dp.x = q.left;
+	dp.y = q.top;
+
+	q.translate(-r.left, -r.top);
+
+
 	byte *s = data + q.left + q.top * r.width();
-	byte *d = (byte*)_buffers[buffer]->getBasePtr(dp.x, dp.y);
+	byte *d = (byte*)surf->getBasePtr(dp.x, dp.y);
 
 	uint sPitch = r.width() - q.width();
-	uint dPitch = _backgroundWidth - q.width();
+	uint dPitch = surf->w - q.width();
 
 	for (uint16 i = 0; i < q.height(); i++) {
 
@@ -439,11 +447,47 @@
 
 }
 
-void Gfx::drawLabel(Label &label) {
-	if (label._text == 0)
+void Gfx::setLabel(Label *label) {
+	_label = label;
+
+	if (_label) {
+		_label->resetPosition();
+	}
+}
+
+void Gfx::drawLabel() {
+	if (!_label || !_label->_text) {
 		return;
+	}
 
-	flatBlitCnv(&label._cnv, label._pos.x, label._pos.y, Gfx::kBitBack);
+	int16 _si, _di;
+
+	Common::Point	cursor;
+	_vm->getCursorPos(cursor);
+
+	if (_vm->_activeItem._id != 0) {
+		_si = cursor.x + 16 - _label->_cnv.w/2;
+		_di = cursor.y + 34;
+	} else {
+		_si = cursor.x + 8 - _label->_cnv.w/2;
+		_di = cursor.y + 21;
+	}
+
+	if (_si < 0) _si = 0;
+	if (_di > 190) _di = 190;
+
+	if (_label->_cnv.w + _si > _vm->_screenWidth)
+		_si = _vm->_screenWidth - _label->_cnv.w;
+
+	_label->_pos.x = _si;
+	_label->_pos.y = _di;
+
+	Common::Rect r(_label->_cnv.w, _label->_cnv.h);
+	r.moveTo(_label->_pos);
+
+	Graphics::Surface* surf = g_system->lockScreen();
+	flatBlit(r, (byte*)_label->_cnv.getBasePtr(0, 0), surf, 0);
+	g_system->unlockScreen();
 }
 
 
@@ -468,7 +512,7 @@
 	Common::Rect r(cnv->w, cnv->h);
 	r.moveTo(x, y);
 
-	flatBlit(r, (byte*)cnv->pixels, buffer, 0);
+	flatBlit(r, (byte*)cnv->pixels, _buffers[buffer], 0);
 	return;
 }
 
@@ -477,7 +521,7 @@
 	Common::Rect r(cnv->w, cnv->h);
 	r.moveTo(x, y);
 
-	blit(r, z, (byte*)cnv->pixels,  buffer);
+	blit(r, z, (byte*)cnv->pixels, _buffers[buffer]);
 	return;
 }
 
@@ -551,8 +595,8 @@
 //
 void Gfx::restoreGetBackground(const Common::Rect& r, byte *data) {
 
-	flatBlit(r, data, kBitBack, 0);
-	flatBlit(r, data, kBit2, 0);
+	flatBlit(r, data, _buffers[kBitBack], 0);
+	flatBlit(r, data, _buffers[kBit2], 0);
 
 	return;
 }
@@ -765,6 +809,8 @@
 
 	setPalette(_palette);
 
+	_label = 0;
+
 	_screenX = 0;
 	_screenY = 0;
 

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2007-11-21 16:55:24 UTC (rev 29592)
+++ scummvm/trunk/engines/parallaction/graphics.h	2007-11-21 20:04:14 UTC (rev 29593)
@@ -217,7 +217,9 @@
 	uint16 getStringWidth(const char *text);
 	void getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height);
 
-	void drawLabel(Label &label);
+	// labels
+	Label	*_label;
+	void setLabel(Label *label);
 
 	// cut/paste
 	void flatBlitCnv(Graphics::Surface *cnv, int16 x, int16 y, Gfx::Buffers buffer);
@@ -278,13 +280,16 @@
 	bool				_halfbrite;
 
 protected:
+	void drawInventory();
+	void drawLabel();
+
 	void initBuffers(int w, int h);
 	void freeBuffers();
 
 	void copyRect(uint width, uint height, byte *dst, uint dstPitch, byte *src, uint srcPitch);
-	void flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer, byte transparentColor);
-	void blit(const Common::Rect& r, uint16 z, byte *data, Gfx::Buffers buffer);
-	void screenClip(Common::Rect& r, Common::Point& p);
+
+	void blit(const Common::Rect& r, uint16 z, byte *data, Graphics::Surface *surf);
+	void flatBlit(const Common::Rect& r, byte *data, Graphics::Surface *surf, byte transparentColor);
 };
 
 

Modified: scummvm/trunk/engines/parallaction/objects.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/objects.cpp	2007-11-21 16:55:24 UTC (rev 29592)
+++ scummvm/trunk/engines/parallaction/objects.cpp	2007-11-21 20:04:14 UTC (rev 29593)
@@ -210,19 +210,12 @@
 void Label::resetPosition() {
 	_pos.x = -1000;
 	_pos.y = -1000;
-	_old.x = -1000;
-	_old.y = -1000;
 }
 
-void Label::getRect(Common::Rect &r, bool old) {
+void Label::getRect(Common::Rect &r) {
 	r.setWidth(_cnv.w);
 	r.setHeight(_cnv.h);
-
-	if (old) {
-		r.moveTo(_old);
-	} else {
-		r.moveTo(_pos);
-	}
+	r.moveTo(_pos);
 }
 
 Answer::Answer() {

Modified: scummvm/trunk/engines/parallaction/objects.h
===================================================================
--- scummvm/trunk/engines/parallaction/objects.h	2007-11-21 16:55:24 UTC (rev 29592)
+++ scummvm/trunk/engines/parallaction/objects.h	2007-11-21 20:04:14 UTC (rev 29593)
@@ -262,14 +262,13 @@
 	Graphics::Surface	_cnv;
 
 	Common::Point		_pos;
-	Common::Point		_old;
 
 	Label();
 	~Label();
 
 	void free();
 	void resetPosition();
-	void getRect(Common::Rect &r, bool old = false);
+	void getRect(Common::Rect &r);
 };
 
 struct Zone {

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2007-11-21 16:55:24 UTC (rev 29592)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2007-11-21 20:04:14 UTC (rev 29593)
@@ -159,8 +159,6 @@
 	_location._startFrame = 0;
 	_location._comment = NULL;
 	_location._endComment = NULL;
-	_label = 0;
-	_deletingLabel = false;
 
 	_backgroundInfo = 0;
 	_pathBuffer = 0;
@@ -285,7 +283,6 @@
 			changeLocation(_location._name);
 		}
 
-		eraseLabel();
 		eraseAnimations();
 
 		runScripts();
@@ -294,7 +291,6 @@
 		runJobs();
 
 		drawAnimations();
-		drawLabel();
 
 		updateView();
 
@@ -313,38 +309,18 @@
 	g_system->delayMillis(30);
 }
 
-void Parallaction::showLabel(Label &label) {
-	label.resetPosition();
-	_label = &label;
-}
 
-void Parallaction::hideLabel(uint priority) {
-
-	if (!_label)
-		return;
-
-	if (priority == kPriority99) {
-		_label = 0;
-	} else {
-		// schedule job for deletion
-		_deletingLabel = true;
-		_engineFlags |= kEngineBlockInput;
-	}
-
-}
-
-
 void Parallaction::processInput(InputData *data) {
 
 	switch (data->_event) {
 	case kEvEnterZone:
 		debugC(2, kDebugInput, "processInput: kEvEnterZone");
-		showLabel(*data->_label);
+		_gfx->setLabel(data->_label);
 		break;
 
 	case kEvExitZone:
 		debugC(2, kDebugInput, "processInput: kEvExitZone");
-		hideLabel(kPriority15);
+		_gfx->setLabel(0);
 		break;
 
 	case kEvAction:
@@ -359,7 +335,7 @@
 	case kEvOpenInventory:
 		_procCurrentHoverItem = -1;
 		_hoverZone = NULL;
-		hideLabel(kPriority2);
+		_gfx->setLabel(0);
 		if (hitZone(kZoneYou, _mousePos.x, _mousePos.y) == 0) {
 			setArrowCursor();
 		}

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2007-11-21 16:55:24 UTC (rev 29592)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2007-11-21 20:04:14 UTC (rev 29593)
@@ -91,8 +91,7 @@
 	kPriority18 = 18,
 	kPriority19 = 19,
 	kPriority20 = 20,
-	kPriority21 = 21,
-	kPriority99 = 99			// fictitious priority value used as a flag to handle quick label deletion
+	kPriority21 = 21
 };
 
 enum {
@@ -439,11 +438,6 @@
 	Table		*_callableNames;
 	Table		*_localFlagNames;
 
-	bool		_deletingLabel;
-	Label		*_label;
-	void showLabel(Label &label);
-	void hideLabel(uint priority);
-
 public:
 	int getGameType() const;
 	uint32 getFeatures() const;
@@ -477,6 +471,9 @@
 	InventoryItem	_activeItem;
 
 	Common::Point	_mousePos;
+	void			getCursorPos(Common::Point& p) {
+		p = _mousePos;
+	}
 
 	Zone	   		*_activeZone;
 
@@ -577,8 +574,6 @@
 	virtual void walk() = 0;
 	virtual void drawAnimations() = 0;
 	virtual void eraseAnimations() = 0;
-	virtual void drawLabel() = 0;
-	virtual void eraseLabel() = 0;
 
 	void		beep();
 
@@ -749,8 +744,6 @@
 	void walk();
 	void drawAnimations();
 	void eraseAnimations();
-	void drawLabel();
-	void eraseLabel();
 
 
 	// location parser

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2007-11-21 16:55:24 UTC (rev 29592)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2007-11-21 20:04:14 UTC (rev 29593)
@@ -204,7 +204,7 @@
 	debugC(1, kDebugInput, "setting mouse cursor to arrow");
 
 	// this stuff is needed to avoid artifacts with labels and selected items when switching cursors
-	hideLabel(kPriority15);
+	_gfx->setLabel(0);
 	_activeItem._id = 0;
 
 	_system->setMouseCursor(_mouseArrow, MOUSEARROW_WIDTH, MOUSEARROW_HEIGHT, 0, 0, 0);
@@ -317,7 +317,7 @@
 	// WORKAROUND: this hideLabel has been added to avoid crashes caused by
 	// execution of label jobs after a location switch. The other workaround in
 	// Parallaction::runGame should have been rendered useless by this one.
-	hideLabel(kPriority99);
+	_gfx->setLabel(0);
 
 	_hoverZone = NULL;
 	if (_engineFlags & kEngineBlockInput) {


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