[Scummvm-cvs-logs] SF.net SVN: scummvm:[35274] scummvm/trunk/engines/tucker

cyx at users.sourceforge.net cyx at users.sourceforge.net
Sun Dec 7 15:22:05 CET 2008


Revision: 35274
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35274&view=rev
Author:   cyx
Date:     2008-12-07 14:22:05 +0000 (Sun, 07 Dec 2008)

Log Message:
-----------
added dirty screen rects redraw

Modified Paths:
--------------
    scummvm/trunk/engines/tucker/locations.cpp
    scummvm/trunk/engines/tucker/resource.cpp
    scummvm/trunk/engines/tucker/sequences.cpp
    scummvm/trunk/engines/tucker/tucker.cpp
    scummvm/trunk/engines/tucker/tucker.h

Modified: scummvm/trunk/engines/tucker/locations.cpp
===================================================================
--- scummvm/trunk/engines/tucker/locations.cpp	2008-12-07 13:41:00 UTC (rev 35273)
+++ scummvm/trunk/engines/tucker/locations.cpp	2008-12-07 14:22:05 UTC (rev 35274)
@@ -94,6 +94,7 @@
 			yPos = 0;
 		}
 		_locationBackgroundGfxBuf[yPos * 640 + xPos] = 100;
+		addDirtyRect(xPos, yPos, 1, 1);
 	}
 }
 
@@ -194,6 +195,7 @@
 				for (int j = 0; j < 2; ++j) {
 					const int offset = (_updateLocationYPosTable2[i] + j) * 640 + _updateLocationXPosTable2[i];
 					_locationBackgroundGfxBuf[offset] = 142 + j * 2;
+					addDirtyRect(offset % 640, offset / 640, 1, 1);
 				}
 				_updateLocationYPosTable2[i] += 2;
 				if (_updateLocationYPosTable2[i] > _updateLocationYMaxTable[i]) {
@@ -538,40 +540,42 @@
 		x2 = 15 - _flagsTable[27];
 	}
 	for (int i = 0; i < x1; ++i) {
-		execData3PreUpdate_locationNum6Helper2(_locationBackgroundGfxBuf + 13125 + i * 8, _data3GfxBuf + _dataTable[238].sourceOffset);
-		execData3PreUpdate_locationNum6Helper2(_locationBackgroundGfxBuf + 13245 - i * 8, _data3GfxBuf + _dataTable[238].sourceOffset);
+		execData3PreUpdate_locationNum6Helper2(13125 + i * 8, _data3GfxBuf + _dataTable[238].sourceOffset);
+		execData3PreUpdate_locationNum6Helper2(13245 - i * 8, _data3GfxBuf + _dataTable[238].sourceOffset);
 	}
 	for (int i = 0; i < x2; ++i) {
-		execData3PreUpdate_locationNum6Helper3(_locationBackgroundGfxBuf + 13125 + x1 * 8 + i * 4, _data3GfxBuf + _dataTable[238].sourceOffset);
-		execData3PreUpdate_locationNum6Helper3(_locationBackgroundGfxBuf + 13249 - x1 * 8 - i * 4, _data3GfxBuf + _dataTable[238].sourceOffset);
+		execData3PreUpdate_locationNum6Helper3(13125 + x1 * 8 + i * 4, _data3GfxBuf + _dataTable[238].sourceOffset);
+		execData3PreUpdate_locationNum6Helper3(13249 - x1 * 8 - i * 4, _data3GfxBuf + _dataTable[238].sourceOffset);
 	}
 }
 
-void TuckerEngine::execData3PreUpdate_locationNum6Helper2(uint8 *dst, const uint8 *src) {
+void TuckerEngine::execData3PreUpdate_locationNum6Helper2(int dstOffset, const uint8 *src) {
 	for (int j = 0; j < 46; ++j) {
-		memcpy(dst + j * 640, src + j * 8, 8);
+		memcpy(_locationBackgroundGfxBuf + dstOffset + j * 640, src + j * 8, 8);
 	}
 	for (int j = 46; j < 51; ++j) {
 		for (int i = 0; i < 8; ++i) {
-			const int offset = j * 640 + i;
-			uint8 color = dst[offset];
+			const int offset = dstOffset + j * 640 + i;
+			uint8 color = _locationBackgroundGfxBuf[offset];
 			if (color < 224) {
-				dst[offset] = src[j * 8 + i];
+				_locationBackgroundGfxBuf[offset] = src[j * 8 + i];
 			}
 		}
 	}
+	addDirtyRect(dstOffset % 640, dstOffset / 640, 8, 51);
 }
 
-void TuckerEngine::execData3PreUpdate_locationNum6Helper3(uint8 *dst, const uint8 *src) {
+void TuckerEngine::execData3PreUpdate_locationNum6Helper3(int dstOffset, const uint8 *src) {
 	for (int j = 0; j < 51; ++j) {
 		for (int i = 0; i < 4; ++i) {
-			const int offset = j * 640 + i;
-			uint8 color = dst[offset];
+			const int offset = dstOffset + j * 640 + i;
+			uint8 color = _locationBackgroundGfxBuf[offset];
 			if (color < 224) {
-				dst[offset] = src[j * 8 + i * 2];
+				_locationBackgroundGfxBuf[offset] = src[j * 8 + i * 2];
 			}
 		}
 	}
+	addDirtyRect(dstOffset % 640, dstOffset / 640, 4, 51);
 }
 
 void TuckerEngine::updateSprite_locationNum7_0(int i) {
@@ -645,16 +649,17 @@
 	}
 	if (_updateLocationYPosTable2[0] > 0) {
 		const int offset = _updateLocationYPosTable2[0] * 640 + _updateLocationXPosTable2[0];
-		_locationBackgroundGfxBuf[offset]         = 142;
-		_locationBackgroundGfxBuf[offset + 0x27F] = 143;
-		_locationBackgroundGfxBuf[offset + 0x280] = 143;
-		_locationBackgroundGfxBuf[offset + 0x281] = 144;
-		_locationBackgroundGfxBuf[offset + 0x4FF] = 144;
-		_locationBackgroundGfxBuf[offset + 0x500] = 144;
-		_locationBackgroundGfxBuf[offset + 0x501] = 145;
-		_locationBackgroundGfxBuf[offset + 0x77F] = 147;
-		_locationBackgroundGfxBuf[offset + 0x780] = 143;
-		_locationBackgroundGfxBuf[offset + 0x781] = 147;
+		_locationBackgroundGfxBuf[offset]               = 142;
+		_locationBackgroundGfxBuf[offset + 640     - 1] = 143;
+		_locationBackgroundGfxBuf[offset + 640]         = 143;
+		_locationBackgroundGfxBuf[offset + 640     + 1] = 144;
+		_locationBackgroundGfxBuf[offset + 640 * 2 - 1] = 144;
+		_locationBackgroundGfxBuf[offset + 640 * 2]     = 144;
+		_locationBackgroundGfxBuf[offset + 640 * 2 + 1] = 145;
+		_locationBackgroundGfxBuf[offset + 640 * 3 - 1] = 147;
+		_locationBackgroundGfxBuf[offset + 640 * 3]     = 143;
+		_locationBackgroundGfxBuf[offset + 640 * 3 + 1] = 147;
+		addDirtyRect(_updateLocationXPosTable2[0] - 1, _updateLocationYPosTable2[0], 3, 4);
 		_updateLocationYPosTable2[0] += 2;
 		if (_updateLocationYPosTable2[0] > 120) {
 			_updateLocationYPosTable2[0] = 0;
@@ -1005,6 +1010,7 @@
 			const int h = _dataTable[num].ySize;
 			const int dstOffset = (_updateLocationYPosTable2[i] / 16 - h / 2) * 640 + (_updateLocationXPosTable2[i] - w / 2);
 			Graphics::decodeRLE_248(_locationBackgroundGfxBuf + dstOffset, _data3GfxBuf + _dataTable[num].sourceOffset, w, h, 0, 0, false);
+			addDirtyRect(dstOffset % 640, dstOffset / 640, w, h);
 		}
 	}
 }
@@ -3020,16 +3026,16 @@
 	setCursorType(2);
 	int pos = getPositionForLine(22, _infoBarBuf);
 	int offset = (_flagsTable[143] == 0) ? 57688 : 46168;
-	drawStringAlt(_locationBackgroundGfxBuf + offset, color, &_infoBarBuf[pos]);
+	drawStringAlt(offset, color, &_infoBarBuf[pos]);
 	Graphics::drawStringChar(_locationBackgroundGfxBuf + offset + 5760, 62, 640, color, _charsetGfxBuf);
 	if (_flagsTable[143] != 0) {
 		pos = getPositionForLine(_flagsTable[143] * 2 + 23, _infoBarBuf);
-		drawStringAlt(_locationBackgroundGfxBuf + offset + 11520, color, &_infoBarBuf[pos]);
+		drawStringAlt(offset + 11520, color, &_infoBarBuf[pos]);
 		pos = getPositionForLine(_flagsTable[143] * 2 + 24, _infoBarBuf);
-		drawStringAlt(_locationBackgroundGfxBuf + offset + 17280, color, &_infoBarBuf[pos]);
+		drawStringAlt(offset + 17280, color, &_infoBarBuf[pos]);
 	}
 	execData3PreUpdate_locationNum70Helper();
-	drawStringAlt(_locationBackgroundGfxBuf + offset + 5768, color, _updateLocation70String, _updateLocation70StringLen);
+	drawStringAlt(offset + 5768, color, _updateLocation70String, _updateLocation70StringLen);
 }
 
 void TuckerEngine::execData3PreUpdate_locationNum70Helper() {

Modified: scummvm/trunk/engines/tucker/resource.cpp
===================================================================
--- scummvm/trunk/engines/tucker/resource.cpp	2008-12-07 13:41:00 UTC (rev 35273)
+++ scummvm/trunk/engines/tucker/resource.cpp	2008-12-07 14:22:05 UTC (rev 35274)
@@ -445,6 +445,7 @@
 		copyLocBitmap(0, 0);
 		Graphics::copyFrom640(_locationBackgroundGfxBuf + 320, _quadBackgroundGfxBuf + 134400, 320, 140);
 	}
+	_fullRedrawCounter = 2;
 }
 
 void TuckerEngine::loadObj() {

Modified: scummvm/trunk/engines/tucker/sequences.cpp
===================================================================
--- scummvm/trunk/engines/tucker/sequences.cpp	2008-12-07 13:41:00 UTC (rev 35273)
+++ scummvm/trunk/engines/tucker/sequences.cpp	2008-12-07 14:22:05 UTC (rev 35274)
@@ -86,12 +86,12 @@
 			Graphics::copyTo640(_locationBackgroundGfxBuf, _quadBackgroundGfxBuf, 320, 320, 200);
 		} else {
 			Graphics::copyTo640(_locationBackgroundGfxBuf, imgBuf + imgNum * 64000, 320, 320, 200);
-			drawString2(5, 48, counter2 * 6);
-			drawString2(5, 60, counter2 * 6 + 1);
-			drawString2(5, 80, counter2 * 6 + 2);
-			drawString2(5, 92, counter2 * 6 + 3);
-			drawString2(5, 140, counter2 * 6 + 4);
-			drawString2(5, 116, counter2 * 6 + 5);
+			drawCreditsString(5, 48, counter2 * 6);
+			drawCreditsString(5, 60, counter2 * 6 + 1);
+			drawCreditsString(5, 80, counter2 * 6 + 2);
+			drawCreditsString(5, 92, counter2 * 6 + 3);
+			drawCreditsString(5, 140, counter2 * 6 + 4);
+			drawCreditsString(5, 116, counter2 * 6 + 5);
 			++counter1;
 			if (counter1 < 20) {
 				fadePaletteColor(191, kFadePaletteStep);
@@ -106,6 +106,7 @@
 				counter2 = 0;
 			}
 		}
+		_fullRedrawCounter = 2;
 		++counter3;
 		if (counter3 == 2) {
 			counter3 = 0;
@@ -114,7 +115,7 @@
 		for (int i = 0; i < _spritesCount; ++i) {
 			drawSprite(i);
 		}
-		copyToVGA(_locationBackgroundGfxBuf);
+		redrawScreen(0);
 		waitForTimer(3);
 		_timerCounter1 = 0;
 		counter4 = _timerCounter2 / 3;
@@ -163,7 +164,7 @@
 			fadeInPalette();
 			--_fadePaletteCounter;
 		}
-		copyToVGA(_locationBackgroundGfxBuf);
+		redrawScreen(0);
 		waitForTimer(2);
 	} while (_fadePaletteCounter > 0);
 }
@@ -175,7 +176,8 @@
 	strcpy(_fileToLoad, "congrat.pcx");
 	loadImage(_loadTempBuf, 1);
 	Graphics::copyTo640(_locationBackgroundGfxBuf, _loadTempBuf, 320, 320, 200);
-	copyToVGA(_locationBackgroundGfxBuf);
+	_fullRedrawCounter = 2;
+	redrawScreen(0);
 	while (!_quitGame && _timerCounter2 < 450) {
 		while (_fadePaletteCounter < 14) {
 			++_fadePaletteCounter;
@@ -242,9 +244,10 @@
 			++_fadePaletteCounter;
 		}
 		Graphics::copyTo640(_locationBackgroundGfxBuf, _quadBackgroundGfxBuf, 320, 320, 200);
+		_fullRedrawCounter = 2;
 		updateSprites();
 		drawSprite(0);
-		copyToVGA(_locationBackgroundGfxBuf);
+		redrawScreen(0);
 		waitForTimer(3);
 		if (_inputKeys[kInputKeyEscape]) {
 			_inputKeys[kInputKeyEscape] = false;
@@ -258,9 +261,10 @@
 			--_fadePaletteCounter;
 		}
 		Graphics::copyTo640(_locationBackgroundGfxBuf, _quadBackgroundGfxBuf, 320, 320, 200);
+		_fullRedrawCounter = 2;
 		updateSprites();
 		drawSprite(0);
-		copyToVGA(_locationBackgroundGfxBuf);
+		redrawScreen(0);
 		waitForTimer(3);
 	} while (_fadePaletteCounter > 0);
 	_locationNum = currentLocation;
@@ -291,7 +295,8 @@
 			++_fadePaletteCounter;
 		}
 		Graphics::copyTo640(_locationBackgroundGfxBuf, _quadBackgroundGfxBuf + 89600, 320, 320, 200);
-		copyToVGA(_locationBackgroundGfxBuf);
+		_fullRedrawCounter = 2;
+		redrawScreen(0);
 		waitForTimer(3);
 		++i;
 	}
@@ -301,7 +306,8 @@
 			--_fadePaletteCounter;
 		}
 		Graphics::copyTo640(_locationBackgroundGfxBuf, _quadBackgroundGfxBuf + 89600, 320, 320, 200);
-		copyToVGA(_locationBackgroundGfxBuf);
+		_fullRedrawCounter = 2;
+		redrawScreen(0);
 		waitForTimer(3);
 	} while (_fadePaletteCounter > 0);
 	memcpy(_currentPalette, backupPalette, 256 * 3);
@@ -334,6 +340,7 @@
 		waitForTimer(2);
 		updateMouseState();
 		Graphics::copyTo640(_locationBackgroundGfxBuf + _scrollOffset, _quadBackgroundGfxBuf + 89600, 320, 320, 200);
+		_fullRedrawCounter = 2;
 		if (_flagsTable[7] > 0 && _mousePosX > 30 && _mousePosX < 86 && _mousePosY > 36 && _mousePosY < 86) {
 			textNum = 13;
 			_nextLocationNum = (_partNum == 1) ? 3 : 65;
@@ -385,7 +392,7 @@
 		if (textNum > 0) {
 			drawSpeechText(_scrollOffset + _mousePosX + 8, _mousePosY - 10, _infoBarBuf, textNum, 96);
 		}
-		copyToVGA(_locationBackgroundGfxBuf + _scrollOffset);
+		redrawScreen(_scrollOffset);
 		if (_fadePaletteCounter < 14) {
 			fadeOutPalette();
 			++_fadePaletteCounter;
@@ -396,7 +403,7 @@
 	}
 	while (_fadePaletteCounter > 0) {
 		fadeInPalette();
-		copyToVGA(_locationBackgroundGfxBuf + _scrollOffset);
+		redrawScreen(_scrollOffset);
 		--_fadePaletteCounter;
 	}
 	_mouseClick = 1;
@@ -444,7 +451,7 @@
 	}
 	while (_fadePaletteCounter > 0) {
 		fadeInPalette();
-		copyToVGA(_locationBackgroundGfxBuf + _scrollOffset);
+		redrawScreen(_scrollOffset);
 		--_fadePaletteCounter;
 	}
 	_mouseClick = 1;
@@ -454,6 +461,7 @@
 		waitForTimer(2);
 		updateMouseState();
 		Graphics::copyTo640(_locationBackgroundGfxBuf + _scrollOffset, _quadBackgroundGfxBuf, 320, 320, 200);
+		_fullRedrawCounter = 2;
 		if (_fadePaletteCounter < 14) {
 			fadeOutPalette();
 			++_fadePaletteCounter;
@@ -470,11 +478,11 @@
 				}
 			}
 		}
-		copyToVGA(_locationBackgroundGfxBuf + _scrollOffset);
+		redrawScreen(_scrollOffset);
 		if (_leftMouseButtonPressed && _mouseClick != 1) {
 			while (_fadePaletteCounter > 0) {
 				fadeInPalette();
-				copyToVGA(_locationBackgroundGfxBuf + _scrollOffset);
+				redrawScreen(_scrollOffset);
 				--_fadePaletteCounter;
 			}
 			_mouseClick = 1;

Modified: scummvm/trunk/engines/tucker/tucker.cpp
===================================================================
--- scummvm/trunk/engines/tucker/tucker.cpp	2008-12-07 13:41:00 UTC (rev 35273)
+++ scummvm/trunk/engines/tucker/tucker.cpp	2008-12-07 14:22:05 UTC (rev 35274)
@@ -303,6 +303,8 @@
 	_currentGfxBackground = 0;
 	_fadePaletteCounter = 0;
 	memset(&_currentPalette, 0, sizeof(_currentPalette));
+	_fullRedrawCounter = 0;
+	_dirtyRectsPrevCount = _dirtyRectsCount = 0;
 
 	_updateLocationFadePaletteCounter = 0;
 	_updateLocationCounter = 10;
@@ -480,8 +482,12 @@
 		if (_syncCounter != 0) {
 			continue;
 		}
-		Graphics::copyTo640(_locationBackgroundGfxBuf + _scrollOffset, _currentGfxBackground + _scrollOffset, 320 - _scrollOffset, 320, _locationHeight);
-		Graphics::copyTo640(_locationBackgroundGfxBuf + 320, _currentGfxBackground + 44800, _scrollOffset, 320, _locationHeight);
+		if (_scrollOffset < 320) {
+			Graphics::copyTo640(_locationBackgroundGfxBuf + _scrollOffset, _currentGfxBackground + _scrollOffset, 320 - _scrollOffset, 320, _locationHeight);
+		}
+		if (_scrollOffset > 0) {
+			Graphics::copyTo640(_locationBackgroundGfxBuf + 320, _currentGfxBackground + 44800, _scrollOffset, 320, _locationHeight);
+		}
 		drawData3();
 		execData3PreUpdate();
 		for (int i = 0; i < _spritesCount; ++i) {
@@ -511,7 +517,7 @@
 			setSoundVolumeDistance();
 		}
 		updateCharSpeechSound();
-		copyToVGA(_locationBackgroundGfxBuf + _scrollOffset);
+		redrawScreen(_scrollOffset);
 		startCharacterSounds();
 		for (int num = 0; num < 2; ++num) {
 			if (_miscSoundFxDelayCounter[num] > 0) {
@@ -1384,7 +1390,7 @@
 
 void TuckerEngine::redrawPanelOverBackground() {
 	const uint8 *src = _itemsGfxBuf;
-	uint8 *dst = _locationBackgroundGfxBuf + 89600 + _scrollOffset;
+	uint8 *dst = _locationBackgroundGfxBuf + 640 * 140 + _scrollOffset;
 	for (int y = 0; y < 10; ++y) {
 		memcpy(dst, src, 320);
 		src += 320;
@@ -1411,6 +1417,7 @@
 	if (_conversationOptionsCount > 0) {
 		drawConversationTexts();
 	}
+	addDirtyRect(0, 140, 320, 60);
 }
 
 void TuckerEngine::drawConversationTexts() {
@@ -1435,6 +1442,7 @@
 }
 
 void TuckerEngine::updateScreenScrolling() {
+	int scrollPrevOffset = _scrollOffset;
 	if (_locationWidthTable[_locationNum] != 2) {
 		_scrollOffset = 0;
 	} else if (_validInstructionId == 1) {
@@ -1455,6 +1463,9 @@
 			_scrollOffset = 320;
 		}
 	}
+	if (scrollPrevOffset != _scrollOffset) {
+		_fullRedrawCounter = 2;
+	}
 }
 
 void TuckerEngine::updateGameHints() {
@@ -1523,9 +1534,10 @@
 void TuckerEngine::drawData3() {
 	for (int i = 0; i < _locationAnimationsCount; ++i) {
 		int num = _locationAnimationsTable[i].graphicNum;
-		const int offset = _dataTable[num].yDest * 640 + _dataTable[num].xDest;
+		const Data *d = &_dataTable[num];
 		if (_locationAnimationsTable[i].drawFlag != 0) {
-			Graphics::decodeRLE(_locationBackgroundGfxBuf + offset, _data3GfxBuf + _dataTable[num].sourceOffset, _dataTable[num].xSize, _dataTable[num].ySize);
+			Graphics::decodeRLE(_locationBackgroundGfxBuf + d->yDest * 640 + d->xDest, _data3GfxBuf + d->sourceOffset, d->xSize, d->ySize);
+			addDirtyRect(d->xDest, d->yDest, d->xSize, d->ySize);
 		}
 	}
 }
@@ -1688,6 +1700,7 @@
 		}
 		int offset = _backgroundSprOffset + srcY * 640 + srcX;
 		Graphics::decodeRLE_248(_locationBackgroundGfxBuf + offset, _backgroundSpriteDataPtr + frameOffset + 12, srcW, srcH, 0, _locationHeightTable[_locationNum], false);
+		addDirtyRect(offset % 640, offset / 640, srcW, srcH);
 	}
 }
 
@@ -1701,6 +1714,7 @@
 	}
 	Graphics::decodeRLE_248(_locationBackgroundGfxBuf + offset, _spritesGfxBuf + chr->sourceOffset, chr->xSize, chr->ySize,
 		chr->yOffset, _locationHeightTable[_locationNum], _mirroredDrawing != 0);
+	addDirtyRect(offset % 640, offset / 640, chr->xSize, chr->ySize);
 	if (_currentSpriteAnimationLength > 1) {
 		SpriteFrame *chr2 = &_spriteFramesTable[_currentSpriteAnimationFrame2];
 		offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr2->yOffset) * 640 + _xPosCurrent;
@@ -1711,6 +1725,7 @@
 		}
 		Graphics::decodeRLE_248(_locationBackgroundGfxBuf + offset, _spritesGfxBuf + chr2->sourceOffset, chr2->xSize, chr2->ySize,
 			chr2->yOffset, _locationHeightTable[_locationNum], _mirroredDrawing != 0);
+		addDirtyRect(offset % 640, offset / 640, chr2->xSize, chr2->ySize);
 	}
 }
 
@@ -1853,6 +1868,7 @@
 			Graphics::decodeRLE_248(dstPtr, srcPtr, srcW, srcH, 0, s->yMaxBackground, s->flipX != 0);
 			break;
 		}
+		addDirtyRect(dstOffset % 640, dstOffset / 640 + srcY, srcW, srcH);
 	}
 }
 
@@ -1863,7 +1879,7 @@
 void TuckerEngine::drawPausedInfoBar() {
 	int len = getStringWidth(36, _infoBarBuf);
 	int x = 159 - len / 2;
-	drawString(_itemsGfxBuf + 326 + x, 36, _infoBarBuf);
+	drawItemString(326 + x, 36, _infoBarBuf);
 }
 
 const uint8 *TuckerEngine::getStringBuf(int type) const {
@@ -1917,15 +1933,15 @@
 	}
 	const int xPos = 159 - infoStringWidth / 2;
 	if (verbPreposition == 0 || (_actionObj2Num == 0 && _actionObj2Type == 0)) {
-		drawString(_itemsGfxBuf + xPos, _actionVerb + 1, infoStrBuf);
+		drawItemString(xPos, _actionVerb + 1, infoStrBuf);
 		if (_actionObj1Num > 0 || _actionObj1Type > 0) {
-			drawString(_itemsGfxBuf + xPos + 4 + verbWidth, _actionObj1Num + 1, obj1StrBuf);
+			drawItemString(xPos + 4 + verbWidth, _actionObj1Num + 1, obj1StrBuf);
 		}
 	}
 	if (verbPreposition > 0) {
-		drawString(_itemsGfxBuf + xPos + 4 + verbWidth + object1NameWidth, verbPreposition, infoStrBuf);
+		drawItemString(xPos + 4 + verbWidth + object1NameWidth, verbPreposition, infoStrBuf);
 		if (_actionObj2Num > 0 || _actionObj2Type > 0) {
-			drawString(_itemsGfxBuf + xPos + 4 + verbWidth + object1NameWidth + verbPrepositionWidth, _actionObj2Num + 1, obj2StrBuf);
+			drawItemString(xPos + 4 + verbWidth + object1NameWidth + verbPrepositionWidth, _actionObj2Num + 1, obj2StrBuf);
 		}
 	}
 }
@@ -1933,7 +1949,7 @@
 void TuckerEngine::drawGameHintString() {
 	const int len = getStringWidth(_gameHintsStringNum + 29, _infoBarBuf);
 	const int x = 159 - len / 2;
-	drawString(_itemsGfxBuf + 326 + x, _gameHintsStringNum + 29, _infoBarBuf);
+	drawItemString(326 + x, _gameHintsStringNum + 29, _infoBarBuf);
 }
 
 void TuckerEngine::updateCharacterAnimation() {
@@ -2314,7 +2330,7 @@
 			}
 			for (int i = 0; i < 14; ++i) {
 				fadeInPalette();
-				copyToVGA(_locationBackgroundGfxBuf + _scrollOffset);
+				redrawScreen(_scrollOffset);
 				_fadePaletteCounter = 34;
 			}
 			_nextLocationNum = _selectedObject.locationObject_locationNum;
@@ -2819,29 +2835,32 @@
 		Graphics::drawStringChar(_locationBackgroundGfxBuf + offset, numStr[i], 640, 102, _charsetGfxBuf);
 		offset += 8;
 	}
+	addDirtyRect(x, y, Graphics::_charset.charW * 3, Graphics::_charset.charH);
 }
 
-void TuckerEngine::drawStringAlt(uint8 *dst, int color, const uint8 *str, int strLen) {
+void TuckerEngine::drawStringAlt(int offset, int color, const uint8 *str, int strLen) {
+	int startOffset = offset;
 	int pos = 0;
 	while (pos != strLen && str[pos] != '\n') {
 		const uint8 chr = str[pos];
-		Graphics::drawStringChar(dst, chr, 640, color, _charsetGfxBuf);
-		dst += _charWidthTable[chr];
+		Graphics::drawStringChar(_locationBackgroundGfxBuf + offset, chr, 640, color, _charsetGfxBuf);
+		offset += _charWidthTable[chr];
 		++pos;
 	}
+	addDirtyRect(startOffset % 640, startOffset / 640, (offset - startOffset) % 640, Graphics::_charset.charH);
 }
 
-void TuckerEngine::drawString(uint8 *dst, int num, const uint8 *str) {
+void TuckerEngine::drawItemString(int offset, int num, const uint8 *str) {
 	int count = getPositionForLine(num, str);
 	while (str[count] != '\n') {
 		const uint8 chr = str[count];
-		Graphics::drawStringChar(dst, chr, 320, 1, _charsetGfxBuf);
-		dst += _charWidthTable[chr];
+		Graphics::drawStringChar(_itemsGfxBuf + offset, chr, 320, 1, _charsetGfxBuf);
+		offset += _charWidthTable[chr];
 		++count;
 	}
 }
 
-void TuckerEngine::drawString2(int x, int y, int num) {
+void TuckerEngine::drawCreditsString(int x, int y, int num) {
 	uint8 *dst = _locationBackgroundGfxBuf + y * 640 + x;
 	int pos = getPositionForLine(num, _ptTextBuf);
 	while (_ptTextBuf[pos] != '\n') {
@@ -2925,11 +2944,6 @@
 	return i;
 }
 
-void TuckerEngine::copyToVGA(const uint8 *src) {
-	_system->copyRectToScreen(src, 640, 0, 0, 320, 200);
-	_system->updateScreen();
-}
-
 void TuckerEngine::findActionKey(int count) {
 	_backgroundSpriteCurrentFrame = 0;
 	_characterAnimationIndex = 0;
@@ -3754,15 +3768,14 @@
 		} else if (dstOffset > _scrollOffset + 320 - lines[i].w) {
 			dstOffset = _scrollOffset + 320 - lines[i].w;
 		}
-		uint8 *dst;
-		if (_conversationOptionsCount) {
+		if (_conversationOptionsCount != 0) {
 			dstOffset = xStart + _scrollOffset;
-			dst = (i * 10 + y) * 640 + _locationBackgroundGfxBuf + dstOffset;
+			dstOffset += (i * 10 + y) * 640;
 			_panelItemWidth = count;
 		} else {
-			dst = (y - (count - i) * 10) * 640 + _locationBackgroundGfxBuf + dstOffset;
+			dstOffset += (y - (count - i) * 10) * 640;
 		}
-		drawSpeechTextLine(dataPtr, lines[i].offset, lines[i].count, dst, color);
+		drawSpeechTextLine(dataPtr, lines[i].offset, lines[i].count, dstOffset, color);
 	}
 }
 
@@ -3789,13 +3802,60 @@
 	return ret;
 }
 
-void TuckerEngine::drawSpeechTextLine(const uint8 *dataPtr, int pos, int count, uint8 *dst, uint8 color) {
+void TuckerEngine::drawSpeechTextLine(const uint8 *dataPtr, int pos, int count, int dstOffset, uint8 color) {
+	int startOffset = dstOffset;
 	while (count > 0 && dataPtr[pos] != '\n') {
-		Graphics::drawStringChar(dst, dataPtr[pos], 640, color, _charsetGfxBuf);
-		dst += _charWidthTable[dataPtr[pos]];
+		Graphics::drawStringChar(_locationBackgroundGfxBuf + dstOffset, dataPtr[pos], 640, color, _charsetGfxBuf);
+		dstOffset += _charWidthTable[dataPtr[pos]];
 		++pos;
 		--count;
 	}
+	addDirtyRect(startOffset % 640, startOffset / 640, (dstOffset - startOffset) % 640, Graphics::_charset.charH);
 }
 
+void TuckerEngine::redrawScreen(int offset) {
+	debug(3, "redrawScreen() _fullRedrawCounter %d offset %d _dirtyRectsCount %d", _fullRedrawCounter, offset, _dirtyRectsCount);
+	assert(offset <= kScreenWidth);
+	if (_fullRedrawCounter > 0) {
+		--_fullRedrawCounter;
+		_system->copyRectToScreen(_locationBackgroundGfxBuf + offset, kScreenPitch, 0, 0, kScreenWidth, kScreenHeight);
+	} else {
+		const int xClip = offset % kScreenPitch;
+		const int yClip = offset / kScreenPitch;
+		Common::Rect clipRect(xClip, yClip, xClip + kScreenWidth, yClip + kScreenHeight);
+		for (int i = 0; i < _dirtyRectsPrevCount; ++i) {
+			redrawScreenRect(clipRect, _dirtyRectsTable[1][i]);
+		}
+		for (int i = 0; i < _dirtyRectsCount; ++i) {
+			redrawScreenRect(clipRect, _dirtyRectsTable[0][i]);
+		}
+		_dirtyRectsPrevCount = _dirtyRectsCount;
+		for (int i = 0; i < _dirtyRectsCount; ++i) {
+			_dirtyRectsTable[1][i] = _dirtyRectsTable[0][i];
+		}
+	}
+	_dirtyRectsCount = 0;
+	_system->updateScreen();
+}
+
+void TuckerEngine::redrawScreenRect(const Common::Rect &clip, const Common::Rect &dirty) {
+	if (dirty.intersects(clip)) {
+		Common::Rect r(dirty);
+		r.clip(clip);
+		const uint8 *src = _locationBackgroundGfxBuf + r.top * 640 + r.left;
+		r.translate(-clip.left, -clip.top);
+		_system->copyRectToScreen(src, 640, r.left, r.top, r.right - r.left, r.bottom - r.top);
+	}
+}
+
+void TuckerEngine::addDirtyRect(int x, int y, int w, int h) {
+	if (_dirtyRectsCount >= kMaxDirtyRects) {
+		_fullRedrawCounter = 2;
+		_dirtyRectsCount = 0;
+	} else {
+		_dirtyRectsTable[0][_dirtyRectsCount] = Common::Rect(x, y, x + w, y + h);
+		++_dirtyRectsCount;
+	}
+}
+
 } // namespace Tucker

Modified: scummvm/trunk/engines/tucker/tucker.h
===================================================================
--- scummvm/trunk/engines/tucker/tucker.h	2008-12-07 13:41:00 UTC (rev 35273)
+++ scummvm/trunk/engines/tucker/tucker.h	2008-12-07 14:22:05 UTC (rev 35274)
@@ -173,6 +173,7 @@
 enum {
 	kScreenWidth = 320,
 	kScreenHeight = 200,
+	kScreenPitch = 640,
 	kFadePaletteStep = 5,
 	kStartupLocation = 1,
 	kDefaultCharSpeechSoundCounter = 1,
@@ -224,7 +225,8 @@
 		kSprC02TableSize = 40,
 		kDataTableSize = 500,
 		kSpeechHistoryTableSize = 5,
-		kMaxCharacters = 8
+		kMaxCharacters = 8,
+		kMaxDirtyRects = 16
 	};
 
 	TuckerEngine(OSystem *system, Common::Language language, bool isDemo);
@@ -305,15 +307,14 @@
 	void updateSprites();
 	void updateSprite(int i);
 	void drawStringInteger(int num, int x, int y, int digits);
-	void drawStringAlt(uint8 *dst, int color, const uint8 *str, int strLen = -1);
-	void drawString(uint8 *dst, int num, const uint8 *str);
-	void drawString2(int x, int y, int num);
+	void drawStringAlt(int offset, int color, const uint8 *str, int strLen = -1);
+	void drawItemString(int offset, int num, const uint8 *str);
+	void drawCreditsString(int x, int y, int num);
 	void updateCharSpeechSound();
 	void updateItemsGfxColors(int bit0, int bit7);
 	int testLocationMask(int x, int y);
 	int getStringWidth(int num, const uint8 *ptr);
 	int getPositionForLine(int num, const uint8 *ptr);
-	void copyToVGA(const uint8 *src);
 	void findActionKey(int count);
 	int parseTableInstruction();
 	void moveUpInventoryObjects();
@@ -331,7 +332,10 @@
 	void playSpeechForAction(int i);
 	void drawSpeechText(int xStart, int y, const uint8 *dataPtr, int num, int color);
 	int splitSpeechTextLines(const uint8 *dataPtr, int pos, int x, int &lineCharsCount, int &lineWidth);
-	void drawSpeechTextLine(const uint8 *dataPtr, int pos, int count, uint8 *dst, uint8 color);
+	void drawSpeechTextLine(const uint8 *dataPtr, int pos, int count, int dstOffset, uint8 color);
+	void redrawScreen(int offset);
+	void redrawScreenRect(const Common::Rect &clip, const Common::Rect &dirty);
+	void addDirtyRect(int x, int y, int w, int h);
 
 	void execData3PreUpdate_locationNum1();
 	void execData3PreUpdate_locationNum1Helper1();
@@ -354,8 +358,8 @@
 	void updateSprite_locationNum6_2(int i);
 	void execData3PreUpdate_locationNum6();
 	void execData3PreUpdate_locationNum6Helper1();
-	void execData3PreUpdate_locationNum6Helper2(uint8 *dst, const uint8 *src);
-	void execData3PreUpdate_locationNum6Helper3(uint8 *dst, const uint8 *src);
+	void execData3PreUpdate_locationNum6Helper2(int dstOffset, const uint8 *src);
+	void execData3PreUpdate_locationNum6Helper3(int dstOffset, const uint8 *src);
 	void updateSprite_locationNum7_0(int i);
 	void updateSprite_locationNum7_1(int i);
 	void updateSprite_locationNum8_0(int i);
@@ -792,6 +796,9 @@
 	uint8 *_currentGfxBackground;
 	int _fadePaletteCounter;
 	uint8 _currentPalette[768];
+	int _fullRedrawCounter;
+	int _dirtyRectsPrevCount, _dirtyRectsCount;
+	Common::Rect _dirtyRectsTable[2][kMaxDirtyRects];
 
 	int _updateLocationFadePaletteCounter;
 	int _updateLocationCounter;


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