[Scummvm-cvs-logs] SF.net SVN: scummvm:[54626] scummvm/trunk/engines/mohawk

bgk at users.sourceforge.net bgk at users.sourceforge.net
Mon Nov 29 21:58:11 CET 2010


Revision: 54626
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54626&view=rev
Author:   bgk
Date:     2010-11-29 20:58:10 +0000 (Mon, 29 Nov 2010)

Log Message:
-----------
MOHAWK: Changed sliders to restore the main background instead of doing their own background caching. It is possible now there is the image cache.

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/myst.cpp
    scummvm/trunk/engines/mohawk/myst.h
    scummvm/trunk/engines/mohawk/myst_areas.cpp
    scummvm/trunk/engines/mohawk/myst_areas.h
    scummvm/trunk/engines/mohawk/myst_scripts.cpp
    scummvm/trunk/engines/mohawk/myst_scripts_selenitic.cpp

Modified: scummvm/trunk/engines/mohawk/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst.cpp	2010-11-29 20:57:54 UTC (rev 54625)
+++ scummvm/trunk/engines/mohawk/myst.cpp	2010-11-29 20:58:10 UTC (rev 54626)
@@ -396,18 +396,26 @@
 	_gfx->clearCache();
 }
 
-void MohawkEngine_Myst::drawCardBackground() {
-if (_view.conditionalImageCount != 0) {
-	for (uint16 i = 0; i < _view.conditionalImageCount; i++) {
-		if (_scriptParser->getVar(_view.conditionalImages[i].var) < _view.conditionalImages[i].numStates)
-			_gfx->copyImageToScreen(_view.conditionalImages[i].values[_scriptParser->getVar(_view.conditionalImages[i].var)], Common::Rect(0, 0, 544, 333));
-		else
-			warning("Conditional image %d variable %d: %d exceeds maximum state of %d", i, _view.conditionalImages[i].var, _scriptParser->getVar(_view.conditionalImages[i].var), _view.conditionalImages[i].numStates-1);
+uint16 MohawkEngine_Myst::getCardBackgroundId() {
+	uint16 imageToDraw = 0;
+
+	if (_view.conditionalImageCount == 0)
+		imageToDraw = _view.mainImage;
+	else {
+		for (uint16 i = 0; i < _view.conditionalImageCount; i++) {
+			uint16 varValue = _scriptParser->getVar(_view.conditionalImages[i].var);
+			if (varValue < _view.conditionalImages[i].numStates)
+				imageToDraw = _view.conditionalImages[i].values[varValue];
+		}
 	}
-} else if (_view.mainImage != 0)
-	_gfx->copyImageToScreen(_view.mainImage, Common::Rect(0, 0, 544, 333));
+
+	return imageToDraw;
 }
 
+void MohawkEngine_Myst::drawCardBackground() {
+	_gfx->copyImageToScreen(getCardBackgroundId(), Common::Rect(0, 0, 544, 333));
+}
+
 void MohawkEngine_Myst::changeToCard(uint16 card) {
 	debug(2, "changeToCard(%d)", card);
 

Modified: scummvm/trunk/engines/mohawk/myst.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst.h	2010-11-29 20:57:54 UTC (rev 54625)
+++ scummvm/trunk/engines/mohawk/myst.h	2010-11-29 20:58:10 UTC (rev 54626)
@@ -201,6 +201,7 @@
 	void redrawResource(MystResourceType8 *_resource);
 	void drawResourceImages();
 	void drawCardBackground();
+	uint16 getCardBackgroundId();
 
 	void setCacheState(bool state) { _cache.enabled = state; }
 	bool getCacheState(void) { return _cache.enabled; }

Modified: scummvm/trunk/engines/mohawk/myst_areas.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_areas.cpp	2010-11-29 20:57:54 UTC (rev 54625)
+++ scummvm/trunk/engines/mohawk/myst_areas.cpp	2010-11-29 20:58:10 UTC (rev 54626)
@@ -468,16 +468,11 @@
 
 	debugC(kDebugResource, "\tdrag sound : %d", _dragSound);
 
-	_background = 0;
 	_sliderWidth = _rect.right - _rect.left;
 	_sliderHeigth = _rect.bottom - _rect.top;
 }
 
 MystResourceType10::~MystResourceType10() {
-	if (_background) {
-		_background->free();
-		delete _background;
-	}
 }
 
 void MystResourceType10::setStep(uint16 step) {
@@ -508,27 +503,20 @@
 	return bb;
 }
 
-void MystResourceType10::drawDataToScreen() {
-	// Save the background to be able to restore it
-	if (!_background) {
-		Common::Rect bb = boundingBox();
-		Graphics::PixelFormat pixelFormat = _vm->_system->getScreenFormat();
+void MystResourceType10::restoreBackground() {
+	// Restore background
+	Common::Rect src = boundingBox();
+	Common::Rect dest = boundingBox();
+	src.top = 333 - dest.bottom;
+	src.bottom = 333 - dest.top;
+	_vm->_gfx->copyImageSectionToScreen(_vm->getCardBackgroundId(), src, dest);
+}
 
-		_background = new Graphics::Surface();
-		_background->create(bb.width(), bb.height(), pixelFormat.bytesPerPixel);
-		Graphics::Surface *screen = _vm->_system->lockScreen();
+void MystResourceType10::drawDataToScreen()
+{
+	// Restore background
+	restoreBackground();
 
-		for (uint16 i = 0; i < bb.height(); i++)
-			memcpy(_background->getBasePtr(0, i), screen->getBasePtr(bb.left, bb.top + i), bb.width() * _background->bytesPerPixel);
-
-		_vm->_system->unlockScreen();
-	} else {
-		// Restore background
-		Common::Rect bb = boundingBox();
-		_vm->_system->copyRectToScreen((byte *)_background->getBasePtr(0, 0), _background->pitch, bb.left, bb.top, bb.width(), bb.height());
-	}
-
-
 	MystResourceType8::drawDataToScreen();
 }
 
@@ -541,8 +529,7 @@
 	MystResourceType11::handleMouseDown(mouse);
 
 	// Restore background
-	Common::Rect bb = boundingBox();
-	_vm->_system->copyRectToScreen((byte *)_background->getBasePtr(0, 0), _background->pitch, bb.left, bb.top, bb.width(), bb.height());
+	restoreBackground();
 
 	// Draw slider
 	drawConditionalDataToScreen(2);
@@ -552,8 +539,7 @@
 	updatePosition(mouse);
 
 	// Restore background
-	Common::Rect bb = boundingBox();
-	_vm->_system->copyRectToScreen((byte *)_background->getBasePtr(0, 0), _background->pitch, bb.left, bb.top, bb.width(), bb.height());
+	restoreBackground();
 
 	// Draw slider
 	drawConditionalDataToScreen(1);
@@ -587,8 +573,7 @@
 	MystResourceType11::handleMouseDrag(mouse);
 
 	// Restore background
-	Common::Rect bb = boundingBox();
-	_vm->_system->copyRectToScreen((byte *)_background->getBasePtr(0, 0), _background->pitch, bb.left, bb.top, bb.width(), bb.height());
+	restoreBackground();
 
 	// Draw slider
 	drawConditionalDataToScreen(2);

Modified: scummvm/trunk/engines/mohawk/myst_areas.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_areas.h	2010-11-29 20:57:54 UTC (rev 54625)
+++ scummvm/trunk/engines/mohawk/myst_areas.h	2010-11-29 20:58:10 UTC (rev 54626)
@@ -183,12 +183,11 @@
 protected:
 	Common::Rect boundingBox();
 	void updatePosition(Common::Point *mouse);
+    void restoreBackground();
 
 	uint16 _dragSound;
 	uint16 _sliderWidth;
 	uint16 _sliderHeigth;
-
-	Graphics::Surface *_background;
 };
 
 class MystResourceType12 : public MystResourceType11 {

Modified: scummvm/trunk/engines/mohawk/myst_scripts.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_scripts.cpp	2010-11-29 20:57:54 UTC (rev 54625)
+++ scummvm/trunk/engines/mohawk/myst_scripts.cpp	2010-11-29 20:58:10 UTC (rev 54626)
@@ -572,17 +572,7 @@
 		debugC(kDebugScript, "\trect.right: %d", rect.right);
 		debugC(kDebugScript, "\trect.bottom: %d", rect.bottom);
 
-		// TODO: Need to fix VIEW logic so this doesn't need
-		//       calculation at this level.
-		uint16 imageToDraw = 0;
-		if (_vm->_view.conditionalImageCount == 0)
-			imageToDraw = _vm->_view.mainImage;
-		else {
-			for (uint16 i = 0; i < _vm->_view.conditionalImageCount; i++)
-				if (getVar(_vm->_view.conditionalImages[i].var) < _vm->_view.conditionalImages[i].numStates)
-					imageToDraw = _vm->_view.conditionalImages[i].values[getVar(_vm->_view.conditionalImages[i].var)];
-		}
-		_vm->_gfx->copyImageSectionToScreen(imageToDraw, rect, rect);
+		_vm->_gfx->copyImageSectionToScreen(_vm->getCardBackgroundId(), rect, rect);
 	} else
 		unknown(op, var, argc, argv);
 }

Modified: scummvm/trunk/engines/mohawk/myst_scripts_selenitic.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_scripts_selenitic.cpp	2010-11-29 20:57:54 UTC (rev 54625)
+++ scummvm/trunk/engines/mohawk/myst_scripts_selenitic.cpp	2010-11-29 20:58:10 UTC (rev 54626)
@@ -663,6 +663,7 @@
 
 	slider->setStep(stepped);
 	slider->drawDataToScreen();
+	_vm->_gfx->updateScreen();
 
 	uint16 soundId = slider->getList3(0);
 	if (soundId)


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