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

bgk at users.sourceforge.net bgk at users.sourceforge.net
Tue Dec 14 20:11:16 CET 2010


Revision: 54907
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54907&view=rev
Author:   bgk
Date:     2010-12-14 19:11:16 +0000 (Tue, 14 Dec 2010)

Log Message:
-----------
MOHAWK: Rework Myst GFX updates
- Initial card state is drawn to the back buffer
- Script driven updates are drawn to the front buffer
Allows opcode 28 (copy back buffer to screen) and opcodes 29/33 (copy image to screen / back buffer) to work properly.
Fixes among others the generator room lights, and the matchbox.

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/console.cpp
    scummvm/trunk/engines/mohawk/graphics.cpp
    scummvm/trunk/engines/mohawk/graphics.h
    scummvm/trunk/engines/mohawk/myst.cpp
    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.h
    scummvm/trunk/engines/mohawk/myst_stacks/credits.cpp
    scummvm/trunk/engines/mohawk/myst_stacks/intro.cpp
    scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp
    scummvm/trunk/engines/mohawk/myst_stacks/preview.cpp
    scummvm/trunk/engines/mohawk/myst_stacks/selenitic.cpp

Modified: scummvm/trunk/engines/mohawk/console.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/console.cpp	2010-12-14 13:17:27 UTC (rev 54906)
+++ scummvm/trunk/engines/mohawk/console.cpp	2010-12-14 19:11:16 UTC (rev 54907)
@@ -174,7 +174,7 @@
 		rect = Common::Rect((uint16)atoi(argv[2]), (uint16)atoi(argv[3]), (uint16)atoi(argv[4]), (uint16)atoi(argv[5]));
 
 	_vm->_gfx->copyImageToScreen((uint16)atoi(argv[1]), rect);
-	_vm->_gfx->updateScreen();
+	_vm->_system->updateScreen();
 	return false;
 }
 

Modified: scummvm/trunk/engines/mohawk/graphics.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.cpp	2010-12-14 13:17:27 UTC (rev 54906)
+++ scummvm/trunk/engines/mohawk/graphics.cpp	2010-12-14 19:11:16 UTC (rev 54907)
@@ -235,8 +235,8 @@
 	_pictureFile.entries = NULL;
 
 	// Initialize our buffer
-	_mainScreen = new Graphics::Surface();
-	_mainScreen->create(_vm->_system->getWidth(), _vm->_system->getHeight(), _pixelFormat.bytesPerPixel);
+	_backBuffer = new Graphics::Surface();
+	_backBuffer->create(_vm->_system->getWidth(), _vm->_system->getHeight(), _pixelFormat.bytesPerPixel);
 }
 
 MystGraphics::~MystGraphics() {
@@ -245,8 +245,8 @@
 	delete _pictDecoder;
 	delete[] _pictureFile.entries;
 
-	_mainScreen->free();
-	delete _mainScreen;
+	_backBuffer->free();
+	delete _backBuffer;
 }
 
 static const char* picFileNames[] = {
@@ -371,36 +371,50 @@
 	// Convert from bitmap coordinates to surface coordinates
 	uint16 top = surface->h - src.top - height;
 
+	_vm->_system->copyRectToScreen((byte *)surface->getBasePtr(src.left, top), surface->pitch, dest.left, dest.top, width, height);
+}
+
+void MystGraphics::copyImageSectionToBackBuffer(uint16 image, Common::Rect src, Common::Rect dest) {
+	// Clip the destination rect to the screen
+	if (dest.right > _vm->_system->getWidth() || dest.bottom > _vm->_system->getHeight())
+		dest.debugPrint(4, "Clipping destination rect to the screen:");
+
+	dest.right = CLIP<int>(dest.right, 0, _vm->_system->getWidth());
+	dest.bottom = CLIP<int>(dest.bottom, 0, _vm->_system->getHeight());
+
+	Graphics::Surface *surface = findImage(image)->getSurface();
+
+	debug(3, "Image Blit:");
+	debug(3, "src.x: %d", src.left);
+	debug(3, "src.y: %d", src.top);
+	debug(3, "dest.x: %d", dest.left);
+	debug(3, "dest.y: %d", dest.top);
+	debug(3, "width: %d", src.width());
+	debug(3, "height: %d", src.height());
+
+	uint16 width = MIN<int>(surface->w, dest.width());
+	uint16 height = MIN<int>(surface->h, dest.height());
+
+	// Convert from bitmap coordinates to surface coordinates
+	uint16 top = surface->h - src.top - height;
+
 	for (uint16 i = 0; i < height; i++)
-		memcpy(_mainScreen->getBasePtr(dest.left, i + dest.top), surface->getBasePtr(src.left, top + i), width * surface->bytesPerPixel);
-
-	// Add to the list of dirty rects
-	_dirtyRects.push_back(dest);
+		memcpy(_backBuffer->getBasePtr(dest.left, i + dest.top), surface->getBasePtr(src.left, top + i), width * surface->bytesPerPixel);
 }
 
 void MystGraphics::copyImageToScreen(uint16 image, Common::Rect dest) {
 	copyImageSectionToScreen(image, Common::Rect(0, 0, 544, 333), dest);
 }
 
-void MystGraphics::updateScreen() {
-	// Only update the screen if there have been changes since last frame
-	if (!_dirtyRects.empty()) {
+void MystGraphics::copyImageToBackBuffer(uint16 image, Common::Rect dest) {
+	copyImageSectionToBackBuffer(image, Common::Rect(0, 0, 544, 333), dest);
+}
 
-		// Copy any modified area
-		for (uint i = 0; i < _dirtyRects.size(); i++) {
-			Common::Rect &r = _dirtyRects[i];
-			_vm->_system->copyRectToScreen((byte *)_mainScreen->getBasePtr(r.left, r.top), _mainScreen->pitch, r.left, r.top, r.width(), r.height());
-		}
-
-		_vm->_system->updateScreen();
-		_dirtyRects.clear();
-	}
+void MystGraphics::copyBackBufferToScreen(const Common::Rect &r) {
+	_vm->_system->copyRectToScreen((byte *)_backBuffer->getBasePtr(r.left, r.top), _backBuffer->pitch, r.left, r.top, r.width(), r.height());
 }
 
 void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, uint16 delay) {
-	// Bypass dirty rects for animated updates
-	_dirtyRects.clear();
-
 	switch (type) {
 	case 0:	{
 			debugC(kDebugScript, "Left to Right");
@@ -413,15 +427,15 @@
 
 				_vm->_system->delayMillis(delay);
 
-				_dirtyRects.push_back(area);
-				updateScreen();
+				copyBackBufferToScreen(area);
+				_vm->_system->updateScreen();
 			}
 			if (area.right < rect.right) {
 				area.left = area.right;
 				area.right = rect.right;
 
-				_dirtyRects.push_back(area);
-				updateScreen();
+				copyBackBufferToScreen(area);
+				_vm->_system->updateScreen();
 			}
 		}
 		break;
@@ -436,15 +450,15 @@
 
 				_vm->_system->delayMillis(delay);
 
-				_dirtyRects.push_back(area);
-				updateScreen();
+				copyBackBufferToScreen(area);
+				_vm->_system->updateScreen();
 			}
 			if (area.left > rect.left) {
 				area.right = area.left;
 				area.left = rect.left;
 
-				_dirtyRects.push_back(area);
-				updateScreen();
+				copyBackBufferToScreen(area);
+				_vm->_system->updateScreen();
 			}
 		}
 		break;
@@ -459,15 +473,15 @@
 
 				_vm->_system->delayMillis(delay);
 
-				_dirtyRects.push_back(area);
-				updateScreen();
+				copyBackBufferToScreen(area);
+				_vm->_system->updateScreen();
 			}
 			if (area.bottom < rect.bottom) {
 				area.top = area.bottom;
 				area.bottom = rect.bottom;
 
-				_dirtyRects.push_back(area);
-				updateScreen();
+				copyBackBufferToScreen(area);
+				_vm->_system->updateScreen();
 			}
 		}
 		break;
@@ -482,15 +496,15 @@
 
 				_vm->_system->delayMillis(delay);
 
-				_dirtyRects.push_back(area);
-				updateScreen();
+				copyBackBufferToScreen(area);
+				_vm->_system->updateScreen();
 			}
 			if (area.top > rect.top) {
 				area.bottom = area.top;
 				area.top = rect.top;
 
-				_dirtyRects.push_back(area);
-				updateScreen();
+				copyBackBufferToScreen(area);
+				_vm->_system->updateScreen();
 			}
 		}
 		break;
@@ -498,8 +512,8 @@
 		warning("Unknown Update Direction");
 
 		//TODO: Replace minimal implementation
-		_dirtyRects.push_back(rect);
-		updateScreen();
+		copyBackBufferToScreen(rect);
+		_vm->_system->updateScreen();
 		break;
 	}
 }
@@ -510,15 +524,15 @@
 		return;
 
 	if (state == kRectEnabled)
-		_mainScreen->frameRect(rect, _pixelFormat.RGBToColor(0, 255, 0));
+		_backBuffer->frameRect(rect, _pixelFormat.RGBToColor(0, 255, 0));
 	else if (state == kRectUnreachable)
-		_mainScreen->frameRect(rect, _pixelFormat.RGBToColor(0, 0, 255));
+		_backBuffer->frameRect(rect, _pixelFormat.RGBToColor(0, 0, 255));
 	else
-		_mainScreen->frameRect(rect, _pixelFormat.RGBToColor(255, 0, 0));
+		_backBuffer->frameRect(rect, _pixelFormat.RGBToColor(255, 0, 0));
 }
 
 void MystGraphics::drawLine(const Common::Point &p1, const Common::Point &p2, uint32 color) {
-	_mainScreen->drawLine(p1.x, p1.y, p2.x, p2.y, color);
+	_backBuffer->drawLine(p1.x, p1.y, p2.x, p2.y, color);
 }
 
 RivenGraphics::RivenGraphics(MohawkEngine_Riven* vm) : GraphicsManager(), _vm(vm) {

Modified: scummvm/trunk/engines/mohawk/graphics.h
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.h	2010-12-14 13:17:27 UTC (rev 54906)
+++ scummvm/trunk/engines/mohawk/graphics.h	2010-12-14 19:11:16 UTC (rev 54907)
@@ -111,8 +111,10 @@
 
 	void loadExternalPictureFile(uint16 stack);
 	void copyImageSectionToScreen(uint16 image, Common::Rect src, Common::Rect dest);
+	void copyImageSectionToBackBuffer(uint16 image, Common::Rect src, Common::Rect dest);
 	void copyImageToScreen(uint16 image, Common::Rect dest);
-	void updateScreen();
+	void copyImageToBackBuffer(uint16 image, Common::Rect dest);
+	void copyBackBufferToScreen(const Common::Rect &r);
 	void runTransition(uint16 type, Common::Rect rect, uint16 steps, uint16 delay);
 	void drawRect(Common::Rect rect, RectState state);
 	void drawLine(const Common::Point &p1, const Common::Point &p2, uint32 color);
@@ -141,8 +143,7 @@
 		Common::File picFile;
 	} _pictureFile;
 
-	Graphics::Surface *_mainScreen;
-	Common::Array<Common::Rect> _dirtyRects;
+	Graphics::Surface *_backBuffer;
 	Graphics::PixelFormat _pixelFormat;
 };
 

Modified: scummvm/trunk/engines/mohawk/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst.cpp	2010-12-14 13:17:27 UTC (rev 54906)
+++ scummvm/trunk/engines/mohawk/myst.cpp	2010-12-14 19:11:16 UTC (rev 54907)
@@ -472,7 +472,7 @@
 }
 
 void MohawkEngine_Myst::drawCardBackground() {
-	_gfx->copyImageToScreen(getCardBackgroundId(), Common::Rect(0, 0, 544, 333));
+	_gfx->copyImageToBackBuffer(getCardBackgroundId(), Common::Rect(0, 0, 544, 333));
 }
 
 void MohawkEngine_Myst::changeToCard(uint16 card, bool updateScreen) {
@@ -568,7 +568,8 @@
 
 	// Make sure the screen is updated
 	if (updateScreen) {
-		_gfx->updateScreen();
+		_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
+		_system->updateScreen();
 	}
 }
 

Modified: scummvm/trunk/engines/mohawk/myst_areas.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_areas.cpp	2010-12-14 13:17:27 UTC (rev 54906)
+++ scummvm/trunk/engines/mohawk/myst_areas.cpp	2010-12-14 19:11:16 UTC (rev 54907)
@@ -386,35 +386,18 @@
 	}
 
 	if (drawSubImage) {
-		uint16 imageToDraw = 0;
+		uint16 imageToDraw = _subImages[subImageId].wdib;
 
-		if (_subImages[subImageId].wdib == 0xFFFF) {
-			// TODO: Think the reason for problematic screen updates in some rects is that they
-			//       are these -1 cases.
-			// They need to be redrawn i.e. if the Myst marker switches are changed, but I don't think
-			// the rects are valid. This does not matter in the original engine as the screen update redraws
-			// the VIEW images, followed by the RLST resource images, and -1 for the WDIB is interpreted as
-			// "Do Not Draw Image" i.e so the VIEW image is shown through.. We need to fix screen update
-			// to do this same behaviour.
-			if (_vm->_view.conditionalImageCount == 0)
-				imageToDraw = _vm->_view.mainImage;
-			else {
-				for (uint16 i = 0; i < _vm->_view.conditionalImageCount; i++)
-					if (_vm->_scriptParser->getVar(_vm->_view.conditionalImages[i].var) < _vm->_view.conditionalImages[i].numStates)
-						imageToDraw = _vm->_view.conditionalImages[i].values[_vm->_scriptParser->getVar(_vm->_view.conditionalImages[i].var)];
-			}
-		} else
-			imageToDraw = _subImages[subImageId].wdib;
+		// This special case means redraw background
+		if (imageToDraw == 0xFFFF) {
+			imageToDraw = _vm->getCardBackgroundId();
+		}
 
-		_vm->_gfx->copyImageSectionToScreen(imageToDraw, _subImages[subImageId].rect, _rect);
+		_vm->_gfx->copyImageSectionToBackBuffer(imageToDraw, _subImages[subImageId].rect, _rect);
 	}
 }
 
 void MystResourceType8::drawConditionalDataToScreen(uint16 state, bool update) {
-	// Need to call overidden Type 7 function to ensure
-	// switch section is processed correctly.
-	MystResourceType7::drawDataToScreen();
-
 	bool drawSubImage = false;
 	int16 subImageId = 0;
 
@@ -432,31 +415,20 @@
 
 
 	if (drawSubImage) {
-		uint16 imageToDraw = 0;
+		uint16 imageToDraw = _subImages[subImageId].wdib;
 
-		if (_subImages[subImageId].wdib == 0xFFFF) {
-			// TODO: Think the reason for problematic screen updates in some rects is that they
-			//       are these -1 cases.
-			// They need to be redrawn i.e. if the Myst marker switches are changed, but I don't think
-			// the rects are valid. This does not matter in the original engine as the screen update redraws
-			// the VIEW images, followed by the RLST resource images, and -1 for the WDIB is interpreted as
-			// "Do Not Draw Image" i.e so the VIEW image is shown through.. We need to fix screen update
-			// to do this same behaviour.
-			if (_vm->_view.conditionalImageCount == 0)
-				imageToDraw = _vm->_view.mainImage;
-			else {
-				for (uint16 i = 0; i < _vm->_view.conditionalImageCount; i++)
-					if (_vm->_scriptParser->getVar(_vm->_view.conditionalImages[i].var) < _vm->_view.conditionalImages[i].numStates)
-						imageToDraw = _vm->_view.conditionalImages[i].values[_vm->_scriptParser->getVar(_vm->_view.conditionalImages[i].var)];
-			}
-		} else
-			imageToDraw = _subImages[subImageId].wdib;
+		// This special case means redraw background
+		if (imageToDraw == 0xFFFF) {
+			imageToDraw = _vm->getCardBackgroundId();
+		}
 
-		_vm->_gfx->copyImageSectionToScreen(imageToDraw, _subImages[subImageId].rect, _rect);
-
 		// Draw to screen
-		if (update)
-			_vm->_gfx->updateScreen();
+		if (update) {
+			_vm->_gfx->copyImageSectionToScreen(imageToDraw, _subImages[subImageId].rect, _rect);
+			_vm->_system->updateScreen();
+		} else {
+			_vm->_gfx->copyImageSectionToBackBuffer(imageToDraw, _subImages[subImageId].rect, _rect);
+		}
 	}
 }
 
@@ -521,14 +493,6 @@
 	_vm->_gfx->copyImageSectionToScreen(_vm->getCardBackgroundId(), src, dest);
 }
 
-void MystResourceType10::drawDataToScreen()
-{
-	// Restore background
-	restoreBackground();
-
-	MystResourceType8::drawDataToScreen();
-}
-
 void MystResourceType10::handleMouseDown(const Common::Point &mouse) {
 	// Tell the engine we are dragging a resource
 	_vm->_dragResource = this;
@@ -775,7 +739,7 @@
 void MystResourceType12::drawFrame(uint16 frame) {
 	_currentFrame = _firstFrame + frame;
 	_vm->_gfx->copyImageToScreen(_currentFrame, _frameRect);
-	_vm->_gfx->updateScreen();
+	_vm->_system->updateScreen();
 }
 
 MystResourceType13::MystResourceType13(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResource(vm, rlstStream, parent) {

Modified: scummvm/trunk/engines/mohawk/myst_areas.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_areas.h	2010-12-14 13:17:27 UTC (rev 54906)
+++ scummvm/trunk/engines/mohawk/myst_areas.h	2010-12-14 19:11:16 UTC (rev 54907)
@@ -203,17 +203,16 @@
 	MystResourceType10(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
 	virtual ~MystResourceType10();
 
-	void drawDataToScreen();
 	void handleMouseDown(const Common::Point &mousee);
 	void handleMouseUp(const Common::Point &mouse);
 	void handleMouseDrag(const Common::Point &mouse);
 	void setStep(uint16 step);
 	void setPosition(uint16 pos);
+    void restoreBackground();
 
 protected:
 	Common::Rect boundingBox();
 	void updatePosition(const Common::Point &mouse);
-    void restoreBackground();
 
 	uint16 _dragSound;
 	uint16 _sliderWidth;

Modified: scummvm/trunk/engines/mohawk/myst_scripts.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_scripts.cpp	2010-12-14 13:17:27 UTC (rev 54906)
+++ scummvm/trunk/engines/mohawk/myst_scripts.cpp	2010-12-14 19:11:16 UTC (rev 54907)
@@ -126,12 +126,12 @@
 	// Opcode 25 is unused; original calls replaceSound
 	OPCODE(26, o_stopSoundBackground);
 	OPCODE(27, o_playSoundBlocking);
-	OPCODE(28, o_restoreDefaultRect);
-	OPCODE(29, o_blitRect);
+	OPCODE(28, o_copyBackBufferToScreen);
+	OPCODE(29, o_copyImageToBackBuffer);
 	OPCODE(30, o_changeSound);
 	OPCODE(31, o_soundPlaySwitch);
 	OPCODE(32, o_soundResumeBackground);
-	OPCODE(33, o_blitRect);
+	OPCODE(33, o_copyImageToScreen);
 	OPCODE(34, o_changeCard);
 	OPCODE(35, o_drawImageChangeCard);
 	OPCODE(36, o_changeMainCursor);
@@ -360,10 +360,10 @@
 void MystScriptParser::o_redrawCard(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 	debugC(kDebugScript, "Opcode %d: Redraw card", op);
 
-	// TODO: Is redrawing the background correct ?
 	_vm->drawCardBackground();
 	_vm->drawResourceImages();
-	_vm->_gfx->updateScreen();
+	_vm->_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
+	_vm->_system->updateScreen();
 }
 
 void MystScriptParser::o_goToDest(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@@ -406,7 +406,7 @@
 }
 
 void MystScriptParser::o_redrawAreaForVar(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
-	debugC(kDebugScript, "Opcode %d: dropPage", op);
+	debugC(kDebugScript, "Opcode %d: redraw area", op);
 	debugC(kDebugScript, "\tvar: %d", var);
 
 	_vm->redrawArea(var);
@@ -577,81 +577,56 @@
 	_vm->_sound->playSoundBlocking(soundId);
 }
 
-void MystScriptParser::o_restoreDefaultRect(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
-	varUnusedCheck(op, var);
+void MystScriptParser::o_copyBackBufferToScreen(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	debugC(kDebugScript, "Opcode %d: Copy back buffer to screen", op);
 
 	Common::Rect rect;
+	if (argv[0] == 0xFFFF) {
+		// Used in Stoneship Card 2111 (Compass Rose)
+		// Used in Mechanical Card 6267 (Code Lock)
+		rect = _invokingResource->getRect();
+	} else {
+		// Used in ... TODO: Fill in.
+		rect = Common::Rect(argv[0], argv[1], argv[2], argv[3]);
+	}
 
-	if (argc == 1 || argc == 4) {
-		debugC(kDebugScript, "Opcode %d: Restore VIEW Default Image in Region", op);
+	debugC(kDebugScript, "\trect.left: %d", rect.left);
+	debugC(kDebugScript, "\trect.top: %d", rect.top);
+	debugC(kDebugScript, "\trect.right: %d", rect.right);
+	debugC(kDebugScript, "\trect.bottom: %d", rect.bottom);
 
-		if (argc == 1) {
-			// Used in Stoneship Card 2111 (Compass Rose)
-			// Used in Mechanical Card 6267 (Code Lock)
-			if (argv[0] == 0xFFFF) {
-				rect = _invokingResource->getRect();
-			} else
-				unknown(op, var, argc, argv);
-		} else if (argc == 4) {
-			// Used in ... TODO: Fill in.
-			rect = Common::Rect(argv[0], argv[1], argv[2], argv[3]);
-		} else
-			warning("Opcode %d: argc Error", op);
-
-		debugC(kDebugScript, "\trect.left: %d", rect.left);
-		debugC(kDebugScript, "\trect.top: %d", rect.top);
-		debugC(kDebugScript, "\trect.right: %d", rect.right);
-		debugC(kDebugScript, "\trect.bottom: %d", rect.bottom);
-
-		Common::Rect src;
-		src.left = rect.left;
-		src.top = 333 - rect.bottom;
-		src.right = rect.right;
-		src.bottom = 333 - rect.top;
-
-		_vm->_gfx->copyImageSectionToScreen(_vm->getCardBackgroundId(), src, rect);
-	} else
-		unknown(op, var, argc, argv);
+	_vm->_gfx->copyBackBufferToScreen(rect);
+	_vm->_system->updateScreen();
 }
 
-void MystScriptParser::o_blitRect(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
-	varUnusedCheck(op, var);
+void MystScriptParser::o_copyImageToBackBuffer(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	uint16 imageId = argv[0];
 
-	// TODO: Opcode 29 called on Mechanical Card 6178 causes a engine
-	//       abort this is because imageId is 7158 (not valid), but the
-	//       script resource gives this as 7178 (valid)...
-	// FIXME: opcode 33 also hides the cursor when drawing if it is in the way
+	Common::Rect srcRect = Common::Rect(argv[1], argv[2], argv[3], argv[4]);
 
-	if (argc == 7) {
-		uint16 imageId = argv[0];
+	Common::Rect dstRect = Common::Rect(argv[5], argv[6], 544, 333);
 
-		Common::Rect srcRect = Common::Rect(argv[1], argv[2], argv[3], argv[4]);
+	if (dstRect.left == -1 || dstRect.top == -1) {
+		// Interpreted as full screen
+		dstRect.left = 0;
+		dstRect.top = 0;
+	}
 
-		Common::Rect dstRect = Common::Rect(argv[5], argv[6], 544, 333);
+	dstRect.right = dstRect.left + srcRect.width();
+	dstRect.bottom = dstRect.top + srcRect.height();
 
-		if (dstRect.left == -1 || dstRect.top == -1) {
-			// Interpreted as full screen
-			dstRect.left = 0;
-			dstRect.top = 0;
-		}
+	debugC(kDebugScript, "Opcode %d: Copy image to back buffer", op);
+	debugC(kDebugScript, "\timageId: %d", imageId);
+	debugC(kDebugScript, "\tsrcRect.left: %d", srcRect.left);
+	debugC(kDebugScript, "\tsrcRect.top: %d", srcRect.top);
+	debugC(kDebugScript, "\tsrcRect.right: %d", srcRect.right);
+	debugC(kDebugScript, "\tsrcRect.bottom: %d", srcRect.bottom);
+	debugC(kDebugScript, "\tdstRect.left: %d", dstRect.left);
+	debugC(kDebugScript, "\tdstRect.top: %d", dstRect.top);
+	debugC(kDebugScript, "\tdstRect.right: %d", dstRect.right);
+	debugC(kDebugScript, "\tdstRect.bottom: %d", dstRect.bottom);
 
-		dstRect.right = dstRect.left + srcRect.width();
-		dstRect.bottom = dstRect.top + srcRect.height();
-
-		debugC(kDebugScript, "Opcode %d: Blit Image", op);
-		debugC(kDebugScript, "\timageId: %d", imageId);
-		debugC(kDebugScript, "\tsrcRect.left: %d", srcRect.left);
-		debugC(kDebugScript, "\tsrcRect.top: %d", srcRect.top);
-		debugC(kDebugScript, "\tsrcRect.right: %d", srcRect.right);
-		debugC(kDebugScript, "\tsrcRect.bottom: %d", srcRect.bottom);
-		debugC(kDebugScript, "\tdstRect.left: %d", dstRect.left);
-		debugC(kDebugScript, "\tdstRect.top: %d", dstRect.top);
-		debugC(kDebugScript, "\tdstRect.right: %d", dstRect.right);
-		debugC(kDebugScript, "\tdstRect.bottom: %d", dstRect.bottom);
-
-		_vm->_gfx->copyImageSectionToScreen(imageId, srcRect, dstRect);
-	} else
-		unknown(op, var, argc, argv);
+	_vm->_gfx->copyImageSectionToBackBuffer(imageId, srcRect, dstRect);
 }
 
 // TODO: Implement common engine function for read and processing of sound blocks
@@ -760,6 +735,37 @@
 	//_vm->_sound->resumeBackground();
 }
 
+void MystScriptParser::o_copyImageToScreen(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	uint16 imageId = argv[0];
+
+	Common::Rect srcRect = Common::Rect(argv[1], argv[2], argv[3], argv[4]);
+
+	Common::Rect dstRect = Common::Rect(argv[5], argv[6], 544, 333);
+
+	if (dstRect.left == -1 || dstRect.top == -1) {
+		// Interpreted as full screen
+		dstRect.left = 0;
+		dstRect.top = 0;
+	}
+
+	dstRect.right = dstRect.left + srcRect.width();
+	dstRect.bottom = dstRect.top + srcRect.height();
+
+	debugC(kDebugScript, "Opcode %d: Copy image to screen", op);
+	debugC(kDebugScript, "\timageId: %d", imageId);
+	debugC(kDebugScript, "\tsrcRect.left: %d", srcRect.left);
+	debugC(kDebugScript, "\tsrcRect.top: %d", srcRect.top);
+	debugC(kDebugScript, "\tsrcRect.right: %d", srcRect.right);
+	debugC(kDebugScript, "\tsrcRect.bottom: %d", srcRect.bottom);
+	debugC(kDebugScript, "\tdstRect.left: %d", dstRect.left);
+	debugC(kDebugScript, "\tdstRect.top: %d", dstRect.top);
+	debugC(kDebugScript, "\tdstRect.right: %d", dstRect.right);
+	debugC(kDebugScript, "\tdstRect.bottom: %d", dstRect.bottom);
+
+	_vm->_gfx->copyImageSectionToScreen(imageId, srcRect, dstRect);
+	_vm->_system->updateScreen();
+}
+
 void MystScriptParser::o_changeCard(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 	debugC(kDebugScript, "Opcode %d: Change Card", op);
 
@@ -789,7 +795,7 @@
 		debugC(kDebugScript, "\tdelay: %d", delay);
 
 		_vm->_gfx->copyImageToScreen(imageId, Common::Rect(0, 0, 544, 333));
-		_vm->_gfx->updateScreen();
+		_vm->_system->updateScreen();
 		_vm->_system->delayMillis(delay * 100);
 		_vm->changeToCard(cardId, true);
 	} else

Modified: scummvm/trunk/engines/mohawk/myst_scripts.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_scripts.h	2010-12-14 13:17:27 UTC (rev 54906)
+++ scummvm/trunk/engines/mohawk/myst_scripts.h	2010-12-14 19:11:16 UTC (rev 54907)
@@ -101,10 +101,11 @@
 	DECLARE_OPCODE(o_playSound);
 	DECLARE_OPCODE(o_stopSoundBackground);
 	DECLARE_OPCODE(o_playSoundBlocking);
-	DECLARE_OPCODE(o_restoreDefaultRect);
-	DECLARE_OPCODE(o_blitRect);
+	DECLARE_OPCODE(o_copyBackBufferToScreen);
+	DECLARE_OPCODE(o_copyImageToBackBuffer);
 	DECLARE_OPCODE(o_changeSound);
 	DECLARE_OPCODE(o_soundPlaySwitch);
+	DECLARE_OPCODE(o_copyImageToScreen);
 	DECLARE_OPCODE(o_soundResumeBackground);
 	DECLARE_OPCODE(o_changeCard);
 	DECLARE_OPCODE(o_drawImageChangeCard);

Modified: scummvm/trunk/engines/mohawk/myst_stacks/credits.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/credits.cpp	2010-12-14 13:17:27 UTC (rev 54906)
+++ scummvm/trunk/engines/mohawk/myst_stacks/credits.cpp	2010-12-14 19:11:16 UTC (rev 54907)
@@ -75,7 +75,7 @@
 
 		// Note: The modulus by 6 is because the 6th image is the one at imageBaseId
 		_vm->_gfx->copyImageToScreen(_baseImageId + curImageIndex % 6, Common::Rect(0, 0, 544, 333));
-		_vm->_gfx->updateScreen();
+		_vm->_system->updateScreen();
 
 		_vm->_varStore->setVar(_creditsVar, curImageIndex + 1);
 		_lastCardTime = _vm->_system->getMillis();

Modified: scummvm/trunk/engines/mohawk/myst_stacks/intro.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/intro.cpp	2010-12-14 13:17:27 UTC (rev 54906)
+++ scummvm/trunk/engines/mohawk/myst_stacks/intro.cpp	2010-12-14 19:11:16 UTC (rev 54907)
@@ -173,13 +173,16 @@
 void MystScriptParser_Intro::opcode_201(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 	varUnusedCheck(op, var);
 
-	_vm->_gfx->updateScreen();
+	_vm->_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
+	_vm->_system->updateScreen();
 	_vm->_system->delayMillis(4 * 1000);
-	_vm->_gfx->copyImageToScreen(4, Common::Rect(0, 0, 544, 333));
+	_vm->_gfx->copyImageToBackBuffer(4, Common::Rect(544, 333));
+	_vm->_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
+	_vm->_system->updateScreen();
 
 	MystResourceType6 *resource = static_cast<MystResourceType6 *>(_invokingResource);
 	resource->playMovie();
-	// TODO: Complete
+	// TODO: Complete / Fix
 }
 
 void MystScriptParser_Intro::opcode_300(uint16 op, uint16 var, uint16 argc, uint16 *argv) {

Modified: scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp	2010-12-14 13:17:27 UTC (rev 54906)
+++ scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp	2010-12-14 19:11:16 UTC (rev 54907)
@@ -579,7 +579,7 @@
 		else
 			_vm->_sound->playSound(_libraryBookSound2);
 
-		_vm->_gfx->updateScreen();
+		_vm->_system->updateScreen();
 	}
 }
 
@@ -597,7 +597,7 @@
 		else
 			_vm->_sound->playSound(_libraryBookSound2);
 
-		_vm->_gfx->updateScreen();
+		_vm->_system->updateScreen();
 	}
 }
 
@@ -615,7 +615,7 @@
 		// Unset button
 		for (uint i = 4795; i >= 4779; i--) {
 			_vm->_gfx->copyImageToScreen(i, _invokingResource->getRect());
-			_vm->_gfx->updateScreen();
+			_vm->_system->updateScreen();
 			_vm->_system->delayMillis(1);
 		}
 		_fireplaceLines[var - 17] &= ~bitmask;
@@ -623,7 +623,7 @@
 		// Set button
 		for (uint i = 4779; i <= 4795; i++) {
 			_vm->_gfx->copyImageToScreen(i, _invokingResource->getRect());
-			_vm->_gfx->updateScreen();
+			_vm->_system->updateScreen();
 			_vm->_system->delayMillis(1);
 		}
 		_fireplaceLines[var - 17] |= bitmask;
@@ -1698,7 +1698,7 @@
 		else
 			_vm->_sound->playSound(_libraryBookSound2);
 
-		_vm->_gfx->updateScreen();
+		_vm->_system->updateScreen();
 	}
 }
 
@@ -1724,7 +1724,7 @@
 		else
 			_vm->_sound->playSound(_libraryBookSound2);
 
-		_vm->_gfx->updateScreen();
+		_vm->_system->updateScreen();
 	}
 }
 
@@ -1879,7 +1879,8 @@
 		towerRotationDrawBuildings();
 
 		// Draw to screen
-		_vm->_gfx->updateScreen();
+		_vm->_gfx->copyBackBufferToScreen(Common::Rect(106, 42, 459, 273));
+		_vm->_system->updateScreen();
 	}
 
 	uint32 time = _vm->_system->getMillis();
@@ -1998,7 +1999,7 @@
 	src.bottom = 333 - rect.top;
 
 	// Redraw background
-	_vm->_gfx->copyImageSectionToScreen(_vm->getCardBackgroundId(), src, rect);
+	_vm->_gfx->copyImageSectionToBackBuffer(_vm->getCardBackgroundId(), src, rect);
 
 	// Draw buildings
 	towerRotationDrawBuildings();
@@ -2011,7 +2012,8 @@
 
 	// Draw line
 	_vm->_gfx->drawLine(center, end, color);
-	_vm->_gfx->updateScreen();
+	_vm->_gfx->copyBackBufferToScreen(rect);
+	_vm->_system->updateScreen();
 }
 
 void MystScriptParser_Myst::towerRotationMapRotate() {

Modified: scummvm/trunk/engines/mohawk/myst_stacks/preview.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/preview.cpp	2010-12-14 13:17:27 UTC (rev 54906)
+++ scummvm/trunk/engines/mohawk/myst_stacks/preview.cpp	2010-12-14 19:11:16 UTC (rev 54907)
@@ -115,12 +115,12 @@
 	// TODO: Flash Library Red
 	// TODO: Move to run process based delay to prevent
 	//       blocking...
-	_vm->_gfx->updateScreen();
+	_vm->_system->updateScreen();
 	_vm->_system->delayMillis(20 * 1000);
 
 	for (uint16 imageId = 3001; imageId <= 3012; imageId++) {
 		_vm->_gfx->copyImageToScreen(imageId, Common::Rect(0, 0, 544, 333));
-		_vm->_gfx->updateScreen();
+		_vm->_system->updateScreen();
 		_vm->_system->delayMillis(5 * 1000);
 	}
 }

Modified: scummvm/trunk/engines/mohawk/myst_stacks/selenitic.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/selenitic.cpp	2010-12-14 13:17:27 UTC (rev 54906)
+++ scummvm/trunk/engines/mohawk/myst_stacks/selenitic.cpp	2010-12-14 19:11:16 UTC (rev 54907)
@@ -872,12 +872,12 @@
 	*value = stepped;
 
 	slider->setStep(stepped);
-	slider->drawDataToScreen();
-	_vm->_gfx->updateScreen();
+	slider->restoreBackground();
+	slider->drawConditionalDataToScreen(1);
 
 	uint16 soundId = slider->getList3(0);
 	if (soundId)
-		_vm->_sound->playSoundBlocking(soundId);
+		_vm->_sound->playSound(soundId);
 
 	_vm->_sound->stopSound();
 	_vm->_sound->resumeBackground();


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