[Scummvm-cvs-logs] SF.net SVN: scummvm:[43280] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue Aug 11 18:46:38 CEST 2009


Revision: 43280
          http://scummvm.svn.sourceforge.net/scummvm/?rev=43280&view=rev
Author:   lordhoto
Date:     2009-08-11 16:46:38 +0000 (Tue, 11 Aug 2009)

Log Message:
-----------
Enable dirty rect handling for the Amiga version again.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/screen.cpp
    scummvm/trunk/engines/kyra/screen.h

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2009-08-11 16:46:20 UTC (rev 43279)
+++ scummvm/trunk/engines/kyra/screen.cpp	2009-08-11 16:46:38 UTC (rev 43280)
@@ -206,6 +206,8 @@
 void Screen::updateScreen() {
 	if (_useOverlays)
 		updateDirtyRectsOvl();
+	else if (_isAmiga && _interfacePaletteEnabled)
+		updateDirtyRectsAmiga();
 	else
 		updateDirtyRects();
 
@@ -220,30 +222,86 @@
 }
 
 void Screen::updateDirtyRects() {
-	// TODO: Enable dirty rect handling for the AMIGA version
-	if (_forceFullUpdate || _isAmiga) {
-		if (_interfacePaletteEnabled) {
-			_system->copyRectToScreen(getCPagePtr(0), SCREEN_W, 0, 0, SCREEN_W, 136);
+	if (_forceFullUpdate) {
+		_system->copyRectToScreen(getCPagePtr(0), SCREEN_W, 0, 0, SCREEN_W, SCREEN_H);
+	} else {
+		const byte *page0 = getCPagePtr(0);
+		Common::List<Common::Rect>::iterator it;
+		for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
+			_system->copyRectToScreen(page0 + it->top * SCREEN_W + it->left, SCREEN_W, it->left, it->top, it->width(), it->height());
+		}
+	}
+	_forceFullUpdate = false;
+	_dirtyRects.clear();
+}
 
-			// Page 8 is not used by Kyra 1 AMIGA, thus we can use it to adjust the colors
-			copyRegion(0, 136, 0, 0, 320, 64, 0, 8, CR_NO_P_CHECK);
+void Screen::updateDirtyRectsAmiga() {
+	if (_forceFullUpdate) {
+		_system->copyRectToScreen(getCPagePtr(0), SCREEN_W, 0, 0, SCREEN_W, 136);
 
-			uint8 *dst = getPagePtr(8);
-			for (int y = 0; y < 64; ++y)
-				for (int x = 0; x < 320; ++x)
-					*dst++ += 32;
+		// Page 8 is not used by Kyra 1 AMIGA, thus we can use it to adjust the colors
+		copyRegion(0, 136, 0, 0, 320, 64, 0, 8, CR_NO_P_CHECK);
 
-			_system->copyRectToScreen(getCPagePtr(8), SCREEN_W, 0, 136, SCREEN_W, 64);
-		} else {
-			_system->copyRectToScreen(getCPagePtr(0), SCREEN_W, 0, 0, SCREEN_W, SCREEN_H);
-		}
+		uint8 *dst = getPagePtr(8);
+		for (int y = 0; y < 64; ++y)
+			for (int x = 0; x < 320; ++x)
+				*dst++ += 32;
+
+		_system->copyRectToScreen(getCPagePtr(8), SCREEN_W, 0, 136, SCREEN_W, 64);
 	} else {
 		const byte *page0 = getCPagePtr(0);
 		Common::List<Common::Rect>::iterator it;
+
 		for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
-			_system->copyRectToScreen(page0 + it->top * SCREEN_W + it->left, SCREEN_W, it->left, it->top, it->width(), it->height());
+			if (it->bottom <= 136) {
+				_system->copyRectToScreen(page0 + it->top * SCREEN_W + it->left, SCREEN_W, it->left, it->top, it->width(), it->height());
+			} else {
+				// Check whether the rectangle is part of both the screen and the interface
+				if (it->top < 136) {
+					// The rectangle covers both screen part and interface part
+
+					const int screenHeight = 136 - it->top;
+					const int interfaceHeight = it->bottom - 136;
+
+					const int width = it->width();
+					const int lineAdd = SCREEN_W - width;
+
+					// Copy the screen part verbatim
+					_system->copyRectToScreen(page0 + it->top * SCREEN_W + it->left, SCREEN_W, it->left, it->top, width, screenHeight);
+
+					// Adjust the interface part
+					copyRegion(it->left, 136, 0, 0, width, interfaceHeight, 0, 8, Screen::CR_NO_P_CHECK);
+
+					uint8 *dst = getPagePtr(8);
+					for (int y = 0; y < interfaceHeight; ++y) {
+						for (int x = 0; x < width; ++x)
+							*dst++ += 32;
+						dst += lineAdd;
+					}
+
+					_system->copyRectToScreen(getCPagePtr(8), SCREEN_W, it->left, 136, width, interfaceHeight);
+				} else {
+					// The rectangle only covers the interface part
+
+					const int width = it->width();
+					const int height = it->height();
+					const int lineAdd = SCREEN_W - width;
+
+					copyRegion(it->left, it->top, 0, 0, width, height, 0, 8, Screen::CR_NO_P_CHECK);
+
+					uint8 *dst = getPagePtr(8);
+					for (int y = 0; y < height; ++y) {
+						for (int x = 0; x < width; ++x)
+							*dst++ += 32;
+						dst += lineAdd;
+					}
+
+					_system->copyRectToScreen(getCPagePtr(8), SCREEN_W, it->left, it->top, width, height);
+				}
+			}
 		}
 	}
+
 	_forceFullUpdate = false;
 	_dirtyRects.clear();
 }

Modified: scummvm/trunk/engines/kyra/screen.h
===================================================================
--- scummvm/trunk/engines/kyra/screen.h	2009-08-11 16:46:20 UTC (rev 43279)
+++ scummvm/trunk/engines/kyra/screen.h	2009-08-11 16:46:38 UTC (rev 43280)
@@ -452,6 +452,7 @@
 protected:
 	uint8 *getPagePtr(int pageNum);
 	void updateDirtyRects();
+	void updateDirtyRectsAmiga();
 	void updateDirtyRectsOvl();
 
 	void scale2x(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h);


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