diff options
author | Gregory Montoir | 2008-12-07 14:22:05 +0000 |
---|---|---|
committer | Gregory Montoir | 2008-12-07 14:22:05 +0000 |
commit | c3fa73a0101df27c2d118d0494b42483461476dc (patch) | |
tree | d04917a724c42c91b1dbfe2d3dda542ca283bd48 /engines/tucker | |
parent | 62d2955d9b6457f007f203424bbdd43ddcec8aff (diff) | |
download | scummvm-rg350-c3fa73a0101df27c2d118d0494b42483461476dc.tar.gz scummvm-rg350-c3fa73a0101df27c2d118d0494b42483461476dc.tar.bz2 scummvm-rg350-c3fa73a0101df27c2d118d0494b42483461476dc.zip |
added dirty screen rects redraw
svn-id: r35274
Diffstat (limited to 'engines/tucker')
-rw-r--r-- | engines/tucker/locations.cpp | 60 | ||||
-rw-r--r-- | engines/tucker/resource.cpp | 1 | ||||
-rw-r--r-- | engines/tucker/sequences.cpp | 44 | ||||
-rw-r--r-- | engines/tucker/tucker.cpp | 126 | ||||
-rw-r--r-- | engines/tucker/tucker.h | 23 |
5 files changed, 168 insertions, 86 deletions
diff --git a/engines/tucker/locations.cpp b/engines/tucker/locations.cpp index 988f0da9a3..b0bd3f1f48 100644 --- a/engines/tucker/locations.cpp +++ b/engines/tucker/locations.cpp @@ -94,6 +94,7 @@ void TuckerEngine::execData3PreUpdate_locationNum1Helper2() { yPos = 0; } _locationBackgroundGfxBuf[yPos * 640 + xPos] = 100; + addDirtyRect(xPos, yPos, 1, 1); } } @@ -194,6 +195,7 @@ void TuckerEngine::execData3PreUpdate_locationNum2() { 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 @@ void TuckerEngine::execData3PreUpdate_locationNum6Helper1() { 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 @@ void TuckerEngine::execData3PostUpdate_locationNum8() { } 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 @@ void TuckerEngine::execData3PreUpdate_locationNum14() { 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 @@ void TuckerEngine::execData3PreUpdate_locationNum70() { 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() { diff --git a/engines/tucker/resource.cpp b/engines/tucker/resource.cpp index 74e5f6d286..f816ee3d2c 100644 --- a/engines/tucker/resource.cpp +++ b/engines/tucker/resource.cpp @@ -445,6 +445,7 @@ void TuckerEngine::loadLoc() { copyLocBitmap(0, 0); Graphics::copyFrom640(_locationBackgroundGfxBuf + 320, _quadBackgroundGfxBuf + 134400, 320, 140); } + _fullRedrawCounter = 2; } void TuckerEngine::loadObj() { diff --git a/engines/tucker/sequences.cpp b/engines/tucker/sequences.cpp index 0ef0bab018..67a0d82775 100644 --- a/engines/tucker/sequences.cpp +++ b/engines/tucker/sequences.cpp @@ -86,12 +86,12 @@ void TuckerEngine::handleCreditsSequence() { 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 @@ void TuckerEngine::handleCreditsSequence() { counter2 = 0; } } + _fullRedrawCounter = 2; ++counter3; if (counter3 == 2) { counter3 = 0; @@ -114,7 +115,7 @@ void TuckerEngine::handleCreditsSequence() { for (int i = 0; i < _spritesCount; ++i) { drawSprite(i); } - copyToVGA(_locationBackgroundGfxBuf); + redrawScreen(0); waitForTimer(3); _timerCounter1 = 0; counter4 = _timerCounter2 / 3; @@ -163,7 +164,7 @@ void TuckerEngine::handleCreditsSequence() { fadeInPalette(); --_fadePaletteCounter; } - copyToVGA(_locationBackgroundGfxBuf); + redrawScreen(0); waitForTimer(2); } while (_fadePaletteCounter > 0); } @@ -175,7 +176,8 @@ void TuckerEngine::handleCongratulationsSequence() { 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 @@ void TuckerEngine::handleNewPartSequence() { ++_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 @@ void TuckerEngine::handleNewPartSequence() { --_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 @@ void TuckerEngine::handleMeanwhileSequence() { ++_fadePaletteCounter; } Graphics::copyTo640(_locationBackgroundGfxBuf, _quadBackgroundGfxBuf + 89600, 320, 320, 200); - copyToVGA(_locationBackgroundGfxBuf); + _fullRedrawCounter = 2; + redrawScreen(0); waitForTimer(3); ++i; } @@ -301,7 +306,8 @@ void TuckerEngine::handleMeanwhileSequence() { --_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 @@ void TuckerEngine::handleMapSequence() { 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 @@ void TuckerEngine::handleMapSequence() { 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 @@ void TuckerEngine::handleMapSequence() { } while (_fadePaletteCounter > 0) { fadeInPalette(); - copyToVGA(_locationBackgroundGfxBuf + _scrollOffset); + redrawScreen(_scrollOffset); --_fadePaletteCounter; } _mouseClick = 1; @@ -444,7 +451,7 @@ int TuckerEngine::handleSpecialObjectSelectionSequence() { } while (_fadePaletteCounter > 0) { fadeInPalette(); - copyToVGA(_locationBackgroundGfxBuf + _scrollOffset); + redrawScreen(_scrollOffset); --_fadePaletteCounter; } _mouseClick = 1; @@ -454,6 +461,7 @@ int TuckerEngine::handleSpecialObjectSelectionSequence() { waitForTimer(2); updateMouseState(); Graphics::copyTo640(_locationBackgroundGfxBuf + _scrollOffset, _quadBackgroundGfxBuf, 320, 320, 200); + _fullRedrawCounter = 2; if (_fadePaletteCounter < 14) { fadeOutPalette(); ++_fadePaletteCounter; @@ -470,11 +478,11 @@ int TuckerEngine::handleSpecialObjectSelectionSequence() { } } } - copyToVGA(_locationBackgroundGfxBuf + _scrollOffset); + redrawScreen(_scrollOffset); if (_leftMouseButtonPressed && _mouseClick != 1) { while (_fadePaletteCounter > 0) { fadeInPalette(); - copyToVGA(_locationBackgroundGfxBuf + _scrollOffset); + redrawScreen(_scrollOffset); --_fadePaletteCounter; } _mouseClick = 1; diff --git a/engines/tucker/tucker.cpp b/engines/tucker/tucker.cpp index 097ffdf158..5c65d83d1a 100644 --- a/engines/tucker/tucker.cpp +++ b/engines/tucker/tucker.cpp @@ -303,6 +303,8 @@ void TuckerEngine::restart() { _currentGfxBackground = 0; _fadePaletteCounter = 0; memset(&_currentPalette, 0, sizeof(_currentPalette)); + _fullRedrawCounter = 0; + _dirtyRectsPrevCount = _dirtyRectsCount = 0; _updateLocationFadePaletteCounter = 0; _updateLocationCounter = 10; @@ -480,8 +482,12 @@ void TuckerEngine::mainLoop() { 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 @@ void TuckerEngine::mainLoop() { 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::switchPanelType() { 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 @@ void TuckerEngine::redrawPanelOverBackground() { if (_conversationOptionsCount > 0) { drawConversationTexts(); } + addDirtyRect(0, 140, 320, 60); } void TuckerEngine::drawConversationTexts() { @@ -1435,6 +1442,7 @@ void TuckerEngine::drawConversationTexts() { } void TuckerEngine::updateScreenScrolling() { + int scrollPrevOffset = _scrollOffset; if (_locationWidthTable[_locationNum] != 2) { _scrollOffset = 0; } else if (_validInstructionId == 1) { @@ -1455,6 +1463,9 @@ void TuckerEngine::updateScreenScrolling() { _scrollOffset = 320; } } + if (scrollPrevOffset != _scrollOffset) { + _fullRedrawCounter = 2; + } } void TuckerEngine::updateGameHints() { @@ -1523,9 +1534,10 @@ void TuckerEngine::updateSoundsTypes3_4() { 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 @@ void TuckerEngine::drawBackgroundSprites() { } 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 @@ void TuckerEngine::drawCurrentSprite() { } 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 @@ void TuckerEngine::drawCurrentSprite() { } 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 @@ void TuckerEngine::drawSprite(int num) { 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::clearItemsGfx() { 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 @@ void TuckerEngine::drawInfoString() { } 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::drawInfoString() { 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 @@ void TuckerEngine::handleMap() { } for (int i = 0; i < 14; ++i) { fadeInPalette(); - copyToVGA(_locationBackgroundGfxBuf + _scrollOffset); + redrawScreen(_scrollOffset); _fadePaletteCounter = 34; } _nextLocationNum = _selectedObject.locationObject_locationNum; @@ -2819,29 +2835,32 @@ void TuckerEngine::drawStringInteger(int num, int x, int y, int digits) { 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 @@ int TuckerEngine::getPositionForLine(int num, const uint8 *ptr) { 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 @@ void TuckerEngine::drawSpeechText(int xStart, int y, const uint8 *dataPtr, int n } 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 @@ int TuckerEngine::splitSpeechTextLines(const uint8 *dataPtr, int pos, int x, int 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 diff --git a/engines/tucker/tucker.h b/engines/tucker/tucker.h index 67084c9dd3..8d759de237 100644 --- a/engines/tucker/tucker.h +++ b/engines/tucker/tucker.h @@ -173,6 +173,7 @@ struct LocationMusic { enum { kScreenWidth = 320, kScreenHeight = 200, + kScreenPitch = 640, kFadePaletteStep = 5, kStartupLocation = 1, kDefaultCharSpeechSoundCounter = 1, @@ -224,7 +225,8 @@ public: kSprC02TableSize = 40, kDataTableSize = 500, kSpeechHistoryTableSize = 5, - kMaxCharacters = 8 + kMaxCharacters = 8, + kMaxDirtyRects = 16 }; TuckerEngine(OSystem *system, Common::Language language, bool isDemo); @@ -305,15 +307,14 @@ protected: 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 @@ protected: 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 @@ protected: 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 @@ protected: uint8 *_currentGfxBackground; int _fadePaletteCounter; uint8 _currentPalette[768]; + int _fullRedrawCounter; + int _dirtyRectsPrevCount, _dirtyRectsCount; + Common::Rect _dirtyRectsTable[2][kMaxDirtyRects]; int _updateLocationFadePaletteCounter; int _updateLocationCounter; |